aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/shash.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-11 10:17:39 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-11 22:46:02 -0400
commit57cfe44bccb0e38ddb44a34a42f517deef1f4e82 (patch)
tree76407ea6aa11d7441aa4bb6811eb6e398554f041 /crypto/shash.c
parent7d024608265eb815ae4ce1e5da097ec9d800dda4 (diff)
crypto: shash - Move null setkey check to registration time
This patch moves the run-time null setkey check to shash_prepare_alg just like we did for finup/digest. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/shash.c')
-rw-r--r--crypto/shash.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index f7fcc652ff32..131e14d2b572 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -22,6 +22,12 @@
22 22
23static const struct crypto_type crypto_shash_type; 23static const struct crypto_type crypto_shash_type;
24 24
25static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
26 unsigned int keylen)
27{
28 return -ENOSYS;
29}
30
25static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key, 31static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
26 unsigned int keylen) 32 unsigned int keylen)
27{ 33{
@@ -50,9 +56,6 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
50 struct shash_alg *shash = crypto_shash_alg(tfm); 56 struct shash_alg *shash = crypto_shash_alg(tfm);
51 unsigned long alignmask = crypto_shash_alignmask(tfm); 57 unsigned long alignmask = crypto_shash_alignmask(tfm);
52 58
53 if (!shash->setkey)
54 return -ENOSYS;
55
56 if ((unsigned long)key & alignmask) 59 if ((unsigned long)key & alignmask)
57 return shash_setkey_unaligned(tfm, key, keylen); 60 return shash_setkey_unaligned(tfm, key, keylen);
58 61
@@ -494,6 +497,8 @@ static int shash_prepare_alg(struct shash_alg *alg)
494 alg->import = shash_no_import; 497 alg->import = shash_no_import;
495 if (!alg->export) 498 if (!alg->export)
496 alg->export = shash_no_export; 499 alg->export = shash_no_export;
500 if (!alg->setkey)
501 alg->setkey = shash_no_setkey;
497 502
498 return 0; 503 return 0;
499} 504}