Go to the documentation of this file.
38 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
46 #if (HKDF_SUPPORT == ENABLED)
64 const uint8_t *salt,
size_t saltLen,
const uint8_t *info,
size_t infoLen,
65 uint8_t *okm,
size_t okmLen)
71 error =
hkdfExtract(hash, ikm, ikmLen, salt, saltLen, prk);
98 const uint8_t *salt,
size_t saltLen, uint8_t *prk)
100 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
107 if(hash == NULL || ikm == NULL || prk == NULL)
111 if(salt == NULL && saltLen != 0)
114 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
118 if(hmacContext == NULL)
127 salt = hmacContext->
digest;
132 hmacInit(hmacContext, hash, salt, saltLen);
136 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
159 const uint8_t *info,
size_t infoLen, uint8_t *okm,
size_t okmLen)
164 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
171 if(hash == NULL || prk == NULL || okm == NULL)
175 if(info == NULL && infoLen != 0)
179 if(prkLen < hash->digestSize)
186 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
190 if(hmacContext == NULL)
198 for(i = 1; okmLen > 0; i++)
201 hmacInit(hmacContext, hash, prk, prkLen);
217 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
#define MAX_HASH_DIGEST_SIZE
@ ERROR_INVALID_PARAMETER
Invalid parameter.
#define osMemcpy(dest, src, length)
General definitions for cryptographic algorithms.
error_t hkdfExpand(const HashAlgo *hash, const uint8_t *prk, size_t prkLen, const uint8_t *info, size_t infoLen, uint8_t *okm, size_t okmLen)
HKDF expand step.
__weak_func void hmacUpdate(HmacContext *context, const void *data, size_t length)
Update the HMAC context with a portion of the message being hashed.
uint8_t digest[MAX_HASH_DIGEST_SIZE]
HKDF (HMAC-based Key Derivation Function)
__weak_func void hmacFinal(HmacContext *context, uint8_t *digest)
Finish the HMAC calculation.
error_t hkdf(const HashAlgo *hash, const uint8_t *ikm, size_t ikmLen, const uint8_t *salt, size_t saltLen, const uint8_t *info, size_t infoLen, uint8_t *okm, size_t okmLen)
HKDF key derivation function.
#define cryptoAllocMem(size)
Common interface for hash algorithms.
error_t hkdfExtract(const HashAlgo *hash, const uint8_t *ikm, size_t ikmLen, const uint8_t *salt, size_t saltLen, uint8_t *prk)
HKDF extract step.
#define osMemset(p, value, length)
__weak_func error_t hmacInit(HmacContext *context, const HashAlgo *hash, const void *key, size_t keyLen)
Initialize HMAC calculation.
HMAC (Keyed-Hashing for Message Authentication)