PR: 2297
authorDr. Stephen Henson <steve@openssl.org>
Fri, 9 Jul 2010 17:26:04 +0000 (17:26 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 9 Jul 2010 17:26:04 +0000 (17:26 +0000)
Submitted by: Antony, Benoy <bantony@ebay.com>
Approved by: steve@openssl.org

Fix bug in AES wrap code when t > 0xff.

crypto/aes/aes_wrap.c

index 9feacd6..a9aebfe 100644 (file)
@@ -85,9 +85,9 @@ int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
                        A[7] ^= (unsigned char)(t & 0xff);
                        if (t > 0xff)   
                                {
-                               A[6] ^= (unsigned char)((t & 0xff) >> 8);
-                               A[5] ^= (unsigned char)((t & 0xff) >> 16);
-                               A[4] ^= (unsigned char)((t & 0xff) >> 24);
+                               A[6] ^= (unsigned char)((t >> 8) & 0xff);
+                               A[5] ^= (unsigned char)((t >> 16) & 0xff);
+                               A[4] ^= (unsigned char)((t >> 24) & 0xff);
                                }
                        memcpy(R, B + 8, 8);
                        }