summaryrefslogtreecommitdiffstats
path: root/crypto/drbg.c
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2015-03-06 08:26:31 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2015-03-09 21:06:18 +1100
commitcde001e4c3c3625c60b68a83eb1f1c2572dee07a (patch)
tree6b0a069f9fdfa36c3741164564ea163f9cb69820 /crypto/drbg.c
parent4842234f83bfce83c93f84f5972a956ef2c87805 (diff)
downloadlinux-cde001e4c3c3625c60b68a83eb1f1c2572dee07a.tar.gz
linux-cde001e4c3c3625c60b68a83eb1f1c2572dee07a.tar.bz2
linux-cde001e4c3c3625c60b68a83eb1f1c2572dee07a.zip
crypto: rng - RNGs must return 0 in success case
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>
Diffstat (limited to 'crypto/drbg.c')
-rw-r--r--crypto/drbg.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c
index 56c1d7ec3d9e..b69409cb7e6a 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1280,7 +1280,7 @@ static void drbg_restore_shadow(struct drbg_state *drbg,
* as defined in SP800-90A. The additional input is mixed into
* the state in addition to the pulled entropy.
*
- * return: generated number of bytes
+ * return: 0 when all bytes are generated; < 0 in case of an error
*/
static int drbg_generate(struct drbg_state *drbg,
unsigned char *buf, unsigned int buflen,
@@ -1419,6 +1419,11 @@ static int drbg_generate(struct drbg_state *drbg,
}
#endif
+ /*
+ * All operations were successful, return 0 as mandated by
+ * the kernel crypto API interface.
+ */
+ len = 0;
err:
shadow->d_ops->crypto_fini(shadow);
drbg_restore_shadow(drbg, &shadow);