Skip to content

Commit 735b725

Browse files
thilluxherbertx
authored andcommitted
crypto: jitter - fix intermediary handling
The intermediary value was included in the wrong hash state. While there, adapt to user-space by setting the timestamp to 0 if stuck and inserting the values nevertheless. Acked-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Markus Theil <theil.markus@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent cb7fa6b commit 735b725

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crypto/jitterentropy-kcapi.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
144144
* Inject the data from the previous loop into the pool. This data is
145145
* not considered to contain any entropy, but it stirs the pool a bit.
146146
*/
147-
ret = crypto_shash_update(desc, intermediary, sizeof(intermediary));
147+
ret = crypto_shash_update(hash_state_desc, intermediary, sizeof(intermediary));
148148
if (ret)
149149
goto err;
150150

@@ -157,11 +157,12 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
157157
* conditioning operation to have an identical amount of input data
158158
* according to section 3.1.5.
159159
*/
160-
if (!stuck) {
161-
ret = crypto_shash_update(hash_state_desc, (u8 *)&time,
162-
sizeof(__u64));
160+
if (stuck) {
161+
time = 0;
163162
}
164163

164+
ret = crypto_shash_update(hash_state_desc, (u8 *)&time, sizeof(__u64));
165+
165166
err:
166167
shash_desc_zero(desc);
167168
memzero_explicit(intermediary, sizeof(intermediary));

0 commit comments

Comments
 (0)