2 * CAAM Protocol Data Block (PDB) definition header file
4 * Copyright 2008-2016 Freescale Semiconductor, Inc.
13 * PDB- IPSec ESP Header Modification Options
15 #define PDBHMO_ESP_DECAP_SHIFT 28
16 #define PDBHMO_ESP_ENCAP_SHIFT 28
18 * Encap and Decap - Decrement TTL (Hop Limit) - Based on the value of the
19 * Options Byte IP version (IPvsn) field:
20 * if IPv4, decrement the inner IP header TTL field (byte 8);
21 * if IPv6 decrement the inner IP header Hop Limit field (byte 7).
23 #define PDBHMO_ESP_DECAP_DEC_TTL (0x02 << PDBHMO_ESP_DECAP_SHIFT)
24 #define PDBHMO_ESP_ENCAP_DEC_TTL (0x02 << PDBHMO_ESP_ENCAP_SHIFT)
26 * Decap - DiffServ Copy - Copy the IPv4 TOS or IPv6 Traffic Class byte
27 * from the outer IP header to the inner IP header.
29 #define PDBHMO_ESP_DIFFSERV (0x01 << PDBHMO_ESP_DECAP_SHIFT)
31 * Encap- Copy DF bit -if an IPv4 tunnel mode outer IP header is coming from
32 * the PDB, copy the DF bit from the inner IP header to the outer IP header.
34 #define PDBHMO_ESP_DFBIT (0x04 << PDBHMO_ESP_ENCAP_SHIFT)
36 #define PDBNH_ESP_ENCAP_SHIFT 16
37 #define PDBNH_ESP_ENCAP_MASK (0xff << PDBNH_ESP_ENCAP_SHIFT)
39 #define PDBHDRLEN_ESP_DECAP_SHIFT 16
40 #define PDBHDRLEN_MASK (0x0fff << PDBHDRLEN_ESP_DECAP_SHIFT)
42 #define PDB_NH_OFFSET_SHIFT 8
43 #define PDB_NH_OFFSET_MASK (0xff << PDB_NH_OFFSET_SHIFT)
46 * PDB - IPSec ESP Encap/Decap Options
48 #define PDBOPTS_ESP_ARSNONE 0x00 /* no antireplay window */
49 #define PDBOPTS_ESP_ARS32 0x40 /* 32-entry antireplay window */
50 #define PDBOPTS_ESP_ARS128 0x80 /* 128-entry antireplay window */
51 #define PDBOPTS_ESP_ARS64 0xc0 /* 64-entry antireplay window */
52 #define PDBOPTS_ESP_ARS_MASK 0xc0 /* antireplay window mask */
53 #define PDBOPTS_ESP_IVSRC 0x20 /* IV comes from internal random gen */
54 #define PDBOPTS_ESP_ESN 0x10 /* extended sequence included */
55 #define PDBOPTS_ESP_OUTFMT 0x08 /* output only decapsulation (decap) */
56 #define PDBOPTS_ESP_IPHDRSRC 0x08 /* IP header comes from PDB (encap) */
57 #define PDBOPTS_ESP_INCIPHDR 0x04 /* Prepend IP header to output frame */
58 #define PDBOPTS_ESP_IPVSN 0x02 /* process IPv6 header */
59 #define PDBOPTS_ESP_AOFL 0x04 /* adjust out frame len (decap, SEC>=5.3)*/
60 #define PDBOPTS_ESP_TUNNEL 0x01 /* tunnel mode next-header byte */
61 #define PDBOPTS_ESP_IPV6 0x02 /* ip header version is V6 */
62 #define PDBOPTS_ESP_DIFFSERV 0x40 /* copy TOS/TC from inner iphdr */
63 #define PDBOPTS_ESP_UPDATE_CSUM 0x80 /* encap-update ip header checksum */
64 #define PDBOPTS_ESP_VERIFY_CSUM 0x20 /* decap-validate ip header checksum */
67 * General IPSec encap/decap PDB definitions
71 * ipsec_encap_cbc - PDB part for IPsec CBC encapsulation
72 * @iv: 16-byte array initialization vector
74 struct ipsec_encap_cbc
{
79 * ipsec_encap_ctr - PDB part for IPsec CTR encapsulation
80 * @ctr_nonce: 4-byte array nonce
81 * @ctr_initial: initial count constant
82 * @iv: initialization vector
84 struct ipsec_encap_ctr
{
91 * ipsec_encap_ccm - PDB part for IPsec CCM encapsulation
92 * @salt: 3-byte array salt (lower 24 bits)
93 * @ccm_opt: CCM algorithm options - MSB-LSB description:
94 * b0_flags (8b) - CCM B0; use 0x5B for 8-byte ICV, 0x6B for 12-byte ICV,
95 * 0x7B for 16-byte ICV (cf. RFC4309, RFC3610)
96 * ctr_flags (8b) - counter flags; constant equal to 0x3
97 * ctr_initial (16b) - initial count constant
98 * @iv: initialization vector
100 struct ipsec_encap_ccm
{
107 * ipsec_encap_gcm - PDB part for IPsec GCM encapsulation
108 * @salt: 3-byte array salt (lower 24 bits)
109 * @rsvd: reserved, do not use
110 * @iv: initialization vector
112 struct ipsec_encap_gcm
{
119 * ipsec_encap_pdb - PDB for IPsec encapsulation
120 * @options: MSB-LSB description
121 * hmo (header manipulation options) - 4b
124 * next header offset - 8b
125 * option flags (depend on selected algorithm) - 8b
126 * @seq_num_ext_hi: (optional) IPsec Extended Sequence Number (ESN)
127 * @seq_num: IPsec sequence number
128 * @spi: IPsec SPI (Security Parameters Index)
129 * @ip_hdr_len: optional IP Header length (in bytes)
131 * Opt. IP Hdr Len - 16b
132 * @ip_hdr: optional IP Header content
134 struct ipsec_encap_pdb
{
139 struct ipsec_encap_cbc cbc
;
140 struct ipsec_encap_ctr ctr
;
141 struct ipsec_encap_ccm ccm
;
142 struct ipsec_encap_gcm gcm
;
150 * ipsec_decap_cbc - PDB part for IPsec CBC decapsulation
151 * @rsvd: reserved, do not use
153 struct ipsec_decap_cbc
{
158 * ipsec_decap_ctr - PDB part for IPsec CTR decapsulation
159 * @ctr_nonce: 4-byte array nonce
160 * @ctr_initial: initial count constant
162 struct ipsec_decap_ctr
{
168 * ipsec_decap_ccm - PDB part for IPsec CCM decapsulation
169 * @salt: 3-byte salt (lower 24 bits)
170 * @ccm_opt: CCM algorithm options - MSB-LSB description:
171 * b0_flags (8b) - CCM B0; use 0x5B for 8-byte ICV, 0x6B for 12-byte ICV,
172 * 0x7B for 16-byte ICV (cf. RFC4309, RFC3610)
173 * ctr_flags (8b) - counter flags; constant equal to 0x3
174 * ctr_initial (16b) - initial count constant
176 struct ipsec_decap_ccm
{
182 * ipsec_decap_gcm - PDB part for IPsec GCN decapsulation
184 * @rsvd: reserved, do not use
186 struct ipsec_decap_gcm
{
192 * ipsec_decap_pdb - PDB for IPsec decapsulation
193 * @options: MSB-LSB description
194 * hmo (header manipulation options) - 4b
195 * IP header length - 12b
196 * next header offset - 8b
197 * option flags (depend on selected algorithm) - 8b
198 * @seq_num_ext_hi: (optional) IPsec Extended Sequence Number (ESN)
199 * @seq_num: IPsec sequence number
200 * @anti_replay: Anti-replay window; size depends on ARS (option flags)
202 struct ipsec_decap_pdb
{
205 struct ipsec_decap_cbc cbc
;
206 struct ipsec_decap_ctr ctr
;
207 struct ipsec_decap_ccm ccm
;
208 struct ipsec_decap_gcm gcm
;
212 __be32 anti_replay
[4];
216 * IPSec ESP Datapath Protocol Override Register (DPOVRD)
218 struct ipsec_deco_dpovrd
{
219 #define IPSEC_ENCAP_DECO_DPOVRD_USE 0x80
223 u8 next_header
; /* reserved if decap */
227 * IEEE 802.11i WiFi Protocol Data Block
229 #define WIFI_PDBOPTS_FCS 0x01
230 #define WIFI_PDBOPTS_AR 0x40
232 struct wifi_encap_pdb
{
250 struct wifi_decap_pdb
{
267 * IEEE 802.16 WiMAX Protocol Data Block
269 #define WIMAX_PDBOPTS_FCS 0x01
270 #define WIMAX_PDBOPTS_AR 0x40 /* decap only */
272 struct wimax_encap_pdb
{
279 /* begin DECO writeback region */
281 /* end DECO writeback region */
284 struct wimax_decap_pdb
{
291 /* begin DECO writeback region */
295 u64 antireplay_scorecard
;
296 /* end DECO writeback region */
300 * IEEE 801.AE MacSEC Protocol Data Block
302 #define MACSEC_PDBOPTS_FCS 0x01
303 #define MACSEC_PDBOPTS_AR 0x40 /* used in decap only */
305 struct macsec_encap_pdb
{
313 /* begin DECO writeback region */
315 /* end DECO writeback region */
318 struct macsec_decap_pdb
{
324 /* begin DECO writeback region */
327 u64 antireplay_scorecard
;
328 /* end DECO writeback region */
332 * SSL/TLS/DTLS Protocol Data Blocks
335 #define TLS_PDBOPTS_ARS32 0x40
336 #define TLS_PDBOPTS_ARS64 0xc0
337 #define TLS_PDBOPTS_OUTFMT 0x08
338 #define TLS_PDBOPTS_IV_WRTBK 0x02 /* 1.1/1.2/DTLS only */
339 #define TLS_PDBOPTS_EXP_RND_IV 0x01 /* 1.1/1.2/DTLS only */
341 struct tls_block_encap_pdb
{
349 struct tls_stream_encap_pdb
{
359 struct dtls_block_encap_pdb
{
368 struct tls_block_decap_pdb
{
375 struct tls_stream_decap_pdb
{
384 struct dtls_block_decap_pdb
{
390 u64 antireplay_scorecard
;
394 * SRTP Protocol Data Blocks
396 #define SRTP_PDBOPTS_MKI 0x08
397 #define SRTP_PDBOPTS_AR 0x40
399 struct srtp_encap_pdb
{
414 struct srtp_decap_pdb
{
427 u64 antireplay_scorecard
;
431 * DSA/ECDSA Protocol Data Blocks
432 * Two of these exist: DSA-SIGN, and DSA-VERIFY. They are similar
433 * except for the treatment of "w" for verify, "s" for sign,
434 * and the placement of "a,b".
436 #define DSA_PDB_SGF_SHIFT 24
437 #define DSA_PDB_SGF_MASK (0xff << DSA_PDB_SGF_SHIFT)
438 #define DSA_PDB_SGF_Q (0x80 << DSA_PDB_SGF_SHIFT)
439 #define DSA_PDB_SGF_R (0x40 << DSA_PDB_SGF_SHIFT)
440 #define DSA_PDB_SGF_G (0x20 << DSA_PDB_SGF_SHIFT)
441 #define DSA_PDB_SGF_W (0x10 << DSA_PDB_SGF_SHIFT)
442 #define DSA_PDB_SGF_S (0x10 << DSA_PDB_SGF_SHIFT)
443 #define DSA_PDB_SGF_F (0x08 << DSA_PDB_SGF_SHIFT)
444 #define DSA_PDB_SGF_C (0x04 << DSA_PDB_SGF_SHIFT)
445 #define DSA_PDB_SGF_D (0x02 << DSA_PDB_SGF_SHIFT)
446 #define DSA_PDB_SGF_AB_SIGN (0x02 << DSA_PDB_SGF_SHIFT)
447 #define DSA_PDB_SGF_AB_VERIFY (0x01 << DSA_PDB_SGF_SHIFT)
449 #define DSA_PDB_L_SHIFT 7
450 #define DSA_PDB_L_MASK (0x3ff << DSA_PDB_L_SHIFT)
452 #define DSA_PDB_N_MASK 0x7f
454 struct dsa_sign_pdb
{
455 u32 sgf_ln
; /* Use DSA_PDB_ defintions per above */
463 u8
*ab
; /* ECC only */
467 struct dsa_verify_pdb
{
476 u8
*tmp
; /* temporary data block */
477 u8
*ab
; /* only used if ECC processing */
480 /* RSA Protocol Data Block */
481 #define RSA_PDB_SGF_SHIFT 28
482 #define RSA_PDB_E_SHIFT 12
483 #define RSA_PDB_E_MASK (0xFFF << RSA_PDB_E_SHIFT)
484 #define RSA_PDB_D_SHIFT 12
485 #define RSA_PDB_D_MASK (0xFFF << RSA_PDB_D_SHIFT)
487 #define RSA_PDB_SGF_F (0x8 << RSA_PDB_SGF_SHIFT)
488 #define RSA_PDB_SGF_G (0x4 << RSA_PDB_SGF_SHIFT)
489 #define RSA_PRIV_PDB_SGF_F (0x4 << RSA_PDB_SGF_SHIFT)
490 #define RSA_PRIV_PDB_SGF_G (0x8 << RSA_PDB_SGF_SHIFT)
492 #define RSA_PRIV_KEY_FRM_1 0
495 * RSA Encrypt Protocol Data Block
496 * @sgf: scatter-gather field
497 * @f_dma: dma address of input data
498 * @g_dma: dma address of encrypted output data
499 * @n_dma: dma address of RSA modulus
500 * @e_dma: dma address of RSA public exponent
501 * @f_len: length in octets of the input data
513 * RSA Decrypt PDB - Private Key Form #1
514 * @sgf: scatter-gather field
515 * @g_dma: dma address of encrypted input data
516 * @f_dma: dma address of output data
517 * @n_dma: dma address of RSA modulus
518 * @d_dma: dma address of RSA private exponent
520 struct rsa_priv_f1_pdb
{