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,
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;
}
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;
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;
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)
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;
}