Skip to content

Commit

Permalink
crypto: shash - Move null setkey check to registration time
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
herbertx committed Jul 12, 2009
1 parent 7d02460 commit 57cfe44
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crypto/shash.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

static const struct crypto_type crypto_shash_type;

static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)
{
return -ENOSYS;
}

static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)
{
Expand Down Expand Up @@ -50,9 +56,6 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm);

if (!shash->setkey)
return -ENOSYS;

if ((unsigned long)key & alignmask)
return shash_setkey_unaligned(tfm, key, keylen);

Expand Down Expand Up @@ -494,6 +497,8 @@ static int shash_prepare_alg(struct shash_alg *alg)
alg->import = shash_no_import;
if (!alg->export)
alg->export = shash_no_export;
if (!alg->setkey)
alg->setkey = shash_no_setkey;

return 0;
}
Expand Down

0 comments on commit 57cfe44

Please sign in to comment.