Re: MIPS linux support patch

2012-09-18 Thread Andy Polyakov
There is more code committed. Check-out or wait for *tomorrow*
openssl-SNAP-20120919 snapshot. There is SmartMIPS AES code (pass
-msmartmips to Configure) and Configure accepts double dash as compiler
options. Please double-check and optionally post performance for new AES
code.

__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-18 Thread Brad House

There is more code committed. Check-out or wait for *tomorrow*
openssl-SNAP-20120919 snapshot. There is SmartMIPS AES code (pass
-msmartmips to Configure) and Configure accepts double dash as compiler
options. Please double-check and optionally post performance for new AES
code.


Do I also need to pass -mips32r2 to enable the other assembler optimizations
for MIPS that are not specific to the smartmips instruction set (such as
BigNum and SHA)?  Or does -msmartmips imply that?

Thanks!
-Brad
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Configure enhancements (Was: Re: MIPS linux support patch)

2012-09-18 Thread Brad House

There is more code committed. Check-out or wait for *tomorrow*
openssl-SNAP-20120919 snapshot. There is SmartMIPS AES code (pass
-msmartmips to Configure) and Configure accepts double dash as compiler
options. Please double-check and optionally post performance for new AES
code.


On a different note, thanks for the double dash fix for Configure.  That
said, I have one more issue in relation to the way Configure handles
flags completely unrelated to MIPS...

On MacOSX, you have to target a specific SDK if you want to ensure
it targets the proper release of MacOSX.  That means you pass flags
like this on to the compiler:

-isysroot /Developer/SDKs/MacOSX10.6.sdk/ -mmacosx-version-min=10.6 
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk/

The issue is that first one, where there is a space between the
arguments.

Now, I know what you're thinking, just quote it ... and sure, that
does work if you call Configure directly such as:

./Configure darwin64-x86_64-cc -isysroot /Developer/SDKs/MacOSX10.6.sdk/ 
-mmacosx-version-min=10.6 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk/

But the problem really comes in when you're using the ./config
wrapper script ... such as this:

export KERNEL_BITS=64
export CONFIG_OPTIONS=\-isysroot /Developer/SDKs/MacOSX10.6.sdk/\ 
-mmacosx-version-min=10.6 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk/
./config

You end up with output like this:
$ ./config
Operating system: i686-apple-darwinDarwin Kernel Version 11.2.0: Tue Aug 9 
20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64
Configuring for darwin64-x86_64-cc
target already defined - darwin64-x86_64-cc (offending arg: -isysroot)

If you don't do the escaped quoting, it complains about 
/Developer/SDKs/MacOSX10.6.sdk in the same way.

Again, you're probably asking why not just use Configure directly?

The answer to that question would be FIPS140-2, where the UserGuide
requires:
./config
make
make install
With no exceptions...

Now, you may say, well MacOSX isn't on the FIPS supported/tested/validated list.
Ok, I'll give you that one ... I'm just thinking towards the future here. :)

Thanks!
-Brad
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-18 Thread Andy Polyakov
 There is more code committed. Check-out or wait for *tomorrow*
 openssl-SNAP-20120919 snapshot. There is SmartMIPS AES code (pass
 -msmartmips to Configure) and Configure accepts double dash as compiler
 options. Please double-check and optionally post performance for new AES
 code.
 
 Do I also need to pass -mips32r2 to enable the other assembler
 optimizations
 for MIPS that are not specific to the smartmips instruction set (such as
 BigNum and SHA)?  Or does -msmartmips imply that?

-msmartmips is sufficient for *assembly modules* [there is #if in AES
and SHA, and there is *no* R2 code in BN] to turn out optimal. In other
words for assembly modules, -msmartmips implies even -mips32r2. But one
can wonder if -mips32r2 -msmartmips combination is appropriate for
compiler-generated code, so feel free to experiment. It might be
appropriate to specify both anyway...
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-18 Thread Brad House

There is more code committed. Check-out or wait for *tomorrow*
openssl-SNAP-20120919 snapshot. There is SmartMIPS AES code (pass
-msmartmips to Configure) and Configure accepts double dash as compiler
options. Please double-check and optionally post performance for new AES
code.


