* [PATCH] crypto: shash - require neither or both ->export() and ->import()
@ 2019-01-07 3:07 Eric Biggers
2019-01-18 10:55 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2019-01-07 3:07 UTC (permalink / raw)
To: linux-crypto, Herbert Xu
From: Eric Biggers <ebiggers@google.com>
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>
---
crypto/shash.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/crypto/shash.c b/crypto/shash.c
index 40311ccad3fae..2bffdecf1f837 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;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: shash - require neither or both ->export() and ->import()
2019-01-07 3:07 [PATCH] crypto: shash - require neither or both ->export() and ->import() Eric Biggers
@ 2019-01-18 10:55 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2019-01-18 10:55 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-crypto
On Sun, Jan 06, 2019 at 07:07:20PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> 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>
> ---
> crypto/shash.c | 3 +++
> 1 file changed, 3 insertions(+)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-18 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 3:07 [PATCH] crypto: shash - require neither or both ->export() and ->import() Eric Biggers
2019-01-18 10:55 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.