]> git.ipfire.org Git - thirdparty/pdns.git/commit
auth: Speed up ECDSA and RSA signatures
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 2 May 2022 09:46:38 +0000 (11:46 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 12 Jan 2023 13:39:02 +0000 (14:39 +0100)
commitab5df14454e7830e446f2ed2ea15fc1750b0d8f3
treed6a4fd4cae52abefe639f75f8b871eec74d8e2c2
parent8b093b31a28c1928f5921a2cbb8900bc74870405
auth: Speed up ECDSA and RSA signatures

For ECDSA, and likely for RSA, computing the public key is not a cheap
operation. So instead of computing it twice to get the lookup key for
our signatures cache, reuse the computed public key and only compute its
digest.
In addition, since ed* algorithms were already using the whole key instead
of a digest, place the cut off at public keys larger than 64 bytes, meaning
that only RSA ones (128+ bytes) will be hashed.
This provides an additional speedup for ECDSA keys (32 or 48 bytes) since
they no longer need to be hashed, and simplifies the signers code as the
hashing can be moved to the key cache now that it only depends on they key
size.
For reference the size of a SHA-1 digest is 20 bytes.

In my tests this reduces by 30% the cost of calling addRRSigs() for ECDSA
signatures when the signature is already present in the cache.
pdns/decafsigners.cc
pdns/dnssecinfra.hh
pdns/dnssecsigner.cc
pdns/opensslsigners.cc
pdns/pkcs11signers.cc
pdns/pkcs11signers.hh
pdns/sodiumsigners.cc
pdns/test-signers.cc