Merge pull request #324 from JacobBarthelmeh/fixes

fix for key init before free
pull/326/head
David Garske 2022-06-24 14:11:56 -07:00 committed by GitHub
commit 7ff4964ff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -113,13 +113,18 @@ int main(int argc, char** argv)
if (pubKeyTmp == NULL)
err_sys("wolfSSL_X509_get_pubkey failed", 0);
/* always initialize both key structs since both are free'd at the end */
ret = wc_InitRsaKey(&pubKeyRsa, NULL);
ret |= wc_ecc_init(&pubKeyEcc);
if (ret != 0)
err_sys("init key failed", ret);
idx = 0;
if (keyType == RSA_KEY_TYPE) {
wc_InitRsaKey(&pubKeyRsa, 0);
ret = wc_RsaPublicKeyDecode((byte*)pubKeyTmp->pkey.ptr, &idx,
&pubKeyRsa, pubKeyTmp->pkey_sz);
} else {
wc_ecc_init(&pubKeyEcc);
ret = wc_EccPublicKeyDecode((byte*)pubKeyTmp->pkey.ptr, &idx,
&pubKeyEcc, pubKeyTmp->pkey_sz);
}