Jean-Daniel,

Jean-Daniel wrote:

I did an other simple test that call SECKEY_CreateRSAPrivateKey() in a
loop and then call the OpenSSL equivalent to compare both functions.
NSS does not perform as bad as I thought first, but it remain slower
than what I expect on a modern machine.

See the result for 20 loops:

----------- NSS -----------
average: 5714 ms
min: 1240 ms, max: 15160

----------- OpenSSL -----------
average: 1646 ms
min: 385 ms, max: 4744

You are running Darwin, and freebl does not have any optimizations for RSA on darwin. It has some assembly optimizations on most other x86 platforms. But on Darwin, freebl is built with plain C code, and no assembly at all. That is one reason why the code is running a lot slower.

It's likely that your OpenSSL version has been built with some assembly optimizations, which could explain the difference.

Even if you end up building NSS with optimizations, they use the regular multiply instructions, which performs best on AMD chips, but not as well on Intel CPUs. For Intel, one needs to use the SSE2 and above instructions set, which NSS currently doesn't do - except on one platform, Linux.

Another possible reason is if you are comparing 32-bit NSS vs 64-bit OpenSSL binaries. Regardless of assembly optimizations. The 64-bit code is always a lot faster, even without optimizations.

FYI, I ran the following command on Solaris x64, on a 4-year old dual AMD Opteron 246 (2.2 GHz), with a 32-bit optimized of NSS 3.12, with optimizations :

time ./rsaperf -n none -k 2048 -g -i 1

This does one keygen, plus one RSA private key op (there is no way to make rsaperf do 0 private key ops ...). But the time of the private key op is about 26 ms, fixed time, and mostly noise lost in the keygen time.

My results were between 0.91 and 5.38 seconds, with an average of 2.72 seconds. Still slower than your openssl build, but about twice as fast as your NSS results.

When using a 64-bit optimized build of NSS, on the same system, the results were way better.

Out of 10, the RSA keygen time only varies from 0.25 to 0.84 second. The average was 0.6 second. The lone private key op time dropped to 4.6 milliseconds, so it's still negligible.
_______________________________________________
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to