Skip to content

Commit 3e34c86

Browse files
committed
stash caller heap before cryptocb fires so InitCmac_* callbacks can honor it
1 parent 9aec51d commit 3e34c86

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
@@ -124,6 +124,13 @@ static int _InitCmac_common(Cmac* cmac, const byte* key, word32 keySz,
124124
#endif
125125
XMEMSET(cmac, 0, sizeof(Cmac));
126126

127+
/* Stash heap so the cryptocb can read it from the zeroed cmac. */
128+
#ifndef NO_AES
129+
cmac->aes.heap = heap;
130+
#else
131+
cmac->heap = heap;
132+
#endif
133+
127134
/* Store id/label on the Cmac struct so the crypto callback can
128135
* inspect them to determine the hardware key slot. */
129136
#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)