summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-04-20 22:46:39 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-04-21 21:30:15 -0400
commit7ca99d814821e8a8ac6d7c48b2ccfc24bda27b1f (patch)
tree2a88fdf67ae0efe03a8061e4ce4cdb4b15f1393c
parentacec27ff35af9caf34d76d16ee17ff3b292e7d83 (diff)
crypto: rng - Add crypto_rng_set_entropy
This patch adds the function crypto_rng_set_entropy. It is only meant to be used by testmgr when testing RNG implementations by providing fixed entropy data in order to verify test vectors. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--include/crypto/internal/rng.h6
-rw-r--r--include/crypto/rng.h4
2 files changed, 10 insertions, 0 deletions
diff --git a/include/crypto/internal/rng.h b/include/crypto/internal/rng.h
index 76f3c9519ba5..93d41bcc444e 100644
--- a/include/crypto/internal/rng.h
+++ b/include/crypto/internal/rng.h
@@ -26,4 +26,10 @@ static inline void *crypto_rng_ctx(struct crypto_rng *tfm)
26 return crypto_tfm_ctx(&tfm->base); 26 return crypto_tfm_ctx(&tfm->base);
27} 27}
28 28
29static inline void crypto_rng_set_entropy(struct crypto_rng *tfm,
30 const u8 *data, unsigned int len)
31{
32 crypto_rng_alg(tfm)->set_ent(tfm, data, len);
33}
34
29#endif 35#endif
diff --git a/include/crypto/rng.h b/include/crypto/rng.h
index 133f0441ad3e..cc22e52a129a 100644
--- a/include/crypto/rng.h
+++ b/include/crypto/rng.h
@@ -32,6 +32,8 @@ struct crypto_rng;
32 * up a new state, the seed must be provided by the 32 * up a new state, the seed must be provided by the
33 * consumer while invoking this function. The required 33 * consumer while invoking this function. The required
34 * size of the seed is defined with @seedsize . 34 * size of the seed is defined with @seedsize .
35 * @set_ent: Set entropy that would otherwise be obtained from
36 * entropy source. Internal use only.
35 * @seedsize: The seed size required for a random number generator 37 * @seedsize: The seed size required for a random number generator
36 * initialization defined with this variable. Some 38 * initialization defined with this variable. Some
37 * random number generators does not require a seed 39 * random number generators does not require a seed
@@ -45,6 +47,8 @@ struct rng_alg {
45 const u8 *src, unsigned int slen, 47 const u8 *src, unsigned int slen,
46 u8 *dst, unsigned int dlen); 48 u8 *dst, unsigned int dlen);
47 int (*seed)(struct crypto_rng *tfm, const u8 *seed, unsigned int slen); 49 int (*seed)(struct crypto_rng *tfm, const u8 *seed, unsigned int slen);
50 void (*set_ent)(struct crypto_rng *tfm, const u8 *data,
51 unsigned int len);
48 52
49 unsigned int seedsize; 53 unsigned int seedsize;
50 54