Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 157942
b: refs/heads/master
c: fd09d7f
h: refs/heads/master
v: v3
  • Loading branch information
Sebastian Andrzej Siewior authored and Herbert Xu committed Jul 3, 2009
1 parent f398a7d commit 160b771
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 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: ed94070058033a3c99fe62c90d00c39dc443c679
refs/heads/master: fd09d7facb7cf3a884979eb5f843338ce1ce9b43
25 changes: 8 additions & 17 deletions trunk/crypto/ansi_cprng.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ static int reset_prng_context(struct prng_context *ctx,
unsigned char *V, unsigned char *DT)
{
int ret;
int rc = -EINVAL;
unsigned char *prng_key;

spin_lock_bh(&ctx->prng_lock);
Expand All @@ -307,41 +306,33 @@ static int reset_prng_context(struct prng_context *ctx,
memset(ctx->rand_data, 0, DEFAULT_BLK_SZ);
memset(ctx->last_rand_data, 0, DEFAULT_BLK_SZ);

if (ctx->tfm)
crypto_free_cipher(ctx->tfm);

ctx->tfm = crypto_alloc_cipher("aes", 0, 0);
if (IS_ERR(ctx->tfm)) {
dbgprint(KERN_CRIT "Failed to alloc tfm for context %p\n",
ctx);
ctx->tfm = NULL;
goto out;
}

ctx->rand_data_valid = DEFAULT_BLK_SZ;

ret = crypto_cipher_setkey(ctx->tfm, prng_key, klen);
if (ret) {
dbgprint(KERN_CRIT "PRNG: setkey() failed flags=%x\n",
crypto_cipher_get_flags(ctx->tfm));
crypto_free_cipher(ctx->tfm);
goto out;
}

rc = 0;
ret = 0;
ctx->flags &= ~PRNG_NEED_RESET;
out:
spin_unlock_bh(&ctx->prng_lock);

return rc;

return ret;
}

static int cprng_init(struct crypto_tfm *tfm)
{
struct prng_context *ctx = crypto_tfm_ctx(tfm);

spin_lock_init(&ctx->prng_lock);
ctx->tfm = crypto_alloc_cipher("aes", 0, 0);
if (IS_ERR(ctx->tfm)) {
dbgprint(KERN_CRIT "Failed to alloc tfm for context %p\n",
ctx);
return PTR_ERR(ctx->tfm);
}

if (reset_prng_context(ctx, NULL, DEFAULT_PRNG_KSZ, NULL, NULL) < 0)
return -EINVAL;
Expand Down

0 comments on commit 160b771

Please sign in to comment.