]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - crypto/drbg.c
crypto: drbg - Do not seed RNG in drbg_kcapi_init
authorHerbert Xu <herbert@gondor.apana.org.au>
Mon, 20 Apr 2015 03:29:15 +0000 (11:29 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 21 Apr 2015 02:19:53 +0000 (10:19 +0800)
commit2a57e4241ec9a11ce89f43099a0f6b83a28058fa
tree1eeece5365a29d687a80ee842aa2fde7d96509cc
parente11a754813e28dbfab63a23ae8fd22e9198489e1
crypto: drbg - Do not seed RNG in drbg_kcapi_init

Initialising the RNG in drbg_kcapi_init is a waste of precious
entropy because all users will immediately seed the RNG after
the allocation.

In fact, all users should seed the RNG before using it.  So there
is no point in doing the seeding in drbg_kcapi_init.

This patch removes the initial seeding and the user must seed
the RNG explicitly (as they all currently do).

This patch also changes drbg_kcapi_reset to allow reseeding.
That is, if you call it after a successful initial seeding, then
it will not reset the internal state of the DRBG before mixing
the new input and entropy.

If you still wish to reset the internal state, you can always
free the DRBG and allocate a new one.

Finally this patch removes locking from drbg_uninstantiate because
it's now only called from the destruction path which must not be
executed in parallel with normal operations.

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