Do I also need to pass -mips32r2 to enable the other assembler
optimizations
for MIPS that are not specific to the smartmips instruction set (such as
BigNum and SHA)?  Or does -msmartmips imply that?


-msmartmips is sufficient for *assembly modules* [there is #if in AES
and SHA, and there is *no* R2 code in BN] to turn out optimal. In other
words for assembly modules, -msmartmips implies even -mips32r2. But one
can wonder if -mips32r2 -msmartmips combination is appropriate for
compiler-generated code, so feel free to experiment. It might be
appropriate to specify both anyway...


Ah, ok.  I think I'll use -march=4ksd -msmartmips then, since that's
really what this processor is.

Thanks!
-Brad
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: Configure enhancements (Was: Re: MIPS linux support patch)

2012-09-18 Thread Andy Polyakov
Brad House wrote:
 There is more code committed. Check-out or wait for *tomorrow*
 openssl-SNAP-20120919 snapshot. There is SmartMIPS AES code (pass
 -msmartmips to Configure) and Configure accepts double dash as compiler
 options. Please double-check and optionally post performance for new AES
 code.
 
 On a different note, thanks for the double dash fix for Configure.  That
 said, I have one more issue in relation to the way Configure handles
 flags completely unrelated to MIPS...
 
 On MacOSX, you have to target a specific SDK if you want to ensure
 it targets the proper release of MacOSX.  That means you pass flags
 like this on to the compiler:
 
 -isysroot /Developer/SDKs/MacOSX10.6.sdk/ -mmacosx-version-min=10.6
 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk/
 
 The issue is that first one, where there is a space between the
 arguments.
 
 Now, I know what you're thinking, just quote it ... and sure, that
 does work if you call Configure directly such as:
 
 ./Configure darwin64-x86_64-cc -isysroot
 /Developer/SDKs/MacOSX10.6.sdk/ -mmacosx-version-min=10.6
 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk/
 
 But the problem really comes in when you're using the ./config
 wrapper script ... such as this:
 
 export KERNEL_BITS=64
 export CONFIG_OPTIONS=\-isysroot /Developer/SDKs/MacOSX10.6.sdk/\
 -mmacosx-version-min=10.6 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk/
 ./config
 
 You end up with output like this:
 $ ./config
 Operating system: i686-apple-darwinDarwin Kernel Version 11.2.0: Tue Aug
 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64
 Configuring for darwin64-x86_64-cc
 target already defined - darwin64-x86_64-cc (offending arg: -isysroot)

-isysroot%20/Developer/SDKs/...
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-18 Thread Brad House

There is more code committed. Check-out or wait for *tomorrow*
openssl-SNAP-20120919 snapshot. There is SmartMIPS AES code (pass
-msmartmips to Configure) and Configure accepts double dash as compiler
options. Please double-check and optionally post performance for new AES
code.


I've done some speed tests incase anyone is interested. linux-generic32,
then with 2 levels of asm optimizations, mips32r2 and finally smartmips.

Nice performance boost for smartmips AES.

./openssl-generic32 speed aes-128-cbc aes-256-cbc sha rsa1024 rsa2048
OpenSSL 1.1.0-dev xx XXX 
built on: Tue Sep 18 10:23:22 EDT 2012
options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) 
blowfish(ptr)
compiler: mipsel-linux-gcc -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN 
-DHAVE_DLFCN_H --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 -march=4ksd 
-DTERMIO -O3 -fomit-frame-pointer -Wall
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes256 bytes   1024 bytes   8192 bytes
sha1   201.48k  670.38k 1792.85k 3054.31k 3559.85k
aes-128 cbc   1188.95k 1256.10k 1274.56k 1273.03k 1170.29k
aes-256 cbc903.22k  947.09k  953.32k  949.16k  889.96k
sha256 151.84k  488.38k  987.51k 1329.50k 1428.14k
sha5123938.8715.79k   21.60k   29.06k   32.34k
  signverifysign/s verify/s
rsa 1024 bits 0.342000s 0.010615s  2.9 94.2
rsa 2048 bits 1.328750s 0.027632s  0.8 36.2


