linux/arch/s390/crypto
Harald Freudenberger 966f53e750 s390/archrandom: Rework arch random implementation.
The arch_get_random_seed_long() invocation done by the random device
driver is done in interrupt context and may be invoked very very
frequently. The existing s390 arch_get_random_seed*() implementation
uses the PRNO(TRNG) instruction which produces excellent high quality
entropy but is relatively slow and thus expensive.

This fix reworks the arch_get_random_seed* implementation. It
introduces a buffer concept to decouple the delivery of random data
via arch_get_random_seed*() from the generation of new random
bytes. The buffer of random data is filled asynchronously by a
workqueue thread.
If there are enough bytes in the buffer the s390_arch_random_generate()
just delivers these bytes. Otherwise false is returned until the worker
thread refills the buffer.
The worker fills the rng buffer by pulling fresh entropy from the
high quality (but slow) true hardware random generator. This entropy
is then spread over the buffer with an pseudo random generator.
As the arch_get_random_seed_long() fetches 8 bytes and the calling
function add_interrupt_randomness() counts this as 1 bit entropy the
distribution needs to make sure there is in fact 1 bit entropy
contained in 8 bytes of the buffer. The current values pull 32 byte
entropy and scatter this into a 2048 byte buffer. So 8 byte in the
buffer will contain 1 bit of entropy.
The worker thread is rescheduled based on the charge level of the
buffer but at least with 500 ms delay to avoid too much cpu consumption.
So the max. amount of rng data delivered via arch_get_random_seed is
limited to 4Kb per second.

Signed-off-by: Harald Freudenberger <freude@de.ibm.com>
Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2018-05-30 11:18:04 +02:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
aes_s390.c s390/crypto: Adjust s390 aes and paes cipher priorities 2018-04-10 07:38:54 +02:00
arch_random.c s390/archrandom: Rework arch random implementation. 2018-05-30 11:18:04 +02:00
crc32-vx.c crypto: hash - annotate algorithms taking optional key 2018-01-12 23:03:35 +11:00
crc32be-vx.S s390/crc32-vx: use expoline for indirect branches 2018-05-07 09:07:34 +02:00
crc32le-vx.S s390/crc32-vx: use expoline for indirect branches 2018-05-07 09:07:34 +02:00
des_s390.c s390: crypto: Remove redundant license text 2017-11-24 15:37:23 +01:00
ghash_s390.c s390: crypto: add SPDX identifiers to the remaining files 2017-11-24 15:37:14 +01:00
paes_s390.c s390/crypto: Adjust s390 aes and paes cipher priorities 2018-04-10 07:38:54 +02:00
prng.c s390: crypto: add SPDX identifiers to the remaining files 2017-11-24 15:37:14 +01:00
sha.h s390: crypto: Remove redundant license text 2017-11-24 15:37:23 +01:00
sha1_s390.c s390: Remove redudant license text 2017-12-05 07:51:09 +01:00
sha256_s390.c s390: crypto: Remove redundant license text 2017-11-24 15:37:23 +01:00
sha512_s390.c s390: crypto: Remove redundant license text 2017-11-24 15:37:23 +01:00
sha_common.c s390: crypto: Remove redundant license text 2017-11-24 15:37:23 +01:00