Check wc_InitRsaKey return value in wc_GetKeyOID

F-748
This commit is contained in:
Juliusz Sosinowicz
2026-03-16 15:44:09 +01:00
committed by David Garske
parent f56356a9b4
commit 265fbdb3dd
+8 -7
View File
@@ -9491,14 +9491,15 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz,
if (rsa == NULL)
return MEMORY_E;
wc_InitRsaKey(rsa, heap);
if (wc_RsaPrivateKeyDecode(key, &tmpIdx, rsa, keySz) == 0) {
*algoID = RSAk;
if (wc_InitRsaKey(rsa, heap) == 0) {
if (wc_RsaPrivateKeyDecode(key, &tmpIdx, rsa, keySz) == 0) {
*algoID = RSAk;
}
else {
WOLFSSL_MSG("Not RSA DER key");
}
wc_FreeRsaKey(rsa);
}
else {
WOLFSSL_MSG("Not RSA DER key");
}
wc_FreeRsaKey(rsa);
XFREE(rsa, heap, DYNAMIC_TYPE_TMP_BUFFER);
}
#endif /* !NO_RSA && !NO_ASN_CRYPT */