aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-04-07 09:43:46 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2013-04-25 09:01:47 -0400
commitd733ac90f9fe8ac284e523f9920b507555b12f6d (patch)
tree5473aaed000ebb394a01a4741108e358ba24bc98
parent9489667d3e3d39ba452037585e48a89ce44ccbfe (diff)
crypto: gcm - fix rfc4543 to handle async crypto correctly
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 <jussi.kivilinna@iki.fi> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/gcm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/crypto/gcm.c b/crypto/gcm.c
index 4ff213997fbd..b0d3cb12334d 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -1099,6 +1099,21 @@ static int crypto_rfc4543_setauthsize(struct crypto_aead *parent,
1099 return crypto_aead_setauthsize(ctx->child, authsize); 1099 return crypto_aead_setauthsize(ctx->child, authsize);
1100} 1100}
1101 1101
1102static void crypto_rfc4543_done(struct crypto_async_request *areq, int err)
1103{
1104 struct aead_request *req = areq->data;
1105 struct crypto_aead *aead = crypto_aead_reqtfm(req);
1106 struct crypto_rfc4543_req_ctx *rctx = crypto_rfc4543_reqctx(req);
1107
1108 if (!err) {
1109 scatterwalk_map_and_copy(rctx->auth_tag, req->dst,
1110 req->cryptlen,
1111 crypto_aead_authsize(aead), 1);
1112 }
1113
1114 aead_request_complete(req, err);
1115}
1116
1102static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req, 1117static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req,
1103 bool enc) 1118 bool enc)
1104{ 1119{
@@ -1145,8 +1160,8 @@ static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req,
1145 scatterwalk_crypto_chain(assoc, payload, 0, 2); 1160 scatterwalk_crypto_chain(assoc, payload, 0, 2);
1146 1161
1147 aead_request_set_tfm(subreq, ctx->child); 1162 aead_request_set_tfm(subreq, ctx->child);
1148 aead_request_set_callback(subreq, req->base.flags, req->base.complete, 1163 aead_request_set_callback(subreq, req->base.flags, crypto_rfc4543_done,
1149 req->base.data); 1164 req);
1150 aead_request_set_crypt(subreq, cipher, cipher, enc ? 0 : authsize, iv); 1165 aead_request_set_crypt(subreq, cipher, cipher, enc ? 0 : authsize, iv);
1151 aead_request_set_assoc(subreq, assoc, assoclen); 1166 aead_request_set_assoc(subreq, assoc, assoclen);
1152 1167