]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - crypto/gcm.c
fat (exportfs): rebuild directory-inode if fat_dget()
[karo-tx-linux.git] / crypto / gcm.c
index 137ad1ec54383ceda3e515490ffc794a0242f907..13ccbda34ff979fbeb037b88ae400f4e248789a7 100644 (file)
@@ -44,6 +44,7 @@ struct crypto_rfc4543_ctx {
 
 struct crypto_rfc4543_req_ctx {
        u8 auth_tag[16];
+       u8 assocbuf[32];
        struct scatterlist cipher[1];
        struct scatterlist payload[2];
        struct scatterlist assoc[2];
@@ -1133,9 +1134,19 @@ static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req,
        scatterwalk_crypto_chain(payload, dst, vdst == req->iv + 8, 2);
        assoclen += 8 + req->cryptlen - (enc ? 0 : authsize);
 
-       sg_init_table(assoc, 2);
-       sg_set_page(assoc, sg_page(req->assoc), req->assoc->length,
-                   req->assoc->offset);
+       if (req->assoc->length == req->assoclen) {
+               sg_init_table(assoc, 2);
+               sg_set_page(assoc, sg_page(req->assoc), req->assoc->length,
+                           req->assoc->offset);
+       } else {
+               BUG_ON(req->assoclen > sizeof(rctx->assocbuf));
+
+               scatterwalk_map_and_copy(rctx->assocbuf, req->assoc, 0,
+                                        req->assoclen, 0);
+
+               sg_init_table(assoc, 2);
+               sg_set_buf(assoc, rctx->assocbuf, req->assoclen);
+       }
        scatterwalk_crypto_chain(assoc, payload, 0, 2);
 
        aead_request_set_tfm(subreq, ctx->child);