./openssl-mips32r2 speed aes-128-cbc aes-256-cbc sha rsa1024 rsa2048
OpenSSL 1.1.0-dev xx XXX 
built on: Tue Sep 18 10:25:23 EDT 2012
options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) 
blowfish(ptr)
compiler: mipsel-linux-gcc -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN 
-DHAVE_DLFCN_H --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 -mips32r2 -mabi=32 
-DTERMIO -O3 -Wall -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DAES_ASM
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes256 bytes   1024 bytes   8192 bytes
sha1   302.52k  980.49k 2510.76k 4113.38k 4575.10k
aes-128 cbc   1342.30k 1438.87k 1465.41k 1471.02k 1339.02k
aes-256 cbc   1005.29k 1057.55k 1072.65k 1073.67k  996.10k
sha256 248.80k  693.67k 1449.93k 1986.76k 2136.45k
sha5123952.0015.81k   21.52k   29.06k   32.23k
  signverifysign/s verify/s
rsa 1024 bits 0.128228s 0.008619s  7.8116.0
rsa 2048 bits 1.055000s 0.023870s  0.9 41.9


./openssl-smartmips speed aes-128-cbc aes-256-cbc sha rsa1024 rsa2048
OpenSSL 1.1.0-dev xx XXX 
built on: Tue Sep 18 10:27:09 EDT 2012
options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) 
blowfish(ptr)
compiler: mipsel-linux-gcc -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN 
-DHAVE_DLFCN_H --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 -march=4ksd 
-msmartmips -mabi=32 -DTERMIO -O3 -Wall -DOPENSSL_BN_ASM_MONT -DSHA1_ASM 
-DSHA256_ASM -DAES_ASM
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes256 bytes   1024 bytes   8192 bytes
sha1   250.35k 1037.93k 2636.80k 4267.35k 4713.80k
aes-128 cbc   1686.07k 1835.78k 1881.77k 1880.28k 1701.00k
aes-256 cbc   1289.04k 1373.28k 1397.96k 1397.88k 1295.48k
sha256 187.98k  624.13k 1368.54k 1951.04k 2135.38k
sha5123954.5215.76k   21.67k   29.16k   32.34k
  signverifysign/s verify/s
rsa 1024 bits 0.128846s 0.008381s  7.8119.3
rsa 2048 bits 1.033000s 0.023841s  1.0 41.9


Here was my build procedure for those that are interested:

export PATH=$PATH:/opt/uclibc/usr/bin
export CROSS_COMPILE=mipsel-linux-
./Configure linux-generic32 --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 -march=4ksd 
 \
make  \
mv apps/openssl apps/openssl-generic32  \
make clean  \
./Configure linux-mips32 --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 -mips32r2 
 \
make  \
mv apps/openssl apps/openssl-mips32r2  \
make clean  \
./Configure linux-mips32 --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 -march=4ksd 
-msmartmips  \
make  \
mv apps/openssl apps/openssl-smartmips


-Brad


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-18 Thread Andy Polyakov

./openssl-generic32 speed rsa1024 rsa2048
rsa 1024 bits 0.342000s 0.010615s  2.9 94.2
rsa 2048 bits 1.328750s 0.027632s  0.8 36.2


./openssl-mips32r2 speed rsa1024 rsa2048
rsa 1024 bits 0.128228s 0.008619s  7.8116.0
rsa 2048 bits 1.055000s 0.023870s  0.9 41.9


As for rsa2048 sign result. Try following. Open 
crypto/bn/asm/mips-mont.pl in text editor, locate line that reads


slt $at,$num,17

replace 17 with 33, make and retry. Essentially the number varies for 
processor to processor and this one what found optimal for R5000.


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-18 Thread Brad House

 ./openssl-generic32 speed rsa1024 rsa2048

rsa 1024 bits 0.342000s 0.010615s  2.9 94.2
rsa 2048 bits 1.328750s 0.027632s  0.8 36.2


./openssl-mips32r2 speed rsa1024 rsa2048
rsa 1024 bits 0.128228s 0.008619s  7.8116.0
rsa 2048 bits 1.055000s 0.023870s  0.9 41.9


As for rsa2048 sign result. Try following. Open crypto/bn/asm/mips-mont.pl in 
text editor, locate line that reads

 slt$at,$num,17

