aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-09 08:36:44 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-11 06:23:33 -0400
commit8267adab9433593adb09d94626475c2a5921f111 (patch)
treef05bc75fb3b6ee993bfb1d94715f794dc2d7ef40 /crypto
parent99d27e1c59e34869605de625b033c52163f5bfa7 (diff)
crypto: shash - Move finup/digest null checks to registration time
This patch moves the run-time null finup/digest checks to the shash_prepare_alg function which is run at registration time. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/shash.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 14a3b707a31f..f7fcc652ff32 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -142,8 +142,7 @@ int crypto_shash_finup(struct shash_desc *desc, const u8 *data,
142 struct shash_alg *shash = crypto_shash_alg(tfm); 142 struct shash_alg *shash = crypto_shash_alg(tfm);
143 unsigned long alignmask = crypto_shash_alignmask(tfm); 143 unsigned long alignmask = crypto_shash_alignmask(tfm);
144 144
145 if (((unsigned long)data | (unsigned long)out) & alignmask || 145 if (((unsigned long)data | (unsigned long)out) & alignmask)
146 !shash->finup)
147 return shash_finup_unaligned(desc, data, len, out); 146 return shash_finup_unaligned(desc, data, len, out);
148 147
149 return shash->finup(desc, data, len, out); 148 return shash->finup(desc, data, len, out);
@@ -164,8 +163,7 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
164 struct shash_alg *shash = crypto_shash_alg(tfm); 163 struct shash_alg *shash = crypto_shash_alg(tfm);
165 unsigned long alignmask = crypto_shash_alignmask(tfm); 164 unsigned long alignmask = crypto_shash_alignmask(tfm);
166 165
167 if (((unsigned long)data | (unsigned long)out) & alignmask || 166 if (((unsigned long)data | (unsigned long)out) & alignmask)
168 !shash->digest)
169 return shash_digest_unaligned(desc, data, len, out); 167 return shash_digest_unaligned(desc, data, len, out);
170 168
171 return shash->digest(desc, data, len, out); 169 return shash->digest(desc, data, len, out);
@@ -488,6 +486,10 @@ static int shash_prepare_alg(struct shash_alg *alg)
488 base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK; 486 base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
489 base->cra_flags |= CRYPTO_ALG_TYPE_SHASH; 487 base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
490 488
489 if (!alg->finup)
490 alg->finup = shash_finup_unaligned;
491 if (!alg->digest)
492 alg->digest = shash_digest_unaligned;
491 if (!alg->import) 493 if (!alg->import)
492 alg->import = shash_no_import; 494 alg->import = shash_no_import;
493 if (!alg->export) 495 if (!alg->export)