Home GnuPG

random: Eliminate unneeded memcpy invocations in the DRBG.
656395ba4cf3Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

random: Eliminate unneeded memcpy invocations in the DRBG.

* random/random-drbg.c (drbg_hash): Remove arg 'outval' and return a
pointer instead.
(drbg_instantiate): Reduce size of scratchpad.
(drbg_hmac_update): Avoid use of scratch buffers for the hash.
(drbg_hmac_generate, drbg_hash_df): Ditto.
(drbg_hash_process_addtl): Ditto.
(drbg_hash_hashgen): Ditto.
(drbg_hash_generate): Ditto.

The gcry_md_read returns a pointer to the hash which can be directly
used instead of copying it into a scratch buffer. This eliminates a
number of memcpy invocations for HMAC and Hash DRBG and reduces the
memory footprint of the Hash DRBG by the block size of the used hash.

The performance increase is between 1 and 3 MB/s depending on the output
buffer size.

ChangeLog entries above written by -wk.

  • Signed-off-by: Stephan Mueller <smueller@chronox.de>

Details

Provenance
smueller_chronox.deAuthored on Dec 3 2016, 7:18 PM
wernerCommitted on Dec 8 2016, 9:06 AM
Parents
rC20886fdcb841: random: Add performance improvements for the DRBG.
Branches
Unknown
Tags
Unknown

Event Timeline

Werner Koch <wk@gnupg.org> committed rC656395ba4cf3: random: Eliminate unneeded memcpy invocations in the DRBG. (authored by Stephan Mueller <smueller@chronox.de>).Dec 8 2016, 9:06 AM