diff --git a/src/ssl.c b/src/ssl.c index b617cf27a..0e75fdbd7 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -18297,7 +18297,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, + ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION, NULL, 0); if (ret != 0) { WOLFSSL_MSG("wc_AesXtsSetKey() failed"); @@ -18327,7 +18327,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, + ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION, NULL, 0); if (ret != 0) { WOLFSSL_MSG("wc_AesXtsSetKey() failed"); @@ -36137,24 +36137,29 @@ int wolfSSL_EC_POINT_get_affine_coordinates_GFp(const WOLFSSL_EC_GROUP *group, /* Map the Jacobian point back to affine space */ if (mp_read_radix(&modulus, ecc_sets[group->curve_idx].prime, MP_RADIX_HEX) != MP_OKAY) { WOLFSSL_MSG("mp_read_radix failed"); + mp_clear(&modulus); return WOLFSSL_FAILURE; } if (mp_montgomery_setup(&modulus, &mp) != MP_OKAY) { WOLFSSL_MSG("mp_montgomery_setup failed"); + mp_clear(&modulus); return WOLFSSL_FAILURE; } if (ecc_map((ecc_point*)point->internal, &modulus, mp) != MP_OKAY) { WOLFSSL_MSG("ecc_map failed"); + mp_clear(&modulus); return WOLFSSL_FAILURE; } if (SetECPointExternal((WOLFSSL_EC_POINT *)point) != WOLFSSL_SUCCESS) { WOLFSSL_MSG("SetECPointExternal failed"); + mp_clear(&modulus); return WOLFSSL_FAILURE; } } BN_copy(x, point->X); BN_copy(y, point->Y); + mp_clear(&modulus); return WOLFSSL_SUCCESS; } @@ -48704,8 +48709,10 @@ int wolfSSL_BN_clear_bit(WOLFSSL_BIGNUM* bn, int n) goto cleanup; } } + ret = WOLFSSL_SUCCESS; cleanup: + mp_clear(tmp); #ifdef WOLFSSL_SMALL_STACK if (tmp) XFREE(tmp, NULL, DYNAMIC_TYPE_BIGINT); diff --git a/tests/api.c b/tests/api.c index 7d70b20cb..47a8843bb 100644 --- a/tests/api.c +++ b/tests/api.c @@ -1839,7 +1839,6 @@ static void test_wolfSSL_EC(void) /* Force non-affine coordinates */ AssertIntEQ(wolfSSL_BN_add(new_point->Z, (WOLFSSL_BIGNUM*)BN_value_one(), (WOLFSSL_BIGNUM*)BN_value_one()), 1); - new_point->inSet = 0; /* extract the coordinates from point */ AssertIntEQ(EC_POINT_get_affine_coordinates_GFp(group, new_point, X, Y, ctx), WOLFSSL_SUCCESS);