Merge pull request #50 from cconlon/eccPkcs8Fix

Get ECC curve OID before calling wc_CreatePKCS8Key for size
pull/52/head
JacobBarthelmeh 2023-06-13 22:23:26 -06:00 committed by GitHub
commit 6281e438d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);