diff mbox series

[03/15] crypto: skcipher - Remove ivsize check for lskcipher simple templates

Message ID 0d402ea82463e6d7dec2cf9b85d0ed92e0f2103f.1707815065.git.herbert@gondor.apana.org.au
State New
Headers show
Series crypto: Add twopass lskcipher for adiantum | expand

Commit Message

Herbert Xu Dec. 7, 2023, 10:03 a.m. UTC
Remove the ivsize check for lskcipher simple templates so that it
can be used for cts.  Check for the ivsize in users such as cbc
instead.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/cbc.c       | 5 +++++
 crypto/lskcipher.c | 6 +-----
 2 files changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/crypto/cbc.c b/crypto/cbc.c
index eedddef9ce40..173e47aecb1f 100644
--- a/crypto/cbc.c
+++ b/crypto/cbc.c
@@ -148,6 +148,11 @@  static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb)
 	if (!is_power_of_2(inst->alg.co.base.cra_blocksize))
 		goto out_free_inst;
 
+	if (inst->alg.co.ivsize)
+		goto out_free_inst;
+
+	inst->alg.co.ivsize = inst->alg.co.base.cra_blocksize;
+
 	inst->alg.encrypt = crypto_cbc_encrypt;
 	inst->alg.decrypt = crypto_cbc_decrypt;
 
diff --git a/crypto/lskcipher.c b/crypto/lskcipher.c
index 2a602911f4fc..260666f34500 100644
--- a/crypto/lskcipher.c
+++ b/crypto/lskcipher.c
@@ -630,10 +630,6 @@  struct lskcipher_instance *lskcipher_alloc_instance_simple(
 			goto err_free_inst;
 	}
 
-	err = -EINVAL;
-	if (cipher_alg->co.ivsize)
-		goto err_free_inst;
-
 	inst->free = lskcipher_free_instance_simple;
 
 	/* Default algorithm properties, can be overridden */
@@ -642,7 +638,7 @@  struct lskcipher_instance *lskcipher_alloc_instance_simple(
 	inst->alg.co.base.cra_priority = cipher_alg->co.base.cra_priority;
 	inst->alg.co.min_keysize = cipher_alg->co.min_keysize;
 	inst->alg.co.max_keysize = cipher_alg->co.max_keysize;
-	inst->alg.co.ivsize = cipher_alg->co.base.cra_blocksize;
+	inst->alg.co.ivsize = cipher_alg->co.ivsize;
 	inst->alg.co.statesize = cipher_alg->co.statesize;
 
 	/* Use struct crypto_lskcipher * by default, can be overridden */