]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit - crypto/drbg.c
crypto: drbg - replace int2byte with cpu_to_be
authorStephan Mueller <smueller@chronox.de>
Sun, 17 Aug 2014 15:37:34 +0000 (17:37 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 25 Aug 2014 12:34:07 +0000 (20:34 +0800)
commit72f3e00dd67ec449199a8844bc012a4fa1e0340a
treeb73c93435e7f60dd8064e6e73b83b974ecff0abe
parent4451d494b1910bf7b7f8381a637d0fe6d2142467
crypto: drbg - replace int2byte with cpu_to_be

The DRBG requires the conversion of an integer into a string
representation of that integer. The previous implementation converted
the given integer byte-wise. However, the kernel offers the cpu_to_be
function which already re-arranges the memory representation of an
integer such that it applies when interpreting the same memory as
character string.

The change therefore uses an integer-cast / union of the target
character array together with the cpu_to_be function to convert an
integer into its string representation.

Tests show that the Hash and CTR DRBG implementations (the HMAC DRBG
does not require such conversion) is about 10% faster (or requires less
computing power, respectively).

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/drbg.c