1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef __NX_CSBCPB_H__
4 #define __NX_CSBCPB_H__
6 struct cop_symcpb_aes_ecb
{
11 struct cop_symcpb_aes_cbc
{
19 struct cop_symcpb_aes_gca
{
27 struct cop_symcpb_aes_gcm
{
35 u8 out_pat_or_mac
[16];
42 struct cop_symcpb_aes_ctr
{
50 struct cop_symcpb_aes_cca
{
59 struct cop_symcpb_aes_ccm
{
65 u8 out_pat_or_mac
[16];
72 struct cop_symcpb_aes_xcbc
{
81 struct cop_symcpb_sha256
{
82 u64 message_bit_length
;
84 u8 input_partial_digest
[32];
85 u8 message_digest
[32];
90 struct cop_symcpb_sha512
{
91 u64 message_bit_length_hi
;
92 u64 message_bit_length_lo
;
93 u8 input_partial_digest
[64];
95 u8 message_digest
[64];
100 #define NX_FDM_INTERMEDIATE 0x01
101 #define NX_FDM_CONTINUATION 0x02
102 #define NX_FDM_ENDE_ENCRYPT 0x80
104 #define NX_CPB_FDM(c) ((c)->cpb.hdr.fdm)
105 #define NX_CPB_KS_DS(c) ((c)->cpb.hdr.ks_ds)
107 #define NX_CPB_KEY_SIZE(c) (NX_CPB_KS_DS(c) >> 4)
108 #define NX_CPB_SET_KEY_SIZE(c, x) NX_CPB_KS_DS(c) |= ((x) << 4)
109 #define NX_CPB_SET_DIGEST_SIZE(c, x) NX_CPB_KS_DS(c) |= (x)
111 struct cop_symcpb_header
{
119 struct cop_parameter_block
{
120 struct cop_symcpb_header hdr
;
122 struct cop_symcpb_aes_ecb aes_ecb
;
123 struct cop_symcpb_aes_cbc aes_cbc
;
124 struct cop_symcpb_aes_gca aes_gca
;
125 struct cop_symcpb_aes_gcm aes_gcm
;
126 struct cop_symcpb_aes_cca aes_cca
;
127 struct cop_symcpb_aes_ccm aes_ccm
;
128 struct cop_symcpb_aes_ctr aes_ctr
;
129 struct cop_symcpb_aes_xcbc aes_xcbc
;
130 struct cop_symcpb_sha256 sha256
;
131 struct cop_symcpb_sha512 sha512
;
135 #define NX_CSB_VALID_BIT 0x80
137 /* co-processor status block */
138 struct cop_status_block
{
142 u8 completion_extension
;
143 u32 processed_byte_count
;
147 /* Nest accelerator workbook section 4.4 */
149 unsigned char __rsvd
[112];
150 struct cop_status_block csb
;
151 struct cop_parameter_block cpb
;
154 /* nx_csbcpb related definitions */
155 #define NX_MODE_AES_ECB 0
156 #define NX_MODE_AES_CBC 1
157 #define NX_MODE_AES_GMAC 2
158 #define NX_MODE_AES_GCA 3
159 #define NX_MODE_AES_GCM 4
160 #define NX_MODE_AES_CCA 5
161 #define NX_MODE_AES_CCM 6
162 #define NX_MODE_AES_CTR 7
163 #define NX_MODE_AES_XCBC_MAC 20
164 #define NX_MODE_SHA 0
165 #define NX_MODE_SHA_HMAC 1
166 #define NX_MODE_AES_CBC_HMAC_ETA 8
167 #define NX_MODE_AES_CBC_HMAC_ATE 9
168 #define NX_MODE_AES_CBC_HMAC_EAA 10
169 #define NX_MODE_AES_CTR_HMAC_ETA 12
170 #define NX_MODE_AES_CTR_HMAC_ATE 13
171 #define NX_MODE_AES_CTR_HMAC_EAA 14
173 #define NX_FDM_CI_FULL 0
174 #define NX_FDM_CI_FIRST 1
175 #define NX_FDM_CI_LAST 2
176 #define NX_FDM_CI_MIDDLE 3
178 #define NX_FDM_PR_NONE 0
179 #define NX_FDM_PR_PAD 1
181 #define NX_KS_AES_128 1
182 #define NX_KS_AES_192 2
183 #define NX_KS_AES_256 3
185 #define NX_DS_SHA256 2
186 #define NX_DS_SHA512 3
190 #define NX_FC_AES_HMAC 6
192 #define NX_MAX_FC (NX_FC_AES_HMAC + 1)
193 #define NX_MAX_MODE (NX_MODE_AES_XCBC_MAC + 1)
195 #define HCOP_FC_AES NX_FC_AES
196 #define HCOP_FC_SHA NX_FC_SHA
197 #define HCOP_FC_AES_HMAC NX_FC_AES_HMAC
199 /* indices into the array of algorithm properties */
200 #define NX_PROPS_AES_128 0
201 #define NX_PROPS_AES_192 1
202 #define NX_PROPS_AES_256 2
203 #define NX_PROPS_SHA256 1
204 #define NX_PROPS_SHA512 2