replace 17 with 33, make and retry. Essentially the number varies for processor 
to processor and this one what found optimal for R5000.


Done (rebuilt the 'smartmips' version with the change):

./openssl-smartmips2 speed rsa1024 rsa2048
rsa 1024 bits 0.129103s 0.008072s  7.7123.9
rsa 2048 bits 0.90s 0.024000s  1.1 41.7

~10% improvement on RSA2048 signs

Thanks.
-Brad
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: Configure enhancements (Was: Re: MIPS linux support patch)

2012-09-18 Thread Brad House

On a different note, thanks for the double dash fix for Configure.  That
said, I have one more issue in relation to the way Configure handles
flags completely unrelated to MIPS...

On MacOSX, you have to target a specific SDK if you want to ensure
it targets the proper release of MacOSX.  That means you pass flags
like this on to the compiler:

-isysroot /Developer/SDKs/MacOSX10.6.sdk/ -mmacosx-version-min=10.6
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk/


...


-isysroot%20/Developer/SDKs/...


Works perfectly.  Never would have thought of that.

Thanks!
-Brad
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-17 Thread Brad House

SSL negotiation (where the device is the server) takes about 2s
as it currently stands, and that's with the current MIPS assembler
support in OpenSSL.

I was planning on running some actual benchmarks but hadn't gotten
around to it yet.


I've just made some commits and here is workflow. First compile 
linux-generic32 build [adding -march=4ksd] and collect
output for 'openssl speed aes-128-cbc sha rsa1024' command. Then check-out 
latest source [alternatively wait for
*tomorrow* openssl-SNAP-20120916 snapshot], './Configure linux-mips32 
-mips32r2', build and collect output for above
command. You can either post outputs here or send to me personally. -mips32r2 
engages r2 code in assembly modules, don't
specify your 4ksd at this point, we'll figure it out later. If your compiler 
doesn't recognize -mips32r2, pass
-D_MIPS_ARCH_MIPS32R2 to ./Configure.

Some notes on new Linux/MIPS config lines. I've chosen not to refer to 
mips2-3-4, but to mips32 and mips64, which are
current MIPS architecture specifications. There also are mips32r2 and mips64r2 
specifications. The lines are
endian-neutral in sense that they work on either endianness target.


I'll do that first thing Monday when I have access to the device again.


I grabbed openssl-SNAP-20120917

Here's what I did to build it:

export PATH=$PATH:/opt/uclibc/usr/bin
export CROSS_COMPILE=mipsel-linux-
./Configure -march=4ksd --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 
linux-generic32
make
mipsel-linux-strip apps/openssl
mv apps/openssl apps/openssl-generic32
make clean

./Configure -D_FILE_OFFSET_BITS=32 --sysroot=/opt/uclibc linux-mips32 
-mips32r2
make
mipsel-linux-strip apps/openssl
mv apps/openssl apps/openssl-mips32r2

Then copied both openssl versions to the device.

