From: Dr. Stephen Henson Date: Thu, 19 Jul 2007 17:39:07 +0000 (+0000) Subject: SSE2 and AES assembly language support for VC++ build. X-Git-Tag: OpenSSL_0_9_8f~83 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f805d30769b0eaf5f44ae77a19fdc86335ac35eb;p=oweals%2Fopenssl.git SSE2 and AES assembly language support for VC++ build. --- diff --git a/CHANGES b/CHANGES index 285aea7dcd..7b25bdc811 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Changes between 0.9.8e and 0.9.8f [xx XXX xxxx] + *) Add AES and SSE2 assembly language support to VC++ build. + [Steve Henson] + *) Mitigate attack on final subtraction in Montgomery reduction. [Andy Polyakov] diff --git a/ms/do_masm.bat b/ms/do_masm.bat index 720d6f367b..6ea1c98716 100755 --- a/ms/do_masm.bat +++ b/ms/do_masm.bat @@ -1,63 +1,77 @@ -@echo off -echo Generating x86 for MASM assember - -echo Bignum -cd crypto\bn\asm -perl x86.pl win32 > bn_win32.asm -cd ..\..\.. - -echo DES -cd crypto\des\asm -perl des-586.pl win32 > d_win32.asm -cd ..\..\.. - -echo "crypt(3)" - -cd crypto\des\asm -perl crypt586.pl win32 > y_win32.asm -cd ..\..\.. - -echo Blowfish - -cd crypto\bf\asm -perl bf-586.pl win32 > b_win32.asm -cd ..\..\.. - -echo CAST5 -cd crypto\cast\asm -perl cast-586.pl win32 > c_win32.asm -cd ..\..\.. - -echo RC4 -cd crypto\rc4\asm -perl rc4-586.pl win32 > r4_win32.asm -cd ..\..\.. - -echo MD5 -cd crypto\md5\asm -perl md5-586.pl win32 > m5_win32.asm -cd ..\..\.. - -echo SHA1 -cd crypto\sha\asm -perl sha1-586.pl win32 > s1_win32.asm -cd ..\..\.. - -echo RIPEMD160 -cd crypto\ripemd\asm -perl rmd-586.pl win32 > rm_win32.asm -cd ..\..\.. - -echo RC5\32 -cd crypto\rc5\asm -perl rc5-586.pl win32 > r5_win32.asm -cd ..\..\.. - -echo on - -perl util\mkfiles.pl >MINFO -perl util\mk1mf.pl VC-WIN32 >ms\nt.mak -perl util\mk1mf.pl dll VC-WIN32 >ms\ntdll.mak - -perl util\mkdef.pl 32 libeay > ms\libeay32.def -perl util\mkdef.pl 32 ssleay > ms\ssleay32.def +@echo off + +SET ASMOPTS=-DOPENSSL_IA32_SSE2 +echo Generating x86 for MASM assember + +echo Bignum +cd crypto\bn\asm +perl bn-586.pl win32 %ASMOPTS% > bn_win32.asm +perl co-586.pl win32 %ASMOPTS% > co_win32.asm +cd ..\..\.. + +echo AES +cd crypto\aes\asm +perl aes-586.pl win32 %ASMOPTS% > a_win32.asm +cd ..\..\.. + +echo DES +cd crypto\des\asm +perl des-586.pl win32 %ASMOPTS% > d_win32.asm +cd ..\..\.. + +echo "crypt(3)" + +cd crypto\des\asm +perl crypt586.pl win32 %ASMOPTS% > y_win32.asm +cd ..\..\.. + +echo Blowfish + +cd crypto\bf\asm +perl bf-586.pl win32 %ASMOPTS% > b_win32.asm +cd ..\..\.. + +echo CAST5 +cd crypto\cast\asm +perl cast-586.pl win32 %ASMOPTS% > c_win32.asm +cd ..\..\.. + +echo RC4 +cd crypto\rc4\asm +perl rc4-586.pl win32 %ASMOPTS% > r4_win32.asm +cd ..\..\.. + +echo MD5 +cd crypto\md5\asm +perl md5-586.pl win32 %ASMOPTS% > m5_win32.asm +cd ..\..\.. + +echo SHA1 +cd crypto\sha\asm +perl sha1-586.pl win32 %ASMOPTS% > s1_win32.asm +perl sha512-sse2.pl win32 %ASMOPTS% > sha512-sse2.asm +cd ..\..\.. + +echo RIPEMD160 +cd crypto\ripemd\asm +perl rmd-586.pl win32 %ASMOPTS% > rm_win32.asm +cd ..\..\.. + +echo RC5\32 +cd crypto\rc5\asm +perl rc5-586.pl win32 %ASMOPTS% > r5_win32.asm +cd ..\..\.. + +echo CPU-ID +cd crypto +perl x86cpuid.pl win32 %ASMOPTS% > cpu_win32.asm +cd .. + +echo on + +perl util\mkfiles.pl >MINFO +perl util\mk1mf.pl VC-WIN32 >ms\nt.mak +perl util\mk1mf.pl dll VC-WIN32 >ms\ntdll.mak + +perl util\mkdef.pl 32 libeay > ms\libeay32.def +perl util\mkdef.pl 32 ssleay > ms\ssleay32.def diff --git a/ms/do_nasm.bat b/ms/do_nasm.bat index 0b51f80704..7a2fa45663 100755 --- a/ms/do_nasm.bat +++ b/ms/do_nasm.bat @@ -1,65 +1,79 @@ - -@echo off -echo Generating x86 for NASM assember - -echo Bignum -cd crypto\bn\asm -perl x86.pl win32n > bn_win32.asm -cd ..\..\.. - -echo DES -cd crypto\des\asm -perl des-586.pl win32n > d_win32.asm -cd ..\..\.. - -echo "crypt(3)" - -cd crypto\des\asm -perl crypt586.pl win32n > y_win32.asm -cd ..\..\.. - -echo Blowfish - -cd crypto\bf\asm -perl bf-586.pl win32n > b_win32.asm -cd ..\..\.. - -echo CAST5 -cd crypto\cast\asm -perl cast-586.pl win32n > c_win32.asm -cd ..\..\.. - -echo RC4 -cd crypto\rc4\asm -perl rc4-586.pl win32n > r4_win32.asm -cd ..\..\.. - -echo MD5 -cd crypto\md5\asm -perl md5-586.pl win32n > m5_win32.asm -cd ..\..\.. - -echo SHA1 -cd crypto\sha\asm -perl sha1-586.pl win32n > s1_win32.asm -cd ..\..\.. - -echo RIPEMD160 -cd crypto\ripemd\asm -perl rmd-586.pl win32n > rm_win32.asm -cd ..\..\.. - -echo RC5\32 -cd crypto\rc5\asm -perl rc5-586.pl win32n > r5_win32.asm -cd ..\..\.. - -echo on - -perl util\mkfiles.pl >MINFO -perl util\mk1mf.pl nasm VC-WIN32 >ms\nt.mak -perl util\mk1mf.pl dll nasm VC-WIN32 >ms\ntdll.mak -perl util\mk1mf.pl nasm BC-NT >ms\bcb.mak - -perl util\mkdef.pl 32 libeay > ms\libeay32.def -perl util\mkdef.pl 32 ssleay > ms\ssleay32.def + +@echo off + +SET ASMOPTS=-DOPENSSL_IA32_SSE2 +echo Generating x86 for NASM assember + +echo Bignum +cd crypto\bn\asm +perl bn-586.pl win32n %ASMOPTS% > bn_win32.asm +perl co-586.pl win32n %ASMOPTS% > co_win32.asm +cd ..\..\.. + +echo AES +cd crypto\aes\asm +perl aes-586.pl win32n %ASMOPTS% > a_win32.asm +cd ..\..\.. + +echo DES +cd crypto\des\asm +perl des-586.pl win32n %ASMOPTS% > d_win32.asm +cd ..\..\.. + +echo "crypt(3)" + +cd crypto\des\asm +perl crypt586.pl win32n %ASMOPTS% > y_win32.asm +cd ..\..\.. + +echo Blowfish + +cd crypto\bf\asm +perl bf-586.pl win32n %ASMOPTS% > b_win32.asm +cd ..\..\.. + +echo CAST5 +cd crypto\cast\asm +perl cast-586.pl win32n %ASMOPTS% > c_win32.asm +cd ..\..\.. + +echo RC4 +cd crypto\rc4\asm +perl rc4-586.pl win32n %ASMOPTS% > r4_win32.asm +cd ..\..\.. + +echo MD5 +cd crypto\md5\asm +perl md5-586.pl win32n %ASMOPTS% > m5_win32.asm +cd ..\..\.. + +echo SHA1 +cd crypto\sha\asm +perl sha1-586.pl win32n %ASMOPTS% > s1_win32.asm +perl sha512-sse2.pl win32n %ASMOPTS% > sha512-sse2.asm +cd ..\..\.. + +echo RIPEMD160 +cd crypto\ripemd\asm +perl rmd-586.pl win32n %ASMOPTS% > rm_win32.asm +cd ..\..\.. + +echo RC5\32 +cd crypto\rc5\asm +perl rc5-586.pl win32n %ASMOPTS% > r5_win32.asm +cd ..\..\.. + +echo CPU-ID +cd crypto +perl x86cpuid.pl win32n %ASMOPTS% > cpu_win32.asm +cd .. + +echo on + +perl util\mkfiles.pl >MINFO +perl util\mk1mf.pl nasm VC-WIN32 >ms\nt.mak +perl util\mk1mf.pl dll nasm VC-WIN32 >ms\ntdll.mak +perl util\mk1mf.pl nasm BC-NT >ms\bcb.mak + +perl util\mkdef.pl 32 libeay > ms\libeay32.def +perl util\mkdef.pl 32 ssleay > ms\ssleay32.def diff --git a/util/mk1mf.pl b/util/mk1mf.pl index 7fde251256..51fa6e8ae5 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -395,6 +395,8 @@ LINK=$link LFLAGS=$lflags RSC=$rsc +AES_ASM_OBJ=$aes_asm_obj +AES_ASM_SRC=$aes_asm_src BN_ASM_OBJ=$bn_asm_obj BN_ASM_SRC=$bn_asm_src BNCO_ASM_OBJ=$bnco_asm_obj @@ -608,7 +610,12 @@ foreach (values %lib_nam) $rules.="\$(O_SSL):\n\n"; next; } - + if (($aes_asm_obj ne "") && ($_ eq "CRYPTO")) + { + $lib_obj =~ s/\s(\S*\/aes_core\S*)/ \$(AES_ASM_OBJ)/; + $lib_obj =~ s/\s\S*\/aes_cbc\S*//; + $rules.=&do_asm_rule($aes_asm_obj,$aes_asm_src); + } if (($bn_asm_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/; @@ -850,6 +857,7 @@ sub do_defs elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } + elsif ($_ =~ /AES_ASM/){ $t="$_ "; } elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } else { $t="$location${o}$_$pf "; } diff --git a/util/mkdef.pl b/util/mkdef.pl index 3f3ae343f3..ee200bdbb8 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -1218,8 +1218,6 @@ EOO LIBRARY $libname $liboptions -DESCRIPTION '$description' - EOF if ($W16) { diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl index 81e92f0ad4..c359c3a652 100644 --- a/util/pl/VC-32.pl +++ b/util/pl/VC-32.pl @@ -173,8 +173,12 @@ $bf_enc_src=''; if (!$no_asm) { + $aes_asm_obj='crypto\aes\asm\a_win32.obj'; + $aes_asm_src='crypto\aes\asm\a_win32.asm'; $bn_asm_obj='crypto\bn\asm\bn_win32.obj'; $bn_asm_src='crypto\bn\asm\bn_win32.asm'; + $bnco_asm_obj='crypto\bn\asm\co_win32.obj'; + $bnco_asm_src='crypto\bn\asm\co_win32.asm'; $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj'; $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm'; $bf_enc_obj='crypto\bf\asm\b_win32.obj'; @@ -187,11 +191,13 @@ if (!$no_asm) $rc5_enc_src='crypto\rc5\asm\r5_win32.asm'; $md5_asm_obj='crypto\md5\asm\m5_win32.obj'; $md5_asm_src='crypto\md5\asm\m5_win32.asm'; - $sha1_asm_obj='crypto\sha\asm\s1_win32.obj'; - $sha1_asm_src='crypto\sha\asm\s1_win32.asm'; + $sha1_asm_obj='crypto\sha\asm\s1_win32.obj crypto\sha\asm\sha512-sse2.obj'; + $sha1_asm_src='crypto\sha\asm\s1_win32.asm crypto\sha\asm\sha512-sse2.asm'; $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj'; $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm'; - $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM"; + $cpuid_asm_obj='crypto\cpu_win32.obj'; + $cpuid_asm_src='crypto\cpu_win32.asm'; + $cflags.=" -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DAES_ASM -DBN_ASM -DOPENSSL_BN_ASM_PART_WORDS -DMD5_ASM -DSHA1_ASM -DRMD160_ASM"; } if ($shlib && $FLAVOR !~ /CE/) @@ -275,7 +281,7 @@ sub do_lib_rule } $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/; $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n"; - $ret.="\tIF EXIST \$@.manifest mt -manifest \$@.manifest -outputresource:\$@;2\n\n"; + $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n"; } $ret.="\n"; return($ret); @@ -291,7 +297,7 @@ sub do_link_rule $ret.="$target: $files $dep_libs\n"; $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n"; $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n"; - $ret.="\tIF EXIST \$@.manifest mt -manifest \$@.manifest -outputresource:\$@;1\n\n"; + $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n"; return($ret); }