2007-12-07 08:19:49

by Herbert Xu

[permalink] [raw]
Subject: [PATCH 3/5] [CRYPTO] aead: Return EBADMSG for ICV mismatch

[CRYPTO] aead: Return EBADMSG for ICV mismatch

This patch changes gcm/authenc to return EBADMSG instead of EINVAL for
ICV mismatches. This convention has already been adopted by IPsec.

Signed-off-by: Herbert Xu <[email protected]>
---

crypto/authenc.c | 2 +-
crypto/gcm.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/authenc.c b/crypto/authenc.c
index 82e03ff..6c9104e 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -200,7 +200,7 @@ auth_unlock:

authsize = crypto_aead_authsize(authenc);
scatterwalk_map_and_copy(ihash, src, cryptlen, authsize, 0);
- return memcmp(ihash, ohash, authsize) ? -EINVAL : 0;
+ return memcmp(ihash, ohash, authsize) ? -EBADMSG: 0;
}

static void crypto_authenc_decrypt_done(struct crypto_async_request *req,
diff --git a/crypto/gcm.c b/crypto/gcm.c
index ed8a626..d60c340 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -327,7 +327,7 @@ static int crypto_gcm_decrypt(struct aead_request *req)

scatterwalk_map_and_copy(iauth_tag, req->src, cryptlen, authsize, 0);
if (memcmp(iauth_tag, auth_tag, authsize))
- return -EINVAL;
+ return -EBADMSG;

return crypto_ablkcipher_decrypt(&abreq);
}