This patch moves the run-time null setkey check to shash_prepare_alg just like we did for finup/digest.
Unified · Split
| @@ -22,6 +22,12 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | static const struct crypto_type crypto_shash_type; |
| 24 | 24 | |
| 25 | +static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key, | |
| 26 | + unsigned int keylen) | |
| 27 | +{ | |
| 28 | + return -ENOSYS; | |
| 29 | +} | |
| 30 | + | |
| 25 | 31 | static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key, |
| 26 | 32 | unsigned int keylen) |
| 27 | 33 | { |
| @@ -50,9 +56,6 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, · 22 unmodified lines | ||
| 50 | 56 | struct shash_alg *shash = crypto_shash_alg(tfm); |
| 51 | 57 | unsigned long alignmask = crypto_shash_alignmask(tfm); |
| 52 | 58 | |
| 53 | − if (!shash->setkey) | |
| 54 | − return -ENOSYS; | |
| 55 | − | |
| 56 | 59 | if ((unsigned long)key & alignmask) |
| 57 | 60 | return shash_setkey_unaligned(tfm, key, keylen); |
| 58 | 61 | |
| @@ -494,6 +497,8 @@ static int shash_prepare_alg(struct shash_alg *alg) · 435 unmodified lines | ||
| 494 | 497 | alg->import = shash_no_import; |
| 495 | 498 | if (!alg->export) |
| 496 | 499 | alg->export = shash_no_export; |
| 500 | + if (!alg->setkey) | |
| 501 | + alg->setkey = shash_no_setkey; | |
| 497 | 502 | |
| 498 | 503 | return 0; |
| 499 | 504 | } |