]> 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)
commit2de26a1f60b25c4a8bf40026b55458d2a2fb4141
treebd110a6cb0612d42fcbc0c70517c9be4c4eec0f6
parent98c820b86797cadaee86dd6548a05f84909466ef
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