From: Jussi Kivilinna Date: Sun, 7 Apr 2013 13:43:46 +0000 (+0300) Subject: crypto: gcm - fix rfc4543 to handle async crypto correctly X-Git-Tag: v3.2.81~42 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=c9dc564e3240cbfa4ec46ff02f33fa5a1b93e468 crypto: gcm - fix rfc4543 to handle async crypto correctly commit d733ac90f9fe8ac284e523f9920b507555b12f6d upstream. If the gcm cipher used by rfc4543 does not complete request immediately, the authentication tag is not copied to destination buffer. Patch adds correct async logic for this case. Signed-off-by: Jussi Kivilinna Signed-off-by: Herbert Xu Signed-off-by: Ben Hutchings --- diff --git a/crypto/gcm.c b/crypto/gcm.c index 1e3356107af2..cd39a6870e2c 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -1103,6 +1103,21 @@ static int crypto_rfc4543_setauthsize(struct crypto_aead *parent, return crypto_aead_setauthsize(ctx->child, authsize); } +static void crypto_rfc4543_done(struct crypto_async_request *areq, int err) +{ + struct aead_request *req = areq->data; + struct crypto_aead *aead = crypto_aead_reqtfm(req); + struct crypto_rfc4543_req_ctx *rctx = crypto_rfc4543_reqctx(req); + + if (!err) { + scatterwalk_map_and_copy(rctx->auth_tag, req->dst, + req->cryptlen, + crypto_aead_authsize(aead), 1); + } + + aead_request_complete(req, err); +} + static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req, int enc) { @@ -1159,8 +1174,8 @@ static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req, scatterwalk_crypto_chain(assoc, payload, 0, 2); aead_request_set_tfm(subreq, ctx->child); - aead_request_set_callback(subreq, req->base.flags, req->base.complete, - req->base.data); + aead_request_set_callback(subreq, req->base.flags, crypto_rfc4543_done, + req); aead_request_set_crypt(subreq, cipher, cipher, enc ? 0 : authsize, iv); aead_request_set_assoc(subreq, assoc, assoclen);