wolfcrypt/src/hmac.c and wolfssl/wolfcrypt/hmac.h: implement WOLFSSL_API wc_HmacCopy(), and remove the WOLFSSL_HMAC_COPY_HASH gate on HmacKeyCopyHash().

This commit is contained in:
Daniel Pouzzner
2025-12-16 16:59:11 -06:00
parent 8090817c11
commit 50b51adc93
2 changed files with 16 additions and 2 deletions

View File

@@ -248,7 +248,6 @@ int _InitHmac(Hmac* hmac, int type, void* heap)
return ret;
}
#ifdef WOLFSSL_HMAC_COPY_HASH
static int HmacKeyCopyHash(byte macType, wc_HmacHash* src, wc_HmacHash* dst)
{
int ret = 0;
@@ -323,7 +322,21 @@ static int HmacKeyCopyHash(byte macType, wc_HmacHash* src, wc_HmacHash* dst)
return ret;
}
#endif
int wc_HmacCopy(Hmac* src, Hmac* dst) {
int ret;
if ((src == NULL) || (dst == NULL))
return BAD_FUNC_ARG;
XMEMCPY(dst, src, sizeof(*dst));
ret = HmacKeyCopyHash(src->macType, &src->hash, &dst->hash);
if (ret != 0)
XMEMSET(dst, 0, sizeof(*dst));
return ret;
}
static int HmacKeyHashUpdate(byte macType, wc_HmacHash* hash, byte* pad)
{

View File

@@ -190,6 +190,7 @@ WOLFSSL_API int wc_HmacInit_Id(Hmac* hmac, byte* id, int len, void* heap,
WOLFSSL_API int wc_HmacInit_Label(Hmac* hmac, const char* label, void* heap,
int devId);
#endif
WOLFSSL_API int wc_HmacCopy(Hmac* src, Hmac* dst);
WOLFSSL_API void wc_HmacFree(Hmac* hmac);
WOLFSSL_API int wolfSSL_GetHmacMaxSize(void);