diff options
author | Stephan Mueller <smueller@chronox.de> | 2014-08-17 17:39:31 +0200 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-08-25 20:34:11 +0800 |
commit | e6c0244ad38a358598392638688b1dcac7878f66 (patch) | |
tree | 974c13306d5fbbfbc221839ec667511247288149 /crypto/drbg.c | |
parent | f072f0e0fe0f3758c7c94bee875564c89fd07d08 (diff) | |
download | op-kernel-dev-e6c0244ad38a358598392638688b1dcac7878f66.zip op-kernel-dev-e6c0244ad38a358598392638688b1dcac7878f66.tar.gz |
crypto: drbg - use kmalloc instead of kzalloc for V and C
When allocating V, C, the zeroization is only needed when
allocating a new instance of the DRBG, i.e. when performing an
initial seeding. For all other allocations, the memcpy implemented in
drbg_copy_drbg ensures that the memory is filled with the correct
information.
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/drbg.c')
-rw-r--r-- | crypto/drbg.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c index 86cffc6..ebe0afc 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1142,6 +1142,11 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers, pr_devel("DRBG: using personalization string\n"); } + if (!reseed) { + memset(drbg->V, 0, drbg_statelen(drbg)); + memset(drbg->C, 0, drbg_statelen(drbg)); + } + ret = drbg->d_ops->update(drbg, &seedlist, reseed); if (ret) goto out; @@ -1186,14 +1191,14 @@ static inline int drbg_alloc_state(struct drbg_state *drbg) if (!drbg) return -EINVAL; - drbg->V = kzalloc(drbg_statelen(drbg), GFP_KERNEL); + drbg->V = kmalloc(drbg_statelen(drbg), GFP_KERNEL); if (!drbg->V) goto err; - drbg->C = kzalloc(drbg_statelen(drbg), GFP_KERNEL); + drbg->C = kmalloc(drbg_statelen(drbg), GFP_KERNEL); if (!drbg->C) goto err; #ifdef CONFIG_CRYPTO_FIPS - drbg->prev = kzalloc(drbg_blocklen(drbg), GFP_KERNEL); + drbg->prev = kmalloc(drbg_blocklen(drbg), GFP_KERNEL); if (!drbg->prev) goto err; drbg->fips_primed = false; |