diff options
author | Eric Biggers <ebiggers@google.com> | 2019-01-06 19:07:20 -0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-01-18 18:40:24 +0800 |
commit | 2ab40e63dd048c38f750e3fe1848543a81694042 (patch) | |
tree | 34912999bad5072b9ad07b43fd09ee80ed0a0e13 /crypto | |
parent | 65e2380d917e0f778ee9c3c19c6b31dfc59c0e2f (diff) | |
download | linux-crypto-2ab40e63dd048c38f750e3fe1848543a81694042.tar.gz linux-crypto-2ab40e63dd048c38f750e3fe1848543a81694042.zip |
crypto: shash - require neither or both ->export() and ->import()
Prevent registering shash algorithms that implement ->export() but not
->import(), or ->import() but not ->export(). Such cases don't make
sense and could confuse the check that shash_prepare_alg() does for just
->export().
I don't believe this affects any existing algorithms; this is just
preventing future mistakes.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r-- | crypto/shash.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index 40311cca..2bffdecf 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -472,6 +472,9 @@ static int shash_prepare_alg(struct shash_alg *alg) alg->statesize > HASH_MAX_STATESIZE) return -EINVAL; + if ((alg->export && !alg->import) || (alg->import && !alg->export)) + return -EINVAL; + base->cra_type = &crypto_shash_type; base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK; base->cra_flags |= CRYPTO_ALG_TYPE_SHASH; |