Fix for possible leak in `openssl_test` because EVP free not called with `WOLFSSL_SMALL_STACK_CACHE` (SHA256/SHA512). Added return code checking to the openssl_test in wolfCrypt test.

pull/3244/head
David Garske 2020-08-24 09:26:24 -07:00 committed by Daniel Pouzzner
parent 32e30d23c6
commit 0f8cf32122
1 changed files with 2 additions and 7 deletions

View File

@ -16100,7 +16100,6 @@ static int openssl_test(void)
0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef
};
DES_key_schedule sched;
static const byte verify[] = {
0x8b,0x7c,0x52,0xb0,0x01,0x2b,0x6c,0xb8,
0x4f,0x0f,0xeb,0xf3,0xfb,0x5f,0x86,0x73,
@ -16137,20 +16136,17 @@ static int openssl_test(void)
{ /* evp_cipher test: EVP_aes_128_cbc */
EVP_CIPHER_CTX ctx;
int idx, cipherSz, plainSz;
static const byte msg[] = { /* "Now is the time for all " w/o trailing 0 */
0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
};
static const byte verify[] = {
0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53,
0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb,
0x3b,0x5d,0x41,0x97,0x94,0x25,0xa4,0xb4,
0xae,0x7b,0x34,0xd0,0x3f,0x0c,0xbc,0x06
};
static const byte verify2[] = {
0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53,
0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb,
@ -16186,6 +16182,7 @@ static int openssl_test(void)
EVP_CIPHER_CTX_init(&ctx);
ret = EVP_CipherInit(&ctx, EVP_aes_128_cbc(), key, iv, 0);
if (ret == WOLFSSL_SUCCESS) {
/* check partial decrypt (not enough padding for full block) */
ret = EVP_CipherUpdate(&ctx, plain, &idx, cipher, 1);
if (ret == WOLFSSL_SUCCESS)
plainSz += idx;
@ -16251,13 +16248,11 @@ static int openssl_test(void)
0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,
0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a
};
static const byte verify[] = {
0xf3,0xee,0xd1,0xbd,0xb5,0xd2,0xa0,0x3c,
0x06,0x4b,0x5a,0x7e,0x3d,0xb1,0x81,0xf8
};
static const byte key[] = {
const byte key[] = {
0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,
0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,
0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,