From 11c9ddb7663c39a5810496656a9cbc5e2a36f66b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 28 Nov 2015 19:00:32 +0200 Subject: [PATCH] Add TEST_FAIL() condition to aes_128_cbc_encrypt/decrypt() This enables more error path testing. Signed-off-by: Jouni Malinen --- src/crypto/aes-cbc.c | 6 ++++++ src/crypto/crypto_openssl.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/crypto/aes-cbc.c b/src/crypto/aes-cbc.c index 2833cfcc8..0835f2cfb 100644 --- a/src/crypto/aes-cbc.c +++ b/src/crypto/aes-cbc.c @@ -28,6 +28,9 @@ int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) u8 *pos = data; int i, j, blocks; + if (TEST_FAIL()) + return -1; + ctx = aes_encrypt_init(key, 16); if (ctx == NULL) 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; int i, j, blocks; + if (TEST_FAIL()) + return -1; + ctx = aes_decrypt_init(key, 16); if (ctx == NULL) return -1; diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c index 9e344d1de..ad2d2d4a2 100644 --- a/src/crypto/crypto_openssl.c +++ b/src/crypto/crypto_openssl.c @@ -345,6 +345,9 @@ int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) int clen, len; u8 buf[16]; + if (TEST_FAIL()) + return -1; + EVP_CIPHER_CTX_init(&ctx); if (EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv) != 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; u8 buf[16]; + if (TEST_FAIL()) + return -1; + EVP_CIPHER_CTX_init(&ctx); if (EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv) != 1) return -1;