2009-11-20 13:52:09

by Jaswinder Singh Rajput

[permalink] [raw]
Subject: [PATCH] crypto: move fips_cprng_get_random and fips_cprng_reset to 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 <[email protected]>
---
crypto/ansi_cprng.c | 56 +++++++++++++++++++++++++-------------------------
1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 45bd218..2bc3321 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,
return get_prng_bytes(rdata, dlen, prng, 0);
}

-static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
- unsigned int dlen)
-{
- struct prng_context *prng = crypto_rng_ctx(tfm);
-
- return get_prng_bytes(rdata, dlen, prng, 1);
-}
-
/*
* This is the cprng_registered reset method the seed value is
* interpreted as the tuple { V KEY DT}
@@ -390,26 +382,6 @@ static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
return 0;
}

-static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
-{
- u8 rdata[DEFAULT_BLK_SZ];
- int rc;
-
- struct prng_context *prng = crypto_rng_ctx(tfm);
-
- rc = cprng_reset(tfm, seed, slen);
-
- if (!rc)
- goto out;
-
- /* this primes our continuity test */
- rc = get_prng_bytes(rdata, DEFAULT_BLK_SZ, prng, 0);
- prng->rand_data_valid = DEFAULT_BLK_SZ;
-
-out:
- return rc;
-}
-
static struct crypto_alg rng_alg = {
.cra_name = "stdrng",
.cra_driver_name = "ansi_cprng",
@@ -431,6 +403,34 @@ static struct crypto_alg rng_alg = {
};

#ifdef CONFIG_CRYPTO_FIPS
+static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
+ unsigned int dlen)
+{
+ struct prng_context *prng = crypto_rng_ctx(tfm);
+
+ return get_prng_bytes(rdata, dlen, prng, 1);
+}
+
+static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
+{
+ u8 rdata[DEFAULT_BLK_SZ];
+ int rc;
+
+ struct prng_context *prng = crypto_rng_ctx(tfm);
+
+ rc = cprng_reset(tfm, seed, slen);
+
+ if (!rc)
+ goto out;
+
+ /* this primes our continuity test */
+ rc = get_prng_bytes(rdata, DEFAULT_BLK_SZ, prng, 0);
+ prng->rand_data_valid = DEFAULT_BLK_SZ;
+
+out:
+ return rc;
+}
+
static struct crypto_alg fips_rng_alg = {
.cra_name = "fips(ansi_cprng)",
.cra_driver_name = "fips_ansi_cprng",
--
1.6.5.3


2009-11-20 15:38:21

by Neil Horman

[permalink] [raw]
Subject: Re: [PATCH] crypto: move fips_cprng_get_random and fips_cprng_reset to CONFIG_CRYPTO_FIPS

On Fri, Nov 20, 2009 at 07:20:19PM +0530, Jaswinder Singh Rajput wrote:
>
> 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 <[email protected]>
Yeah, looks good to me, thanks!
Acked-by: Neil Horman <[email protected]>

>

2009-11-23 12:26:19

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: move fips_cprng_get_random and fips_cprng_reset to CONFIG_CRYPTO_FIPS

On Fri, Nov 20, 2009 at 10:38:01AM -0500, Neil Horman wrote:
> On Fri, Nov 20, 2009 at 07:20:19PM +0530, Jaswinder Singh Rajput wrote:
> >
> > 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 <[email protected]>
> Yeah, looks good to me, thanks!
> Acked-by: Neil Horman <[email protected]>

Patch applied. Thanks!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt