]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: drbg - replace spinlock with mutex
authorStephan Mueller <smueller@chronox.de>
Sat, 18 Apr 2015 17:36:17 +0000 (19:36 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 21 Apr 2015 01:14:45 +0000 (09:14 +0800)
commit79f7a86ad3ede9b9a6be3fce4c30c85282225ca1
treebd110a6cb0612d42fcbc0c70517c9be4c4eec0f6
parent2b66203dcae66770d29bed100814f92985506e83
crypto: drbg - replace spinlock with mutex

The creation of a shadow copy is intended to only hold a short term
lock. But the drawback is that parallel users have a very similar DRBG
state which only differs by a high-resolution time stamp.

The DRBG will now hold a long term lock. Therefore, the lock is changed
to a mutex which implies that the DRBG can only be used in process
context.

The lock now guards the instantiation as well as the entire DRBG
generation operation. Therefore, multiple callers are fully serialized
when generating a random number.

As the locking is changed to use a long-term lock to avoid such similar
DRBG states, the entire creation and maintenance of a shadow copy can be
removed.

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