aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-10-25 19:43:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-25 19:43:35 -0400
commit62606c224d72a98c35d21a849f95cccf95b0a252 (patch)
tree6f6f3466451edf9baa2ea8b5f9fc558aa555c69a /drivers/char/random.c
parent24ed334f33666f2ae929ccc08f72e7e72e353c64 (diff)
parenta1c6fd4308d37f072e939a2782f24214115fc7e8 (diff)
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu: "API: - Remove VLA usage - Add cryptostat user-space interface - Add notifier for new crypto algorithms Algorithms: - Add OFB mode - Remove speck Drivers: - Remove x86/sha*-mb as they are buggy - Remove pcbc(aes) from x86/aesni - Improve performance of arm/ghash-ce by up to 85% - Implement CTS-CBC in arm64/aes-blk, faster by up to 50% - Remove PMULL based arm64/crc32 driver - Use PMULL in arm64/crct10dif - Add aes-ctr support in s5p-sss - Add caam/qi2 driver Others: - Pick better transform if one becomes available in crc-t10dif" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (124 commits) crypto: chelsio - Update ntx queue received from cxgb4 crypto: ccree - avoid implicit enum conversion crypto: caam - add SPDX license identifier to all files crypto: caam/qi - simplify CGR allocation, freeing crypto: mxs-dcp - make symbols 'sha1_null_hash' and 'sha256_null_hash' static crypto: arm64/aes-blk - ensure XTS mask is always loaded crypto: testmgr - fix sizeof() on COMP_BUF_SIZE crypto: chtls - remove set but not used variable 'csk' crypto: axis - fix platform_no_drv_owner.cocci warnings crypto: x86/aes-ni - fix build error following fpu template removal crypto: arm64/aes - fix handling sub-block CTS-CBC inputs crypto: caam/qi2 - avoid double export crypto: mxs-dcp - Fix AES issues crypto: mxs-dcp - Fix SHA null hashes and output length crypto: mxs-dcp - Implement sha import/export crypto: aegis/generic - fix for big endian systems crypto: morus/generic - fix for big endian systems crypto: lrw - fix rebase error after out of bounds fix crypto: cavium/nitrox - use pci_alloc_irq_vectors() while enabling MSI-X. crypto: cavium/nitrox - NITROX command queue changes. ...
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index c75b6cdf0053..2eb70e76ed35 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -433,9 +433,9 @@ static int crng_init_cnt = 0;
433static unsigned long crng_global_init_time = 0; 433static unsigned long crng_global_init_time = 0;
434#define CRNG_INIT_CNT_THRESH (2*CHACHA20_KEY_SIZE) 434#define CRNG_INIT_CNT_THRESH (2*CHACHA20_KEY_SIZE)
435static void _extract_crng(struct crng_state *crng, 435static void _extract_crng(struct crng_state *crng,
436 __u32 out[CHACHA20_BLOCK_WORDS]); 436 __u8 out[CHACHA20_BLOCK_SIZE]);
437static void _crng_backtrack_protect(struct crng_state *crng, 437static void _crng_backtrack_protect(struct crng_state *crng,
438 __u32 tmp[CHACHA20_BLOCK_WORDS], int used); 438 __u8 tmp[CHACHA20_BLOCK_SIZE], int used);
439static void process_random_ready_list(void); 439static void process_random_ready_list(void);
440static void _get_random_bytes(void *buf, int nbytes); 440static void _get_random_bytes(void *buf, int nbytes);
441 441
@@ -926,7 +926,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
926 unsigned long flags; 926 unsigned long flags;
927 int i, num; 927 int i, num;
928 union { 928 union {
929 __u32 block[CHACHA20_BLOCK_WORDS]; 929 __u8 block[CHACHA20_BLOCK_SIZE];
930 __u32 key[8]; 930 __u32 key[8];
931 } buf; 931 } buf;
932 932
@@ -973,7 +973,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
973} 973}
974 974
975static void _extract_crng(struct crng_state *crng, 975static void _extract_crng(struct crng_state *crng,
976 __u32 out[CHACHA20_BLOCK_WORDS]) 976 __u8 out[CHACHA20_BLOCK_SIZE])
977{ 977{
978 unsigned long v, flags; 978 unsigned long v, flags;
979 979
@@ -990,7 +990,7 @@ static void _extract_crng(struct crng_state *crng,
990 spin_unlock_irqrestore(&crng->lock, flags); 990 spin_unlock_irqrestore(&crng->lock, flags);
991} 991}
992 992
993static void extract_crng(__u32 out[CHACHA20_BLOCK_WORDS]) 993static void extract_crng(__u8 out[CHACHA20_BLOCK_SIZE])
994{ 994{
995 struct crng_state *crng = NULL; 995 struct crng_state *crng = NULL;
996 996
@@ -1008,7 +1008,7 @@ static void extract_crng(__u32 out[CHACHA20_BLOCK_WORDS])
1008 * enough) to mutate the CRNG key to provide backtracking protection. 1008 * enough) to mutate the CRNG key to provide backtracking protection.
1009 */ 1009 */
1010static void _crng_backtrack_protect(struct crng_state *crng, 1010static void _crng_backtrack_protect(struct crng_state *crng,
1011 __u32 tmp[CHACHA20_BLOCK_WORDS], int used) 1011 __u8 tmp[CHACHA20_BLOCK_SIZE], int used)
1012{ 1012{
1013 unsigned long flags; 1013 unsigned long flags;
1014 __u32 *s, *d; 1014 __u32 *s, *d;
@@ -1020,14 +1020,14 @@ static void _crng_backtrack_protect(struct crng_state *crng,
1020 used = 0; 1020 used = 0;
1021 } 1021 }
1022 spin_lock_irqsave(&crng->lock, flags); 1022 spin_lock_irqsave(&crng->lock, flags);
1023 s = &tmp[used / sizeof(__u32)]; 1023 s = (__u32 *) &tmp[used];
1024 d = &crng->state[4]; 1024 d = &crng->state[4];
1025 for (i=0; i < 8; i++) 1025 for (i=0; i < 8; i++)
1026 *d++ ^= *s++; 1026 *d++ ^= *s++;
1027 spin_unlock_irqrestore(&crng->lock, flags); 1027 spin_unlock_irqrestore(&crng->lock, flags);
1028} 1028}
1029 1029
1030static void crng_backtrack_protect(__u32 tmp[CHACHA20_BLOCK_WORDS], int used) 1030static void crng_backtrack_protect(__u8 tmp[CHACHA20_BLOCK_SIZE], int used)
1031{ 1031{
1032 struct crng_state *crng = NULL; 1032 struct crng_state *crng = NULL;
1033 1033
@@ -1043,7 +1043,7 @@ static void crng_backtrack_protect(__u32 tmp[CHACHA20_BLOCK_WORDS], int used)
1043static ssize_t extract_crng_user(void __user *buf, size_t nbytes) 1043static ssize_t extract_crng_user(void __user *buf, size_t nbytes)
1044{ 1044{
1045 ssize_t ret = 0, i = CHACHA20_BLOCK_SIZE; 1045 ssize_t ret = 0, i = CHACHA20_BLOCK_SIZE;
1046 __u32 tmp[CHACHA20_BLOCK_WORDS]; 1046 __u8 tmp[CHACHA20_BLOCK_SIZE] __aligned(4);
1047 int large_request = (nbytes > 256); 1047 int large_request = (nbytes > 256);
1048 1048
1049 while (nbytes) { 1049 while (nbytes) {
@@ -1622,7 +1622,7 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller,
1622 */ 1622 */
1623static void _get_random_bytes(void *buf, int nbytes) 1623static void _get_random_bytes(void *buf, int nbytes)
1624{ 1624{
1625 __u32 tmp[CHACHA20_BLOCK_WORDS]; 1625 __u8 tmp[CHACHA20_BLOCK_SIZE] __aligned(4);
1626 1626
1627 trace_get_random_bytes(nbytes, _RET_IP_); 1627 trace_get_random_bytes(nbytes, _RET_IP_);
1628 1628
@@ -2248,7 +2248,7 @@ u64 get_random_u64(void)
2248 if (use_lock) 2248 if (use_lock)
2249 read_lock_irqsave(&batched_entropy_reset_lock, flags); 2249 read_lock_irqsave(&batched_entropy_reset_lock, flags);
2250 if (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) { 2250 if (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) {
2251 extract_crng((__u32 *)batch->entropy_u64); 2251 extract_crng((u8 *)batch->entropy_u64);
2252 batch->position = 0; 2252 batch->position = 0;
2253 } 2253 }
2254 ret = batch->entropy_u64[batch->position++]; 2254 ret = batch->entropy_u64[batch->position++];
@@ -2278,7 +2278,7 @@ u32 get_random_u32(void)
2278 if (use_lock) 2278 if (use_lock)
2279 read_lock_irqsave(&batched_entropy_reset_lock, flags); 2279 read_lock_irqsave(&batched_entropy_reset_lock, flags);
2280 if (batch->position % ARRAY_SIZE(batch->entropy_u32) == 0) { 2280 if (batch->position % ARRAY_SIZE(batch->entropy_u32) == 0) {
2281 extract_crng(batch->entropy_u32); 2281 extract_crng((u8 *)batch->entropy_u32);
2282 batch->position = 0; 2282 batch->position = 0;
2283 } 2283 }
2284 ret = batch->entropy_u32[batch->position++]; 2284 ret = batch->entropy_u32[batch->position++];