Skip to content

Commit 291ec20

Browse files
committed
stash caller heap before cryptocb fires so InitCmac_* callbacks can honor it
1 parent a3f5260 commit 291ec20

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

wolfcrypt/src/cmac.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ static int _InitCmac_common(Cmac* cmac, const byte* key, word32 keySz,
126126
#endif
127127
XMEMSET(cmac, 0, sizeof(Cmac));
128128

129+
/* Stash heap so the cryptocb can read it from the zeroed cmac. */
130+
#ifndef NO_AES
131+
cmac->aes.heap = heap;
132+
#else
133+
cmac->heap = heap;
134+
#endif
135+
129136
/* Store id/label on the Cmac struct so the crypto callback can
130137
* inspect them to determine the hardware key slot. */
131138
#ifdef WOLF_PRIVATE_KEY_ID

wolfssl/wolfcrypt/cmac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ struct Cmac {
6363
byte digest[WC_AES_BLOCK_SIZE]; /* running digest */
6464
byte k1[WC_AES_BLOCK_SIZE];
6565
byte k2[WC_AES_BLOCK_SIZE];
66+
#else
67+
void* heap; /* fallback when no aes.heap is available */
6668
#endif
6769
word32 bufferSz;
6870
word32 totalSz;

0 commit comments

Comments
 (0)