summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2016-04-16 23:08:56 +0200
committerMatt Caswell <matt@openssl.org>2016-05-03 13:06:36 +0100
commit4159f311671cf3bac03815e5de44681eb758304a (patch)
treee2c92d9f9d8000f5dec3e058e2ee8b8d15c61cdd
parente903aaf894d542c02dc9bfd5065f906dc720d841 (diff)
Check that we have enough padding characters.
Reviewed-by: Emilia Käsper <emilia@openssl.org> CVE-2016-2107 MR: #2572
-rw-r--r--crypto/evp/e_aes_cbc_hmac_sha1.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/evp/e_aes_cbc_hmac_sha1.c b/crypto/evp/e_aes_cbc_hmac_sha1.c
index d1f5928f62..1d598db359 100644
--- a/crypto/evp/e_aes_cbc_hmac_sha1.c
+++ b/crypto/evp/e_aes_cbc_hmac_sha1.c
@@ -59,6 +59,7 @@
# include <openssl/aes.h>
# include <openssl/sha.h>
# include "evp_locl.h"
+# include "constant_time_locl.h"
# ifndef EVP_CIPH_FLAG_AEAD_CIPHER
# define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000
@@ -286,6 +287,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;