aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/aes
diff options
context:
space:
mode:
authorSimon L. B. Nielsen <simon@FreeBSD.org>2010-11-21 22:45:18 +0000
committerSimon L. B. Nielsen <simon@FreeBSD.org>2010-11-21 22:45:18 +0000
commitf2c43d19b91f8847c1dfd87721254b44f963d9a2 (patch)
tree4710d37952455e247de95eedf55ea05ee4df9f69 /crypto/aes
parent0cedaa6c89235ed396068f2ebf546c9a909439e1 (diff)
downloadsrc-f2c43d19b91f8847c1dfd87721254b44f963d9a2.tar.gz
src-f2c43d19b91f8847c1dfd87721254b44f963d9a2.zip
Import OpenSSL 0.9.8p.vendor/openssl/0.9.8p
Notes
Notes: svn path=/vendor-crypto/openssl/dist/; revision=215643 svn path=/vendor-crypto/openssl/0.9.8p/; revision=215644; tag=vendor/openssl/0.9.8p
Diffstat (limited to 'crypto/aes')
-rw-r--r--crypto/aes/aes_wrap.c12
-rwxr-xr-xcrypto/aes/asm/aes-x86_64.pl38
2 files changed, 31 insertions, 19 deletions
diff --git a/crypto/aes/aes_wrap.c b/crypto/aes/aes_wrap.c
index 9feacd65d8cd..e2d73d37ceda 100644
--- a/crypto/aes/aes_wrap.c
+++ b/crypto/aes/aes_wrap.c
@@ -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);
}
@@ -119,9 +119,9 @@ int AES_unwrap_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(B + 8, R, 8);
AES_decrypt(B, B, key);
diff --git a/crypto/aes/asm/aes-x86_64.pl b/crypto/aes/asm/aes-x86_64.pl
index b008ab527d08..b510057d166c 100755
--- a/crypto/aes/asm/aes-x86_64.pl
+++ b/crypto/aes/asm/aes-x86_64.pl
@@ -751,7 +751,19 @@ $code.=<<___;
AES_set_encrypt_key:
push %rbx
push %rbp
+ sub \$8,%rsp
+ call _x86_64_AES_set_encrypt_key
+
+ mov 8(%rsp),%rbp
+ mov 16(%rsp),%rbx
+ add \$24,%rsp
+ ret
+.size AES_set_encrypt_key,.-AES_set_encrypt_key
+
+.type _x86_64_AES_set_encrypt_key,\@abi-omnipotent
+.align 16
+_x86_64_AES_set_encrypt_key:
mov %esi,%ecx # %ecx=bits
mov %rdi,%rsi # %rsi=userKey
mov %rdx,%rdi # %rdi=key
@@ -938,10 +950,8 @@ $code.=<<___;
.Lbadpointer:
mov \$-1,%rax
.Lexit:
- pop %rbp
- pop %rbx
- ret
-.size AES_set_encrypt_key,.-AES_set_encrypt_key
+ .byte 0xf3,0xc3 # rep ret
+.size _x86_64_AES_set_encrypt_key,.-_x86_64_AES_set_encrypt_key
___
sub deckey()
@@ -973,15 +983,14 @@ $code.=<<___;
.type AES_set_decrypt_key,\@function,3
.align 16
AES_set_decrypt_key:
- push %rdx
- call AES_set_encrypt_key
- cmp \$0,%eax
- je .Lproceed
- lea 24(%rsp),%rsp
- ret
-.Lproceed:
+ push %rbx
+ push %rbp
+ push %rdx # save key schedule
+
+ call _x86_64_AES_set_encrypt_key
mov (%rsp),%r8 # restore key schedule
- mov %rbx,(%rsp)
+ cmp \$0,%eax
+ jne .Labort
mov 240(%r8),%ecx # pull number of rounds
xor %rdi,%rdi
@@ -1023,7 +1032,10 @@ $code.=<<___;
jnz .Lpermute
xor %rax,%rax
- pop %rbx
+.Labort:
+ mov 8(%rsp),%rbp
+ mov 16(%rsp),%rbx
+ add \$24,%rsp
ret
.size AES_set_decrypt_key,.-AES_set_decrypt_key
___