]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: jitter - fix intermediary handling
authorMarkus Theil <theil.markus@gmail.com>
Sat, 21 Jun 2025 11:36:43 +0000 (13:36 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 7 Jul 2025 03:27:04 +0000 (15:27 +1200)
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>
crypto/jitterentropy-kcapi.c

index c24d4ff2b4a8b09ef6ef45768c0d46135baeb513..1266eb790708b878cdc0c9b7ffb3d7c29a05500c 100644 (file)
@@ -144,7 +144,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
         * Inject the data from the previous loop into the pool. This data is
         * not considered to contain any entropy, but it stirs the pool a bit.
         */
-       ret = crypto_shash_update(desc, intermediary, sizeof(intermediary));
+       ret = crypto_shash_update(hash_state_desc, intermediary, sizeof(intermediary));
        if (ret)
                goto err;
 
@@ -157,11 +157,12 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
         * conditioning operation to have an identical amount of input data
         * according to section 3.1.5.
         */
-       if (!stuck) {
-               ret = crypto_shash_update(hash_state_desc, (u8 *)&time,
-                                         sizeof(__u64));
+       if (stuck) {
+               time = 0;
        }
 
+       ret = crypto_shash_update(hash_state_desc, (u8 *)&time, sizeof(__u64));
+
 err:
        shash_desc_zero(desc);
        memzero_explicit(intermediary, sizeof(intermediary));