#include <linux/unaligned.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <crypto/aead.h>
#include <crypto/aes.h>
#include <crypto/authenc.h>
#include <crypto/chacha.h>
#include <crypto/ctr.h>
#include <crypto/internal/des.h>
#include <crypto/gcm.h>
#include <crypto/ghash.h>
#include <crypto/poly1305.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include <crypto/sm3.h>
#include <crypto/sm4.h>
#include <crypto/xts.h>
#include <crypto/skcipher.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#include "safexcel.h"
enum safexcel_cipher_direction { … };
enum safexcel_cipher_alg { … };
struct safexcel_cipher_ctx { … };
struct safexcel_cipher_req { … };
static int safexcel_skcipher_iv(struct safexcel_cipher_ctx *ctx, u8 *iv,
struct safexcel_command_desc *cdesc)
{ … }
static void safexcel_skcipher_token(struct safexcel_cipher_ctx *ctx, u8 *iv,
struct safexcel_command_desc *cdesc,
struct safexcel_token *atoken,
u32 length)
{ … }
static void safexcel_aead_iv(struct safexcel_cipher_ctx *ctx, u8 *iv,
struct safexcel_command_desc *cdesc)
{ … }
static void safexcel_aead_token(struct safexcel_cipher_ctx *ctx, u8 *iv,
struct safexcel_command_desc *cdesc,
struct safexcel_token *atoken,
enum safexcel_cipher_direction direction,
u32 cryptlen, u32 assoclen, u32 digestsize)
{ … }
static int safexcel_skcipher_aes_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8 *key,
unsigned int len)
{ … }
static int safexcel_context_control(struct safexcel_cipher_ctx *ctx,
struct crypto_async_request *async,
struct safexcel_cipher_req *sreq,
struct safexcel_command_desc *cdesc)
{ … }
static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv, int ring,
struct crypto_async_request *async,
struct scatterlist *src,
struct scatterlist *dst,
unsigned int cryptlen,
struct safexcel_cipher_req *sreq,
bool *should_complete, int *ret)
{ … }
static int safexcel_send_req(struct crypto_async_request *base, int ring,
struct safexcel_cipher_req *sreq,
struct scatterlist *src, struct scatterlist *dst,
unsigned int cryptlen, unsigned int assoclen,
unsigned int digestsize, u8 *iv, int *commands,
int *results)
{ … }
static int safexcel_handle_inv_result(struct safexcel_crypto_priv *priv,
int ring,
struct crypto_async_request *base,
struct safexcel_cipher_req *sreq,
bool *should_complete, int *ret)
{ … }
static int safexcel_skcipher_handle_result(struct safexcel_crypto_priv *priv,
int ring,
struct crypto_async_request *async,
bool *should_complete, int *ret)
{ … }
static int safexcel_aead_handle_result(struct safexcel_crypto_priv *priv,
int ring,
struct crypto_async_request *async,
bool *should_complete, int *ret)
{ … }
static int safexcel_cipher_send_inv(struct crypto_async_request *base,
int ring, int *commands, int *results)
{ … }
static int safexcel_skcipher_send(struct crypto_async_request *async, int ring,
int *commands, int *results)
{ … }
static int safexcel_aead_send(struct crypto_async_request *async, int ring,
int *commands, int *results)
{ … }
static int safexcel_cipher_exit_inv(struct crypto_tfm *tfm,
struct crypto_async_request *base,
struct safexcel_cipher_req *sreq,
struct crypto_wait *result)
{ … }
static int safexcel_skcipher_exit_inv(struct crypto_tfm *tfm)
{ … }
static int safexcel_aead_exit_inv(struct crypto_tfm *tfm)
{ … }
static int safexcel_queue_req(struct crypto_async_request *base,
struct safexcel_cipher_req *sreq,
enum safexcel_cipher_direction dir)
{ … }
static int safexcel_encrypt(struct skcipher_request *req)
{ … }
static int safexcel_decrypt(struct skcipher_request *req)
{ … }
static int safexcel_skcipher_cra_init(struct crypto_tfm *tfm)
{ … }
static int safexcel_cipher_cra_exit(struct crypto_tfm *tfm)
{ … }
static void safexcel_skcipher_cra_exit(struct crypto_tfm *tfm)
{ … }
static void safexcel_aead_cra_exit(struct crypto_tfm *tfm)
{ … }
static int safexcel_skcipher_aes_ecb_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_ecb_aes = …;
static int safexcel_skcipher_aes_cbc_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_cbc_aes = …;
static int safexcel_skcipher_aesctr_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_skcipher_aes_ctr_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_ctr_aes = …;
static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key,
unsigned int len)
{ … }
static int safexcel_skcipher_des_cbc_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_cbc_des = …;
static int safexcel_skcipher_des_ecb_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_ecb_des = …;
static int safexcel_des3_ede_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_skcipher_des3_cbc_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_cbc_des3_ede = …;
static int safexcel_skcipher_des3_ecb_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_ecb_des3_ede = …;
static int safexcel_aead_encrypt(struct aead_request *req)
{ … }
static int safexcel_aead_decrypt(struct aead_request *req)
{ … }
static int safexcel_aead_cra_init(struct crypto_tfm *tfm)
{ … }
static int safexcel_aead_sha1_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_aes = …;
static int safexcel_aead_sha256_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_aes = …;
static int safexcel_aead_sha224_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_aes = …;
static int safexcel_aead_sha512_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_aes = …;
static int safexcel_aead_sha384_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_aes = …;
static int safexcel_aead_sha1_des3_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des3_ede = …;
static int safexcel_aead_sha256_des3_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des3_ede = …;
static int safexcel_aead_sha224_des3_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des3_ede = …;
static int safexcel_aead_sha512_des3_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des3_ede = …;
static int safexcel_aead_sha384_des3_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des3_ede = …;
static int safexcel_aead_sha1_des_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des = …;
static int safexcel_aead_sha256_des_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des = …;
static int safexcel_aead_sha224_des_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des = …;
static int safexcel_aead_sha512_des_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des = …;
static int safexcel_aead_sha384_des_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des = …;
static int safexcel_aead_sha1_ctr_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_ctr_aes = …;
static int safexcel_aead_sha256_ctr_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_ctr_aes = …;
static int safexcel_aead_sha224_ctr_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_ctr_aes = …;
static int safexcel_aead_sha512_ctr_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_ctr_aes = …;
static int safexcel_aead_sha384_ctr_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_ctr_aes = …;
static int safexcel_skcipher_aesxts_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_skcipher_aes_xts_cra_init(struct crypto_tfm *tfm)
{ … }
static int safexcel_encrypt_xts(struct skcipher_request *req)
{ … }
static int safexcel_decrypt_xts(struct skcipher_request *req)
{ … }
struct safexcel_alg_template safexcel_alg_xts_aes = …;
static int safexcel_aead_gcm_setkey(struct crypto_aead *ctfm, const u8 *key,
unsigned int len)
{ … }
static int safexcel_aead_gcm_cra_init(struct crypto_tfm *tfm)
{ … }
static void safexcel_aead_gcm_cra_exit(struct crypto_tfm *tfm)
{ … }
static int safexcel_aead_gcm_setauthsize(struct crypto_aead *tfm,
unsigned int authsize)
{ … }
struct safexcel_alg_template safexcel_alg_gcm = …;
static int safexcel_aead_ccm_setkey(struct crypto_aead *ctfm, const u8 *key,
unsigned int len)
{ … }
static int safexcel_aead_ccm_cra_init(struct crypto_tfm *tfm)
{ … }
static int safexcel_aead_ccm_setauthsize(struct crypto_aead *tfm,
unsigned int authsize)
{ … }
static int safexcel_ccm_encrypt(struct aead_request *req)
{ … }
static int safexcel_ccm_decrypt(struct aead_request *req)
{ … }
struct safexcel_alg_template safexcel_alg_ccm = …;
static void safexcel_chacha20_setkey(struct safexcel_cipher_ctx *ctx,
const u8 *key)
{ … }
static int safexcel_skcipher_chacha20_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_skcipher_chacha20_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_chacha20 = …;
static int safexcel_aead_chachapoly_setkey(struct crypto_aead *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_aead_chachapoly_setauthsize(struct crypto_aead *tfm,
unsigned int authsize)
{ … }
static int safexcel_aead_chachapoly_crypt(struct aead_request *req,
enum safexcel_cipher_direction dir)
{ … }
static int safexcel_aead_chachapoly_encrypt(struct aead_request *req)
{ … }
static int safexcel_aead_chachapoly_decrypt(struct aead_request *req)
{ … }
static int safexcel_aead_fallback_cra_init(struct crypto_tfm *tfm)
{ … }
static int safexcel_aead_chachapoly_cra_init(struct crypto_tfm *tfm)
{ … }
static void safexcel_aead_fallback_cra_exit(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_chachapoly = …;
static int safexcel_aead_chachapolyesp_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_chachapoly_esp = …;
static int safexcel_skcipher_sm4_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_sm4_blk_encrypt(struct skcipher_request *req)
{ … }
static int safexcel_sm4_blk_decrypt(struct skcipher_request *req)
{ … }
static int safexcel_skcipher_sm4_ecb_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_ecb_sm4 = …;
static int safexcel_skcipher_sm4_cbc_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_cbc_sm4 = …;
static int safexcel_skcipher_sm4ctr_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_skcipher_sm4_ctr_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_ctr_sm4 = …;
static int safexcel_aead_sm4_blk_encrypt(struct aead_request *req)
{ … }
static int safexcel_aead_sm4_blk_decrypt(struct aead_request *req)
{ … }
static int safexcel_aead_sm4cbc_sha1_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_sm4 = …;
static int safexcel_aead_fallback_setkey(struct crypto_aead *ctfm,
const u8 *key, unsigned int len)
{ … }
static int safexcel_aead_fallback_setauthsize(struct crypto_aead *ctfm,
unsigned int authsize)
{ … }
static int safexcel_aead_fallback_crypt(struct aead_request *req,
enum safexcel_cipher_direction dir)
{ … }
static int safexcel_aead_sm4cbc_sm3_encrypt(struct aead_request *req)
{ … }
static int safexcel_aead_sm4cbc_sm3_decrypt(struct aead_request *req)
{ … }
static int safexcel_aead_sm4cbc_sm3_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sm3_cbc_sm4 = …;
static int safexcel_aead_sm4ctr_sha1_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_ctr_sm4 = …;
static int safexcel_aead_sm4ctr_sm3_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_authenc_hmac_sm3_ctr_sm4 = …;
static int safexcel_rfc4106_gcm_setkey(struct crypto_aead *ctfm, const u8 *key,
unsigned int len)
{ … }
static int safexcel_rfc4106_gcm_setauthsize(struct crypto_aead *tfm,
unsigned int authsize)
{ … }
static int safexcel_rfc4106_encrypt(struct aead_request *req)
{ … }
static int safexcel_rfc4106_decrypt(struct aead_request *req)
{ … }
static int safexcel_rfc4106_gcm_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_rfc4106_gcm = …;
static int safexcel_rfc4543_gcm_setauthsize(struct crypto_aead *tfm,
unsigned int authsize)
{ … }
static int safexcel_rfc4543_gcm_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_rfc4543_gcm = …;
static int safexcel_rfc4309_ccm_setkey(struct crypto_aead *ctfm, const u8 *key,
unsigned int len)
{ … }
static int safexcel_rfc4309_ccm_setauthsize(struct crypto_aead *tfm,
unsigned int authsize)
{ … }
static int safexcel_rfc4309_ccm_encrypt(struct aead_request *req)
{ … }
static int safexcel_rfc4309_ccm_decrypt(struct aead_request *req)
{ … }
static int safexcel_rfc4309_ccm_cra_init(struct crypto_tfm *tfm)
{ … }
struct safexcel_alg_template safexcel_alg_rfc4309_ccm = …;