/* * Support for Intel AES-NI instructions. This file contains glue * code, the real AES implementation is in intel-aes_asm.S. * * Copyright (C) 2008, Intel Corp. * Author: Huang Ying <ying.huang@intel.com> * * Added RFC4106 AES-GCM support for 128-bit keys under the AEAD * interface for 64-bit kernels. * Authors: Adrian Hoban <adrian.hoban@intel.com> * Gabriele Paoloni <gabriele.paoloni@intel.com> * Tadeusz Struk (tadeusz.struk@intel.com) * Aidan O'Mahony (aidan.o.mahony@intel.com) * Copyright (c) 2010, Intel Corporation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */#include<linux/hardirq.h>#include<linux/types.h>#include<linux/crypto.h>#include<linux/module.h>#include<linux/err.h>#include<crypto/algapi.h>#include<crypto/aes.h>#include<crypto/cryptd.h>#include<crypto/ctr.h>#include<crypto/b128ops.h>#include<crypto/lrw.h>#include<crypto/xts.h>#include<asm/cpu_device_id.h>#include<asm/i387.h>#include<asm/crypto/aes.h>#include<crypto/ablk_helper.h>#include<crypto/scatterwalk.h>#include<crypto/internal/aead.h>#include<linux/workqueue.h>#include<linux/spinlock.h>#ifdef CONFIG_X86_64#include<asm/crypto/glue_helper.h>#endif#if defined(CONFIG_CRYPTO_PCBC) || defined(CONFIG_CRYPTO_PCBC_MODULE)#define HAS_PCBC#endif/* This data is stored at the end of the crypto_tfm struct. * It's a type of per "session" data storage location. * This needs to be 16 byte aligned. */structaesni_rfc4106_gcm_ctx{u8hash_subkey[16];structcrypto_aes_ctxaes_key_expanded;u8nonce[4];structcryptd_aead*cryptd_tfm;};structaesni_gcm_set_hash_subkey_result{interr;structcompletioncompletion;};structaesni_hash_subkey_req_data{u8iv[16];structaesni_gcm_set_hash_subkey_resultresult;structscatterlistsg;};#define AESNI_ALIGN (16)#define AES_BLOCK_MASK (~(AES_BLOCK_SIZE-1))#define RFC4106_HASH_SUBKEY_SIZE 16structaesni_lrw_ctx{structlrw_table_ctxlrw_table;u8raw_aes_ctx[sizeof(structcrypto_aes_ctx)+AESNI_ALIGN-1];};structaesni_xts_ctx{u8raw_tweak_ctx[sizeof(structcrypto_aes_ctx)+AESNI_ALIGN-1];u8raw_crypt_ctx[sizeof(structcrypto_aes_ctx)+AESNI_ALIGN-1];};asmlinkageintaesni_set_key(structcrypto_aes_ctx*ctx,