F-11877: check key initialization results in WolfCrypt verify/decrypt helpers

pull/408/head
Chris Conlon 2026-08-26 16:55:56 -06:00
parent 0742792d48
commit 14673f945c
2 changed files with 15 additions and 3 deletions

View File

@ -70,7 +70,11 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfCryptECC_doVerify
return -1;
}
wc_ecc_init(&myKey);
ret = wc_ecc_init(&myKey);
if (ret != 0) {
printf("wc_ecc_init failed, ret = %d\n", ret);
return ret;
}
ret = wc_ecc_import_x963(keyBuf, (unsigned int)keySz, &myKey);

View File

@ -171,7 +171,11 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfCryptRSA_doVerify
return -1;
}
wc_InitRsaKey(&myKey, NULL);
ret = wc_InitRsaKey(&myKey, NULL);
if (ret != 0) {
printf("wc_InitRsaKey failed, ret = %d\n", ret);
return ret;
}
idx = 0;
ret = wc_RsaPublicKeyDecode(keyBuf, &idx, &myKey, (unsigned int)keySz);
@ -533,7 +537,11 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfCryptRSA_doDec
return -1;
}
wc_InitRsaKey(&myKey, NULL);
ret = wc_InitRsaKey(&myKey, NULL);
if (ret != 0) {
printf("wc_InitRsaKey failed, ret = %d\n", ret);
return ret;
}
idx = 0;
ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, (unsigned int)keySz);