random: Eliminate unneeded memcpy invocations in the DRBG.
authorStephan Mueller <smueller@chronox.de>
Sat, 3 Dec 2016 18:18:01 +0000 (19:18 +0100)
committerWerner Koch <wk@gnupg.org>
Thu, 8 Dec 2016 08:06:30 +0000 (09:06 +0100)
commit656395ba4cf34f42dda3a120bda3ed1220755a3d
tree54378dbc8d422fa6c1e5f12e26577bc4eacf793c
parent20886fdcb841b0bf89bb1d44303d42f1804e38cb
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.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
ChangeLog entries above written by -wk.
random/random-drbg.c