25.1.7.1.2 Starting a New HMAC Using the SHA-1 Hash Function and HMAC Key Processing
The following procedure is used to begin a new HMAC operation, starting from initial digest values.
- Load the key value in the SHA_ODIGEST_A/SHA_IDIGEST_A to SHA_ODIGEST_H/SHA_IDIGEST_H registers.
- Pad the rest of the SHA _ODIGEST_x and SHA_IDIGEST registers with zeros.
- Load the message in the SHA_DATA_n_IN FIFO registers.
- Enable HMAC key processing by setting the HMAC_KEY_PROC bit in the SHA_MODE register.
- Select the SHA-1 hash function by programming the ALGO bit in the SHA_MODE register to 0x1.
- Select the already loaded key by programming the ALGO_CONSTANT bit in the SHA_MODE register to 0x0.
- Set the CLOSE_HASH bit and the HMAC_OUTER_HASH bit in the SHA_MODE register so that appropriate padding is inserted and the outer hash is performed immediately after the inner hash has finished.
- Program the SHA_LENGTH register with the block length. Writing this register triggers the HMAC engine to begin processing.
NOTE
If more than one pass is used during the process (SHA_MODE[4] CLOSE_HASH == 0x0), the block length value must be a 64-byte multiple. From this point, three operational modes are possible to continue with the processing: polling, interrupt, and DMA. For more information, see the Operational Modes Configuration section.