Skip to content

Commit 265fbdb

Browse files
julek-wolfssldgarske
authored andcommitted
Check wc_InitRsaKey return value in wc_GetKeyOID
F-748
1 parent f56356a commit 265fbdb

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9491,14 +9491,15 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz,
94919491
if (rsa == NULL)
94929492
return MEMORY_E;
94939493

9494-
wc_InitRsaKey(rsa, heap);
9495-
if (wc_RsaPrivateKeyDecode(key, &tmpIdx, rsa, keySz) == 0) {
9496-
*algoID = RSAk;
9497-
}
9498-
else {
9499-
WOLFSSL_MSG("Not RSA DER key");
9494+
if (wc_InitRsaKey(rsa, heap) == 0) {
9495+
if (wc_RsaPrivateKeyDecode(key, &tmpIdx, rsa, keySz) == 0) {
9496+
*algoID = RSAk;
9497+
}
9498+
else {
9499+
WOLFSSL_MSG("Not RSA DER key");
9500+
}
9501+
wc_FreeRsaKey(rsa);
95009502
}
9501-
wc_FreeRsaKey(rsa);
95029503
XFREE(rsa, heap, DYNAMIC_TYPE_TMP_BUFFER);
95039504
}
95049505
#endif /* !NO_RSA && !NO_ASN_CRYPT */

0 commit comments

Comments
 (0)