get ECC curve OID before calling wc_CreatePKCS8Key for size

pull/50/head
Chris Conlon 2023-06-09 11:54:03 -06:00
parent ccd5d805d6
commit 6822bb5cb8
1 changed files with 8 additions and 8 deletions

View File

@ -1032,6 +1032,14 @@ JNIEXPORT jbyteArray JNICALL Java_com_wolfssl_wolfcrypt_Ecc_wc_1ecc_1private_1ke
}
}
if (ret == 0) {
ret = wc_ecc_get_oid(ecc->dp->oidSum, &curveOID, &oidSz);
if (ret > 0) {
/* reset ret, returns oid as well as setting curveOID */
ret = 0;
}
}
if (ret == 0) {
/* get pkcs8 output size, into pkcs8Sz */
ret = wc_CreatePKCS8Key(NULL, &pkcs8Sz, derKey, derKeySz, algoID,
@ -1049,14 +1057,6 @@ JNIEXPORT jbyteArray JNICALL Java_com_wolfssl_wolfcrypt_Ecc_wc_1ecc_1private_1ke
}
}
if (ret == 0) {
ret = wc_ecc_get_oid(ecc->dp->oidSum, &curveOID, &oidSz);
if (ret > 0) {
/* reset ret, returns oid as well as setting curveOID */
ret = 0;
}
}
if (ret == 0) {
ret = wc_CreatePKCS8Key(pkcs8, &pkcs8Sz, derKey, derKeySz,
algoID, curveOID, oidSz);