SLAU723A October 2017 – October 2018 MSP432E401Y , MSP432E411Y
To start a new hash, follow these steps:
After the configuration is complete, the INPUT_READY status bit equals 1 in the SHA Interrupt Status (SHA_IRQSTATUS) register (regardless of whether or not the M_INPUT_READY bit in the SHA_IRQENABLE register is set). When this bit is set, it indicates the SHA engine can receive the data to process. Data must be written to the 16 × 32-bit SHA_DATA_n_IN registers that provide storage for one 64-byte block of data. Unless the CLOSE_HASH bit is set, all of the SHA_DATA_n_IN input buffers must be filled. Data can be written by single write accesses to the 16 registers from a processor or by a DMA transfer.
For µDMA transfers, the DMA_EN bit must be set in the SHA_SYSCONFIG register and the appropriate mask bits must be set in the SHA_DMAIM register before starting the new hash. Note that if the µDMA is used for transfers, the SHA_IRQENABLE register should be clear so all interrupts are generated through the µDMA interrupt registers.
The µDMA must be configured to transfer 16 data words of 32 bits each time it is triggered by a µDMA request from the SHA/MD5 Module. The 16 data words written are sent to the 16 SHA_DATA_n_IN registers.
The module detects that a 64-byte block is available, and then moves the data to a working register space for processing and asserts the INPUT_READY bit in the SHA_IRQSTATUS register to 1. If the DMA_EN bit in the SHA_SYSCONFIG register has been set to 1, a new µDMA request triggers a new block transfer; otherwise, the processor polls the INPUT_READY bit and writes the 16 data words of 32 bits when it equals 1.
This operation is repeated until the length of the message to hash is reached. The OUPUT_READY bit in the SHA_IRQSTATUS register then indicates that the hash operation is complete. If the IT_EN bit in the SHA_SYSCONFIG register is set, an interrupt (active low) is also generated to indicate the hash completion.
The processor can then read the eight digest registers A through H that contain the hash and/or HMAC result. If the hash is an intermediate result of a larger hash, the digest count register must also be read and saved.
NOTE
The number of digest registers used depends on the algorithm selected for the SHA/MD5 Module (MD5, SHA-1, SHA-224, or SHA-256) (see Table 25-3 and Table 25-4).
Register | Address | MD5 (Read/Write) | SHA-1 (Read/Write) | SHA-2 (Read/Write) | HMAC Key Processing (write) |
---|---|---|---|---|---|
SHA_ODIGEST_A | 0x000 | Outer digest [127:96] | Outer digest [159:128] | Outer digest [255:224] | HMAC Key [31:0] |
SHA_ODIGEST_B | 0x004 | Outer digest [95:64] | Outer digest [127:96] | Outer digest [223:192] | HMAC key [63:32] |
SHA_ODIGEST_C | 0x008 | Outer digest [63:32] | Outer digest [95:64] | Outer digest [191:160] | HMAC key [95:64] |
SHA_ODIGEST_D | 0x00C | Outer digest [31:0] | Outer digest [63:32] | Outer digest [159:128] | HMAC key [127:96] |
SHA_ODIGEST_E | 0x010 | Outer digest [31:0] | Outer digest [127:96] | HMAC key [159:128] | |
SHA_ODIGEST_F | 0x014 | Outer digest [95:64] | HMAC key [191:160] | ||
SHA_ODIGEST_G | 0x018 | Outer digest [63:32] | HMAC key [223:192] | ||
SHA_ODIGEST_H | 0x01C | Outer digest [31:0] | HMAC key [255:224] |
Register | Address | MD5 (Read/Write) | SHA-1 (Read/Write) | SHA-2 (Read/Write) | SHA-256 (Read/Write) | HMAC Key Processing (write) |
---|---|---|---|---|---|---|
SHA_IDIGEST_A | 0x020 | Inner digest [127:96] | Inner digest [159:128] | Inner digest [223:192] | Inner digest [255:224] | HMAC key [287:256] |
SHA_IDIGEST_B | 0x024 | Inner digest [95:64] | Inner digest [127:96] | Inner digest [191:160] | Inner digest [223:192] | HMAC key [319:288] |
SHA_IDIGEST_C | 0x028 | Inner digest [63:32] | Inner digest [95:64] | Inner digest [159:128] | Inner digest [191:160] | HMAC key [351:320] |
SHA_IDIGEST_D | 0x02C | Inner digest [31:0] | Inner digest [63:32] | Inner digest [127:96] | Inner digest [159:128] | HMAC key [383:352] |
SHA_IDIGEST_E | 0x030 | Inner digest[31:0] | Inner digest [95:64] | Inner digest [127:96] | HMAC key [415:384] | |
SHA_IDIGEST_F | 0x034 | Inner digest [63:32] | Inner digest [95:64] | HMAC key [447:416] | ||
SHA_IDIGEST_G | 0x038 | Inner digest [31:0] | Inner digest [63:32] | HMAC key [479:448] | ||
SHA_IDIGEST_H | 0x03C | Inner digest[31:0] | HMAC key [511:480] |
NOTE
Inner digests are initial, intermediate, and result digests.