From 96c22053738e360f016ec56b6136018bee3d16ed Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 6 Dec 2007 14:59:53 +0800 Subject: [PATCH] --- yaml --- r: 75947 b: refs/heads/master c: 7f6813786a6521380e1756ca5b4336bc63c5bf7d h: refs/heads/master i: 75945: e479096e8b2143b95b1816c6422ea465c7280ff5 75943: ecde7ebff37927e6530d18a7fc4393824a7d22d8 v: v3 --- [refs] | 2 +- trunk/crypto/gcm.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index a3acd5aae242..a4fcba074ba6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b2ab4a57b018aafbba35bff088218f5cc3d2142e +refs/heads/master: 7f6813786a6521380e1756ca5b4336bc63c5bf7d diff --git a/trunk/crypto/gcm.c b/trunk/crypto/gcm.c index 502da929a5fc..73565d607ee7 100644 --- a/trunk/crypto/gcm.c +++ b/trunk/crypto/gcm.c @@ -40,6 +40,7 @@ struct crypto_gcm_req_priv_ctx { u8 iauth_tag[16]; u8 counter[16]; struct crypto_gcm_ghash_ctx ghash; + struct ablkcipher_request abreq; }; static void crypto_gcm_ghash_init(struct crypto_gcm_ghash_ctx *ctx, u32 flags, @@ -280,16 +281,17 @@ static void crypto_gcm_encrypt_done(struct crypto_async_request *areq, int err) static int crypto_gcm_encrypt(struct aead_request *req) { - struct ablkcipher_request abreq; + struct crypto_gcm_req_priv_ctx *pctx = aead_request_ctx(req); + struct ablkcipher_request *abreq = &pctx->abreq; int err = 0; - err = crypto_gcm_init_crypt(&abreq, req, req->cryptlen, + err = crypto_gcm_init_crypt(abreq, req, req->cryptlen, crypto_gcm_encrypt_done); if (err) return err; if (req->cryptlen) { - err = crypto_ablkcipher_encrypt(&abreq); + err = crypto_ablkcipher_encrypt(abreq); if (err) return err; } @@ -304,9 +306,9 @@ static void crypto_gcm_decrypt_done(struct crypto_async_request *areq, int err) static int crypto_gcm_decrypt(struct aead_request *req) { - struct ablkcipher_request abreq; struct crypto_aead *aead = crypto_aead_reqtfm(req); struct crypto_gcm_req_priv_ctx *pctx = aead_request_ctx(req); + struct ablkcipher_request *abreq = &pctx->abreq; u8 *auth_tag = pctx->auth_tag; u8 *iauth_tag = pctx->iauth_tag; struct crypto_gcm_ghash_ctx *ghash = &pctx->ghash; @@ -318,7 +320,7 @@ static int crypto_gcm_decrypt(struct aead_request *req) return -EINVAL; cryptlen -= authsize; - err = crypto_gcm_init_crypt(&abreq, req, cryptlen, + err = crypto_gcm_init_crypt(abreq, req, cryptlen, crypto_gcm_decrypt_done); if (err) return err; @@ -330,7 +332,7 @@ static int crypto_gcm_decrypt(struct aead_request *req) if (memcmp(iauth_tag, auth_tag, authsize)) return -EBADMSG; - return crypto_ablkcipher_decrypt(&abreq); + return crypto_ablkcipher_decrypt(abreq); } static int crypto_gcm_init_tfm(struct crypto_tfm *tfm) @@ -353,7 +355,9 @@ static int crypto_gcm_init_tfm(struct crypto_tfm *tfm) align = max_t(unsigned long, crypto_ablkcipher_alignmask(ctr), __alignof__(u32) - 1); align &= ~(crypto_tfm_ctx_alignment() - 1); - tfm->crt_aead.reqsize = align + sizeof(struct crypto_gcm_req_priv_ctx); + tfm->crt_aead.reqsize = align + + sizeof(struct crypto_gcm_req_priv_ctx) + + crypto_ablkcipher_reqsize(ctr); return 0; }