28#ifndef WOLF_CRYPT_HMAC_H
29#define WOLF_CRYPT_HMAC_H
33#if defined(HAVE_FIPS) && \
34 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
36 #include <cyassl/ctaocrypt/hmac.h>
37 #define WC_HMAC_BLOCK_SIZE HMAC_BLOCK_SIZE
41#if defined(HAVE_FIPS) && \
42 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
43 #include <wolfssl/wolfcrypt/fips.h>
51#if !defined(HAVE_FIPS) || \
52 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
54#ifdef WOLFSSL_ASYNC_CRYPT
55 #include <wolfssl/wolfcrypt/async.h>
58#ifndef NO_OLD_WC_NAMES
59 #define HMAC_BLOCK_SIZE WC_HMAC_BLOCK_SIZE
62#define WC_HMAC_INNER_HASH_KEYED_SW 1
63#define WC_HMAC_INNER_HASH_KEYED_DEV 2
66 HMAC_FIPS_MIN_KEY = 14,
73 WC_MD5 = WC_HASH_TYPE_MD5,
76 WC_SHA = WC_HASH_TYPE_SHA,
79 WC_SHA256 = WC_HASH_TYPE_SHA256,
82 WC_SHA512 = WC_HASH_TYPE_SHA512,
85 WC_SHA384 = WC_HASH_TYPE_SHA384,
88 WC_SHA224 = WC_HASH_TYPE_SHA224,
91 WC_SHA3_224 = WC_HASH_TYPE_SHA3_224,
92 WC_SHA3_256 = WC_HASH_TYPE_SHA3_256,
93 WC_SHA3_384 = WC_HASH_TYPE_SHA3_384,
94 WC_SHA3_512 = WC_HASH_TYPE_SHA3_512,
102#define WC_HMAC_BLOCK_SIZE WC_MAX_BLOCK_SIZE
104#if !defined(WOLFSSL_SHA3) && !defined(WOLFSSL_SHA512) && \
105 !defined(WOLFSSL_SHA384) && defined(NO_SHA256) && \
106 defined(WOLFSSL_SHA224) && defined(NO_SHA) && defined(NO_MD5)
107 #error "You have to have some kind of hash if you want to use HMAC."
139 word32 ipad[WC_HMAC_BLOCK_SIZE /
sizeof(word32)];
140 word32 opad[WC_HMAC_BLOCK_SIZE /
sizeof(word32)];
141 word32 innerHash[WC_MAX_DIGEST_SIZE /
sizeof(word32)];
145#ifdef WOLFSSL_ASYNC_CRYPT
146 WC_ASYNC_DEV asyncDev;
154 byte id[HMAC_MAX_ID_LEN];
157#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLF_CRYPTO_CB)
162#ifndef WC_HMAC_TYPE_DEFINED
164 #define WC_HMAC_TYPE_DEFINED
174WOLFSSL_API
int wc_HmacSizeByType(
int type);
176WOLFSSL_API
int wc_HmacInit(
Hmac* hmac,
void* heap,
int devId);
177WOLFSSL_API
int wc_HmacInit_Id(
Hmac* hmac,
byte*
id,
int len,
void* heap,
179WOLFSSL_API
void wc_HmacFree(
Hmac*);
183WOLFSSL_LOCAL
int _InitHmac(
Hmac* hmac,
int type,
void* heap);
187WOLFSSL_API
int wc_HKDF_Extract(
int type,
const byte* salt, word32 saltSz,
188 const byte* inKey, word32 inKeySz,
byte* out);
189WOLFSSL_API
int wc_HKDF_Expand(
int type,
const byte* inKey, word32 inKeySz,
190 const byte* info, word32 infoSz,
191 byte* out, word32 outSz);
193WOLFSSL_API
int wc_HKDF(
int type,
const byte* inKey, word32 inKeySz,
194 const byte* salt, word32 saltSz,
195 const byte* info, word32 infoSz,
196 byte* out, word32 outSz);
WOLFSSL_API int wolfSSL_GetHmacMaxSize(void)
This function returns the largest HMAC digest size available based on the configured cipher suites.
Definition hmac.c:1147
WOLFSSL_API int wc_HmacFinal(Hmac *, byte *)
This function computes the final hash of an Hmac object's message.
Definition hmac.c:757
WOLFSSL_API int wc_HmacSetKey(Hmac *, int type, const byte *key, word32 keySz)
This function initializes an Hmac object, setting its encryption type, key and HMAC length.
Definition hmac.c:279
WOLFSSL_API int wc_HKDF(int type, const byte *inKey, word32 inKeySz, const byte *salt, word32 saltSz, const byte *info, word32 infoSz, byte *out, word32 outSz)
This function provides access to a HMAC Key Derivation Function (HKDF). It utilizes HMAC to convert i...
Definition hmac.c:1268
WOLFSSL_API int wc_HmacUpdate(Hmac *, const byte *, word32)
This function updates the message to authenticate using HMAC. It should be called after the Hmac obje...
Definition hmac.c:654
Definition wolfcaam_sha.h:68
Definition afalg_hash.h:31