update pkey sz in actual length

This commit is contained in:
Hideki Miyazaki
2021-07-29 23:28:10 +09:00
parent 0ec848e2bd
commit 2b43052f36
2 changed files with 18 additions and 2 deletions

View File

@ -28801,7 +28801,10 @@ static void test_wolfSSL_PEM_PUBKEY(void)
const char* fname = "./certs/ecc-client-keyPub.pem";
size_t sz;
byte* buf;
EVP_PKEY* pkey2;
EC_KEY* ec_key;
file = XFOPEN(fname, "rb");
AssertTrue((file != XBADFILE));
XFSEEK(file, 0, XSEEK_END);
@ -28818,6 +28821,19 @@ static void test_wolfSSL_PEM_PUBKEY(void)
XFREE(buf, NULL, DYNAMIC_TYPE_FILE);
BIO_free(bio);
bio = NULL;
/* Qt unit test case*/
AssertNotNull(pkey2 = EVP_PKEY_new());
AssertNotNull(ec_key = EVP_PKEY_get1_EC_KEY(pkey));
AssertIntEQ(EVP_PKEY_set1_EC_KEY(pkey2, ec_key), WOLFSSL_SUCCESS);
#ifdef WOLFSSL_ERROR_CODE_OPENSSL
AssertIntEQ(EVP_PKEY_cmp(pkey, pkey2), 1/* match */);
#else
AssertIntEQ(EVP_PKEY_cmp(pkey, pkey2), 0);
#endif
EC_KEY_free(ec_key);
EVP_PKEY_free(pkey2);
EVP_PKEY_free(pkey);
pkey = NULL;
}

View File

@ -6685,7 +6685,7 @@ static int ECC_populate_EVP_PKEY(EVP_PKEY* pkey, WOLFSSL_EC_KEY *key)
DYNAMIC_TYPE_OPENSSL);
if (derBuf != NULL) {
pkey->pkey.ptr = (char*)derBuf;
if (wc_EccPublicKeyToDer(ecc, derBuf, derSz, 1) < 0) {
if ((derSz = wc_EccPublicKeyToDer(ecc, derBuf, derSz, 1)) < 0) {
XFREE(derBuf, NULL, DYNAMIC_TYPE_OPENSSL);
derBuf = NULL;
}