]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: rng - RNGs must return 0 in success case
authorStephan Mueller <smueller@chronox.de>
Fri, 6 Mar 2015 07:26:31 +0000 (08:26 +0100)
committerJiri Slaby <jslaby@suse.cz>
Wed, 10 Jun 2015 11:53:11 +0000 (13:53 +0200)
commit cde001e4c3c3625c60b68a83eb1f1c2572dee07a upstream.

Change the RNGs to always return 0 in success case.

This patch ensures that seqiv.c works with RNGs other than krng. seqiv
expects that any return code other than 0 is an error. Without the
patch, rfc4106(gcm(aes)) will not work when using a DRBG or an ANSI
X9.31 RNG.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
crypto/ansi_cprng.c

index 6f5bebc9bf01ebea38bca6dd616c6bd2c3ce2111..765fe76093482df7dbf16965c3516b5934d789b0 100644 (file)
@@ -210,7 +210,11 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx,
                byte_count = DEFAULT_BLK_SZ;
        }
 
-       err = byte_count;
+       /*
+        * Return 0 in case of success as mandated by the kernel
+        * crypto API interface definition.
+        */
+       err = 0;
 
        dbgprint(KERN_CRIT "getting %d random bytes for context %p\n",
                byte_count, ctx);