/* * GCM: Galois/Counter Mode. * * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. */#include<crypto/gf128mul.h>#include<crypto/internal/aead.h>#include<crypto/internal/skcipher.h>#include<crypto/internal/hash.h>#include<crypto/null.h>#include<crypto/scatterwalk.h>#include<crypto/gcm.h>#include<crypto/hash.h>#include"internal.h"#include<linux/err.h>#include<linux/init.h>#include<linux/kernel.h>#include<linux/module.h>#include<linux/slab.h>structgcm_instance_ctx{structcrypto_skcipher_spawnctr;structcrypto_ahash_spawnghash;};structcrypto_gcm_ctx{structcrypto_skcipher*ctr;structcrypto_ahash*ghash;};structcrypto_rfc4106_ctx{structcrypto_aead*child;u8nonce[4];};structcrypto_rfc4106_req_ctx{structscatterlistsrc[3];structscatterlistdst[3];structaead_requestsubreq;};structcrypto_rfc4543_instance_ctx{structcrypto_aead_spawnaead;};structcrypto_rfc4543_ctx{structcrypto_aead*child;structcrypto_sync_skcipher*null;u8nonce[4];};structcrypto_rfc4543_req_ctx{structaead_requestsubreq;};structcrypto_gcm_ghash_ctx{unsignedintcryptlen;structscatterlist*src;int(*complete)(structaead_request*req,u32flags);};structcrypto_gcm_req_priv_ctx{u8iv[16];u8auth_tag[16];u8iauth_tag[16];structscatterlistsrc[3];structscatterlistdst[3];structscatterlistsg;structcrypto_gcm_ghash_ctxghash_ctx;union{structahash_requestahreq;structskcipher_requestskreq;}u;};staticstruct{u8buf[16];structscatterlistsg;}*gcm_zeroes;staticintcrypto_rfc4543_copy_src_to_dst(structaead_request*req,boolenc);staticinlinestructcrypto_gcm_req_priv_ctx*crypto_gcm_reqctx(structaead_request*req){unsignedlongalign=crypto_aead_alignmask(crypto_aead_reqtfm(req));return(void*)PTR_ALIGN((u8*)aead_request_ctx(req),align+1);}staticintcrypto_gcm_setkey(structcrypto_aead*aead,constu8*key,unsignedintkeylen){structcrypto_gcm_ctx*ctx=crypto_aead_ctx(aead);structcrypto_ahash*ghash=ctx->ghash