Skip to content

Commit 2f32bfd

Browse files
jaswinderrajputherbertx
authored andcommitted
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>
1 parent 507069c commit 2f32bfd

1 file changed

Lines changed: 28 additions & 28 deletions

File tree

‎crypto/ansi_cprng.c‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,6 @@ static int cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
357357
return get_prng_bytes(rdata, dlen, prng, 0);
358358
}
359359

360-
static 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-
368360
/*
369361
* This is the cprng_registered reset method the seed value is
370362
* interpreted as the tuple { V KEY DT}
@@ -390,26 +382,6 @@ static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
390382
return 0;
391383
}
392384

393-
static 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-
409-
out:
410-
return rc;
411-
}
412-
413385
static struct crypto_alg rng_alg = {
414386
.cra_name = "stdrng",
415387
.cra_driver_name = "ansi_cprng",
@@ -431,6 +403,34 @@ static struct crypto_alg rng_alg = {
431403
};
432404

433405
#ifdef CONFIG_CRYPTO_FIPS
406+
static 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+
414+
static 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+
430+
out:
431+
return rc;
432+
}
433+
434434
static struct crypto_alg fips_rng_alg = {
435435
.cra_name = "fips(ansi_cprng)",
436436
.cra_driver_name = "fips_ansi_cprng",

0 commit comments

Comments
 (0)