Subject: Re: OpenSSL RSA very very slow
To: Frank van der Linden <fvdl@NetBSD.org>
From: J.T. Conklin <jtc@acorntoolworks.com>
List: port-amd64
Date: 01/10/2005 19:00:23
>>> Just an observation that the RSA operations in the OpenSSL distribution
>>> that comes with NetBSD-amd64 version 2.0 is very slow compared to the
>>> NetBSD-i386 version when run on a machine with similar CPU clock speed.
>>
>> What commandline are you using to measure the speed?
>
> I see this with 'openssl speed rsa' when comparing the stock NetBSD
> OpenSSL, and one using SIXTY_FOUR_BIT_LONG and bn/asm/x86_64-gcc.c.
>
> Submitting a Configure patch to the OpenSSL folks and a NetBSD PR with
> Makefile *.inc changes has been on my queue for some time, I'll try to
> make it happen this evening.
I spent some time this afternoon making the "obvious" change of adding a
.../lib/crypto/arch/x86_64/bn.inc that defined SIXTY_FOUR_BIT_LONG and
replaced bn_asm.c with bn/asm/x86_64-gcc.c in SRCS. Unfortunately, it
seems that NetBSD's bn.h has been extensively modified, removing all the
definitions for SIXTY_FOUR_BIT and SIXTY_FOUR_BIT_LONG, so the resulting
executable crashes.
Fixing this would be worthwhile. For reference NetBSD's "openssl
speed rsa" is:
OpenSSL 0.9.7d 17 Mar 2004
built on: NetBSD 2.0
options:bn(32,32) md2(int) rc4(ptr,int) des(idx,cisc,4,int) aes(partial) blowfish(idx)
compiler: gcc version 3.3.3 (NetBSD nb3 20040520)
available timing options: USE_TOD HZ=100 [sysconf value]
timing function used: getrusage
sign verify sign/s verify/s
rsa 512 bits 0.0011s 0.0001s 934.6 8358.1
rsa 1024 bits 0.0061s 0.0004s 163.4 2760.1
rsa 2048 bits 0.0394s 0.0013s 25.4 797.3
rsa 4096 bits 0.2739s 0.0045s 3.7 220.3
While a version I built with SIXTY_FOUR_BIT_LONG and x86_64-gcc.c is:
OpenSSL 0.9.7d 17 Mar 2004
built on: Tue Oct 5 11:07:45 PDT 2004
options:bn(64,64) md2(int) rc4(ptr,char) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx)
compiler: gcc -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_NO_KRB5 -DTERMIOS -O3 -Wall -DL_ENDIAN -DMD32_REG_T=int
available timing options: USE_TOD HZ=100 [sysconf value]
timing function used: getrusage
sign verify sign/s verify/s
rsa 512 bits 0.0003s 0.0000s 3873.5 46767.9
rsa 1024 bits 0.0008s 0.0000s 1249.0 20547.2
rsa 2048 bits 0.0043s 0.0001s 234.8 7498.6
rsa 4096 bits 0.0266s 0.0004s 37.6 2360.1
--jtc
--
J.T. Conklin