4 #ifndef OPENTITAN_SW_DEVICE_LIB_CRYPTO_DRIVERS_HMAC_H_
5 #define OPENTITAN_SW_DEVICE_LIB_CRYPTO_DRIVERS_HMAC_H_
12 #include "sw/device/lib/crypto/impl/status.h"
14 #include "hmac_regs.h"
22 kHmacSha256DigestBits = 256,
23 kHmacSha256DigestBytes = kHmacSha256DigestBits / 8,
24 kHmacSha256DigestWords = kHmacSha256DigestBytes /
sizeof(uint32_t),
26 kHmacSha384DigestBits = 384,
27 kHmacSha384DigestBytes = kHmacSha384DigestBits / 8,
28 kHmacSha384DigestWords = kHmacSha384DigestBytes /
sizeof(uint32_t),
30 kHmacSha512DigestBits = 512,
31 kHmacSha512DigestBytes = kHmacSha512DigestBits / 8,
32 kHmacSha512DigestWords = kHmacSha512DigestBytes /
sizeof(uint32_t),
35 kHmacSha256BlockBits = 2 * kHmacSha256DigestBits,
36 kHmacSha256BlockBytes = kHmacSha256BlockBits / 8,
37 kHmacSha256BlockWords = kHmacSha256BlockBytes /
sizeof(uint32_t),
40 kHmacSha512BlockBits = 2 * kHmacSha512DigestBits,
41 kHmacSha512BlockBytes = kHmacSha512BlockBits / 8,
42 kHmacSha512BlockWords = kHmacSha512BlockBytes /
sizeof(uint32_t),
45 kHmacMaxDigestBits = kHmacSha512DigestBits,
46 kHmacMaxDigestBytes = kHmacMaxDigestBits / 8,
47 kHmacMaxDigestWords = kHmacMaxDigestBytes /
sizeof(uint32_t),
49 kHmacMaxBlockBits = kHmacSha512BlockBits,
50 kHmacMaxBlockBytes = kHmacMaxBlockBits / 8,
51 kHmacMaxBlockWords = kHmacMaxBlockBytes /
sizeof(uint32_t),
61 uint32_t key[kHmacMaxBlockWords];
65 size_t msg_block_bytelen;
66 size_t digest_wordlen;
68 uint32_t H[kHmacMaxDigestWords];
74 uint8_t partial_block[kHmacMaxBlockBytes];
76 size_t partial_block_len;
79 typedef enum hmac_mode {
128 const uint32_t *key,
size_t key_wordlen);
212 status_t hmac(
const hmac_mode_t hmac_mode,
const uint32_t *key,
213 size_t key_wordlen,
const uint8_t *data,
size_t len,
214 uint32_t *digest,
size_t digest_wordlen);
220 #endif // OPENTITAN_SW_DEVICE_LIB_CRYPTO_DRIVERS_HMAC_H_