Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * caam - Freescale FSL CAAM support for crypto API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Copyright 2008-2011 Freescale Semiconductor, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Copyright 2016-2019 NXP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * Based on talitos crypto API driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  * relationship of job descriptors to shared descriptors (SteveC Dec 10 2008):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  * ---------------                     ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  * | JobDesc #1  |-------------------->|  ShareDesc  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  * | *(packet 1) |                     |   (PDB)     |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  * ---------------      |------------->|  (hashKey)  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  *       .              |              | (cipherKey) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *       .              |    |-------->| (operation) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  * ---------------      |    |         ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  * | JobDesc #2  |------|    |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20)  * | *(packet 2) |           |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21)  * ---------------           |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22)  *       .                   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23)  *       .                   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24)  * ---------------           |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25)  * | JobDesc #3  |------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26)  * | *(packet 3) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27)  * ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29)  * The SharedDesc never changes for a connection unless rekeyed, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30)  * each packet will likely be in a different place. So all we need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31)  * to know to process the packet is where the input is, where the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32)  * output goes, and what context we want to process with. Context is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33)  * in the SharedDesc, packet references in the JobDesc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35)  * So, a job desc looks like:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37)  * ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38)  * | Header            |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39)  * | ShareDesc Pointer |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40)  * | SEQ_OUT_PTR       |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41)  * | (output buffer)   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42)  * | (output length)   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43)  * | SEQ_IN_PTR        |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44)  * | (input buffer)    |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45)  * | (input length)    |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46)  * ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #include "compat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #include "regs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) #include "intern.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #include "desc_constr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) #include "jr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #include "error.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) #include "sg_sw_sec4.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #include "key_gen.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) #include "caamalg_desc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) #include <crypto/engine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) #include <crypto/xts.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64)  * crypto alg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) #define CAAM_CRA_PRIORITY		3000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) /* max key is sum of AES_MAX_KEY_SIZE, max split key size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) #define CAAM_MAX_KEY_SIZE		(AES_MAX_KEY_SIZE + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 					 CTR_RFC3686_NONCE_SIZE + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 					 SHA512_DIGEST_SIZE * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) #define AEAD_DESC_JOB_IO_LEN		(DESC_JOB_IO_LEN + CAAM_CMD_SZ * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) #define GCM_DESC_JOB_IO_LEN		(AEAD_DESC_JOB_IO_LEN + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 					 CAAM_CMD_SZ * 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) #define AUTHENC_DESC_JOB_IO_LEN		(AEAD_DESC_JOB_IO_LEN + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 					 CAAM_CMD_SZ * 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #define CHACHAPOLY_DESC_JOB_IO_LEN	(AEAD_DESC_JOB_IO_LEN + CAAM_CMD_SZ * 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) #define DESC_MAX_USED_BYTES		(CAAM_DESC_BYTES_MAX - DESC_JOB_IO_LEN_MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) #define DESC_MAX_USED_LEN		(DESC_MAX_USED_BYTES / CAAM_CMD_SZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) struct caam_alg_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 	int class1_alg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 	int class2_alg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	bool rfc3686;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	bool geniv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	bool nodkp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) struct caam_aead_alg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	struct aead_alg aead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	struct caam_alg_entry caam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	bool registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) struct caam_skcipher_alg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	struct skcipher_alg skcipher;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	struct caam_alg_entry caam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	bool registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104)  * per-session context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) struct caam_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	struct crypto_engine_ctx enginectx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	u32 sh_desc_enc[DESC_MAX_USED_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	u32 sh_desc_dec[DESC_MAX_USED_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	u8 key[CAAM_MAX_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	dma_addr_t sh_desc_enc_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	dma_addr_t sh_desc_dec_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	dma_addr_t key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	enum dma_data_direction dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	struct device *jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	struct alginfo adata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	struct alginfo cdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	unsigned int authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	bool xts_key_fallback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	struct crypto_skcipher *fallback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) struct caam_skcipher_req_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	struct skcipher_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	struct skcipher_request fallback_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) struct caam_aead_req_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	struct aead_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) static int aead_null_set_sh_desc(struct crypto_aead *aead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	struct caam_drv_private *ctrlpriv = dev_get_drvdata(jrdev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 	int rem_bytes = CAAM_DESC_BYTES_MAX - AEAD_DESC_JOB_IO_LEN -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 			ctx->adata.keylen_pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	if (rem_bytes >= DESC_AEAD_NULL_ENC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 		ctx->adata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 		ctx->adata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 		ctx->adata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 		ctx->adata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	/* aead_encrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	cnstr_shdsc_aead_null_encap(desc, &ctx->adata, ctx->authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 				    ctrlpriv->era);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	if (rem_bytes >= DESC_AEAD_NULL_DEC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 		ctx->adata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 		ctx->adata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 		ctx->adata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 		ctx->adata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	/* aead_decrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	cnstr_shdsc_aead_null_decap(desc, &ctx->adata, ctx->authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 				    ctrlpriv->era);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) static int aead_set_sh_desc(struct crypto_aead *aead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	struct caam_aead_alg *alg = container_of(crypto_aead_alg(aead),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 						 struct caam_aead_alg, aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	struct caam_drv_private *ctrlpriv = dev_get_drvdata(jrdev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	u32 ctx1_iv_off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	u32 *desc, *nonce = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	u32 inl_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	unsigned int data_len[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	const bool ctr_mode = ((ctx->cdata.algtype & OP_ALG_AAI_MASK) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 			       OP_ALG_AAI_CTR_MOD128);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	const bool is_rfc3686 = alg->caam.rfc3686;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	if (!ctx->authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	/* NULL encryption / decryption */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	if (!ctx->cdata.keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 		return aead_null_set_sh_desc(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	 * AES-CTR needs to load IV in CONTEXT1 reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	 * at an offset of 128bits (16bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	 * CONTEXT1[255:128] = IV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	if (ctr_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		ctx1_iv_off = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	 * RFC3686 specific:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	 *	CONTEXT1[255:128] = {NONCE, IV, COUNTER}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	if (is_rfc3686) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 		ctx1_iv_off = 16 + CTR_RFC3686_NONCE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 		nonce = (u32 *)((void *)ctx->key + ctx->adata.keylen_pad +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 				ctx->cdata.keylen - CTR_RFC3686_NONCE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	 * In case |user key| > |derived key|, using DKP<imm,imm>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	 * would result in invalid opcodes (last bytes of user key) in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	 * the resulting descriptor. Use DKP<ptr,imm> instead => both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	 * virtual and dma key addresses are needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	ctx->adata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	ctx->adata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	ctx->cdata.key_virt = ctx->key + ctx->adata.keylen_pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	ctx->cdata.key_dma = ctx->key_dma + ctx->adata.keylen_pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	data_len[0] = ctx->adata.keylen_pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	data_len[1] = ctx->cdata.keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	if (alg->caam.geniv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 		goto skip_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	if (desc_inline_query(DESC_AEAD_ENC_LEN +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 			      (is_rfc3686 ? DESC_AEAD_CTR_RFC3686_LEN : 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 			      AUTHENC_DESC_JOB_IO_LEN, data_len, &inl_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 			      ARRAY_SIZE(data_len)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	ctx->adata.key_inline = !!(inl_mask & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	ctx->cdata.key_inline = !!(inl_mask & 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	/* aead_encrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	cnstr_shdsc_aead_encap(desc, &ctx->cdata, &ctx->adata, ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 			       ctx->authsize, is_rfc3686, nonce, ctx1_iv_off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 			       false, ctrlpriv->era);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) skip_enc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	if (desc_inline_query(DESC_AEAD_DEC_LEN +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 			      (is_rfc3686 ? DESC_AEAD_CTR_RFC3686_LEN : 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 			      AUTHENC_DESC_JOB_IO_LEN, data_len, &inl_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 			      ARRAY_SIZE(data_len)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	ctx->adata.key_inline = !!(inl_mask & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	ctx->cdata.key_inline = !!(inl_mask & 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 	/* aead_decrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	cnstr_shdsc_aead_decap(desc, &ctx->cdata, &ctx->adata, ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 			       ctx->authsize, alg->caam.geniv, is_rfc3686,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 			       nonce, ctx1_iv_off, false, ctrlpriv->era);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	if (!alg->caam.geniv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		goto skip_givenc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	if (desc_inline_query(DESC_AEAD_GIVENC_LEN +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 			      (is_rfc3686 ? DESC_AEAD_CTR_RFC3686_LEN : 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 			      AUTHENC_DESC_JOB_IO_LEN, data_len, &inl_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 			      ARRAY_SIZE(data_len)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	ctx->adata.key_inline = !!(inl_mask & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	ctx->cdata.key_inline = !!(inl_mask & 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	/* aead_givencrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	cnstr_shdsc_aead_givencap(desc, &ctx->cdata, &ctx->adata, ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 				  ctx->authsize, is_rfc3686, nonce,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 				  ctx1_iv_off, false, ctrlpriv->era);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) skip_givenc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) static int aead_setauthsize(struct crypto_aead *authenc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 				    unsigned int authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	struct caam_ctx *ctx = crypto_aead_ctx(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	ctx->authsize = authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	aead_set_sh_desc(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) static int gcm_set_sh_desc(struct crypto_aead *aead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	int rem_bytes = CAAM_DESC_BYTES_MAX - GCM_DESC_JOB_IO_LEN -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 			ctx->cdata.keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	if (!ctx->cdata.keylen || !ctx->authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	 * AES GCM encrypt shared descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	 * Job Descriptor and Shared Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	 * must fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	if (rem_bytes >= DESC_GCM_ENC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 		ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 		ctx->cdata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		ctx->cdata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		ctx->cdata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	cnstr_shdsc_gcm_encap(desc, &ctx->cdata, ivsize, ctx->authsize, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	if (rem_bytes >= DESC_GCM_DEC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 		ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 		ctx->cdata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		ctx->cdata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 		ctx->cdata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 	cnstr_shdsc_gcm_decap(desc, &ctx->cdata, ivsize, ctx->authsize, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) static int gcm_setauthsize(struct crypto_aead *authenc, unsigned int authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	struct caam_ctx *ctx = crypto_aead_ctx(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	err = crypto_gcm_check_authsize(authsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	ctx->authsize = authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	gcm_set_sh_desc(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) static int rfc4106_set_sh_desc(struct crypto_aead *aead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	int rem_bytes = CAAM_DESC_BYTES_MAX - GCM_DESC_JOB_IO_LEN -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 			ctx->cdata.keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	if (!ctx->cdata.keylen || !ctx->authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	 * RFC4106 encrypt shared descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	 * Job Descriptor and Shared Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	 * must fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	if (rem_bytes >= DESC_RFC4106_ENC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 		ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 		ctx->cdata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 		ctx->cdata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		ctx->cdata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	cnstr_shdsc_rfc4106_encap(desc, &ctx->cdata, ivsize, ctx->authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 				  false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	if (rem_bytes >= DESC_RFC4106_DEC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		ctx->cdata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 		ctx->cdata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		ctx->cdata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	cnstr_shdsc_rfc4106_decap(desc, &ctx->cdata, ivsize, ctx->authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 				  false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) static int rfc4106_setauthsize(struct crypto_aead *authenc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 			       unsigned int authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	struct caam_ctx *ctx = crypto_aead_ctx(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	err = crypto_rfc4106_check_authsize(authsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	ctx->authsize = authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	rfc4106_set_sh_desc(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) static int rfc4543_set_sh_desc(struct crypto_aead *aead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	int rem_bytes = CAAM_DESC_BYTES_MAX - GCM_DESC_JOB_IO_LEN -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 			ctx->cdata.keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	if (!ctx->cdata.keylen || !ctx->authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	 * RFC4543 encrypt shared descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	 * Job Descriptor and Shared Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	 * must fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	if (rem_bytes >= DESC_RFC4543_ENC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 		ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 		ctx->cdata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 		ctx->cdata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 		ctx->cdata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 	cnstr_shdsc_rfc4543_encap(desc, &ctx->cdata, ivsize, ctx->authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 				  false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	 * Job Descriptor and Shared Descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	 * must all fit into the 64-word Descriptor h/w Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	if (rem_bytes >= DESC_RFC4543_DEC_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 		ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		ctx->cdata.key_virt = ctx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 		ctx->cdata.key_inline = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 		ctx->cdata.key_dma = ctx->key_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	cnstr_shdsc_rfc4543_decap(desc, &ctx->cdata, ivsize, ctx->authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 				  false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) static int rfc4543_setauthsize(struct crypto_aead *authenc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 			       unsigned int authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	struct caam_ctx *ctx = crypto_aead_ctx(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	if (authsize != 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	ctx->authsize = authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	rfc4543_set_sh_desc(authenc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) static int chachapoly_set_sh_desc(struct crypto_aead *aead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 	if (!ctx->cdata.keylen || !ctx->authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 	cnstr_shdsc_chachapoly(desc, &ctx->cdata, &ctx->adata, ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 			       ctx->authsize, true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	cnstr_shdsc_chachapoly(desc, &ctx->cdata, &ctx->adata, ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 			       ctx->authsize, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) static int chachapoly_setauthsize(struct crypto_aead *aead,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 				  unsigned int authsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	if (authsize != POLY1305_DIGEST_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	ctx->authsize = authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	return chachapoly_set_sh_desc(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) static int chachapoly_setkey(struct crypto_aead *aead, const u8 *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 			     unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	unsigned int saltlen = CHACHAPOLY_IV_SIZE - ivsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	if (keylen != CHACHA_KEY_SIZE + saltlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	ctx->cdata.key_virt = key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	ctx->cdata.keylen = keylen - saltlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	return chachapoly_set_sh_desc(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) static int aead_setkey(struct crypto_aead *aead,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 			       const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	struct caam_drv_private *ctrlpriv = dev_get_drvdata(jrdev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	struct crypto_authenc_keys keys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 		goto badkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	dev_dbg(jrdev, "keylen %d enckeylen %d authkeylen %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	       keys.authkeylen + keys.enckeylen, keys.enckeylen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	       keys.authkeylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 			     DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	 * If DKP is supported, use it in the shared descriptor to generate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	 * the split key.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	if (ctrlpriv->era >= 6) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 		ctx->adata.keylen = keys.authkeylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 		ctx->adata.keylen_pad = split_key_len(ctx->adata.algtype &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 						      OP_ALG_ALGSEL_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		if (ctx->adata.keylen_pad + keys.enckeylen > CAAM_MAX_KEY_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 			goto badkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		memcpy(ctx->key, keys.authkey, keys.authkeylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		memcpy(ctx->key + ctx->adata.keylen_pad, keys.enckey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		       keys.enckeylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		dma_sync_single_for_device(jrdev, ctx->key_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 					   ctx->adata.keylen_pad +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 					   keys.enckeylen, ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		goto skip_split_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	ret = gen_split_key(ctx->jrdev, ctx->key, &ctx->adata, keys.authkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 			    keys.authkeylen, CAAM_MAX_KEY_SIZE -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 			    keys.enckeylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 		goto badkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	/* postpend encryption key to auth split key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	memcpy(ctx->key + ctx->adata.keylen_pad, keys.enckey, keys.enckeylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	dma_sync_single_for_device(jrdev, ctx->key_dma, ctx->adata.keylen_pad +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 				   keys.enckeylen, ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	print_hex_dump_debug("ctx.key@"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 			     DUMP_PREFIX_ADDRESS, 16, 4, ctx->key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 			     ctx->adata.keylen_pad + keys.enckeylen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) skip_split_key:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	ctx->cdata.keylen = keys.enckeylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	memzero_explicit(&keys, sizeof(keys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	return aead_set_sh_desc(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) badkey:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	memzero_explicit(&keys, sizeof(keys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) static int des3_aead_setkey(struct crypto_aead *aead, const u8 *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 			    unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	struct crypto_authenc_keys keys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	err = crypto_authenc_extractkeys(&keys, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	if (unlikely(err))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	err = verify_aead_des3_key(aead, keys.enckey, keys.enckeylen) ?:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	      aead_setkey(aead, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 	memzero_explicit(&keys, sizeof(keys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) static int gcm_setkey(struct crypto_aead *aead,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 		      const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	err = aes_check_keylen(keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 			     DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	memcpy(ctx->key, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	dma_sync_single_for_device(jrdev, ctx->key_dma, keylen, ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	ctx->cdata.keylen = keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	return gcm_set_sh_desc(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) static int rfc4106_setkey(struct crypto_aead *aead,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 			  const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	err = aes_check_keylen(keylen - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 			     DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	memcpy(ctx->key, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	 * The last four bytes of the key material are used as the salt value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	 * in the nonce. Update the AES key length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	ctx->cdata.keylen = keylen - 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	dma_sync_single_for_device(jrdev, ctx->key_dma, ctx->cdata.keylen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 				   ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	return rfc4106_set_sh_desc(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) static int rfc4543_setkey(struct crypto_aead *aead,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 			  const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	err = aes_check_keylen(keylen - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			     DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	memcpy(ctx->key, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	 * The last four bytes of the key material are used as the salt value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	 * in the nonce. Update the AES key length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 	ctx->cdata.keylen = keylen - 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	dma_sync_single_for_device(jrdev, ctx->key_dma, ctx->cdata.keylen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 				   ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	return rfc4543_set_sh_desc(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 			   unsigned int keylen, const u32 ctx1_iv_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 	struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	struct caam_skcipher_alg *alg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 		container_of(crypto_skcipher_alg(skcipher), typeof(*alg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 			     skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	const bool is_rfc3686 = alg->caam.rfc3686;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	print_hex_dump_debug("key in @"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 			     DUMP_PREFIX_ADDRESS, 16, 4, key, keylen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	ctx->cdata.keylen = keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	ctx->cdata.key_virt = key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	/* skcipher_encrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	cnstr_shdsc_skcipher_encap(desc, &ctx->cdata, ivsize, is_rfc3686,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 				   ctx1_iv_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	/* skcipher_decrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	cnstr_shdsc_skcipher_decap(desc, &ctx->cdata, ivsize, is_rfc3686,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 				   ctx1_iv_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) static int aes_skcipher_setkey(struct crypto_skcipher *skcipher,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 			       const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	err = aes_check_keylen(keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	return skcipher_setkey(skcipher, key, keylen, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) static int rfc3686_skcipher_setkey(struct crypto_skcipher *skcipher,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 				   const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	u32 ctx1_iv_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	 * RFC3686 specific:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	 *	| CONTEXT1[255:128] = {NONCE, IV, COUNTER}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	 *	| *key = {KEY, NONCE}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	ctx1_iv_off = 16 + CTR_RFC3686_NONCE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	keylen -= CTR_RFC3686_NONCE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	err = aes_check_keylen(keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	return skcipher_setkey(skcipher, key, keylen, ctx1_iv_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) static int ctr_skcipher_setkey(struct crypto_skcipher *skcipher,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 			       const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	u32 ctx1_iv_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	 * AES-CTR needs to load IV in CONTEXT1 reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	 * at an offset of 128bits (16bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	 * CONTEXT1[255:128] = IV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	ctx1_iv_off = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	err = aes_check_keylen(keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	return skcipher_setkey(skcipher, key, keylen, ctx1_iv_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) static int des_skcipher_setkey(struct crypto_skcipher *skcipher,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 			       const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	return verify_skcipher_des_key(skcipher, key) ?:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	       skcipher_setkey(skcipher, key, keylen, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) static int des3_skcipher_setkey(struct crypto_skcipher *skcipher,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 				const u8 *key, unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	return verify_skcipher_des3_key(skcipher, key) ?:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	       skcipher_setkey(skcipher, key, keylen, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 			       unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 	struct caam_drv_private *ctrlpriv = dev_get_drvdata(jrdev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 	err = xts_verify_key(skcipher, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		dev_dbg(jrdev, "key size mismatch\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	if (keylen != 2 * AES_KEYSIZE_128 && keylen != 2 * AES_KEYSIZE_256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 		ctx->xts_key_fallback = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	if (ctrlpriv->era <= 8 || ctx->xts_key_fallback) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 		err = crypto_skcipher_setkey(ctx->fallback, key, keylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	ctx->cdata.keylen = keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 	ctx->cdata.key_virt = key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	ctx->cdata.key_inline = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	/* xts_skcipher_encrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	desc = ctx->sh_desc_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	cnstr_shdsc_xts_skcipher_encap(desc, &ctx->cdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	/* xts_skcipher_decrypt shared descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	desc = ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 	cnstr_shdsc_xts_skcipher_decap(desc, &ctx->cdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 				   desc_bytes(desc), ctx->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876)  * aead_edesc - s/w-extended aead descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877)  * @src_nents: number of segments in input s/w scatterlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878)  * @dst_nents: number of segments in output s/w scatterlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879)  * @mapped_src_nents: number of segments in input h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880)  * @mapped_dst_nents: number of segments in output h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881)  * @sec4_sg_bytes: length of dma mapped sec4_sg space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882)  * @bklog: stored to determine if the request needs backlog
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883)  * @sec4_sg_dma: bus physical mapped address of h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884)  * @sec4_sg: pointer to h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885)  * @hw_desc: the h/w job descriptor followed by any referenced link tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) struct aead_edesc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	int src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	int dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	int mapped_src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	int mapped_dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	int sec4_sg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	bool bklog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	dma_addr_t sec4_sg_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	struct sec4_sg_entry *sec4_sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	u32 hw_desc[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900)  * skcipher_edesc - s/w-extended skcipher descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901)  * @src_nents: number of segments in input s/w scatterlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902)  * @dst_nents: number of segments in output s/w scatterlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903)  * @mapped_src_nents: number of segments in input h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904)  * @mapped_dst_nents: number of segments in output h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905)  * @iv_dma: dma address of iv for checking continuity and link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906)  * @sec4_sg_bytes: length of dma mapped sec4_sg space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907)  * @bklog: stored to determine if the request needs backlog
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908)  * @sec4_sg_dma: bus physical mapped address of h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909)  * @sec4_sg: pointer to h/w link table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910)  * @hw_desc: the h/w job descriptor followed by any referenced link tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911)  *	     and IV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) struct skcipher_edesc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 	int src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	int dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	int mapped_src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	int mapped_dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	dma_addr_t iv_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 	int sec4_sg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	bool bklog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	dma_addr_t sec4_sg_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	struct sec4_sg_entry *sec4_sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	u32 hw_desc[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) static void caam_unmap(struct device *dev, struct scatterlist *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 		       struct scatterlist *dst, int src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 		       int dst_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 		       dma_addr_t iv_dma, int ivsize, dma_addr_t sec4_sg_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 		       int sec4_sg_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	if (dst != src) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 		if (src_nents)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 			dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 		if (dst_nents)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 			dma_unmap_sg(dev, dst, dst_nents, DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 		dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	if (iv_dma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 		dma_unmap_single(dev, iv_dma, ivsize, DMA_BIDIRECTIONAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	if (sec4_sg_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 		dma_unmap_single(dev, sec4_sg_dma, sec4_sg_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 				 DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) static void aead_unmap(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		       struct aead_edesc *edesc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 		       struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	caam_unmap(dev, req->src, req->dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 		   edesc->src_nents, edesc->dst_nents, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		   edesc->sec4_sg_dma, edesc->sec4_sg_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) static void skcipher_unmap(struct device *dev, struct skcipher_edesc *edesc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 			   struct skcipher_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 	struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	int ivsize = crypto_skcipher_ivsize(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	caam_unmap(dev, req->src, req->dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 		   edesc->src_nents, edesc->dst_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		   edesc->iv_dma, ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		   edesc->sec4_sg_dma, edesc->sec4_sg_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) static void aead_crypt_done(struct device *jrdev, u32 *desc, u32 err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 			    void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	struct aead_request *req = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 	struct caam_aead_req_ctx *rctx = aead_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 	struct caam_drv_private_jr *jrp = dev_get_drvdata(jrdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	struct aead_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	int ecode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	bool has_bklog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	dev_dbg(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	edesc = rctx->edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	has_bklog = edesc->bklog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		ecode = caam_jr_strstatus(jrdev, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	aead_unmap(jrdev, edesc, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	kfree(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	 * If no backlog flag, the completion of the request is done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 	 * by CAAM, not crypto engine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	if (!has_bklog)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		aead_request_complete(req, ecode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 		crypto_finalize_aead_request(jrp->engine, req, ecode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) static void skcipher_crypt_done(struct device *jrdev, u32 *desc, u32 err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 				void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	struct skcipher_request *req = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	struct skcipher_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	struct caam_drv_private_jr *jrp = dev_get_drvdata(jrdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	int ivsize = crypto_skcipher_ivsize(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	int ecode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	bool has_bklog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	dev_dbg(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	edesc = rctx->edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	has_bklog = edesc->bklog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 		ecode = caam_jr_strstatus(jrdev, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	skcipher_unmap(jrdev, edesc, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	 * The crypto API expects us to set the IV (req->iv) to the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	 * ciphertext block (CBC mode) or last counter (CTR mode).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	 * This is used e.g. by the CTS mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	if (ivsize && !ecode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 		memcpy(req->iv, (u8 *)edesc->sec4_sg + edesc->sec4_sg_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 		       ivsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 		print_hex_dump_debug("dstiv  @" __stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 				     DUMP_PREFIX_ADDRESS, 16, 4, req->iv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 				     ivsize, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	caam_dump_sg("dst    @" __stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		     DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 		     edesc->dst_nents > 1 ? 100 : req->cryptlen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	kfree(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 	 * If no backlog flag, the completion of the request is done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 	 * by CAAM, not crypto engine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	if (!has_bklog)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 		skcipher_request_complete(req, ecode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 		crypto_finalize_skcipher_request(jrp->engine, req, ecode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)  * Fill in aead job descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) static void init_aead_job(struct aead_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 			  struct aead_edesc *edesc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 			  bool all_contig, bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	int authsize = ctx->authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	u32 *desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	u32 out_options, in_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	dma_addr_t dst_dma, src_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	int len, sec4_sg_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	dma_addr_t ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	u32 *sh_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	sh_desc = encrypt ? ctx->sh_desc_enc : ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	ptr = encrypt ? ctx->sh_desc_enc_dma : ctx->sh_desc_dec_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	len = desc_len(sh_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	init_job_desc_shared(desc, ptr, len, HDR_SHARE_DEFER | HDR_REVERSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	if (all_contig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 		src_dma = edesc->mapped_src_nents ? sg_dma_address(req->src) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 						    0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 		in_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 		src_dma = edesc->sec4_sg_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 		sec4_sg_index += edesc->mapped_src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 		in_options = LDST_SGF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	append_seq_in_ptr(desc, src_dma, req->assoclen + req->cryptlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 			  in_options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 	dst_dma = src_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	out_options = in_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 	if (unlikely(req->src != req->dst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 		if (!edesc->mapped_dst_nents) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 			dst_dma = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 			out_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 		} else if (edesc->mapped_dst_nents == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 			dst_dma = sg_dma_address(req->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 			out_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 			dst_dma = edesc->sec4_sg_dma +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 				  sec4_sg_index *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 				  sizeof(struct sec4_sg_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 			out_options = LDST_SGF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	if (encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 		append_seq_out_ptr(desc, dst_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 				   req->assoclen + req->cryptlen + authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 				   out_options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 		append_seq_out_ptr(desc, dst_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 				   req->assoclen + req->cryptlen - authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 				   out_options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) static void init_gcm_job(struct aead_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 			 struct aead_edesc *edesc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 			 bool all_contig, bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 	u32 *desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	bool generic_gcm = (ivsize == GCM_AES_IV_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	unsigned int last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	init_aead_job(req, edesc, all_contig, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 	append_math_add_imm_u32(desc, REG3, ZERO, IMM, req->assoclen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 	/* BUG This should not be specific to generic GCM. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 	if (encrypt && generic_gcm && !(req->assoclen + req->cryptlen))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 		last = FIFOLD_TYPE_LAST1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	/* Read GCM IV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 			 FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | GCM_AES_IV_SIZE | last);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 	/* Append Salt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 	if (!generic_gcm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 		append_data(desc, ctx->key + ctx->cdata.keylen, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 	/* Append IV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 	append_data(desc, req->iv, ivsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	/* End of blank commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) static void init_chachapoly_job(struct aead_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 				struct aead_edesc *edesc, bool all_contig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 				bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	unsigned int assoclen = req->assoclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	u32 *desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	u32 ctx_iv_off = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	init_aead_job(req, edesc, all_contig, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	if (ivsize != CHACHAPOLY_IV_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 		/* IPsec specific: CONTEXT1[223:128] = {NONCE, IV} */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 		ctx_iv_off += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 		 * The associated data comes already with the IV but we need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 		 * to skip it when we authenticate or encrypt...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 		assoclen -= ivsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	append_math_add_imm_u32(desc, REG3, ZERO, IMM, assoclen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	 * For IPsec load the IV further in the same register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	 * For RFC7539 simply load the 12 bytes nonce in a single operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	append_load_as_imm(desc, req->iv, ivsize, LDST_CLASS_1_CCB |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 			   LDST_SRCDST_BYTE_CONTEXT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 			   ctx_iv_off << LDST_OFFSET_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) static void init_authenc_job(struct aead_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 			     struct aead_edesc *edesc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 			     bool all_contig, bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	struct caam_aead_alg *alg = container_of(crypto_aead_alg(aead),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 						 struct caam_aead_alg, aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 	unsigned int ivsize = crypto_aead_ivsize(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctx->jrdev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	const bool ctr_mode = ((ctx->cdata.algtype & OP_ALG_AAI_MASK) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 			       OP_ALG_AAI_CTR_MOD128);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	const bool is_rfc3686 = alg->caam.rfc3686;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	u32 *desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	u32 ivoffset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	 * AES-CTR needs to load IV in CONTEXT1 reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	 * at an offset of 128bits (16bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	 * CONTEXT1[255:128] = IV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	if (ctr_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 		ivoffset = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 	 * RFC3686 specific:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	 *	CONTEXT1[255:128] = {NONCE, IV, COUNTER}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	if (is_rfc3686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 		ivoffset = 16 + CTR_RFC3686_NONCE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	init_aead_job(req, edesc, all_contig, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 	 * {REG3, DPOVRD} = assoclen, depending on whether MATH command supports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	 * having DPOVRD as destination.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 	if (ctrlpriv->era < 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 		append_math_add_imm_u32(desc, REG3, ZERO, IMM, req->assoclen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 		append_math_add_imm_u32(desc, DPOVRD, ZERO, IMM, req->assoclen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	if (ivsize && ((is_rfc3686 && encrypt) || !alg->caam.geniv))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 		append_load_as_imm(desc, req->iv, ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 				   LDST_CLASS_1_CCB |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 				   LDST_SRCDST_BYTE_CONTEXT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 				   (ivoffset << LDST_OFFSET_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230)  * Fill in skcipher job descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) static void init_skcipher_job(struct skcipher_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 			      struct skcipher_edesc *edesc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 			      const bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 	struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	int ivsize = crypto_skcipher_ivsize(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	u32 *desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	u32 *sh_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	u32 in_options = 0, out_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	dma_addr_t src_dma, dst_dma, ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	int len, sec4_sg_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	print_hex_dump_debug("presciv@"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 			     DUMP_PREFIX_ADDRESS, 16, 4, req->iv, ivsize, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	dev_dbg(jrdev, "asked=%d, cryptlen%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	       (int)edesc->src_nents > 1 ? 100 : req->cryptlen, req->cryptlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	caam_dump_sg("src    @" __stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 		     DUMP_PREFIX_ADDRESS, 16, 4, req->src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 		     edesc->src_nents > 1 ? 100 : req->cryptlen, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	sh_desc = encrypt ? ctx->sh_desc_enc : ctx->sh_desc_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	ptr = encrypt ? ctx->sh_desc_enc_dma : ctx->sh_desc_dec_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	len = desc_len(sh_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	init_job_desc_shared(desc, ptr, len, HDR_SHARE_DEFER | HDR_REVERSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	if (ivsize || edesc->mapped_src_nents > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 		src_dma = edesc->sec4_sg_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 		sec4_sg_index = edesc->mapped_src_nents + !!ivsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 		in_options = LDST_SGF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 		src_dma = sg_dma_address(req->src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	append_seq_in_ptr(desc, src_dma, req->cryptlen + ivsize, in_options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 	if (likely(req->src == req->dst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 		dst_dma = src_dma + !!ivsize * sizeof(struct sec4_sg_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 		out_options = in_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 	} else if (!ivsize && edesc->mapped_dst_nents == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 		dst_dma = sg_dma_address(req->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 		dst_dma = edesc->sec4_sg_dma + sec4_sg_index *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 			  sizeof(struct sec4_sg_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 		out_options = LDST_SGF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	append_seq_out_ptr(desc, dst_dma, req->cryptlen + ivsize, out_options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286)  * allocate and map the aead extended descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 					   int desc_bytes, bool *all_contig_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 					   bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 	struct caam_aead_req_ctx *rctx = aead_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 		       GFP_KERNEL : GFP_ATOMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 	int src_len, dst_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	struct aead_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 	int sec4_sg_index, sec4_sg_len, sec4_sg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	unsigned int authsize = ctx->authsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	if (unlikely(req->dst != req->src)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 		src_len = req->assoclen + req->cryptlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 		dst_len = src_len + (encrypt ? authsize : (-authsize));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 		src_nents = sg_nents_for_len(req->src, src_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 		if (unlikely(src_nents < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 			dev_err(jrdev, "Insufficient bytes (%d) in src S/G\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 				src_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 			return ERR_PTR(src_nents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 		dst_nents = sg_nents_for_len(req->dst, dst_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 		if (unlikely(dst_nents < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 			dev_err(jrdev, "Insufficient bytes (%d) in dst S/G\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 				dst_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 			return ERR_PTR(dst_nents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 		src_len = req->assoclen + req->cryptlen +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 			  (encrypt ? authsize : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 		src_nents = sg_nents_for_len(req->src, src_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 		if (unlikely(src_nents < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 			dev_err(jrdev, "Insufficient bytes (%d) in src S/G\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 				src_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 			return ERR_PTR(src_nents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 	if (likely(req->src == req->dst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 		mapped_src_nents = dma_map_sg(jrdev, req->src, src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 					      DMA_BIDIRECTIONAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 		if (unlikely(!mapped_src_nents)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 			dev_err(jrdev, "unable to map source\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 			return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 		/* Cover also the case of null (zero length) input data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 		if (src_nents) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 			mapped_src_nents = dma_map_sg(jrdev, req->src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 						      src_nents, DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 			if (unlikely(!mapped_src_nents)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 				dev_err(jrdev, "unable to map source\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 				return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 			mapped_src_nents = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 		/* Cover also the case of null (zero length) output data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 		if (dst_nents) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 			mapped_dst_nents = dma_map_sg(jrdev, req->dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 						      dst_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 						      DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 			if (unlikely(!mapped_dst_nents)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 				dev_err(jrdev, "unable to map destination\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 				dma_unmap_sg(jrdev, req->src, src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 					     DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 				return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 			mapped_dst_nents = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 	 * HW reads 4 S/G entries at a time; make sure the reads don't go beyond
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 	 * the end of the table by allocating more S/G entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 	sec4_sg_len = mapped_src_nents > 1 ? mapped_src_nents : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	if (mapped_dst_nents > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 		sec4_sg_len += pad_sg_nents(mapped_dst_nents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 		sec4_sg_len = pad_sg_nents(sec4_sg_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 	sec4_sg_bytes = sec4_sg_len * sizeof(struct sec4_sg_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	/* allocate space for base edesc and hw desc commands, link tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	edesc = kzalloc(sizeof(*edesc) + desc_bytes + sec4_sg_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 			GFP_DMA | flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 	if (!edesc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 		caam_unmap(jrdev, req->src, req->dst, src_nents, dst_nents, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 			   0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 	edesc->src_nents = src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	edesc->dst_nents = dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	edesc->mapped_src_nents = mapped_src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	edesc->mapped_dst_nents = mapped_dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	edesc->sec4_sg = (void *)edesc + sizeof(struct aead_edesc) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 			 desc_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	rctx->edesc = edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	*all_contig_ptr = !(mapped_src_nents > 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 	sec4_sg_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 	if (mapped_src_nents > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 		sg_to_sec4_sg_last(req->src, src_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 				   edesc->sec4_sg + sec4_sg_index, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 		sec4_sg_index += mapped_src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	if (mapped_dst_nents > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 		sg_to_sec4_sg_last(req->dst, dst_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 				   edesc->sec4_sg + sec4_sg_index, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	if (!sec4_sg_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 		return edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 	edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 					    sec4_sg_bytes, DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 	if (dma_mapping_error(jrdev, edesc->sec4_sg_dma)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 		dev_err(jrdev, "unable to map S/G table\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 		aead_unmap(jrdev, edesc, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 		kfree(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 	edesc->sec4_sg_bytes = sec4_sg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 	return edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) static int aead_enqueue_req(struct device *jrdev, struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 	struct caam_drv_private_jr *jrpriv = dev_get_drvdata(jrdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 	struct caam_aead_req_ctx *rctx = aead_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 	struct aead_edesc *edesc = rctx->edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 	u32 *desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 	 * Only the backlog request are sent to crypto-engine since the others
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 	 * can be handled by CAAM, if free, especially since JR has up to 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 	 * entries (more than the 10 entries from crypto-engine).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 	if (req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 		ret = crypto_transfer_aead_request_to_engine(jrpriv->engine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 							     req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 		ret = caam_jr_enqueue(jrdev, desc, aead_crypt_done, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 	if ((ret != -EINPROGRESS) && (ret != -EBUSY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 		aead_unmap(jrdev, edesc, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 		kfree(rctx->edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) static inline int chachapoly_crypt(struct aead_request *req, bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 	struct aead_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	bool all_contig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 	edesc = aead_edesc_alloc(req, CHACHAPOLY_DESC_JOB_IO_LEN, &all_contig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 				 encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 	if (IS_ERR(edesc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 		return PTR_ERR(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 	desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	init_chachapoly_job(req, edesc, all_contig, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 	print_hex_dump_debug("chachapoly jobdesc@" __stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 			     DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 			     1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 	return aead_enqueue_req(jrdev, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) static int chachapoly_encrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 	return chachapoly_crypt(req, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) static int chachapoly_decrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 	return chachapoly_crypt(req, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) static inline int aead_crypt(struct aead_request *req, bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 	struct aead_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 	bool all_contig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 	/* allocate extended descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 	edesc = aead_edesc_alloc(req, AUTHENC_DESC_JOB_IO_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 				 &all_contig, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 	if (IS_ERR(edesc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 		return PTR_ERR(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 	/* Create and submit job descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 	init_authenc_job(req, edesc, all_contig, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 	print_hex_dump_debug("aead jobdesc@"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 			     DUMP_PREFIX_ADDRESS, 16, 4, edesc->hw_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 			     desc_bytes(edesc->hw_desc), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 	return aead_enqueue_req(jrdev, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) static int aead_encrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 	return aead_crypt(req, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) static int aead_decrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 	return aead_crypt(req, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) static int aead_do_one_req(struct crypto_engine *engine, void *areq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	struct aead_request *req = aead_request_cast(areq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 	struct caam_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 	struct caam_aead_req_ctx *rctx = aead_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	u32 *desc = rctx->edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	rctx->edesc->bklog = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 	ret = caam_jr_enqueue(ctx->jrdev, desc, aead_crypt_done, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 	if (ret != -EINPROGRESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 		aead_unmap(ctx->jrdev, rctx->edesc, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 		kfree(rctx->edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 		ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) static inline int gcm_crypt(struct aead_request *req, bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 	struct aead_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 	struct crypto_aead *aead = crypto_aead_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	struct caam_ctx *ctx = crypto_aead_ctx(aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 	bool all_contig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 	/* allocate extended descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 	edesc = aead_edesc_alloc(req, GCM_DESC_JOB_IO_LEN, &all_contig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 				 encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 	if (IS_ERR(edesc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 		return PTR_ERR(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 	/* Create and submit job descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 	init_gcm_job(req, edesc, all_contig, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 	print_hex_dump_debug("aead jobdesc@"__stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 			     DUMP_PREFIX_ADDRESS, 16, 4, edesc->hw_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) 			     desc_bytes(edesc->hw_desc), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 	return aead_enqueue_req(jrdev, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) static int gcm_encrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 	return gcm_crypt(req, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) static int gcm_decrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 	return gcm_crypt(req, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) static int ipsec_gcm_encrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 	return crypto_ipsec_check_assoclen(req->assoclen) ? : gcm_encrypt(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) static int ipsec_gcm_decrypt(struct aead_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 	return crypto_ipsec_check_assoclen(req->assoclen) ? : gcm_decrypt(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)  * allocate and map the skcipher extended descriptor for skcipher
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) static struct skcipher_edesc *skcipher_edesc_alloc(struct skcipher_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 						   int desc_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 	struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 	struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 	struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 	gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 		       GFP_KERNEL : GFP_ATOMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 	int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 	struct skcipher_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 	dma_addr_t iv_dma = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 	u8 *iv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 	int ivsize = crypto_skcipher_ivsize(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 	int dst_sg_idx, sec4_sg_ents, sec4_sg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 	src_nents = sg_nents_for_len(req->src, req->cryptlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 	if (unlikely(src_nents < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 		dev_err(jrdev, "Insufficient bytes (%d) in src S/G\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 			req->cryptlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 		return ERR_PTR(src_nents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 	if (req->dst != req->src) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) 		dst_nents = sg_nents_for_len(req->dst, req->cryptlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 		if (unlikely(dst_nents < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) 			dev_err(jrdev, "Insufficient bytes (%d) in dst S/G\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 				req->cryptlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 			return ERR_PTR(dst_nents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 	if (likely(req->src == req->dst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 		mapped_src_nents = dma_map_sg(jrdev, req->src, src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 					      DMA_BIDIRECTIONAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 		if (unlikely(!mapped_src_nents)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) 			dev_err(jrdev, "unable to map source\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) 			return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 		mapped_src_nents = dma_map_sg(jrdev, req->src, src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 					      DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 		if (unlikely(!mapped_src_nents)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 			dev_err(jrdev, "unable to map source\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 			return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) 		mapped_dst_nents = dma_map_sg(jrdev, req->dst, dst_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) 					      DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) 		if (unlikely(!mapped_dst_nents)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) 			dev_err(jrdev, "unable to map destination\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) 			dma_unmap_sg(jrdev, req->src, src_nents, DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) 			return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) 	if (!ivsize && mapped_src_nents == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) 		sec4_sg_ents = 0; // no need for an input hw s/g table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 		sec4_sg_ents = mapped_src_nents + !!ivsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) 	dst_sg_idx = sec4_sg_ents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) 	 * Input, output HW S/G tables: [IV, src][dst, IV]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) 	 * IV entries point to the same buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) 	 * If src == dst, S/G entries are reused (S/G tables overlap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 	 * HW reads 4 S/G entries at a time; make sure the reads don't go beyond
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) 	 * the end of the table by allocating more S/G entries. Logic:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) 	 * if (output S/G)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) 	 *      pad output S/G, if needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) 	 * else if (input S/G) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) 	 *      pad input S/G, if needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) 	if (ivsize || mapped_dst_nents > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) 		if (req->src == req->dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 			sec4_sg_ents = !!ivsize + pad_sg_nents(sec4_sg_ents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) 			sec4_sg_ents += pad_sg_nents(mapped_dst_nents +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) 						     !!ivsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 		sec4_sg_ents = pad_sg_nents(sec4_sg_ents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 	sec4_sg_bytes = sec4_sg_ents * sizeof(struct sec4_sg_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) 	 * allocate space for base edesc and hw desc commands, link tables, IV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 	edesc = kzalloc(sizeof(*edesc) + desc_bytes + sec4_sg_bytes + ivsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) 			GFP_DMA | flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) 	if (!edesc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) 		dev_err(jrdev, "could not allocate extended descriptor\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) 		caam_unmap(jrdev, req->src, req->dst, src_nents, dst_nents, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) 			   0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) 	edesc->src_nents = src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) 	edesc->dst_nents = dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) 	edesc->mapped_src_nents = mapped_src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) 	edesc->mapped_dst_nents = mapped_dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) 	edesc->sec4_sg_bytes = sec4_sg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) 	edesc->sec4_sg = (struct sec4_sg_entry *)((u8 *)edesc->hw_desc +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) 						  desc_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) 	rctx->edesc = edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) 	/* Make sure IV is located in a DMAable area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) 	if (ivsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) 		iv = (u8 *)edesc->sec4_sg + sec4_sg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) 		memcpy(iv, req->iv, ivsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) 		iv_dma = dma_map_single(jrdev, iv, ivsize, DMA_BIDIRECTIONAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) 		if (dma_mapping_error(jrdev, iv_dma)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) 			dev_err(jrdev, "unable to map IV\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) 			caam_unmap(jrdev, req->src, req->dst, src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) 				   dst_nents, 0, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) 			kfree(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) 			return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) 		dma_to_sec4_sg_one(edesc->sec4_sg, iv_dma, ivsize, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) 	if (dst_sg_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) 		sg_to_sec4_sg(req->src, req->cryptlen, edesc->sec4_sg +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) 			      !!ivsize, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) 	if (req->src != req->dst && (ivsize || mapped_dst_nents > 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) 		sg_to_sec4_sg(req->dst, req->cryptlen, edesc->sec4_sg +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) 			      dst_sg_idx, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) 	if (ivsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) 		dma_to_sec4_sg_one(edesc->sec4_sg + dst_sg_idx +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) 				   mapped_dst_nents, iv_dma, ivsize, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) 	if (ivsize || mapped_dst_nents > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) 		sg_to_sec4_set_last(edesc->sec4_sg + dst_sg_idx +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) 				    mapped_dst_nents - 1 + !!ivsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) 	if (sec4_sg_bytes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) 		edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) 						    sec4_sg_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) 						    DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) 		if (dma_mapping_error(jrdev, edesc->sec4_sg_dma)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) 			dev_err(jrdev, "unable to map S/G table\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) 			caam_unmap(jrdev, req->src, req->dst, src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) 				   dst_nents, iv_dma, ivsize, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) 			kfree(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) 			return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) 	edesc->iv_dma = iv_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) 	print_hex_dump_debug("skcipher sec4_sg@" __stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) 			     DUMP_PREFIX_ADDRESS, 16, 4, edesc->sec4_sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) 			     sec4_sg_bytes, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) 	return edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) static int skcipher_do_one_req(struct crypto_engine *engine, void *areq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) 	struct skcipher_request *req = skcipher_request_cast(areq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) 	struct caam_ctx *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) 	struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) 	u32 *desc = rctx->edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) 	rctx->edesc->bklog = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) 	ret = caam_jr_enqueue(ctx->jrdev, desc, skcipher_crypt_done, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) 	if (ret != -EINPROGRESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) 		skcipher_unmap(ctx->jrdev, rctx->edesc, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) 		kfree(rctx->edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) 		ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) static inline bool xts_skcipher_ivsize(struct skcipher_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) 	struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) 	unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) 	return !!get_unaligned((u64 *)(req->iv + (ivsize / 2)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) 	struct skcipher_edesc *edesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) 	struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) 	struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) 	struct device *jrdev = ctx->jrdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) 	struct caam_drv_private_jr *jrpriv = dev_get_drvdata(jrdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) 	struct caam_drv_private *ctrlpriv = dev_get_drvdata(jrdev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) 	u32 *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) 	 * XTS is expected to return an error even for input length = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) 	 * Note that the case input length < block size will be caught during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) 	 * HW offloading and return an error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) 	if (!req->cryptlen && !ctx->fallback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) 	if (ctx->fallback && ((ctrlpriv->era <= 8 && xts_skcipher_ivsize(req)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) 			      ctx->xts_key_fallback)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) 		struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) 		skcipher_request_set_tfm(&rctx->fallback_req, ctx->fallback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) 		skcipher_request_set_callback(&rctx->fallback_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) 					      req->base.flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) 					      req->base.complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) 					      req->base.data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) 		skcipher_request_set_crypt(&rctx->fallback_req, req->src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) 					   req->dst, req->cryptlen, req->iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) 		return encrypt ? crypto_skcipher_encrypt(&rctx->fallback_req) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) 				 crypto_skcipher_decrypt(&rctx->fallback_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) 	/* allocate extended descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) 	edesc = skcipher_edesc_alloc(req, DESC_JOB_IO_LEN * CAAM_CMD_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) 	if (IS_ERR(edesc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) 		return PTR_ERR(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) 	/* Create and submit job descriptor*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) 	init_skcipher_job(req, edesc, encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) 	print_hex_dump_debug("skcipher jobdesc@" __stringify(__LINE__)": ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) 			     DUMP_PREFIX_ADDRESS, 16, 4, edesc->hw_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) 			     desc_bytes(edesc->hw_desc), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) 	desc = edesc->hw_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) 	 * Only the backlog request are sent to crypto-engine since the others
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) 	 * can be handled by CAAM, if free, especially since JR has up to 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) 	 * entries (more than the 10 entries from crypto-engine).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) 	if (req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) 		ret = crypto_transfer_skcipher_request_to_engine(jrpriv->engine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) 								 req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) 		ret = caam_jr_enqueue(jrdev, desc, skcipher_crypt_done, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) 	if ((ret != -EINPROGRESS) && (ret != -EBUSY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) 		skcipher_unmap(jrdev, edesc, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) 		kfree(edesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) static int skcipher_encrypt(struct skcipher_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) 	return skcipher_crypt(req, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) static int skcipher_decrypt(struct skcipher_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) 	return skcipher_crypt(req, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) static struct caam_skcipher_alg driver_algs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) 				.cra_name = "cbc(aes)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) 				.cra_driver_name = "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) 			.setkey = aes_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) 			.min_keysize = AES_MIN_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) 			.max_keysize = AES_MAX_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) 		.caam.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) 				.cra_name = "cbc(des3_ede)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) 				.cra_driver_name = "cbc-3des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) 			.setkey = des3_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) 			.min_keysize = DES3_EDE_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) 			.max_keysize = DES3_EDE_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) 		.caam.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) 				.cra_name = "cbc(des)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) 				.cra_driver_name = "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) 			.setkey = des_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) 			.min_keysize = DES_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) 			.max_keysize = DES_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) 		.caam.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) 				.cra_name = "ctr(aes)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) 				.cra_driver_name = "ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) 			.setkey = ctr_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) 			.min_keysize = AES_MIN_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) 			.max_keysize = AES_MAX_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) 			.chunksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) 		.caam.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) 					OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) 				.cra_name = "rfc3686(ctr(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) 				.cra_driver_name = "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) 			.setkey = rfc3686_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) 			.min_keysize = AES_MIN_KEY_SIZE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) 				       CTR_RFC3686_NONCE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) 			.max_keysize = AES_MAX_KEY_SIZE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) 				       CTR_RFC3686_NONCE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) 			.chunksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) 				.cra_name = "xts(aes)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) 				.cra_driver_name = "xts-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) 				.cra_flags = CRYPTO_ALG_NEED_FALLBACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) 			.setkey = xts_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) 			.min_keysize = 2 * AES_MIN_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) 			.max_keysize = 2 * AES_MAX_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) 		.caam.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_XTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) 				.cra_name = "ecb(des)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) 				.cra_driver_name = "ecb-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) 			.setkey = des_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) 			.min_keysize = DES_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) 			.max_keysize = DES_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) 		.caam.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_ECB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) 				.cra_name = "ecb(aes)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) 				.cra_driver_name = "ecb-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) 			.setkey = aes_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) 			.min_keysize = AES_MIN_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) 			.max_keysize = AES_MAX_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) 		.caam.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_ECB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) 		.skcipher = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) 				.cra_name = "ecb(des3_ede)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) 				.cra_driver_name = "ecb-des3-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) 			.setkey = des3_skcipher_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) 			.encrypt = skcipher_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) 			.decrypt = skcipher_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) 			.min_keysize = DES3_EDE_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) 			.max_keysize = DES3_EDE_KEY_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) 		.caam.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_ECB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) static struct caam_aead_alg driver_aeads[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) 				.cra_name = "rfc4106(gcm(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) 				.cra_driver_name = "rfc4106-gcm-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) 			.setkey = rfc4106_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) 			.setauthsize = rfc4106_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) 			.encrypt = ipsec_gcm_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) 			.decrypt = ipsec_gcm_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) 			.ivsize = GCM_RFC4106_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) 			.maxauthsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) 			.nodkp = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) 				.cra_name = "rfc4543(gcm(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) 				.cra_driver_name = "rfc4543-gcm-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) 			.setkey = rfc4543_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) 			.setauthsize = rfc4543_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) 			.encrypt = ipsec_gcm_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) 			.decrypt = ipsec_gcm_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) 			.ivsize = GCM_RFC4543_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) 			.maxauthsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) 			.nodkp = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) 	/* Galois Counter Mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) 				.cra_name = "gcm(aes)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) 				.cra_driver_name = "gcm-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) 			.setkey = gcm_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) 			.setauthsize = gcm_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) 			.encrypt = gcm_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) 			.decrypt = gcm_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) 			.ivsize = GCM_AES_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) 			.maxauthsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) 			.nodkp = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) 	/* single-pass ipsec_esp descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) 				.cra_name = "authenc(hmac(md5),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) 					    "ecb(cipher_null))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) 				.cra_driver_name = "authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) 						   "ecb-cipher_null-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) 				.cra_blocksize = NULL_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) 			.ivsize = NULL_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) 				.cra_name = "authenc(hmac(sha1),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) 					    "ecb(cipher_null))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) 				.cra_driver_name = "authenc-hmac-sha1-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) 						   "ecb-cipher_null-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) 				.cra_blocksize = NULL_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) 			.ivsize = NULL_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) 				.cra_name = "authenc(hmac(sha224),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) 					    "ecb(cipher_null))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) 				.cra_driver_name = "authenc-hmac-sha224-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) 						   "ecb-cipher_null-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) 				.cra_blocksize = NULL_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) 			.ivsize = NULL_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) 				.cra_name = "authenc(hmac(sha256),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) 					    "ecb(cipher_null))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) 				.cra_driver_name = "authenc-hmac-sha256-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) 						   "ecb-cipher_null-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) 				.cra_blocksize = NULL_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) 			.ivsize = NULL_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) 				.cra_name = "authenc(hmac(sha384),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) 					    "ecb(cipher_null))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) 				.cra_driver_name = "authenc-hmac-sha384-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) 						   "ecb-cipher_null-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) 				.cra_blocksize = NULL_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) 			.ivsize = NULL_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) 				.cra_name = "authenc(hmac(sha512),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) 					    "ecb(cipher_null))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) 				.cra_driver_name = "authenc-hmac-sha512-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) 						   "ecb-cipher_null-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) 				.cra_blocksize = NULL_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) 			.ivsize = NULL_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) 				.cra_name = "authenc(hmac(md5),cbc(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) 				.cra_driver_name = "authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) 						   "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) 				.cra_name = "echainiv(authenc(hmac(md5),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) 					    "cbc(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) 				.cra_driver_name = "echainiv-authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) 						   "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) 				.cra_name = "authenc(hmac(sha1),cbc(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) 				.cra_driver_name = "authenc-hmac-sha1-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) 						   "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) 				.cra_name = "echainiv(authenc(hmac(sha1),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) 					    "cbc(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) 						   "hmac-sha1-cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) 				.cra_name = "authenc(hmac(sha224),cbc(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) 				.cra_driver_name = "authenc-hmac-sha224-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) 						   "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) 				.cra_name = "echainiv(authenc(hmac(sha224),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) 					    "cbc(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) 						   "hmac-sha224-cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) 				.cra_name = "authenc(hmac(sha256),cbc(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) 				.cra_driver_name = "authenc-hmac-sha256-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) 						   "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) 				.cra_name = "echainiv(authenc(hmac(sha256),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) 					    "cbc(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) 						   "hmac-sha256-cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) 				.cra_name = "authenc(hmac(sha384),cbc(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) 				.cra_driver_name = "authenc-hmac-sha384-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) 						   "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) 				.cra_name = "echainiv(authenc(hmac(sha384),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) 					    "cbc(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) 						   "hmac-sha384-cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) 				.cra_name = "authenc(hmac(sha512),cbc(aes))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) 				.cra_driver_name = "authenc-hmac-sha512-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) 						   "cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) 				.cra_name = "echainiv(authenc(hmac(sha512),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) 					    "cbc(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) 						   "hmac-sha512-cbc-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) 				.cra_blocksize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) 			.ivsize = AES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) 			.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) 				.cra_name = "authenc(hmac(md5),cbc(des3_ede))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) 				.cra_driver_name = "authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) 				.cra_name = "echainiv(authenc(hmac(md5),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) 					    "cbc(des3_ede)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) 				.cra_driver_name = "echainiv-authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) 				.cra_name = "authenc(hmac(sha1),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) 					    "cbc(des3_ede))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) 				.cra_driver_name = "authenc-hmac-sha1-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) 				.cra_name = "echainiv(authenc(hmac(sha1),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) 					    "cbc(des3_ede)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) 						   "hmac-sha1-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) 				.cra_name = "authenc(hmac(sha224),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) 					    "cbc(des3_ede))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) 				.cra_driver_name = "authenc-hmac-sha224-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) 				.cra_name = "echainiv(authenc(hmac(sha224),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) 					    "cbc(des3_ede)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) 						   "hmac-sha224-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) 				.cra_name = "authenc(hmac(sha256),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) 					    "cbc(des3_ede))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) 				.cra_driver_name = "authenc-hmac-sha256-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) 				.cra_name = "echainiv(authenc(hmac(sha256),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) 					    "cbc(des3_ede)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) 						   "hmac-sha256-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) 				.cra_name = "authenc(hmac(sha384),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) 					    "cbc(des3_ede))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) 				.cra_driver_name = "authenc-hmac-sha384-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) 				.cra_name = "echainiv(authenc(hmac(sha384),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) 					    "cbc(des3_ede)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) 						   "hmac-sha384-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) 				.cra_name = "authenc(hmac(sha512),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) 					    "cbc(des3_ede))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) 				.cra_driver_name = "authenc-hmac-sha512-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) 				.cra_name = "echainiv(authenc(hmac(sha512),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) 					    "cbc(des3_ede)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) 						   "hmac-sha512-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) 						   "cbc-des3_ede-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) 				.cra_blocksize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) 			.setkey = des3_aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) 			.ivsize = DES3_EDE_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) 			.class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) 				.cra_name = "authenc(hmac(md5),cbc(des))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) 				.cra_driver_name = "authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) 						   "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) 				.cra_name = "echainiv(authenc(hmac(md5),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) 					    "cbc(des)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) 				.cra_driver_name = "echainiv-authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) 						   "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) 				.cra_name = "authenc(hmac(sha1),cbc(des))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) 				.cra_driver_name = "authenc-hmac-sha1-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) 						   "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) 				.cra_name = "echainiv(authenc(hmac(sha1),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) 					    "cbc(des)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) 						   "hmac-sha1-cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) 				.cra_name = "authenc(hmac(sha224),cbc(des))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) 				.cra_driver_name = "authenc-hmac-sha224-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) 						   "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) 				.cra_name = "echainiv(authenc(hmac(sha224),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) 					    "cbc(des)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) 						   "hmac-sha224-cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) 				.cra_name = "authenc(hmac(sha256),cbc(des))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) 				.cra_driver_name = "authenc-hmac-sha256-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) 						   "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) 				.cra_name = "echainiv(authenc(hmac(sha256),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) 					    "cbc(des)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) 						   "hmac-sha256-cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) 				.cra_name = "authenc(hmac(sha384),cbc(des))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) 				.cra_driver_name = "authenc-hmac-sha384-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) 						   "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) 				.cra_name = "echainiv(authenc(hmac(sha384),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) 					    "cbc(des)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) 						   "hmac-sha384-cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) 				.cra_name = "authenc(hmac(sha512),cbc(des))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) 				.cra_driver_name = "authenc-hmac-sha512-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) 						   "cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) 				.cra_name = "echainiv(authenc(hmac(sha512),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) 					    "cbc(des)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) 				.cra_driver_name = "echainiv-authenc-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) 						   "hmac-sha512-cbc-des-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) 				.cra_blocksize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) 			.ivsize = DES_BLOCK_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) 			.class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) 				.cra_name = "authenc(hmac(md5),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) 					    "rfc3686(ctr(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) 				.cra_driver_name = "authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) 				.cra_name = "seqiv(authenc("
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) 					    "hmac(md5),rfc3686(ctr(aes))))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) 				.cra_driver_name = "seqiv-authenc-hmac-md5-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) 			.maxauthsize = MD5_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) 			.class2_alg_type = OP_ALG_ALGSEL_MD5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) 				.cra_name = "authenc(hmac(sha1),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) 					    "rfc3686(ctr(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) 				.cra_driver_name = "authenc-hmac-sha1-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) 				.cra_name = "seqiv(authenc("
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) 					    "hmac(sha1),rfc3686(ctr(aes))))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) 				.cra_driver_name = "seqiv-authenc-hmac-sha1-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) 			.maxauthsize = SHA1_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) 			.class2_alg_type = OP_ALG_ALGSEL_SHA1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) 				.cra_name = "authenc(hmac(sha224),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) 					    "rfc3686(ctr(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) 				.cra_driver_name = "authenc-hmac-sha224-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) 				.cra_name = "seqiv(authenc("
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) 					    "hmac(sha224),rfc3686(ctr(aes))))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) 				.cra_driver_name = "seqiv-authenc-hmac-sha224-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) 			.maxauthsize = SHA224_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) 			.class2_alg_type = OP_ALG_ALGSEL_SHA224 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) 				.cra_name = "authenc(hmac(sha256),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) 					    "rfc3686(ctr(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) 				.cra_driver_name = "authenc-hmac-sha256-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) 				.cra_name = "seqiv(authenc(hmac(sha256),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) 					    "rfc3686(ctr(aes))))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) 				.cra_driver_name = "seqiv-authenc-hmac-sha256-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) 			.maxauthsize = SHA256_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) 			.class2_alg_type = OP_ALG_ALGSEL_SHA256 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) 				.cra_name = "authenc(hmac(sha384),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) 					    "rfc3686(ctr(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) 				.cra_driver_name = "authenc-hmac-sha384-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) 				.cra_name = "seqiv(authenc(hmac(sha384),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) 					    "rfc3686(ctr(aes))))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) 				.cra_driver_name = "seqiv-authenc-hmac-sha384-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) 			.maxauthsize = SHA384_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) 			.class2_alg_type = OP_ALG_ALGSEL_SHA384 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) 				.cra_name = "authenc(hmac(sha512),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) 					    "rfc3686(ctr(aes)))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) 				.cra_driver_name = "authenc-hmac-sha512-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) 				.cra_name = "seqiv(authenc(hmac(sha512),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) 					    "rfc3686(ctr(aes))))",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) 				.cra_driver_name = "seqiv-authenc-hmac-sha512-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) 						   "rfc3686-ctr-aes-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) 			.setkey = aead_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) 			.setauthsize = aead_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) 			.encrypt = aead_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) 			.decrypt = aead_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) 			.ivsize = CTR_RFC3686_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) 			.maxauthsize = SHA512_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) 			.class1_alg_type = OP_ALG_ALGSEL_AES |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) 					   OP_ALG_AAI_CTR_MOD128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) 			.class2_alg_type = OP_ALG_ALGSEL_SHA512 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) 					   OP_ALG_AAI_HMAC_PRECOMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) 			.rfc3686 = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) 			.geniv = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) 				.cra_name = "rfc7539(chacha20,poly1305)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) 				.cra_driver_name = "rfc7539-chacha20-poly1305-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) 						   "caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) 			.setkey = chachapoly_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) 			.setauthsize = chachapoly_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) 			.encrypt = chachapoly_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) 			.decrypt = chachapoly_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) 			.ivsize = CHACHAPOLY_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) 			.maxauthsize = POLY1305_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) 			.class1_alg_type = OP_ALG_ALGSEL_CHACHA20 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) 					   OP_ALG_AAI_AEAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) 			.class2_alg_type = OP_ALG_ALGSEL_POLY1305 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) 					   OP_ALG_AAI_AEAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) 			.nodkp = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) 		.aead = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) 			.base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) 				.cra_name = "rfc7539esp(chacha20,poly1305)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) 				.cra_driver_name = "rfc7539esp-chacha20-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) 						   "poly1305-caam",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) 				.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) 			.setkey = chachapoly_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) 			.setauthsize = chachapoly_setauthsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) 			.encrypt = chachapoly_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) 			.decrypt = chachapoly_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) 			.ivsize = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) 			.maxauthsize = POLY1305_DIGEST_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) 		.caam = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) 			.class1_alg_type = OP_ALG_ALGSEL_CHACHA20 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) 					   OP_ALG_AAI_AEAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) 			.class2_alg_type = OP_ALG_ALGSEL_POLY1305 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) 					   OP_ALG_AAI_AEAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) 			.nodkp = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) static int caam_init_common(struct caam_ctx *ctx, struct caam_alg_entry *caam,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) 			    bool uses_dkp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) 	dma_addr_t dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) 	struct caam_drv_private *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) 	const size_t sh_desc_enc_offset = offsetof(struct caam_ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) 						   sh_desc_enc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) 	ctx->jrdev = caam_jr_alloc();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) 	if (IS_ERR(ctx->jrdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) 		pr_err("Job Ring Device allocation for transform failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) 		return PTR_ERR(ctx->jrdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) 	priv = dev_get_drvdata(ctx->jrdev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) 	if (priv->era >= 6 && uses_dkp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) 		ctx->dir = DMA_BIDIRECTIONAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) 		ctx->dir = DMA_TO_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) 	dma_addr = dma_map_single_attrs(ctx->jrdev, ctx->sh_desc_enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) 					offsetof(struct caam_ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) 						 sh_desc_enc_dma) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) 					sh_desc_enc_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) 					ctx->dir, DMA_ATTR_SKIP_CPU_SYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) 	if (dma_mapping_error(ctx->jrdev, dma_addr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) 		dev_err(ctx->jrdev, "unable to map key, shared descriptors\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) 		caam_jr_free(ctx->jrdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) 	ctx->sh_desc_enc_dma = dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) 	ctx->sh_desc_dec_dma = dma_addr + offsetof(struct caam_ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) 						   sh_desc_dec) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) 					sh_desc_enc_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) 	ctx->key_dma = dma_addr + offsetof(struct caam_ctx, key) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) 					sh_desc_enc_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) 	/* copy descriptor header template value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) 	ctx->cdata.algtype = OP_TYPE_CLASS1_ALG | caam->class1_alg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) 	ctx->adata.algtype = OP_TYPE_CLASS2_ALG | caam->class2_alg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) static int caam_cra_init(struct crypto_skcipher *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) 	struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) 	struct caam_skcipher_alg *caam_alg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) 		container_of(alg, typeof(*caam_alg), skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) 	struct caam_ctx *ctx = crypto_skcipher_ctx(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) 	u32 alg_aai = caam_alg->caam.class1_alg_type & OP_ALG_AAI_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) 	ctx->enginectx.op.do_one_request = skcipher_do_one_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) 	if (alg_aai == OP_ALG_AAI_XTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) 		const char *tfm_name = crypto_tfm_alg_name(&tfm->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) 		struct crypto_skcipher *fallback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) 		fallback = crypto_alloc_skcipher(tfm_name, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) 						 CRYPTO_ALG_NEED_FALLBACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) 		if (IS_ERR(fallback)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) 			pr_err("Failed to allocate %s fallback: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) 			       tfm_name, PTR_ERR(fallback));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) 			return PTR_ERR(fallback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) 		ctx->fallback = fallback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) 		crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) 					    crypto_skcipher_reqsize(fallback));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) 		crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) 	ret = caam_init_common(ctx, &caam_alg->caam, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) 	if (ret && ctx->fallback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) 		crypto_free_skcipher(ctx->fallback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) static int caam_aead_init(struct crypto_aead *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) 	struct aead_alg *alg = crypto_aead_alg(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) 	struct caam_aead_alg *caam_alg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) 		 container_of(alg, struct caam_aead_alg, aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) 	struct caam_ctx *ctx = crypto_aead_ctx(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) 	crypto_aead_set_reqsize(tfm, sizeof(struct caam_aead_req_ctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) 	ctx->enginectx.op.do_one_request = aead_do_one_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) 	return caam_init_common(ctx, &caam_alg->caam, !caam_alg->caam.nodkp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) static void caam_exit_common(struct caam_ctx *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) 	dma_unmap_single_attrs(ctx->jrdev, ctx->sh_desc_enc_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) 			       offsetof(struct caam_ctx, sh_desc_enc_dma) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) 			       offsetof(struct caam_ctx, sh_desc_enc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) 			       ctx->dir, DMA_ATTR_SKIP_CPU_SYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) 	caam_jr_free(ctx->jrdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) static void caam_cra_exit(struct crypto_skcipher *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) 	struct caam_ctx *ctx = crypto_skcipher_ctx(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) 	if (ctx->fallback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) 		crypto_free_skcipher(ctx->fallback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) 	caam_exit_common(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) static void caam_aead_exit(struct crypto_aead *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) 	caam_exit_common(crypto_aead_ctx(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) void caam_algapi_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) 	for (i = 0; i < ARRAY_SIZE(driver_aeads); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) 		struct caam_aead_alg *t_alg = driver_aeads + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) 		if (t_alg->registered)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) 			crypto_unregister_aead(&t_alg->aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) 	for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) 		struct caam_skcipher_alg *t_alg = driver_algs + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) 		if (t_alg->registered)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) 			crypto_unregister_skcipher(&t_alg->skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) static void caam_skcipher_alg_init(struct caam_skcipher_alg *t_alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) 	struct skcipher_alg *alg = &t_alg->skcipher;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) 	alg->base.cra_module = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) 	alg->base.cra_priority = CAAM_CRA_PRIORITY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) 	alg->base.cra_ctxsize = sizeof(struct caam_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) 	alg->base.cra_flags |= (CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) 			      CRYPTO_ALG_KERN_DRIVER_ONLY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) 	alg->init = caam_cra_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) 	alg->exit = caam_cra_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) static void caam_aead_alg_init(struct caam_aead_alg *t_alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) 	struct aead_alg *alg = &t_alg->aead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) 	alg->base.cra_module = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) 	alg->base.cra_priority = CAAM_CRA_PRIORITY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) 	alg->base.cra_ctxsize = sizeof(struct caam_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) 	alg->base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) 			      CRYPTO_ALG_KERN_DRIVER_ONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) 	alg->init = caam_aead_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) 	alg->exit = caam_aead_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) int caam_algapi_init(struct device *ctrldev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) 	struct caam_drv_private *priv = dev_get_drvdata(ctrldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) 	int i = 0, err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) 	u32 aes_vid, aes_inst, des_inst, md_vid, md_inst, ccha_inst, ptha_inst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) 	unsigned int md_limit = SHA512_DIGEST_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) 	bool registered = false, gcm_support;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) 	 * Register crypto algorithms the device supports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) 	 * First, detect presence and attributes of DES, AES, and MD blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) 	if (priv->era < 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) 		u32 cha_vid, cha_inst, aes_rn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) 		cha_vid = rd_reg32(&priv->ctrl->perfmon.cha_id_ls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) 		aes_vid = cha_vid & CHA_ID_LS_AES_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) 		md_vid = (cha_vid & CHA_ID_LS_MD_MASK) >> CHA_ID_LS_MD_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) 		cha_inst = rd_reg32(&priv->ctrl->perfmon.cha_num_ls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) 		des_inst = (cha_inst & CHA_ID_LS_DES_MASK) >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) 			   CHA_ID_LS_DES_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) 		aes_inst = cha_inst & CHA_ID_LS_AES_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) 		md_inst = (cha_inst & CHA_ID_LS_MD_MASK) >> CHA_ID_LS_MD_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) 		ccha_inst = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) 		ptha_inst = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) 		aes_rn = rd_reg32(&priv->ctrl->perfmon.cha_rev_ls) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) 			 CHA_ID_LS_AES_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) 		gcm_support = !(aes_vid == CHA_VER_VID_AES_LP && aes_rn < 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) 		u32 aesa, mdha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) 		aesa = rd_reg32(&priv->ctrl->vreg.aesa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) 		mdha = rd_reg32(&priv->ctrl->vreg.mdha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) 		aes_vid = (aesa & CHA_VER_VID_MASK) >> CHA_VER_VID_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) 		md_vid = (mdha & CHA_VER_VID_MASK) >> CHA_VER_VID_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) 		des_inst = rd_reg32(&priv->ctrl->vreg.desa) & CHA_VER_NUM_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) 		aes_inst = aesa & CHA_VER_NUM_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) 		md_inst = mdha & CHA_VER_NUM_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) 		ccha_inst = rd_reg32(&priv->ctrl->vreg.ccha) & CHA_VER_NUM_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) 		ptha_inst = rd_reg32(&priv->ctrl->vreg.ptha) & CHA_VER_NUM_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) 		gcm_support = aesa & CHA_VER_MISC_AES_GCM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) 	/* If MD is present, limit digest size based on LP256 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) 	if (md_inst && md_vid  == CHA_VER_VID_MD_LP256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) 		md_limit = SHA256_DIGEST_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) 	for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) 		struct caam_skcipher_alg *t_alg = driver_algs + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) 		u32 alg_sel = t_alg->caam.class1_alg_type & OP_ALG_ALGSEL_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) 		/* Skip DES algorithms if not supported by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) 		if (!des_inst &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) 		    ((alg_sel == OP_ALG_ALGSEL_3DES) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) 		     (alg_sel == OP_ALG_ALGSEL_DES)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) 		/* Skip AES algorithms if not supported by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) 		if (!aes_inst && (alg_sel == OP_ALG_ALGSEL_AES))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) 		 * Check support for AES modes not available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) 		 * on LP devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) 		if (aes_vid == CHA_VER_VID_AES_LP &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) 		    (t_alg->caam.class1_alg_type & OP_ALG_AAI_MASK) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) 		    OP_ALG_AAI_XTS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) 		caam_skcipher_alg_init(t_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) 		err = crypto_register_skcipher(&t_alg->skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) 		if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) 			pr_warn("%s alg registration failed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) 				t_alg->skcipher.base.cra_driver_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) 		t_alg->registered = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) 		registered = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) 	for (i = 0; i < ARRAY_SIZE(driver_aeads); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) 		struct caam_aead_alg *t_alg = driver_aeads + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) 		u32 c1_alg_sel = t_alg->caam.class1_alg_type &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) 				 OP_ALG_ALGSEL_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) 		u32 c2_alg_sel = t_alg->caam.class2_alg_type &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) 				 OP_ALG_ALGSEL_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) 		u32 alg_aai = t_alg->caam.class1_alg_type & OP_ALG_AAI_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) 		/* Skip DES algorithms if not supported by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) 		if (!des_inst &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) 		    ((c1_alg_sel == OP_ALG_ALGSEL_3DES) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) 		     (c1_alg_sel == OP_ALG_ALGSEL_DES)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) 		/* Skip AES algorithms if not supported by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) 		if (!aes_inst && (c1_alg_sel == OP_ALG_ALGSEL_AES))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) 		/* Skip CHACHA20 algorithms if not supported by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) 		if (c1_alg_sel == OP_ALG_ALGSEL_CHACHA20 && !ccha_inst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) 		/* Skip POLY1305 algorithms if not supported by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) 		if (c2_alg_sel == OP_ALG_ALGSEL_POLY1305 && !ptha_inst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) 		/* Skip GCM algorithms if not supported by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) 		if (c1_alg_sel == OP_ALG_ALGSEL_AES &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) 		    alg_aai == OP_ALG_AAI_GCM && !gcm_support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) 		 * Skip algorithms requiring message digests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) 		 * if MD or MD size is not supported by device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) 		if (is_mdha(c2_alg_sel) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) 		    (!md_inst || t_alg->aead.maxauthsize > md_limit))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) 		caam_aead_alg_init(t_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) 		err = crypto_register_aead(&t_alg->aead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) 		if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) 			pr_warn("%s alg registration failed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) 				t_alg->aead.base.cra_driver_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) 		t_alg->registered = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) 		registered = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) 	if (registered)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) 		pr_info("caam algorithms registered in /proc/crypto\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) }