./openssl-generic32 speed aes-128-cbc sha rsa1024
Doing sha1 for 3s on 16 size blocks: 36149 sha1's in 3.01s
Doing sha1 for 3s on 64 size blocks: 30076 sha1's in 3.01s
Doing sha1 for 3s on 256 size blocks: 19962 sha1's in 2.99s
Doing sha1 for 3s on 1024 size blocks: 8533 sha1's in 3.01s
Doing sha1 for 3s on 8192 size blocks: 1244 sha1's in 3.01s
Doing sha256 for 3s on 16 size blocks: 27339 sha256's in 3.00s
Doing sha256 for 3s on 64 size blocks: 21866 sha256's in 2.99s
Doing sha256 for 3s on 256 size blocks: 11082 sha256's in 3.01s
Doing sha256 for 3s on 1024 size blocks: 3710 sha256's in 3.01s
Doing sha256 for 3s on 8192 size blocks: 499 sha256's in 3.01s
Doing sha512 for 3s on 16 size blocks: 703 sha512's in 3.00s
Doing sha512 for 3s on 64 size blocks: 704 sha512's in 3.01s
Doing sha512 for 3s on 256 size blocks: 241 sha512's in 3.00s
Doing sha512 for 3s on 1024 size blocks: 82 sha512's in 3.04s
Doing sha512 for 3s on 8192 size blocks: 12 sha512's in 3.20s
Doing aes-128 cbc for 3s on 16 size blocks: 209052 aes-128 cbc's in 3.00s
Doing aes-128 cbc for 3s on 64 size blocks: 55532 aes-128 cbc's in 3.01s
Doing aes-128 cbc for 3s on 256 size blocks: 14079 aes-128 cbc's in 3.01s
Doing aes-128 cbc for 3s on 1024 size blocks: 3506 aes-128 cbc's in 3.01s
Doing aes-128 cbc for 3s on 8192 size blocks: 403 aes-128 cbc's in 3.01s
Doing 1024 bit private rsa's for 10s: 28 1024 bit private RSA's in 10.18s
Doing 1024 bit public rsa's for 10s: 887 1024 bit public RSA's in 9.90s
OpenSSL 1.1.0-dev xx XXX 
built on: Mon Sep 17 09:30:05 EDT 2012
options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) 
blowfish(ptr)
compiler: mipsel-linux-gcc -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN 
-DHAVE_DLFCN_H -march=4ksd --sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32 
-DTERMIO -O3 -fomit-frame-pointer -Wall
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes256 bytes   1024 bytes   8192 bytes
sha1   192.15k  639.49k 1709.12k 2902.92k 3385.66k
aes-128 cbc   1114.94k 1180.75k 1197.42k 1192.74k 1096.80k
sha256 145.81k  468.03k  942.52k 1262.14k 1358.08k
sha5123749.3314.97k   20.57k   27.62k   30.72k
  signverifysign/s verify/s
rsa 1024 bits 0.363571s 0.011161s  2.8 89.6


./openssl-mips32r2  speed aes-128-cbc sha rsa1024
Doing sha1 for 3s on 16 size blocks: 54904 sha1's in 2.95s
Doing sha1 for 3s on 64 size blocks: 45365 sha1's in 3.01s
Doing sha1 for 3s on 256 size blocks: 28959 sha1's in 2.99s
Doing sha1 for 3s on 1024 size blocks: 11840 sha1's in 3.01s
Doing sha1 for 3s on 8192 size blocks: 1649 sha1's in 3.01s
Doing sha256 for 3s on 16 size blocks: 45012 sha256's in 3.01s
Doing sha256 for 3s on 64 size blocks: 31131 sha256's in 2.99s
Doing sha256 for 3s on 256 size blocks: 16242 sha256's in 3.00s
Doing sha256 for 3s on 1024 size blocks: 5522 sha256's in 2.98s
Doing sha256 for 3s on 8192 size blocks: 748 sha256's in 3.01s
Doing sha512 for 3s on 16 size blocks: 706 sha512's in 3.01s
Doing sha512 for 3s on 64 size blocks: 705 sha512's in 3.01s
Doing sha512 for 3s on 256 size blocks: 241 sha512's in 3.01s

Re: MIPS linux support patch

2012-09-17 Thread Andy Polyakov

SSL negotiation (where the device is the server) takes about 2s
as it currently stands, and that's with the current MIPS assembler
support in OpenSSL.


I grabbed openssl-SNAP-20120917
...
./openssl-generic32 speed aes-128-cbc sha rsa1024
type 16 bytes 64 bytes256 bytes   1024 bytes   8192 bytes
sha1   192.15k  639.49k 1709.12k 2902.92k 3385.66k
aes-128 cbc   1114.94k 1180.75k 1197.42k 1192.74k 1096.80k
sha256 145.81k  468.03k  942.52k 1262.14k 1358.08k
sha5123749.3314.97k   20.57k   27.62k   30.72k
  signverifysign/s verify/s
rsa 1024 bits 0.363571s 0.011161s  2.8 89.6


./openssl-mips32r2  speed aes-128-cbc sha rsa1024
type 16 bytes 64 bytes256 bytes   1024 bytes   8192 bytes
sha1   297.78k  964.57k 2479.43k 4027.96k 4487.91k
aes-128 cbc   1284.54k 1369.60k 1392.86k 1396.18k 1272.49k
sha256 239.27k  666.35k 1385.98k 1897.49k 2035.75k
sha5123752.8214.99k   20.50k   27.65k   30.72k
  signverifysign/s verify/s
