diff options
| author | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
| commit | 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e (patch) | |
| tree | d57f3a63479a07b4e0cece029886e76e04feb984 /lib/crypto/blake2s-selftest.c | |
| parent | 5dc63e56a9cf8df0b59c234a505a1653f1bdf885 (diff) | |
| parent | 53bea86b5712c7491bb3dae12e271666df0a308c (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.4 merge window.
Diffstat (limited to 'lib/crypto/blake2s-selftest.c')
| -rw-r--r-- | lib/crypto/blake2s-selftest.c | 25 | 
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/crypto/blake2s-selftest.c b/lib/crypto/blake2s-selftest.c index 7d77dea15587..d0634ed6a937 100644 --- a/lib/crypto/blake2s-selftest.c +++ b/lib/crypto/blake2s-selftest.c @@ -545,7 +545,7 @@ static const u8 blake2s_testvecs[][BLAKE2S_HASH_SIZE] __initconst = {      0xd6, 0x98, 0x6b, 0x07, 0x10, 0x65, 0x52, 0x65, },  }; -bool __init blake2s_selftest(void) +static bool __init noinline_for_stack blake2s_digest_test(void)  {  	u8 key[BLAKE2S_KEY_SIZE];  	u8 buf[ARRAY_SIZE(blake2s_testvecs)]; @@ -589,11 +589,20 @@ bool __init blake2s_selftest(void)  		}  	} +	return success; +} + +static bool __init noinline_for_stack blake2s_random_test(void) +{ +	struct blake2s_state state; +	bool success = true; +	int i, l; +  	for (i = 0; i < 32; ++i) {  		enum { TEST_ALIGNMENT = 16 }; -		u8 unaligned_block[BLAKE2S_BLOCK_SIZE + TEST_ALIGNMENT - 1] +		u8 blocks[BLAKE2S_BLOCK_SIZE * 2 + TEST_ALIGNMENT - 1]  					__aligned(TEST_ALIGNMENT); -		u8 blocks[BLAKE2S_BLOCK_SIZE * 2]; +		u8 *unaligned_block = blocks + BLAKE2S_BLOCK_SIZE;  		struct blake2s_state state1, state2;  		get_random_bytes(blocks, sizeof(blocks)); @@ -630,3 +639,13 @@ bool __init blake2s_selftest(void)  	return success;  } + +bool __init blake2s_selftest(void) +{ +	bool success; + +	success = blake2s_digest_test(); +	success &= blake2s_random_test(); + +	return success; +}  |