linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: shash - remove pointless checks of shash_alg::{export,import}
@ 2019-01-07  3:08 Eric Biggers
  2019-01-18 10:56 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2019-01-07  3:08 UTC (permalink / raw)
  To: linux-crypto, Herbert Xu

From: Eric Biggers <ebiggers@google.com>

crypto_init_shash_ops_async() only gives the ahash tfm non-NULL
->export() and ->import() if the underlying shash alg has these
non-NULL.  This doesn't make sense because when an shash algorithm is
registered, shash_prepare_alg() sets a default ->export() and ->import()
if the implementor didn't provide them.  And elsewhere it's assumed that
all shash algs and ahash tfms have non-NULL ->export() and ->import().

Therefore, remove these unnecessary, always-true conditions.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 crypto/shash.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/crypto/shash.c b/crypto/shash.c
index 2bffdecf1f837..15b369c4745f6 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -388,10 +388,8 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
 	crypto_ahash_set_flags(crt, crypto_shash_get_flags(shash) &
 				    CRYPTO_TFM_NEED_KEY);
 
-	if (alg->export)
-		crt->export = shash_async_export;
-	if (alg->import)
-		crt->import = shash_async_import;
+	crt->export = shash_async_export;
+	crt->import = shash_async_import;
 
 	crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: shash - remove pointless checks of shash_alg::{export,import}
  2019-01-07  3:08 [PATCH] crypto: shash - remove pointless checks of shash_alg::{export,import} Eric Biggers
@ 2019-01-18 10:56 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2019-01-18 10:56 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-crypto

On Sun, Jan 06, 2019 at 07:08:01PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> crypto_init_shash_ops_async() only gives the ahash tfm non-NULL
> ->export() and ->import() if the underlying shash alg has these
> non-NULL.  This doesn't make sense because when an shash algorithm is
> registered, shash_prepare_alg() sets a default ->export() and ->import()
> if the implementor didn't provide them.  And elsewhere it's assumed that
> all shash algs and ahash tfms have non-NULL ->export() and ->import().
> 
> Therefore, remove these unnecessary, always-true conditions.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  crypto/shash.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

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:56 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:08 [PATCH] crypto: shash - remove pointless checks of shash_alg::{export,import} Eric Biggers
2019-01-18 10:56 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).