rsa 1024 bits 0.135811s 0.009086s  7.4110.1


Thanks!


Thank *you*! I was expecting a bit better performance (in absolute 
terms), but it might be limited by interface to external memory. At 
least sha512 performance is exceptionally bad and it surely depends on 
poor external memory performance. I mean it has to keep data in memory 
more than any other algorithm in question and that's what is likely to 
hurt it that much. It should be only few times slower than sha256 (e.g. 
2.2 was observed on R5000), not *60* as you measured. 2x improvement in 
rsa1024 is also unexpected, but the other way, it more than expected, so 
that one can't complain here...


Now to the original question. You said that SSL negotiation takes 2s 
(server side you said, assuming RSA, i.e. RSA sign is dominating), and 
it's open question if it's fast enough for your purposes. If you are 
using 1024-bit key, then it should go faster. 2s probably means that 
you're spending notable portion of the time elsewhere, most likely 
synthesizing randoms. The datasheet you referred to mentions that the 
microcontroller in question has TRNG and it definitely should improve 
situation if you find a way to utilize it. If it's longer key we're 
talking about, then... Well, as mentioned, CPU in question implements 
SmartMIPS extension, which means that there is room for further 
improvement. It's hard to estimate... 
https://www.mips.com/products/processor-cores/classic/mips32-4k/ 
mentions 15ms for rsa1024 sign at 200MHz, which is 4x better than above 
result (scaled for 96MHz)... Well, it might be possible if one 
implements dedicated procedure targeting specifically 1024-bit key 
operations (modulo security counter-measures implemented in OpenSSL), 
otherwise 2x is probably more feasible for general case...


Datasheet also mentions that CPU in question has support for hardware 
AES-128. It would surely make difference if one manages to utilize it. 
Just keep in mind that in such case hash function would be the limiting 
factor. I mean if encryption gets a lot faster, you still have to hash 
the data, so you won't be able to break ~4.5MBps for SHA1.


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-17 Thread Andy Polyakov
I was expecting a bit better performance (in absolute 
terms),


Could you double-check one thing? Run 'mipsel-linux-objdump -d 
crypto/sha/sha1-mips.o | grep ror | wc'. Do you get a lot of hits? This 
is to double-check that -mips32r2 was in fact effective and passed down 
_MIPS_ARCH_MIPS32R2 pre-define.

__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-17 Thread Brad House

I was expecting a bit better performance (in absolute terms),


Could you double-check one thing? Run 'mipsel-linux-objdump -d 
crypto/sha/sha1-mips.o | grep ror | wc'. Do you get a lot of hits? This is to 
double-check that -mips32r2 was in fact effective and passed down 
_MIPS_ARCH_MIPS32R2 pre-define.


$ mipsel-linux-objdump -d crypto/sha/sha1-mips.o | grep ror | wc
240 9608320
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-15 Thread Andy Polyakov

Brad,


This patchset is against OpenSSL 1.0.1c.


Whatever we will do, will apply to HEAD and optionally 1.0.2. 1.0.1 is 
closed for new features, including new platforms, and linux-generic32 is 
the one that serves MIPS there.



It does 2 things very minor things.

First, it adds a linux-mipsel target to Configure.


What's your target more specifically? You mention 4ksd in commentary, is 
it it? Do you have something else? The thing about linux-mips is that 
[as far as I understand] there are n32 dists, and n32 allows for much 
faster bignum and sha512 assembler. I don't know if there is 64-bit 
linux for MIPS, but it makes sense to reserve at least for plain o32 
and n32. Latter can run on processors compliant with mips3, mips4, 
mips64 and mips64r2 specifications.


As for 4ksd. It appears to be mips32r2 processor, and even with 
SmartMIPS ASE. Actually on r2 compiler has all chances to beat currently 
available assembler, if it recognizes rotates and deploys rotate 
instruction. I have r2 code, and wonder if you can test and benchmark 
it. SmartMIPS extension offers improved support for bignum and 
polynomial multiplication, but I have no code for it.



Second, it fixes the MIPS perlasm, it appears as though at some point
AES_set_encrypt_key and AES_set_decrypt_key in the ASM needed to be
renamed to private_AES_set_encrypt_key and private_AES_set_decrypt_key,
respectively and MIPS got missed.


