Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Shared descriptors for aead, skcipher algorithms
4 *
5 * Copyright 2016, 2025 NXP
6 */
7
8#ifndef _CAAMALG_DESC_H_
9#define _CAAMALG_DESC_H_
10
11/* length of descriptors text */
12#define DESC_AEAD_BASE (4 * CAAM_CMD_SZ)
13#define DESC_AEAD_ENC_LEN (DESC_AEAD_BASE + 11 * CAAM_CMD_SZ)
14#define DESC_AEAD_DEC_LEN (DESC_AEAD_BASE + 15 * CAAM_CMD_SZ)
15#define DESC_AEAD_GIVENC_LEN (DESC_AEAD_ENC_LEN + 8 * CAAM_CMD_SZ)
16#define DESC_QI_AEAD_ENC_LEN (DESC_AEAD_ENC_LEN + 3 * CAAM_CMD_SZ)
17#define DESC_QI_AEAD_DEC_LEN (DESC_AEAD_DEC_LEN + 3 * CAAM_CMD_SZ)
18#define DESC_QI_AEAD_GIVENC_LEN (DESC_AEAD_GIVENC_LEN + 3 * CAAM_CMD_SZ)
19
20/* Note: Nonce is counted in cdata.keylen */
21#define DESC_AEAD_CTR_RFC3686_LEN (4 * CAAM_CMD_SZ)
22
23#define DESC_AEAD_NULL_BASE (3 * CAAM_CMD_SZ)
24#define DESC_AEAD_NULL_ENC_LEN (DESC_AEAD_NULL_BASE + 11 * CAAM_CMD_SZ)
25#define DESC_AEAD_NULL_DEC_LEN (DESC_AEAD_NULL_BASE + 13 * CAAM_CMD_SZ)
26
27#define DESC_GCM_BASE (3 * CAAM_CMD_SZ)
28#define DESC_GCM_ENC_LEN (DESC_GCM_BASE + 16 * CAAM_CMD_SZ)
29#define DESC_GCM_DEC_LEN (DESC_GCM_BASE + 12 * CAAM_CMD_SZ)
30#define DESC_QI_GCM_ENC_LEN (DESC_GCM_ENC_LEN + 6 * CAAM_CMD_SZ)
31#define DESC_QI_GCM_DEC_LEN (DESC_GCM_DEC_LEN + 3 * CAAM_CMD_SZ)
32
33#define DESC_RFC4106_BASE (3 * CAAM_CMD_SZ)
34#define DESC_RFC4106_ENC_LEN (DESC_RFC4106_BASE + 16 * CAAM_CMD_SZ)
35#define DESC_RFC4106_DEC_LEN (DESC_RFC4106_BASE + 13 * CAAM_CMD_SZ)
36#define DESC_QI_RFC4106_ENC_LEN (DESC_RFC4106_ENC_LEN + 5 * CAAM_CMD_SZ)
37#define DESC_QI_RFC4106_DEC_LEN (DESC_RFC4106_DEC_LEN + 5 * CAAM_CMD_SZ)
38
39#define DESC_RFC4543_BASE (3 * CAAM_CMD_SZ)
40#define DESC_RFC4543_ENC_LEN (DESC_RFC4543_BASE + 11 * CAAM_CMD_SZ)
41#define DESC_RFC4543_DEC_LEN (DESC_RFC4543_BASE + 12 * CAAM_CMD_SZ)
42#define DESC_QI_RFC4543_ENC_LEN (DESC_RFC4543_ENC_LEN + 4 * CAAM_CMD_SZ)
43#define DESC_QI_RFC4543_DEC_LEN (DESC_RFC4543_DEC_LEN + 4 * CAAM_CMD_SZ)
44
45#define DESC_SKCIPHER_BASE (3 * CAAM_CMD_SZ)
46#define DESC_SKCIPHER_ENC_LEN (DESC_SKCIPHER_BASE + \
47 21 * CAAM_CMD_SZ)
48#define DESC_SKCIPHER_DEC_LEN (DESC_SKCIPHER_BASE + \
49 16 * CAAM_CMD_SZ)
50
51/* Key modifier for CAAM Protected blobs */
52#define KEYMOD "SECURE_KEY"
53
54void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata,
55 unsigned int icvsize, int era);
56
57void cnstr_shdsc_aead_null_decap(u32 * const desc, struct alginfo *adata,
58 unsigned int icvsize, int era);
59
60void cnstr_shdsc_aead_encap(u32 * const desc, struct alginfo *cdata,
61 struct alginfo *adata, unsigned int ivsize,
62 unsigned int icvsize, const bool is_rfc3686,
63 u32 *nonce, const u32 ctx1_iv_off,
64 const bool is_qi, int era);
65
66void cnstr_shdsc_aead_decap(u32 * const desc, struct alginfo *cdata,
67 struct alginfo *adata, unsigned int ivsize,
68 unsigned int icvsize, const bool geniv,
69 const bool is_rfc3686, u32 *nonce,
70 const u32 ctx1_iv_off, const bool is_qi, int era);
71
72void cnstr_shdsc_aead_givencap(u32 * const desc, struct alginfo *cdata,
73 struct alginfo *adata, unsigned int ivsize,
74 unsigned int icvsize, const bool is_rfc3686,
75 u32 *nonce, const u32 ctx1_iv_off,
76 const bool is_qi, int era);
77
78void cnstr_shdsc_gcm_encap(u32 * const desc, struct alginfo *cdata,
79 unsigned int ivsize, unsigned int icvsize,
80 const bool is_qi);
81
82void cnstr_shdsc_gcm_decap(u32 * const desc, struct alginfo *cdata,
83 unsigned int ivsize, unsigned int icvsize,
84 const bool is_qi);
85
86void cnstr_shdsc_rfc4106_encap(u32 * const desc, struct alginfo *cdata,
87 unsigned int ivsize, unsigned int icvsize,
88 const bool is_qi);
89
90void cnstr_shdsc_rfc4106_decap(u32 * const desc, struct alginfo *cdata,
91 unsigned int ivsize, unsigned int icvsize,
92 const bool is_qi);
93
94void cnstr_shdsc_rfc4543_encap(u32 * const desc, struct alginfo *cdata,
95 unsigned int ivsize, unsigned int icvsize,
96 const bool is_qi);
97
98void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata,
99 unsigned int ivsize, unsigned int icvsize,
100 const bool is_qi);
101
102void cnstr_shdsc_chachapoly(u32 * const desc, struct alginfo *cdata,
103 struct alginfo *adata, unsigned int ivsize,
104 unsigned int icvsize, const bool encap,
105 const bool is_qi);
106
107void cnstr_shdsc_skcipher_encap(u32 * const desc, struct alginfo *cdata,
108 unsigned int ivsize, const bool is_rfc3686,
109 const u32 ctx1_iv_off);
110
111void cnstr_shdsc_skcipher_decap(u32 * const desc, struct alginfo *cdata,
112 unsigned int ivsize, const bool is_rfc3686,
113 const u32 ctx1_iv_off);
114
115void cnstr_shdsc_xts_skcipher_encap(u32 * const desc, struct alginfo *cdata);
116
117void cnstr_shdsc_xts_skcipher_decap(u32 * const desc, struct alginfo *cdata);
118
119void cnstr_desc_protected_blob_decap(u32 * const desc, struct alginfo *cdata,
120 dma_addr_t next_desc);
121
122void cnstr_desc_skcipher_enc_dec(u32 * const desc, struct alginfo *cdata,
123 dma_addr_t src, dma_addr_t dst, unsigned int data_sz,
124 unsigned int in_options, unsigned int out_options,
125 unsigned int ivsize, const bool encrypt);
126
127#endif /* _CAAMALG_DESC_H_ */