Skip to content

Commit 57cfe44

Browse files
committed
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>
1 parent 7d02460 commit 57cfe44

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎crypto/shash.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
static const struct crypto_type crypto_shash_type;
2424

25+
static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
26+
unsigned int keylen)
27+
{
28+
return -ENOSYS;
29+
}
30+
2531
static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
2632
unsigned int keylen)
2733
{
@@ -50,9 +56,6 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
5056
struct shash_alg *shash = crypto_shash_alg(tfm);
5157
unsigned long alignmask = crypto_shash_alignmask(tfm);
5258

53-
if (!shash->setkey)
54-
return -ENOSYS;
55-
5659
if ((unsigned long)key & alignmask)
5760
return shash_setkey_unaligned(tfm, key, keylen);
5861

@@ -494,6 +497,8 @@ static int shash_prepare_alg(struct shash_alg *alg)
494497
alg->import = shash_no_import;
495498
if (!alg->export)
496499
alg->export = shash_no_export;
500+
if (!alg->setkey)
501+
alg->setkey = shash_no_setkey;
497502

498503
return 0;
499504
}

0 commit comments

Comments
 (0)