Skip to content

Commit 53d80c0

Browse files
committed
correctly set invalid devId for when cryptoCb is on
but the user has opted to use software, or cmac is not available on for their device. currently a devId of 0 is set which causes CRYPTOCB_UNAVAILABLE
1 parent bab01ca commit 53d80c0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

wolfcrypt/src/cmac.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ int wc_InitCmac_ex(Cmac* cmac, const byte* key, word32 keySz,
114114
#endif
115115
XMEMSET(cmac, 0, sizeof(Cmac));
116116

117+
/* set invalid devId regardless of cryptoCb */
118+
cmac->devId = devId;
117119
#ifdef WOLF_CRYPTO_CB
118120
#ifndef WOLF_CRYPTO_CB_FIND
119121
if (devId != INVALID_DEVID)
120122
#endif
121123
{
122-
cmac->devId = devId;
123124
cmac->devCtx = NULL;
124125

125126
ret = wc_CryptoCb_Cmac(cmac, key, keySz, NULL, 0, NULL, NULL,
@@ -128,6 +129,7 @@ int wc_InitCmac_ex(Cmac* cmac, const byte* key, word32 keySz,
128129
return ret;
129130
/* fall-through when unavailable */
130131
}
132+
131133
#else
132134
(void)devId;
133135
#endif

0 commit comments

Comments
 (0)