On a lightly loaded 24Kc, as measured by 'openssl speed sha1', shows between 
27% and 120% speedup depending on block size. SHA1 is notably used in 
Transmission for piece verification.

>>> no-perlasm <<<
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
sha1              1421.10k     4019.38k     8498.85k    11452.85k    13073.53k

>>> mips32_asm <<<
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
sha1              1814.05k     6046.81k    14637.55k    23456.13k    28825.77k

relative:
27%  50%  72%  104%  120%
---
I haven't tested this too thoroughly, so at this point I'm just looking for 
people willing to try this out and for feedback in general. If it doesn't cause 
too much grief, I can clean it up to a point where it's merge-able.

 package/openssl/Makefile                           |    2 +-
 .../openssl/patches/110-optimize-for-size.patch    |    2 +-
 package/openssl/patches/210-fix_aes_fips.patch     |   64 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 2 deletions(-)
 create mode 100644 package/openssl/patches/210-fix_aes_fips.patch

diff --git a/package/openssl/Makefile b/package/openssl/Makefile
index d95783a..4dfcdf6 100644
--- a/package/openssl/Makefile
+++ b/package/openssl/Makefile
@@ -89,7 +89,7 @@ ifeq ($(CONFIG_x86_64),y)
   OPENSSL_TARGET:=linux-x86_64
 else
   OPENSSL_TARGET:=linux-openwrt
-  OPENSSL_OPTIONS+=no-perlasm no-sse2
+  OPENSSL_OPTIONS+=no-sse2
 endif
 
 define Build/Configure
diff --git a/package/openssl/patches/110-optimize-for-size.patch 
b/package/openssl/patches/110-optimize-for-size.patch
index c0160a3..8895f4f 100644
--- a/package/openssl/patches/110-optimize-for-size.patch
+++ b/package/openssl/patches/110-optimize-for-size.patch
@@ -5,7 +5,7 @@
  "linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN 
-DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR 
DES_RISC1 DES_UNROLL:${alpha_asm}",
  "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN 
-DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR 
DES_RISC1 DES_UNROLL:${alpha_asm}",
 +# OpenWrt targets
-+"linux-openwrt","gcc:-DTERMIO \$(OPENWRT_OPTIMIZATION_FLAGS) 
-fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK 
DES_INT DES_UNROLL 
BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"linux-openwrt","gcc:-DTERMIO \$(OPENWRT_OPTIMIZATION_FLAGS) 
-fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK 
DES_INT DES_UNROLL 
BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
  
  # Android: linux-* but without -DTERMIO and pointers to headers and libs.
  "android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 
-fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK 
DES_INT DES_UNROLL 
BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
diff --git a/package/openssl/patches/210-fix_aes_fips.patch 
b/package/openssl/patches/210-fix_aes_fips.patch
new file mode 100644
index 0000000..bbfc63a
--- /dev/null
+++ b/package/openssl/patches/210-fix_aes_fips.patch
@@ -0,0 +1,64 @@
+--- a/crypto/aes/asm/aes-mips.pl
++++ b/crypto/aes/asm/aes-mips.pl
+@@ -1036,9 +1036,9 @@ _mips_AES_set_encrypt_key:
+       nop
+ .end  _mips_AES_set_encrypt_key
+ 
+-.globl        AES_set_encrypt_key
+-.ent  AES_set_encrypt_key
+-AES_set_encrypt_key:
++.globl        private_AES_set_encrypt_key
++.ent  private_AES_set_encrypt_key
++private_AES_set_encrypt_key:
+       .frame  $sp,$FRAMESIZE,$ra
+       .mask   $SAVED_REGS_MASK,-$SZREG
+       .set    noreorder
+@@ -1060,7 +1060,7 @@ $code.=<<___ if ($flavour =~ /nubi/i);   #
+ ___
+ $code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification
+       .cplocal        $Tbl
+-      .cpsetup        $pf,$zero,AES_set_encrypt_key
++      .cpsetup        $pf,$zero,private_AES_set_encrypt_key
+ ___
+ $code.=<<___;
+       .set    reorder
+@@ -1083,7 +1083,7 @@ ___
+ $code.=<<___;
+       jr      $ra
+       $PTR_ADD $sp,$FRAMESIZE
+-.end  AES_set_encrypt_key
++.end  private_AES_set_encrypt_key
+ ___
+ 
+ my ($head,$tail)=($inp,$bits);
+@@ -1091,9 +1091,9 @@ my ($tp1,$tp2,$tp4,$tp8,$tp9,$tpb,$tpd,$
+ my ($m,$x80808080,$x7f7f7f7f,$x1b1b1b1b)=($at,$t0,$t1,$t2);
+ $code.=<<___;
+ .align        5
+-.globl        AES_set_decrypt_key
+-.ent  AES_set_decrypt_key
+-AES_set_decrypt_key:
++.globl        private_AES_set_decrypt_key
++.ent  private_AES_set_decrypt_key
++private_AES_set_decrypt_key:
+       .frame  $sp,$FRAMESIZE,$ra
+       .mask   $SAVED_REGS_MASK,-$SZREG
+       .set    noreorder
+@@ -1115,7 +1115,7 @@ $code.=<<___ if ($flavour =~ /nubi/i);   #
+ ___
+ $code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification
+       .cplocal        $Tbl
+-      .cpsetup        $pf,$zero,AES_set_decrypt_key
++      .cpsetup        $pf,$zero,private_AES_set_decrypt_key
+ ___
+ $code.=<<___;
+       .set    reorder
+@@ -1226,7 +1226,7 @@ ___
+ $code.=<<___;
+       jr      $ra
+       $PTR_ADD $sp,$FRAMESIZE
+-.end  AES_set_decrypt_key
++.end  private_AES_set_decrypt_key
+ ___
+ }}}
+ 
-- 
1.7.7.3

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to