2007-12-12 12:30:58

by Herbert Xu

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

[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 <[email protected]>
---

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;