mirror of https://github.com/wolfSSL/wolfssl.git
Fix for bug in `wolfSSL_EC_POINT_free` not freeing the internal ECC point. Unit test fixup for `test_wolfSSL_EVP_PKEY_new_mac_key` with malloc and size 0. Cleanup the EC_POINT unit test to not set `Gxy->inSet`, since its already 0.
parent
72a33136f5
commit
cc7a5fd490
|
@ -22040,9 +22040,8 @@ void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *p)
|
||||||
WOLFSSL_ENTER("wolfSSL_EC_POINT_free");
|
WOLFSSL_ENTER("wolfSSL_EC_POINT_free");
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
if (p->internal == NULL) {
|
if (p->internal != NULL) {
|
||||||
wc_ecc_del_point((ecc_point*)p->internal);
|
wc_ecc_del_point((ecc_point*)p->internal);
|
||||||
XFREE(p->internal, NULL, DYNAMIC_TYPE_ECC);
|
|
||||||
p->internal = NULL;
|
p->internal = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
tests/api.c
15
tests/api.c
|
@ -775,7 +775,6 @@ static void test_wolfSSL_EC(void)
|
||||||
Gxy->X = Gx;
|
Gxy->X = Gx;
|
||||||
Gxy->Y = Gy;
|
Gxy->Y = Gy;
|
||||||
Gxy->Z = Gz;
|
Gxy->Z = Gz;
|
||||||
Gxy->inSet = 0;
|
|
||||||
|
|
||||||
/* perform point multiplication */
|
/* perform point multiplication */
|
||||||
AssertIntEQ(EC_POINT_mul(group, new_point, NULL, Gxy, k, ctx), WOLFSSL_SUCCESS);
|
AssertIntEQ(EC_POINT_mul(group, new_point, NULL, Gxy, k, ctx), WOLFSSL_SUCCESS);
|
||||||
|
@ -9759,9 +9758,9 @@ static void test_wolfSSL_EVP_PKEY_new_mac_key(void)
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
static const unsigned char pw[] = "password";
|
static const unsigned char pw[] = "password";
|
||||||
static const int pwSz = sizeof(pw) - 1;
|
static const int pwSz = sizeof(pw) - 1;
|
||||||
size_t checkPwSz;
|
size_t checkPwSz = 0;
|
||||||
const unsigned char* checkPw;
|
const unsigned char* checkPw = NULL;
|
||||||
WOLFSSL_EVP_PKEY* key;
|
WOLFSSL_EVP_PKEY* key = NULL;
|
||||||
|
|
||||||
printf(testingFmt, "wolfSSL_EVP_PKEY_new_mac_key()");
|
printf(testingFmt, "wolfSSL_EVP_PKEY_new_mac_key()");
|
||||||
|
|
||||||
|
@ -9780,15 +9779,15 @@ static void test_wolfSSL_EVP_PKEY_new_mac_key(void)
|
||||||
|
|
||||||
AssertNotNull(key = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, pw, 0));
|
AssertNotNull(key = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, pw, 0));
|
||||||
AssertIntEQ(key->pkey_sz, 0);
|
AssertIntEQ(key->pkey_sz, 0);
|
||||||
AssertNotNull(key->pkey.ptr);
|
checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz);
|
||||||
AssertNotNull(checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz));
|
(void)checkPw;
|
||||||
AssertIntEQ((int)checkPwSz, 0);
|
AssertIntEQ((int)checkPwSz, 0);
|
||||||
wolfSSL_EVP_PKEY_free(key);
|
wolfSSL_EVP_PKEY_free(key);
|
||||||
|
|
||||||
AssertNotNull(key = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, NULL, 0));
|
AssertNotNull(key = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, NULL, 0));
|
||||||
AssertIntEQ(key->pkey_sz, 0);
|
AssertIntEQ(key->pkey_sz, 0);
|
||||||
AssertNotNull(key->pkey.ptr);
|
checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz);
|
||||||
AssertNotNull(checkPw = wolfSSL_EVP_PKEY_get0_hmac(key, &checkPwSz));
|
(void)checkPw;
|
||||||
AssertIntEQ((int)checkPwSz, 0);
|
AssertIntEQ((int)checkPwSz, 0);
|
||||||
wolfSSL_EVP_PKEY_free(key);
|
wolfSSL_EVP_PKEY_free(key);
|
||||||
|
|
||||||
|
|
|
@ -569,7 +569,7 @@ WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_mac_key(int type, ENGINE* e,
|
||||||
pkey = wolfSSL_PKEY_new();
|
pkey = wolfSSL_PKEY_new();
|
||||||
if (pkey != NULL) {
|
if (pkey != NULL) {
|
||||||
pkey->pkey.ptr = (char*)XMALLOC(keylen, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
|
pkey->pkey.ptr = (char*)XMALLOC(keylen, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
if (pkey->pkey.ptr == NULL) {
|
if (pkey->pkey.ptr == NULL && keylen > 0) {
|
||||||
wolfSSL_EVP_PKEY_free(pkey);
|
wolfSSL_EVP_PKEY_free(pkey);
|
||||||
pkey = NULL;
|
pkey = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue