Re-enable AES-NI on 32-bit x86 too. commit 05750f23aec26bd80fe6a8fbdfab47efadda7212 disabled AES-NI for 32-bit x86, perhaps unintentionally. Change-Id: Ie950c4f49526257138ecc803df5ecfc115bc648d Reviewed-on: https://boringssl-review.googlesource.com/c/33365 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/fipsmodule/aes/asm/aesni-x86.pl b/crypto/fipsmodule/aes/asm/aesni-x86.pl index cf1a51e..aff2b40 100644 --- a/crypto/fipsmodule/aes/asm/aesni-x86.pl +++ b/crypto/fipsmodule/aes/asm/aesni-x86.pl
@@ -67,9 +67,10 @@ # Goldmont 3.84/1.39 1.39 1.63 1.31 1.70 # Bulldozer 5.80/0.98 1.05 1.24 0.93 1.23 -$PREFIX="aesni"; # if $PREFIX is set to "AES", the script +$PREFIX="aes_hw"; # if $PREFIX is set to "AES", the script # generates drop-in replacement for # crypto/aes/asm/aes-586.pl:-) +$AESNI_PREFIX="aes_hw"; $inline=1; # inline _aesni_[en|de]crypt $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; @@ -85,7 +86,7 @@ &external_label("OPENSSL_ia32cap_P"); &static_label("key_const"); -if ($PREFIX eq "aesni") { $movekey=\&movups; } +if ($PREFIX eq $AESNI_PREFIX) { $movekey=\&movups; } else { $movekey=\&movups; } $len="eax"; @@ -414,21 +415,21 @@ &ret(); &function_end_B("_aesni_${p}rypt6"); } -&aesni_generate2("enc") if ($PREFIX eq "aesni"); +&aesni_generate2("enc") if ($PREFIX eq $AESNI_PREFIX); &aesni_generate2("dec"); -&aesni_generate3("enc") if ($PREFIX eq "aesni"); +&aesni_generate3("enc") if ($PREFIX eq $AESNI_PREFIX); &aesni_generate3("dec"); -&aesni_generate4("enc") if ($PREFIX eq "aesni"); +&aesni_generate4("enc") if ($PREFIX eq $AESNI_PREFIX); &aesni_generate4("dec"); -&aesni_generate6("enc") if ($PREFIX eq "aesni"); +&aesni_generate6("enc") if ($PREFIX eq $AESNI_PREFIX); &aesni_generate6("dec"); -if ($PREFIX eq "aesni") { +if ($PREFIX eq $AESNI_PREFIX) { ###################################################################### -# void aesni_ecb_encrypt (const void *in, void *out, +# void aes_hw_ecb_encrypt (const void *in, void *out, # size_t length, const AES_KEY *key, # int enc); -&function_begin("aesni_ecb_encrypt"); +&function_begin("${PREFIX}_ecb_encrypt"); &mov ($inp,&wparam(0)); &mov ($out,&wparam(1)); &mov ($len,&wparam(2)); @@ -647,10 +648,10 @@ &pxor ("xmm5","xmm5"); &pxor ("xmm6","xmm6"); &pxor ("xmm7","xmm7"); -&function_end("aesni_ecb_encrypt"); +&function_end("${PREFIX}_ecb_encrypt"); ###################################################################### -# void aesni_ccm64_[en|de]crypt_blocks (const void *in, void *out, +# void aes_hw_ccm64_[en|de]crypt_blocks (const void *in, void *out, # size_t blocks, const AES_KEY *key, # const char *ivec,char *cmac); # @@ -659,7 +660,7 @@ # (see engine/eng_aesni.c for details) # { my $cmac=$inout1; -&function_begin("aesni_ccm64_encrypt_blocks"); +&function_begin("${PREFIX}_ccm64_encrypt_blocks"); &mov ($inp,&wparam(0)); &mov ($out,&wparam(1)); &mov ($len,&wparam(2)); @@ -745,9 +746,9 @@ &pxor ("xmm5","xmm5"); &pxor ("xmm6","xmm6"); &pxor ("xmm7","xmm7"); -&function_end("aesni_ccm64_encrypt_blocks"); +&function_end("${PREFIX}_ccm64_encrypt_blocks"); -&function_begin("aesni_ccm64_decrypt_blocks"); +&function_begin("${PREFIX}_ccm64_decrypt_blocks"); &mov ($inp,&wparam(0)); &mov ($out,&wparam(1)); &mov ($len,&wparam(2)); @@ -854,11 +855,11 @@ &pxor ("xmm5","xmm5"); &pxor ("xmm6","xmm6"); &pxor ("xmm7","xmm7"); -&function_end("aesni_ccm64_decrypt_blocks"); +&function_end("${PREFIX}_ccm64_decrypt_blocks"); } ###################################################################### -# void aesni_ctr32_encrypt_blocks (const void *in, void *out, +# void aes_hw_ctr32_encrypt_blocks (const void *in, void *out, # size_t blocks, const AES_KEY *key, # const char *ivec); # @@ -873,7 +874,7 @@ # 64 2nd triplet of counter vector # 80 saved %esp -&function_begin("aesni_ctr32_encrypt_blocks"); +&function_begin("${PREFIX}_ctr32_encrypt_blocks"); &mov ($inp,&wparam(0)); &mov ($out,&wparam(1)); &mov ($len,&wparam(2)); @@ -1115,16 +1116,16 @@ &movdqa (&QWP(64,"esp"),"xmm0"); &pxor ("xmm7","xmm7"); &mov ("esp",&DWP(80,"esp")); -&function_end("aesni_ctr32_encrypt_blocks"); +&function_end("${PREFIX}_ctr32_encrypt_blocks"); ###################################################################### -# void aesni_xts_[en|de]crypt(const char *inp,char *out,size_t len, +# void aes_hw_xts_[en|de]crypt(const char *inp,char *out,size_t len, # const AES_KEY *key1, const AES_KEY *key2 # const unsigned char iv[16]); # { my ($tweak,$twtmp,$twres,$twmask)=($rndkey1,$rndkey0,$inout0,$inout1); -&function_begin("aesni_xts_encrypt"); +&function_begin("${PREFIX}_xts_encrypt"); &mov ($key,&wparam(4)); # key2 &mov ($inp,&wparam(5)); # clear-text tweak @@ -1470,9 +1471,9 @@ &pxor ("xmm7","xmm7"); &movdqa (&QWP(16*5,"esp"),"xmm0"); &mov ("esp",&DWP(16*7+4,"esp")); # restore %esp -&function_end("aesni_xts_encrypt"); +&function_end("${PREFIX}_xts_encrypt"); -&function_begin("aesni_xts_decrypt"); +&function_begin("${PREFIX}_xts_decrypt"); &mov ($key,&wparam(4)); # key2 &mov ($inp,&wparam(5)); # clear-text tweak @@ -1846,7 +1847,7 @@ &pxor ("xmm7","xmm7"); &movdqa (&QWP(16*5,"esp"),"xmm0"); &mov ("esp",&DWP(16*7+4,"esp")); # restore %esp -&function_end("aesni_xts_decrypt"); +&function_end("${PREFIX}_xts_decrypt"); } }
diff --git a/crypto/fipsmodule/aes/internal.h b/crypto/fipsmodule/aes/internal.h index 7c19b9c..a9f8a8c 100644 --- a/crypto/fipsmodule/aes/internal.h +++ b/crypto/fipsmodule/aes/internal.h
@@ -26,7 +26,7 @@ #if !defined(OPENSSL_NO_ASM) -#if defined(OPENSSL_X86_64) +#if defined(OPENSSL_X86) || defined(OPENSSL_X86_64) #define HWAES #define HWAES_ECB