[PATCH 4/10] [CRYPTO] skcipher: Return EINVAL on zero IV when making givcipher

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[CRYPTO] skcipher: Return EINVAL on zero IV when making givcipher

Returning EAGAIN on a zero IV when making givcipher will lead to an
infinite loop since the upper layer will simply retry the operation.

During normal operation IV sizes shouldn't change given the same
algorithm so it's safe to return EINVAL.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
---

 crypto/blkcipher.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index 10c2229..6f84481 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -604,7 +604,7 @@ struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl,
 		balg.geniv = alg->cra_ablkcipher.geniv;
 	}
 
-	err = -EAGAIN;
+	err = -EINVAL;
 	if (!balg.ivsize)
 		goto err_drop_alg;
 
@@ -616,6 +616,7 @@ struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl,
 	if (algt->mask & CRYPTO_ALG_GENIV) {
 		if (!balg.geniv)
 			balg.geniv = crypto_default_geniv(alg);
+		err = -EAGAIN;
 		if (strcmp(tmpl->name, balg.geniv))
 			goto err_drop_alg;
 
-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux