25.4.5 SHA
The CRYPTO SHA instruction implements SHA-1 with a 160-bit digest or SHA-2 with a 224-bit digest (SHA-224) or 256-bit digest
(SHA-256). Depending on SHAMODE in CRYPTO_CTRL, SHA-1, SHA-224 or SHA-256 will be run on the data in QDATA1, and the
result will be put on DDATA0. The contents in QDATA1 will be destroyed in the process.
To run SHA on a dataset, it must first be pre-processed by appending a bit '1' to the message, then padding the data with '0' bits until
the message length in bits modulo 512 is 448. Then append the length of the message before pre-processing as a 64-bit big-endian
integer. This pre-processing is known as MD-strengthening, and must be done by software before processing with the CRYPTO mod-
ule.
The pre-processed data can now be run through the CRYPTO module. Begin by writing the values listed in
to CRYPTO_DDATA1 from top to bottom, then execute the instructions listed in in
Table 25.6 SHA Preparations on page
Table 25.5. SHA Init Values
SHA-1
SHA-224
SHA-256
0x67452301
0xC1059ED8
0x6A09E667
0xEFCDAB89
0x367CD507
0xBB67AE85
0x98BADCFE
0x3070DD17
0x3C6EF372
0x10325476
0xF70E5939
0xA54FF53A
0xC3D2E1F0
0xFFC00B31
0x510E527F
0x00000000
0x68581511
0x9B05688C
0x00000000
0x64F98FA7
0x1F83D9AB
0x00000000
0xBEFA4FA4
0x5BE0CD19
Table 25.6. SHA Preparations
STEP
ACTION
Description
STEP0
DDATA1TODDATA0
Copy init data to DDATA0
STEP1
SELDDATA0DDATA1
Select DDATA0 and DDATA1 as operands for SHA instruction
Then, for each 512-bit block, write the block to CRYPTO_QDATA1BIG, execute the instructions listed in
Table 25.7. SHA for 512-bit Block
STEP
ACTION
Description
STEP0
SHA
Perform SHA operation on data in QDATA1
STEP1
MADD32
Accumulate with previous data in DDATA1
STEP2
DDATA0TODDATA1
Copy hash to DDATA1
After the last iteration, the resulting hash can be read out from CRYPTO_DDATA0BIG.
25.4.6 ECC
The CRYPTO module implements support for Elliptic Curve Cryptography through the modular instructions MADD, MMUL and MSUB,
which perform modular addition, multiplication and subtraction respectively. The instructions can operate on a set of both prime fields
GF(p) and binary fields GF(2^m).
The type of modular arithmetic used and the modulus for the modular operations are specified by MODOP and MODULUS in CRYP-
TO_WAC respectively. Changing these in the middle of an operation leads to undefined behaviour.
EFM32JG1 Reference Manual
CRYPTO - Crypto Accelerator
silabs.com
| Smart. Connected. Energy-friendly.
Preliminary Rev. 0.6 | 829