aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2015-03-06 02:26:31 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2015-03-09 06:06:18 -0400
commitcde001e4c3c3625c60b68a83eb1f1c2572dee07a (patch)
tree6b0a069f9fdfa36c3741164564ea163f9cb69820 /crypto
parent4842234f83bfce83c93f84f5972a956ef2c87805 (diff)
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')
-rw-r--r--crypto/ansi_cprng.c6
-rw-r--r--crypto/drbg.c7
2 files changed, 11 insertions, 2 deletions
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 6f5bebc9bf01..765fe7609348 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -210,7 +210,11 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx,
210 byte_count = DEFAULT_BLK_SZ; 210 byte_count = DEFAULT_BLK_SZ;
211 } 211 }
212 212
213 err = byte_count; 213 /*
214 * Return 0 in case of success as mandated by the kernel
215 * crypto API interface definition.
216 */
217 err = 0;
214 218
215 dbgprint(KERN_CRIT "getting %d random bytes for context %p\n", 219 dbgprint(KERN_CRIT "getting %d random bytes for context %p\n",
216 byte_count, ctx); 220 byte_count, ctx);
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,
1280 * as defined in SP800-90A. The additional input is mixed into 1280 * as defined in SP800-90A. The additional input is mixed into
1281 * the state in addition to the pulled entropy. 1281 * the state in addition to the pulled entropy.
1282 * 1282 *
1283 * return: generated number of bytes 1283 * return: 0 when all bytes are generated; < 0 in case of an error
1284 */ 1284 */
1285static int drbg_generate(struct drbg_state *drbg, 1285static int drbg_generate(struct drbg_state *drbg,
1286 unsigned char *buf, unsigned int buflen, 1286 unsigned char *buf, unsigned int buflen,
@@ -1419,6 +1419,11 @@ static int drbg_generate(struct drbg_state *drbg,
1419 } 1419 }
1420#endif 1420#endif
1421 1421
1422 /*
1423 * All operations were successful, return 0 as mandated by
1424 * the kernel crypto API interface.
1425 */
1426 len = 0;
1422err: 1427err:
1423 shadow->d_ops->crypto_fini(shadow); 1428 shadow->d_ops->crypto_fini(shadow);
1424 drbg_restore_shadow(drbg, &shadow); 1429 drbg_restore_shadow(drbg, &shadow);