Check that we have enough padding characters.
[openssl.git] / crypto / evp / e_aes_cbc_hmac_sha1.c
index 394a380aa00f9fcbc237cddf3e96a7d3a4ae290c..2d5131f2842997d2168eb94eb9c16f36270390cb 100644 (file)
@@ -59,6 +59,7 @@
 #include <openssl/rand.h>
 #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;