Use ForceZero to clean up HMAC-BLAKE2[bs]

This commit is contained in:
Josh Holtrop
2026-01-14 09:03:17 -05:00
parent ee708dc457
commit 2b3c02531c
2 changed files with 16 additions and 4 deletions

View File

@@ -37,6 +37,12 @@
#include <wolfssl/wolfcrypt/blake2.h>
#include <wolfssl/wolfcrypt/blake2-impl.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
#else
#define WOLFSSL_MISC_INCLUDED
#include <wolfcrypt/src/misc.c>
#endif
static const word64 blake2b_IV[8] =
{
@@ -564,8 +570,8 @@ int wc_Blake2bHmac(const byte * in, size_t in_len,
return ret;
XMEMCPY(out, i_hash, BLAKE2B_OUTBYTES);
XMEMSET(x_key, 0, BLAKE2B_BLOCKBYTES);
XMEMSET(i_hash, 0, BLAKE2B_OUTBYTES);
ForceZero(x_key, BLAKE2B_BLOCKBYTES);
ForceZero(i_hash, BLAKE2B_OUTBYTES);
return 0;
}

View File

@@ -37,6 +37,12 @@
#include <wolfssl/wolfcrypt/blake2.h>
#include <wolfssl/wolfcrypt/blake2-impl.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
#else
#define WOLFSSL_MISC_INCLUDED
#include <wolfcrypt/src/misc.c>
#endif
static const word32 blake2s_IV[8] =
{
@@ -558,8 +564,8 @@ int wc_Blake2sHmac(const byte * in, size_t in_len,
return ret;
XMEMCPY(out, i_hash, BLAKE2S_OUTBYTES);
XMEMSET(x_key, 0, BLAKE2S_BLOCKBYTES);
XMEMSET(i_hash, 0, BLAKE2S_OUTBYTES);
ForceZero(x_key, BLAKE2S_BLOCKBYTES);
ForceZero(i_hash, BLAKE2S_OUTBYTES);
return 0;
}