Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120593
b: refs/heads/master
c: 2566578
h: refs/heads/master
i:
  120591: a3e8b1c
v: v3
  • Loading branch information
Neil Horman authored and Herbert Xu committed Dec 25, 2008
1 parent ab03b25 commit c8f3fe5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 420a4b20c504e4674bf253601f793bdb254f99fa
refs/heads/master: 2566578a6feb9d9e39da41326afe8ed6022db3c5
16 changes: 13 additions & 3 deletions trunk/crypto/ansi_cprng.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,25 @@ static int cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
return get_prng_bytes(rdata, dlen, prng);
}

/*
* This is the cprng_registered reset method the seed value is
* interpreted as the tuple { V KEY DT}
* V and KEY are required during reset, and DT is optional, detected
* as being present by testing the length of the seed
*/
static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
{
struct prng_context *prng = crypto_rng_ctx(tfm);
u8 *key = seed + DEFAULT_PRNG_KSZ;
u8 *key = seed + DEFAULT_BLK_SZ;
u8 *dt = NULL;

if (slen < DEFAULT_PRNG_KSZ + DEFAULT_BLK_SZ)
return -EINVAL;

reset_prng_context(prng, key, DEFAULT_PRNG_KSZ, seed, NULL);
if (slen >= (2 * DEFAULT_BLK_SZ + DEFAULT_PRNG_KSZ))
dt = key + DEFAULT_PRNG_KSZ;

reset_prng_context(prng, key, DEFAULT_PRNG_KSZ, seed, dt);

if (prng->flags & PRNG_NEED_RESET)
return -EINVAL;
Expand All @@ -379,7 +389,7 @@ static struct crypto_alg rng_alg = {
.rng = {
.rng_make_random = cprng_get_random,
.rng_reset = cprng_reset,
.seedsize = DEFAULT_PRNG_KSZ + DEFAULT_BLK_SZ,
.seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ,
}
}
};
Expand Down

0 comments on commit c8f3fe5

Please sign in to comment.