提交 57cfe44b 编写于 作者: H Herbert Xu

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: NHerbert Xu <herbert@gondor.apana.org.au>
上级 7d024608
...@@ -22,6 +22,12 @@ ...@@ -22,6 +22,12 @@
static const struct crypto_type crypto_shash_type; 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, static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen) unsigned int keylen)
{ {
...@@ -50,9 +56,6 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, ...@@ -50,9 +56,6 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
struct shash_alg *shash = crypto_shash_alg(tfm); struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned long alignmask = crypto_shash_alignmask(tfm); unsigned long alignmask = crypto_shash_alignmask(tfm);
if (!shash->setkey)
return -ENOSYS;
if ((unsigned long)key & alignmask) if ((unsigned long)key & alignmask)
return shash_setkey_unaligned(tfm, key, keylen); return shash_setkey_unaligned(tfm, key, keylen);
...@@ -494,6 +497,8 @@ static int shash_prepare_alg(struct shash_alg *alg) ...@@ -494,6 +497,8 @@ static int shash_prepare_alg(struct shash_alg *alg)
alg->import = shash_no_import; alg->import = shash_no_import;
if (!alg->export) if (!alg->export)
alg->export = shash_no_export; alg->export = shash_no_export;
if (!alg->setkey)
alg->setkey = shash_no_setkey;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册