diff options
author | Stephan Mueller <smueller@chronox.de> | 2014-08-17 11:39:31 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-08-25 08:34:11 -0400 |
commit | e6c0244ad38a358598392638688b1dcac7878f66 (patch) | |
tree | 974c13306d5fbbfbc221839ec667511247288149 /crypto | |
parent | f072f0e0fe0f3758c7c94bee875564c89fd07d08 (diff) |
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')
-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 86cffc600acd..ebe0afc4e94b 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, | |||
1142 | pr_devel("DRBG: using personalization string\n"); | 1142 | pr_devel("DRBG: using personalization string\n"); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | if (!reseed) { | ||
1146 | memset(drbg->V, 0, drbg_statelen(drbg)); | ||
1147 | memset(drbg->C, 0, drbg_statelen(drbg)); | ||
1148 | } | ||
1149 | |||
1145 | ret = drbg->d_ops->update(drbg, &seedlist, reseed); | 1150 | ret = drbg->d_ops->update(drbg, &seedlist, reseed); |
1146 | if (ret) | 1151 | if (ret) |
1147 | goto out; | 1152 | goto out; |
@@ -1186,14 +1191,14 @@ static inline int drbg_alloc_state(struct drbg_state *drbg) | |||
1186 | if (!drbg) | 1191 | if (!drbg) |
1187 | return -EINVAL; | 1192 | return -EINVAL; |
1188 | 1193 | ||
1189 | drbg->V = kzalloc(drbg_statelen(drbg), GFP_KERNEL); | 1194 | drbg->V = kmalloc(drbg_statelen(drbg), GFP_KERNEL); |
1190 | if (!drbg->V) | 1195 | if (!drbg->V) |
1191 | goto err; | 1196 | goto err; |
1192 | drbg->C = kzalloc(drbg_statelen(drbg), GFP_KERNEL); | 1197 | drbg->C = kmalloc(drbg_statelen(drbg), GFP_KERNEL); |
1193 | if (!drbg->C) | 1198 | if (!drbg->C) |
1194 | goto err; | 1199 | goto err; |
1195 | #ifdef CONFIG_CRYPTO_FIPS | 1200 | #ifdef CONFIG_CRYPTO_FIPS |
1196 | drbg->prev = kzalloc(drbg_blocklen(drbg), GFP_KERNEL); | 1201 | drbg->prev = kmalloc(drbg_blocklen(drbg), GFP_KERNEL); |
1197 | if (!drbg->prev) | 1202 | if (!drbg->prev) |
1198 | goto err; | 1203 | goto err; |
1199 | drbg->fips_primed = false; | 1204 | drbg->fips_primed = false; |