Libgcrypt and libgmp

Dmitry Eremin-Solenikov dbaryshkov at gmail.com
Fri Sep 5 00:14:22 CEST 2014


Hello,

I was looking on how to improve the performance of public key
implementation in libgcrypt.
One of ideas was to check if using libgmp can improve the situation.
Nowdays GMP is
dual-licensed under GPLv2+ or LGPLv3+. As far as I understand, this
licensing is compatible
with libgcrypt LGPLv2.1+.

Surprisingly even replacing several asm-coded functions resulted in
nearly 20-25% speed
increase (according to tests/benchmark pubkey). Do such patches have a
chance to be
reviewed & accepted, or it is a waste of time, as you would prefer to
keep libgcrypt
independent of libgmp. I'm not changing the gcry_mpi_t internals, or
removing secure
allocation/reallocation, only replacing the computational code.

Before:
Algorithm         generate 1000*priv 1000*public
------------------------------------------------
RSA 1024 bit          10ms     770ms        40ms
RSA 2048 bit         320ms    4850ms       130ms
RSA 3072 bit        1460ms   13640ms       220ms
RSA 4096 bit        1690ms   31830ms       390ms
ELG 1024 bit             -    1360ms      1190ms
ELG 2048 bit             -    4840ms      5260ms
ELG 3072 bit             -   10050ms     11400ms
DSA 1024/160             -     560ms       690ms
DSA 2048/224             -    2060ms      2860ms
DSA 3072/256             -    4220ms      5890ms
ECDSA 192 bit          0ms    1270ms      2170ms
ECDSA 224 bit         10ms    2060ms      3800ms
ECDSA 256 bit          0ms    1800ms      3200ms
ECDSA 384 bit         20ms    3770ms      6830ms
ECDSA 521 bit         30ms    8990ms     16490ms
EdDSA Ed25519          0ms    4010ms      5650ms
GOST  256 bit         10ms    1730ms      3270ms
GOST  512 bit         30ms    8030ms     15250ms

After:
Algorithm         generate 1000*priv 1000*public
------------------------------------------------
RSA 1024 bit          10ms     550ms        30ms
RSA 2048 bit         100ms    3270ms        80ms
RSA 3072 bit         120ms    8980ms       150ms
RSA 4096 bit         850ms   21110ms       250ms
ELG 1024 bit             -    1020ms       850ms
ELG 2048 bit             -    3400ms      3530ms
ELG 3072 bit             -    6960ms      7850ms
DSA 1024/160             -     380ms       470ms
DSA 2048/224             -    1390ms      1850ms
DSA 3072/256             -    2870ms      4030ms
ECDSA 192 bit          0ms    1200ms      2100ms
ECDSA 224 bit         10ms    1860ms      3470ms
ECDSA 256 bit         10ms    1730ms      3070ms
ECDSA 384 bit         10ms    3150ms      5800ms
ECDSA 521 bit         30ms    6880ms     13090ms
EdDSA Ed25519         10ms    3550ms      5110ms
GOST  256 bit          0ms    1680ms      3200ms
GOST  512 bit         20ms    6400ms     12590ms


-- 
With best wishes
Dmitry



More information about the Gcrypt-devel mailing list