linux/drivers/crypto/caam/caamalg_qi.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Freescale FSL CAAM support for crypto API over QI backend.
 * Based on caamalg.c
 *
 * Copyright 2013-2016 Freescale Semiconductor, Inc.
 * Copyright 2016-2019 NXP
 */

#include "compat.h"
#include "ctrl.h"
#include "regs.h"
#include "intern.h"
#include "desc_constr.h"
#include "error.h"
#include "sg_sw_qm.h"
#include "key_gen.h"
#include "qi.h"
#include "jr.h"
#include "caamalg_desc.h"
#include <crypto/xts.h>
#include <linux/unaligned.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/dma-mapping.h>
#include <linux/kernel.h>
#include <linux/string.h>

/*
 * crypto alg
 */
#define CAAM_CRA_PRIORITY
/* max key is sum of AES_MAX_KEY_SIZE, max split key size */
#define CAAM_MAX_KEY_SIZE

#define DESC_MAX_USED_BYTES
#define DESC_MAX_USED_LEN

struct caam_alg_entry {};

struct caam_aead_alg {};

struct caam_skcipher_alg {};

/*
 * per-session context
 */
struct caam_ctx {};

struct caam_skcipher_req_ctx {};

static int aead_set_sh_desc(struct crypto_aead *aead)
{}

static int aead_setauthsize(struct crypto_aead *authenc, unsigned int authsize)
{}

static int aead_setkey(struct crypto_aead *aead, const u8 *key,
		       unsigned int keylen)
{}

static int des3_aead_setkey(struct crypto_aead *aead, const u8 *key,
			    unsigned int keylen)
{}

static int gcm_set_sh_desc(struct crypto_aead *aead)
{}

static int gcm_setauthsize(struct crypto_aead *authenc, unsigned int authsize)
{}

static int gcm_setkey(struct crypto_aead *aead,
		      const u8 *key, unsigned int keylen)
{}

static int rfc4106_set_sh_desc(struct crypto_aead *aead)
{}

static int rfc4106_setauthsize(struct crypto_aead *authenc,
			       unsigned int authsize)
{}

static int rfc4106_setkey(struct crypto_aead *aead,
			  const u8 *key, unsigned int keylen)
{}

static int rfc4543_set_sh_desc(struct crypto_aead *aead)
{}

static int rfc4543_setauthsize(struct crypto_aead *authenc,
			       unsigned int authsize)
{}

static int rfc4543_setkey(struct crypto_aead *aead,
			  const u8 *key, unsigned int keylen)
{}

static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
			   unsigned int keylen, const u32 ctx1_iv_off)
{}

static int aes_skcipher_setkey(struct crypto_skcipher *skcipher,
			       const u8 *key, unsigned int keylen)
{}

static int rfc3686_skcipher_setkey(struct crypto_skcipher *skcipher,
				   const u8 *key, unsigned int keylen)
{}

static int ctr_skcipher_setkey(struct crypto_skcipher *skcipher,
			       const u8 *key, unsigned int keylen)
{}

static int des3_skcipher_setkey(struct crypto_skcipher *skcipher,
				const u8 *key, unsigned int keylen)
{}

static int des_skcipher_setkey(struct crypto_skcipher *skcipher,
			       const u8 *key, unsigned int keylen)
{}

static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
			       unsigned int keylen)
{}

/*
 * aead_edesc - s/w-extended aead descriptor
 * @src_nents: number of segments in input scatterlist
 * @dst_nents: number of segments in output scatterlist
 * @iv_dma: dma address of iv for checking continuity and link table
 * @qm_sg_bytes: length of dma mapped h/w link table
 * @qm_sg_dma: bus physical mapped address of h/w link table
 * @assoclen: associated data length, in CAAM endianness
 * @assoclen_dma: bus physical mapped address of req->assoclen
 * @drv_req: driver-specific request structure
 * @sgt: the h/w link table, followed by IV
 */
struct aead_edesc {};

/*
 * skcipher_edesc - s/w-extended skcipher descriptor
 * @src_nents: number of segments in input scatterlist
 * @dst_nents: number of segments in output scatterlist
 * @iv_dma: dma address of iv for checking continuity and link table
 * @qm_sg_bytes: length of dma mapped h/w link table
 * @qm_sg_dma: bus physical mapped address of h/w link table
 * @drv_req: driver-specific request structure
 * @sgt: the h/w link table, followed by IV
 */
struct skcipher_edesc {};

static struct caam_drv_ctx *get_drv_ctx(struct caam_ctx *ctx,
					enum optype type)
{}

static void caam_unmap(struct device *dev, struct scatterlist *src,
		       struct scatterlist *dst, int src_nents,
		       int dst_nents, dma_addr_t iv_dma, int ivsize,
		       enum dma_data_direction iv_dir, dma_addr_t qm_sg_dma,
		       int qm_sg_bytes)
{}

static void aead_unmap(struct device *dev,
		       struct aead_edesc *edesc,
		       struct aead_request *req)
{}

static void skcipher_unmap(struct device *dev, struct skcipher_edesc *edesc,
			   struct skcipher_request *req)
{}

static void aead_done(struct caam_drv_req *drv_req, u32 status)
{}

/*
 * allocate and map the aead extended descriptor
 */
static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
					   bool encrypt)
{}

static inline int aead_crypt(struct aead_request *req, bool encrypt)
{}

static int aead_encrypt(struct aead_request *req)
{}

static int aead_decrypt(struct aead_request *req)
{}

static int ipsec_gcm_encrypt(struct aead_request *req)
{}

static int ipsec_gcm_decrypt(struct aead_request *req)
{}

static inline u8 *skcipher_edesc_iv(struct skcipher_edesc *edesc)
{}

static void skcipher_done(struct caam_drv_req *drv_req, u32 status)
{}

static struct skcipher_edesc *skcipher_edesc_alloc(struct skcipher_request *req,
						   bool encrypt)
{}

static inline bool xts_skcipher_ivsize(struct skcipher_request *req)
{}

static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt)
{}

static int skcipher_encrypt(struct skcipher_request *req)
{}

static int skcipher_decrypt(struct skcipher_request *req)
{}

static struct caam_skcipher_alg driver_algs[] =;

static struct caam_aead_alg driver_aeads[] =;

static int caam_init_common(struct caam_ctx *ctx, struct caam_alg_entry *caam,
			    bool uses_dkp)
{}

static int caam_cra_init(struct crypto_skcipher *tfm)
{}

static int caam_aead_init(struct crypto_aead *tfm)
{}

static void caam_exit_common(struct caam_ctx *ctx)
{}

static void caam_cra_exit(struct crypto_skcipher *tfm)
{}

static void caam_aead_exit(struct crypto_aead *tfm)
{}

void caam_qi_algapi_exit(void)
{}

static void caam_skcipher_alg_init(struct caam_skcipher_alg *t_alg)
{}

static void caam_aead_alg_init(struct caam_aead_alg *t_alg)
{}

int caam_qi_algapi_init(struct device *ctrldev)
{}