Add TEST_FAIL() condition to aes_128_cbc_encrypt/decrypt()

This enables more error path testing.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-11-28 19:00:32 +02:00
parent ea52a46e13
commit 11c9ddb766
2 changed files with 12 additions and 0 deletions

View file

@ -28,6 +28,9 @@ int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len)
u8 *pos = data; u8 *pos = data;
int i, j, blocks; int i, j, blocks;
if (TEST_FAIL())
return -1;
ctx = aes_encrypt_init(key, 16); ctx = aes_encrypt_init(key, 16);
if (ctx == NULL) if (ctx == NULL)
return -1; return -1;
@ -61,6 +64,9 @@ int aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len)
u8 *pos = data; u8 *pos = data;
int i, j, blocks; int i, j, blocks;
if (TEST_FAIL())
return -1;
ctx = aes_decrypt_init(key, 16); ctx = aes_decrypt_init(key, 16);
if (ctx == NULL) if (ctx == NULL)
return -1; return -1;

View file

@ -345,6 +345,9 @@ int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len)
int clen, len; int clen, len;
u8 buf[16]; u8 buf[16];
if (TEST_FAIL())
return -1;
EVP_CIPHER_CTX_init(&ctx); EVP_CIPHER_CTX_init(&ctx);
if (EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv) != 1) if (EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv) != 1)
return -1; return -1;
@ -370,6 +373,9 @@ int aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len)
int plen, len; int plen, len;
u8 buf[16]; u8 buf[16];
if (TEST_FAIL())
return -1;
EVP_CIPHER_CTX_init(&ctx); EVP_CIPHER_CTX_init(&ctx);
if (EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv) != 1) if (EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv) != 1)
return -1; return -1;