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>
This commit is contained in:
parent
6ebc97006b
commit
41a2e94f81
|
@ -472,6 +472,9 @@ static int shash_prepare_alg(struct shash_alg *alg)
|
||||||
alg->statesize > HASH_MAX_STATESIZE)
|
alg->statesize > HASH_MAX_STATESIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if ((alg->export && !alg->import) || (alg->import && !alg->export))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
base->cra_type = &crypto_shash_type;
|
base->cra_type = &crypto_shash_type;
|
||||||
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
|
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
|
||||||
base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
|
base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
|
||||||
|
|
Loading…
Reference in New Issue