Skip to contentSkip to conversation

crypto: shash - remove pointless checks of shash_alg::{export,import}

PATCH In review Eric Biggers 2 participants 2 messages Jan 7, 2019 – Jan 18, 2019 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: shash - remove pointless checks of shash_alg::{export,import}

From: Eric Biggers <[email protected]>

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.

---
 crypto/shash.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/shash.c +2 -4
index 2bffdecf1f837..15b369c4745f6 100644
@@ -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);
 
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 9 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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().

Quoted 6 lines

Therefore, remove these unnecessary, always-true conditions.

---
 crypto/shash.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt