mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
crypto: gcm - fix assumption that assoc has one segment
commit d3dde52209
upstream.
rfc4543(gcm(*)) code for GMAC assumes that assoc scatterlist always contains
only one segment and only makes use of this first segment. However ipsec passes
assoc with three segments when using 'extended sequence number' thus in this
case rfc4543(gcm(*)) fails to function correctly. Patch fixes this issue.
Reported-by: Chaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
Tested-by: Chaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a227904b82
commit
972595ab7b
1 changed files with 14 additions and 3 deletions
17
crypto/gcm.c
17
crypto/gcm.c
|
@ -44,6 +44,7 @@ struct crypto_rfc4543_ctx {
|
||||||
|
|
||||||
struct crypto_rfc4543_req_ctx {
|
struct crypto_rfc4543_req_ctx {
|
||||||
u8 auth_tag[16];
|
u8 auth_tag[16];
|
||||||
|
u8 assocbuf[32];
|
||||||
struct scatterlist cipher[1];
|
struct scatterlist cipher[1];
|
||||||
struct scatterlist payload[2];
|
struct scatterlist payload[2];
|
||||||
struct scatterlist assoc[2];
|
struct scatterlist assoc[2];
|
||||||
|
@ -1142,9 +1143,19 @@ static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req,
|
||||||
scatterwalk_crypto_chain(payload, dst, vdst == req->iv + 8, 2);
|
scatterwalk_crypto_chain(payload, dst, vdst == req->iv + 8, 2);
|
||||||
assoclen += 8 + req->cryptlen - (enc ? 0 : authsize);
|
assoclen += 8 + req->cryptlen - (enc ? 0 : authsize);
|
||||||
|
|
||||||
sg_init_table(assoc, 2);
|
if (req->assoc->length == req->assoclen) {
|
||||||
sg_set_page(assoc, sg_page(req->assoc), req->assoc->length,
|
sg_init_table(assoc, 2);
|
||||||
req->assoc->offset);
|
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);
|
scatterwalk_crypto_chain(assoc, payload, 0, 2);
|
||||||
|
|
||||||
aead_request_set_tfm(subreq, ctx->child);
|
aead_request_set_tfm(subreq, ctx->child);
|
||||||
|
|
Loading…
Reference in a new issue