Skip to content

Commit 7ca99d8

Browse files
committed
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>
1 parent acec27f commit 7ca99d8

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎include/crypto/internal/rng.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ static inline void *crypto_rng_ctx(struct crypto_rng *tfm)
2626
return crypto_tfm_ctx(&tfm->base);
2727
}
2828

29+
static 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+
2935
#endif

‎include/crypto/rng.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ struct crypto_rng;
3232
* up a new state, the seed must be provided by the
3333
* consumer while invoking this function. The required
3434
* 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.
3537
* @seedsize: The seed size required for a random number generator
3638
* initialization defined with this variable. Some
3739
* random number generators does not require a seed
@@ -45,6 +47,8 @@ struct rng_alg {
4547
const u8 *src, unsigned int slen,
4648
u8 *dst, unsigned int dlen);
4749
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);
4852

4953
unsigned int seedsize;
5054

0 commit comments

Comments
 (0)