64e30c
From 9ab3ce124616cb12bd39c6aa1e1bde0f46969b29 Mon Sep 17 00:00:00 2001
64e30c
From: Andy Polyakov <appro@openssl.org>
64e30c
Date: Mon, 18 Mar 2013 19:29:41 +0100
64e30c
Subject: [PATCH] e_aes_cbc_hmac_sha1.c: fix rare bad record mac on AES-NI
64e30c
 plaforms.
64e30c
64e30c
PR: 3002
64e30c
(cherry picked from commit 5c60046553716fcf160718f59160493194f212dc)
64e30c
---
64e30c
 crypto/evp/e_aes_cbc_hmac_sha1.c |    5 +++--
64e30c
 1 file changed, 3 insertions(+), 2 deletions(-)
64e30c
64e30c
diff --git a/crypto/evp/e_aes_cbc_hmac_sha1.c b/crypto/evp/e_aes_cbc_hmac_sha1.c
64e30c
index 483e04b..fb2c884 100644
64e30c
--- a/crypto/evp/e_aes_cbc_hmac_sha1.c
64e30c
+++ b/crypto/evp/e_aes_cbc_hmac_sha1.c
64e30c
@@ -328,10 +328,11 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
64e30c
 
64e30c
 				if (res!=SHA_CBLOCK) continue;
64e30c
 
64e30c
-				mask = 0-((inp_len+8-j)>>(sizeof(j)*8-1));
64e30c
+				/* j is not incremented yet */
64e30c
+				mask = 0-((inp_len+7-j)>>(sizeof(j)*8-1));
64e30c
 				data->u[SHA_LBLOCK-1] |= bitlen&mask;
64e30c
 				sha1_block_data_order(&key->md,data,1);
64e30c
-				mask &= 0-((j-inp_len-73)>>(sizeof(j)*8-1));
64e30c
+				mask &= 0-((j-inp_len-72)>>(sizeof(j)*8-1));
64e30c
 				pmac->u[0] |= key->md.h0 & mask;
64e30c
 				pmac->u[1] |= key->md.h1 & mask;
64e30c
 				pmac->u[2] |= key->md.h2 & mask;
64e30c
-- 
64e30c
1.7.9.5
64e30c