diff options
author | Stephan Mueller <smueller@chronox.de> | 2015-03-06 02:26:31 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-03-09 06:06:18 -0400 |
commit | cde001e4c3c3625c60b68a83eb1f1c2572dee07a (patch) | |
tree | 6b0a069f9fdfa36c3741164564ea163f9cb69820 /crypto/drbg.c | |
parent | 4842234f83bfce83c93f84f5972a956ef2c87805 (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/drbg.c')
-rw-r--r-- | crypto/drbg.c | 7 |
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, | |||
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 | */ |
1285 | static int drbg_generate(struct drbg_state *drbg, | 1285 | static 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; | ||
1422 | err: | 1427 | err: |
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); |