From 18394ed50f2fcce2366c129e1a36a3ae0646c83e Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Sun, 30 May 2010 22:02:03 +0000 Subject: [PATCH] 098 aes-x86_64.pl module was erroneously enabled in Win64 build without being adapted for Win64 ABI. Fix this. --- crypto/aes/asm/aes-x86_64.pl | 38 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/crypto/aes/asm/aes-x86_64.pl b/crypto/aes/asm/aes-x86_64.pl index b008ab527d..b510057d16 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 ___ -- 2.25.1