From: Kurt Roeckx Date: Sat, 16 Apr 2016 21:08:56 +0000 (+0200) Subject: Check that we have enough padding characters. X-Git-Tag: OpenSSL_1_1_0-pre6~948 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=70428eada9bc4cf31424d723d1f992baffeb0dfb;p=oweals%2Fopenssl.git Check that we have enough padding characters. Reviewed-by: Emilia Käsper CVE-2016-2107 MR: #2572 --- diff --git a/crypto/evp/e_aes_cbc_hmac_sha1.c b/crypto/evp/e_aes_cbc_hmac_sha1.c index 394a380aa0..2d5131f284 100644 --- a/crypto/evp/e_aes_cbc_hmac_sha1.c +++ b/crypto/evp/e_aes_cbc_hmac_sha1.c @@ -59,6 +59,7 @@ #include #include "modes_lcl.h" #include "internal/evp_int.h" +#include "internal/constant_time_locl.h" #ifndef EVP_CIPH_FLAG_AEAD_CIPHER # define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 @@ -583,6 +584,8 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8); maxpad &= 255; + ret &= constant_time_ge(maxpad, pad); + inp_len = len - (SHA_DIGEST_LENGTH + pad + 1); mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1))); inp_len &= mask; diff --git a/crypto/evp/e_aes_cbc_hmac_sha256.c b/crypto/evp/e_aes_cbc_hmac_sha256.c index 956cd58a05..3ac59abc34 100644 --- a/crypto/evp/e_aes_cbc_hmac_sha256.c +++ b/crypto/evp/e_aes_cbc_hmac_sha256.c @@ -59,6 +59,7 @@ #include #include #include "modes_lcl.h" +#include "internal/constant_time_locl.h" #include "internal/evp_int.h" #ifndef EVP_CIPH_FLAG_AEAD_CIPHER @@ -594,6 +595,8 @@ static int aesni_cbc_hmac_sha256_cipher(EVP_CIPHER_CTX *ctx, maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8); maxpad &= 255; + ret &= constant_time_ge(maxpad, pad); + inp_len = len - (SHA256_DIGEST_LENGTH + pad + 1); mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1))); inp_len &= mask;