This was recently fixed.
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-15 Thread Brad House

Commenting below ...


This patchset is against OpenSSL 1.0.1c.


Whatever we will do, will apply to HEAD and optionally 1.0.2. 1.0.1 is closed 
for new features, including new platforms,
and linux-generic32 is the one that serves MIPS there.


Ok, not a problem ... more about future support, I can maintain my own patch 
for 1.0.1.
linux-generic32 doesn't include the mips assembler, so that would be undesirable
for my purposes.


It does 2 things very minor things.

First, it adds a linux-mipsel target to Configure.


What's your target more specifically? You mention 4ksd in commentary, is it it? 
Do you have something else? The thing
about linux-mips is that [as far as I understand] there are n32 dists, and n32 
allows for much faster bignum and sha512
assembler. I don't know if there is 64-bit linux for MIPS, but it makes sense to reserve 
at least for plain o32 and
n32. Latter can run on processors compliant with mips3, mips4, mips64 and 
mips64r2 specifications.


This is the processor I'm running, it is a 32bit 96MHz MIPS 4ksd processor:
http://www.maximintegrated.com/datasheet/index.mvp/id/6134

I'm not the manufacturer of the device being used, we were just given a
cross-compiler for the mipsel-linux uclibc environment the device runs, and
were asked to see if we could port our application to the environment with
reasonable performance.

It looks like n32 is for 64bit CPUs only, so I'm assuming I'm using o32.


As for 4ksd. It appears to be mips32r2 processor, and even with SmartMIPS ASE. 
Actually on r2 compiler has all chances
to beat currently available assembler, if it recognizes rotates and deploys 
rotate instruction. I have r2 code, and
wonder if you can test and benchmark it. SmartMIPS extension offers improved 
support for bignum and polynomial
multiplication, but I have no code for it.


I can definitely test and benchmark whatever you want on the platform,
I'm definitely willing to try out any new code you may have.

The device is definitely a bit anemic from a performance standpoint,
SSL negotiation (where the device is the server) takes about 2s
as it currently stands, and that's with the current MIPS assembler
support in OpenSSL.

I was planning on running some actual benchmarks but hadn't gotten
around to it yet.




Second, it fixes the MIPS perlasm, it appears as though at some point
AES_set_encrypt_key and AES_set_decrypt_key in the ASM needed to be
renamed to private_AES_set_encrypt_key and private_AES_set_decrypt_key,
respectively and MIPS got missed.


This was recently fixed.


Ah, I missed that.

Thanks!
-Brad
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-15 Thread Andy Polyakov
What's your target more specifically? You mention 4ksd in commentary, 
is it it?


This is the processor I'm running, it is a 32bit 96MHz MIPS 4ksd processor:
http://www.maximintegrated.com/datasheet/index.mvp/id/6134

It looks like n32 is for 64bit CPUs only, so I'm assuming I'm using o32.


Correct, n32 is option only for 64-bit processors, and o32 is the only 
option for 32-bit processors.


As for 4ksd. It appears to be mips32r2 processor, and even with 
SmartMIPS ASE. Actually on r2 compiler has all chances
to beat currently available assembler, if it recognizes rotates and 
deploys rotate instruction. I have r2 code, and
wonder if you can test and benchmark it. SmartMIPS extension offers 
improved support for bignum and polynomial

multiplication, but I have no code for it.


I can definitely test and benchmark whatever you want on the platform,
I'm definitely willing to try out any new code you may have.

The device is definitely a bit anemic from a performance standpoint,


How is it possible? The URL you mentioned above says Industry's Highest 
Performance, Most Secure 32-Bit MIPS Processor. :-) :-) :-)



SSL negotiation (where the device is the server) takes about 2s
as it currently stands, and that's with the current MIPS assembler
support in OpenSSL.

I was planning on running some actual benchmarks but hadn't gotten
around to it yet.


