Skip to content

Commit b087808

Browse files
committed
Fix for crypto callback if called and no TPM key is setup (fallback to software).
1 parent 8ce8eaa commit b087808

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/tpm2_cryptocb.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
153153
case RSA_PRIVATE_DECRYPT:
154154
{
155155
/* private operations */
156+
if (tlsCtx->rsaKey == NULL) {
157+
/* TPM key not setup, fallback to software */
158+
rc = exit_rc;
159+
break;
160+
}
156161
rc = wolfTPM2_RsaDecrypt(tlsCtx->dev, tlsCtx->rsaKey,
157162
TPM_ALG_NULL, /* no padding */
158163
info->pk.rsa.in, info->pk.rsa.inLen,
@@ -237,6 +242,11 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
237242
word32 rsLen = sizeof(sigRS), keySz;
238243
word32 inlen = info->pk.eccsign.inlen;
239244

245+
if (tlsCtx->eccKey == NULL) {
246+
/* TPM key not setup, fallback to software */
247+
return exit_rc;
248+
}
249+
240250
/* get key size from wolf signing key */
241251
keySz = wc_ecc_size(info->pk.eccsign.key);
242252
if (keySz == 0) {

0 commit comments

Comments
 (0)