aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ansi_cprng.c
diff options
context:
space:
mode:
authorJaswinder Singh Rajput <jaswinderrajput@gmail.com>2009-11-23 07:25:50 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2009-11-23 07:25:50 -0500
commit2f32bfd834d5d7eb230bcbf39aaacccd2a01d767 (patch)
tree82f214b733e93ff81c4f0da45a756fe9fdc4dee2 /crypto/ansi_cprng.c
parent507069c91e36786b3fa5d9515c35ed6bb0ce469b (diff)
crypto: ansi_cprng - Move FIPS functions under CONFIG_CRYPTO_FIPS
fips_cprng_get_random and fips_cprng_reset is used only by CONFIG_CRYPTO_FIPS. This also fixes compilation warnings: crypto/ansi_cprng.c:360: warning: ‘fips_cprng_get_random’ defined but not used crypto/ansi_cprng.c:393: warning: ‘fips_cprng_reset’ defined but not used Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ansi_cprng.c')
-rw-r--r--crypto/ansi_cprng.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 45bd2182cb36..2bc332142849 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -357,14 +357,6 @@ static int cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
357 return get_prng_bytes(rdata, dlen, prng, 0); 357 return get_prng_bytes(rdata, dlen, prng, 0);
358} 358}
359 359
360static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
361 unsigned int dlen)
362{
363 struct prng_context *prng = crypto_rng_ctx(tfm);
364
365 return get_prng_bytes(rdata, dlen, prng, 1);
366}
367
368/* 360/*
369 * This is the cprng_registered reset method the seed value is 361 * This is the cprng_registered reset method the seed value is
370 * interpreted as the tuple { V KEY DT} 362 * interpreted as the tuple { V KEY DT}
@@ -390,26 +382,6 @@ static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
390 return 0; 382 return 0;
391} 383}
392 384
393static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
394{
395 u8 rdata[DEFAULT_BLK_SZ];
396 int rc;
397
398 struct prng_context *prng = crypto_rng_ctx(tfm);
399
400 rc = cprng_reset(tfm, seed, slen);
401
402 if (!rc)
403 goto out;
404
405 /* this primes our continuity test */
406 rc = get_prng_bytes(rdata, DEFAULT_BLK_SZ, prng, 0);
407 prng->rand_data_valid = DEFAULT_BLK_SZ;
408
409out:
410 return rc;
411}
412
413static struct crypto_alg rng_alg = { 385static struct crypto_alg rng_alg = {
414 .cra_name = "stdrng", 386 .cra_name = "stdrng",
415 .cra_driver_name = "ansi_cprng", 387 .cra_driver_name = "ansi_cprng",
@@ -431,6 +403,34 @@ static struct crypto_alg rng_alg = {
431}; 403};
432 404
433#ifdef CONFIG_CRYPTO_FIPS 405#ifdef CONFIG_CRYPTO_FIPS
406static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
407 unsigned int dlen)
408{
409 struct prng_context *prng = crypto_rng_ctx(tfm);
410
411 return get_prng_bytes(rdata, dlen, prng, 1);
412}
413
414static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
415{
416 u8 rdata[DEFAULT_BLK_SZ];
417 int rc;
418
419 struct prng_context *prng = crypto_rng_ctx(tfm);
420
421 rc = cprng_reset(tfm, seed, slen);
422
423 if (!rc)
424 goto out;
425
426 /* this primes our continuity test */
427 rc = get_prng_bytes(rdata, DEFAULT_BLK_SZ, prng, 0);
428 prng->rand_data_valid = DEFAULT_BLK_SZ;
429
430out:
431 return rc;
432}
433
434static struct crypto_alg fips_rng_alg = { 434static struct crypto_alg fips_rng_alg = {
435 .cra_name = "fips(ansi_cprng)", 435 .cra_name = "fips(ansi_cprng)",
436 .cra_driver_name = "fips_ansi_cprng", 436 .cra_driver_name = "fips_ansi_cprng",