I've just made some commits and here is workflow. First compile 
linux-generic32 build [adding -march=4ksd] and collect output for 
'openssl speed aes-128-cbc sha rsa1024' command. Then check-out latest 
source [alternatively wait for *tomorrow* openssl-SNAP-20120916 
snapshot], './Configure linux-mips32 -mips32r2', build and collect 
output for above command. You can either post outputs here or send to me 
personally. -mips32r2 engages r2 code in assembly modules, don't specify 
your 4ksd at this point, we'll figure it out later. If your compiler 
doesn't recognize -mips32r2, pass -D_MIPS_ARCH_MIPS32R2 to ./Configure.


Some notes on new Linux/MIPS config lines. I've chosen not to refer to 
mips2-3-4, but to mips32 and mips64, which are current MIPS architecture 
specifications. There also are mips32r2 and mips64r2 specifications. The 
lines are endian-neutral in sense that they work on either endianness 
target.


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-15 Thread Brad House

SSL negotiation (where the device is the server) takes about 2s
as it currently stands, and that's with the current MIPS assembler
support in OpenSSL.

I was planning on running some actual benchmarks but hadn't gotten
around to it yet.


I've just made some commits and here is workflow. First compile 
linux-generic32 build [adding -march=4ksd] and collect
output for 'openssl speed aes-128-cbc sha rsa1024' command. Then check-out 
latest source [alternatively wait for
*tomorrow* openssl-SNAP-20120916 snapshot], './Configure linux-mips32 
-mips32r2', build and collect output for above
command. You can either post outputs here or send to me personally. -mips32r2 
engages r2 code in assembly modules, don't
specify your 4ksd at this point, we'll figure it out later. If your compiler 
doesn't recognize -mips32r2, pass
-D_MIPS_ARCH_MIPS32R2 to ./Configure.

Some notes on new Linux/MIPS config lines. I've chosen not to refer to 
mips2-3-4, but to mips32 and mips64, which are
current MIPS architecture specifications. There also are mips32r2 and mips64r2 
specifications. The lines are
endian-neutral in sense that they work on either endianness target.


I'll do that first thing Monday when I have access to the device again.
Thanks!
-Brad
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: MIPS linux support patch

2012-09-07 Thread Brad House

On 09/07/2012 11:55 AM, Brad House wrote:

This patchset is against OpenSSL 1.0.1c.

It does 2 things very minor things.

First, it adds a linux-mipsel target to Configure.

Second, it fixes the MIPS perlasm, it appears as though at some point
AES_set_encrypt_key and AES_set_decrypt_key in the ASM needed to be
renamed to private_AES_set_encrypt_key and private_AES_set_decrypt_key,
respectively and MIPS got missed.


Here's a second patch which updates the config os guess script
as well, it should be applied along with the previous patch, as well
as the patch I provided for the Configure script for supporting
--sysroot.

Example usage for my cross-development environment:

export PATH=$PATH:/opt/uclibc/usr/bin
export MACHINE=mips
export CROSS_COMPILE=mipsel-linux-
export ARCH=4ksd
export SYSTEM=Linux
export RELEASE=2.6
export options=--sysroot=/opt/uclibc -D_FILE_OFFSET_BITS=32
./config -t
Operating system: mips-whatever-linux2
Configuring for linux-mipsel
/usr/bin/perl ./Configure linux-mipsel --sysroot=/opt/uclibc 
-D_FILE_OFFSET_BITS=32 -march=4ksd -Wa,--noexecstack


Thanks.
-Brad
--- openssl-1.0.1c.old/config   2011-11-14 16:12:53.0 -0500
+++ openssl-1.0.1c/config   2012-09-07 12:35:37.843453817 -0400
@@ -644,6 +644,11 @@
   armv[1-3]*-*-linux2) OUT=linux-generic32 ;;
   armv[7-9]*-*-linux2) OUT=linux-armv4; options=$options -march=armv7-a ;;
   arm*-*-linux2) OUT=linux-armv4 ;;
+  mips*-*-linux2)
+   OUT=linux-mipsel
+   [ $ARCH ] || ARCH=mips2
+   options=$options -march=$ARCH
+   ;;
   sh*b-*-linux2) OUT=linux-generic32; options=$options -DB_ENDIAN ;;
   sh*-*-linux2)  OUT=linux-generic32; options=$options -DL_ENDIAN ;;
   m68k*-*-linux2) OUT=linux-generic32; options=$options -DB_ENDIAN ;;