pdb.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*
  2. * CAAM Protocol Data Block (PDB) definition header file
  3. *
  4. * Copyright 2008-2012 Freescale Semiconductor, Inc.
  5. *
  6. */
  7. #ifndef CAAM_PDB_H
  8. #define CAAM_PDB_H
  9. /*
  10. * PDB- IPSec ESP Header Modification Options
  11. */
  12. #define PDBHMO_ESP_DECAP_SHIFT 12
  13. #define PDBHMO_ESP_ENCAP_SHIFT 4
  14. /*
  15. * Encap and Decap - Decrement TTL (Hop Limit) - Based on the value of the
  16. * Options Byte IP version (IPvsn) field:
  17. * if IPv4, decrement the inner IP header TTL field (byte 8);
  18. * if IPv6 decrement the inner IP header Hop Limit field (byte 7).
  19. */
  20. #define PDBHMO_ESP_DECAP_DEC_TTL (0x02 << PDBHMO_ESP_DECAP_SHIFT)
  21. #define PDBHMO_ESP_ENCAP_DEC_TTL (0x02 << PDBHMO_ESP_ENCAP_SHIFT)
  22. /*
  23. * Decap - DiffServ Copy - Copy the IPv4 TOS or IPv6 Traffic Class byte
  24. * from the outer IP header to the inner IP header.
  25. */
  26. #define PDBHMO_ESP_DIFFSERV (0x01 << PDBHMO_ESP_DECAP_SHIFT)
  27. /*
  28. * Encap- Copy DF bit -if an IPv4 tunnel mode outer IP header is coming from
  29. * the PDB, copy the DF bit from the inner IP header to the outer IP header.
  30. */
  31. #define PDBHMO_ESP_DFBIT (0x04 << PDBHMO_ESP_ENCAP_SHIFT)
  32. /*
  33. * PDB - IPSec ESP Encap/Decap Options
  34. */
  35. #define PDBOPTS_ESP_ARSNONE 0x00 /* no antireplay window */
  36. #define PDBOPTS_ESP_ARS32 0x40 /* 32-entry antireplay window */
  37. #define PDBOPTS_ESP_ARS64 0xc0 /* 64-entry antireplay window */
  38. #define PDBOPTS_ESP_IVSRC 0x20 /* IV comes from internal random gen */
  39. #define PDBOPTS_ESP_ESN 0x10 /* extended sequence included */
  40. #define PDBOPTS_ESP_OUTFMT 0x08 /* output only decapsulation (decap) */
  41. #define PDBOPTS_ESP_IPHDRSRC 0x08 /* IP header comes from PDB (encap) */
  42. #define PDBOPTS_ESP_INCIPHDR 0x04 /* Prepend IP header to output frame */
  43. #define PDBOPTS_ESP_IPVSN 0x02 /* process IPv6 header */
  44. #define PDBOPTS_ESP_TUNNEL 0x01 /* tunnel mode next-header byte */
  45. #define PDBOPTS_ESP_IPV6 0x02 /* ip header version is V6 */
  46. #define PDBOPTS_ESP_DIFFSERV 0x40 /* copy TOS/TC from inner iphdr */
  47. #define PDBOPTS_ESP_UPDATE_CSUM 0x80 /* encap-update ip header checksum */
  48. #define PDBOPTS_ESP_VERIFY_CSUM 0x20 /* decap-validate ip header checksum */
  49. /*
  50. * General IPSec encap/decap PDB definitions
  51. */
  52. struct ipsec_encap_cbc {
  53. u32 iv[4];
  54. };
  55. struct ipsec_encap_ctr {
  56. u32 ctr_nonce;
  57. u32 ctr_initial;
  58. u32 iv[2];
  59. };
  60. struct ipsec_encap_ccm {
  61. u32 salt; /* lower 24 bits */
  62. u8 b0_flags;
  63. u8 ctr_flags;
  64. u16 ctr_initial;
  65. u32 iv[2];
  66. };
  67. struct ipsec_encap_gcm {
  68. u32 salt; /* lower 24 bits */
  69. u32 rsvd1;
  70. u32 iv[2];
  71. };
  72. struct ipsec_encap_pdb {
  73. u8 hmo_rsvd;
  74. u8 ip_nh;
  75. u8 ip_nh_offset;
  76. u8 options;
  77. u32 seq_num_ext_hi;
  78. u32 seq_num;
  79. union {
  80. struct ipsec_encap_cbc cbc;
  81. struct ipsec_encap_ctr ctr;
  82. struct ipsec_encap_ccm ccm;
  83. struct ipsec_encap_gcm gcm;
  84. };
  85. u32 spi;
  86. u16 rsvd1;
  87. u16 ip_hdr_len;
  88. u32 ip_hdr[0]; /* optional IP Header content */
  89. };
  90. struct ipsec_decap_cbc {
  91. u32 rsvd[2];
  92. };
  93. struct ipsec_decap_ctr {
  94. u32 salt;
  95. u32 ctr_initial;
  96. };
  97. struct ipsec_decap_ccm {
  98. u32 salt;
  99. u8 iv_flags;
  100. u8 ctr_flags;
  101. u16 ctr_initial;
  102. };
  103. struct ipsec_decap_gcm {
  104. u32 salt;
  105. u32 resvd;
  106. };
  107. struct ipsec_decap_pdb {
  108. u16 hmo_ip_hdr_len;
  109. u8 ip_nh_offset;
  110. u8 options;
  111. union {
  112. struct ipsec_decap_cbc cbc;
  113. struct ipsec_decap_ctr ctr;
  114. struct ipsec_decap_ccm ccm;
  115. struct ipsec_decap_gcm gcm;
  116. };
  117. u32 seq_num_ext_hi;
  118. u32 seq_num;
  119. u32 anti_replay[2];
  120. u32 end_index[0];
  121. };
  122. /*
  123. * IPSec ESP Datapath Protocol Override Register (DPOVRD)
  124. */
  125. struct ipsec_deco_dpovrd {
  126. #define IPSEC_ENCAP_DECO_DPOVRD_USE 0x80
  127. u8 ovrd_ecn;
  128. u8 ip_hdr_len;
  129. u8 nh_offset;
  130. u8 next_header; /* reserved if decap */
  131. };
  132. /*
  133. * IEEE 802.11i WiFi Protocol Data Block
  134. */
  135. #define WIFI_PDBOPTS_FCS 0x01
  136. #define WIFI_PDBOPTS_AR 0x40
  137. struct wifi_encap_pdb {
  138. u16 mac_hdr_len;
  139. u8 rsvd;
  140. u8 options;
  141. u8 iv_flags;
  142. u8 pri;
  143. u16 pn1;
  144. u32 pn2;
  145. u16 frm_ctrl_mask;
  146. u16 seq_ctrl_mask;
  147. u8 rsvd1[2];
  148. u8 cnst;
  149. u8 key_id;
  150. u8 ctr_flags;
  151. u8 rsvd2;
  152. u16 ctr_init;
  153. };
  154. struct wifi_decap_pdb {
  155. u16 mac_hdr_len;
  156. u8 rsvd;
  157. u8 options;
  158. u8 iv_flags;
  159. u8 pri;
  160. u16 pn1;
  161. u32 pn2;
  162. u16 frm_ctrl_mask;
  163. u16 seq_ctrl_mask;
  164. u8 rsvd1[4];
  165. u8 ctr_flags;
  166. u8 rsvd2;
  167. u16 ctr_init;
  168. };
  169. /*
  170. * IEEE 802.16 WiMAX Protocol Data Block
  171. */
  172. #define WIMAX_PDBOPTS_FCS 0x01
  173. #define WIMAX_PDBOPTS_AR 0x40 /* decap only */
  174. struct wimax_encap_pdb {
  175. u8 rsvd[3];
  176. u8 options;
  177. u32 nonce;
  178. u8 b0_flags;
  179. u8 ctr_flags;
  180. u16 ctr_init;
  181. /* begin DECO writeback region */
  182. u32 pn;
  183. /* end DECO writeback region */
  184. };
  185. struct wimax_decap_pdb {
  186. u8 rsvd[3];
  187. u8 options;
  188. u32 nonce;
  189. u8 iv_flags;
  190. u8 ctr_flags;
  191. u16 ctr_init;
  192. /* begin DECO writeback region */
  193. u32 pn;
  194. u8 rsvd1[2];
  195. u16 antireplay_len;
  196. u64 antireplay_scorecard;
  197. /* end DECO writeback region */
  198. };
  199. /*
  200. * IEEE 801.AE MacSEC Protocol Data Block
  201. */
  202. #define MACSEC_PDBOPTS_FCS 0x01
  203. #define MACSEC_PDBOPTS_AR 0x40 /* used in decap only */
  204. struct macsec_encap_pdb {
  205. u16 aad_len;
  206. u8 rsvd;
  207. u8 options;
  208. u64 sci;
  209. u16 ethertype;
  210. u8 tci_an;
  211. u8 rsvd1;
  212. /* begin DECO writeback region */
  213. u32 pn;
  214. /* end DECO writeback region */
  215. };
  216. struct macsec_decap_pdb {
  217. u16 aad_len;
  218. u8 rsvd;
  219. u8 options;
  220. u64 sci;
  221. u8 rsvd1[3];
  222. /* begin DECO writeback region */
  223. u8 antireplay_len;
  224. u32 pn;
  225. u64 antireplay_scorecard;
  226. /* end DECO writeback region */
  227. };
  228. /*
  229. * SSL/TLS/DTLS Protocol Data Blocks
  230. */
  231. #define TLS_PDBOPTS_ARS32 0x40
  232. #define TLS_PDBOPTS_ARS64 0xc0
  233. #define TLS_PDBOPTS_OUTFMT 0x08
  234. #define TLS_PDBOPTS_IV_WRTBK 0x02 /* 1.1/1.2/DTLS only */
  235. #define TLS_PDBOPTS_EXP_RND_IV 0x01 /* 1.1/1.2/DTLS only */
  236. struct tls_block_encap_pdb {
  237. u8 type;
  238. u8 version[2];
  239. u8 options;
  240. u64 seq_num;
  241. u32 iv[4];
  242. };
  243. struct tls_stream_encap_pdb {
  244. u8 type;
  245. u8 version[2];
  246. u8 options;
  247. u64 seq_num;
  248. u8 i;
  249. u8 j;
  250. u8 rsvd1[2];
  251. };
  252. struct dtls_block_encap_pdb {
  253. u8 type;
  254. u8 version[2];
  255. u8 options;
  256. u16 epoch;
  257. u16 seq_num[3];
  258. u32 iv[4];
  259. };
  260. struct tls_block_decap_pdb {
  261. u8 rsvd[3];
  262. u8 options;
  263. u64 seq_num;
  264. u32 iv[4];
  265. };
  266. struct tls_stream_decap_pdb {
  267. u8 rsvd[3];
  268. u8 options;
  269. u64 seq_num;
  270. u8 i;
  271. u8 j;
  272. u8 rsvd1[2];
  273. };
  274. struct dtls_block_decap_pdb {
  275. u8 rsvd[3];
  276. u8 options;
  277. u16 epoch;
  278. u16 seq_num[3];
  279. u32 iv[4];
  280. u64 antireplay_scorecard;
  281. };
  282. /*
  283. * SRTP Protocol Data Blocks
  284. */
  285. #define SRTP_PDBOPTS_MKI 0x08
  286. #define SRTP_PDBOPTS_AR 0x40
  287. struct srtp_encap_pdb {
  288. u8 x_len;
  289. u8 mki_len;
  290. u8 n_tag;
  291. u8 options;
  292. u32 cnst0;
  293. u8 rsvd[2];
  294. u16 cnst1;
  295. u16 salt[7];
  296. u16 cnst2;
  297. u32 rsvd1;
  298. u32 roc;
  299. u32 opt_mki;
  300. };
  301. struct srtp_decap_pdb {
  302. u8 x_len;
  303. u8 mki_len;
  304. u8 n_tag;
  305. u8 options;
  306. u32 cnst0;
  307. u8 rsvd[2];
  308. u16 cnst1;
  309. u16 salt[7];
  310. u16 cnst2;
  311. u16 rsvd1;
  312. u16 seq_num;
  313. u32 roc;
  314. u64 antireplay_scorecard;
  315. };
  316. /*
  317. * DSA/ECDSA Protocol Data Blocks
  318. * Two of these exist: DSA-SIGN, and DSA-VERIFY. They are similar
  319. * except for the treatment of "w" for verify, "s" for sign,
  320. * and the placement of "a,b".
  321. */
  322. #define DSA_PDB_SGF_SHIFT 24
  323. #define DSA_PDB_SGF_MASK (0xff << DSA_PDB_SGF_SHIFT)
  324. #define DSA_PDB_SGF_Q (0x80 << DSA_PDB_SGF_SHIFT)
  325. #define DSA_PDB_SGF_R (0x40 << DSA_PDB_SGF_SHIFT)
  326. #define DSA_PDB_SGF_G (0x20 << DSA_PDB_SGF_SHIFT)
  327. #define DSA_PDB_SGF_W (0x10 << DSA_PDB_SGF_SHIFT)
  328. #define DSA_PDB_SGF_S (0x10 << DSA_PDB_SGF_SHIFT)
  329. #define DSA_PDB_SGF_F (0x08 << DSA_PDB_SGF_SHIFT)
  330. #define DSA_PDB_SGF_C (0x04 << DSA_PDB_SGF_SHIFT)
  331. #define DSA_PDB_SGF_D (0x02 << DSA_PDB_SGF_SHIFT)
  332. #define DSA_PDB_SGF_AB_SIGN (0x02 << DSA_PDB_SGF_SHIFT)
  333. #define DSA_PDB_SGF_AB_VERIFY (0x01 << DSA_PDB_SGF_SHIFT)
  334. #define DSA_PDB_L_SHIFT 7
  335. #define DSA_PDB_L_MASK (0x3ff << DSA_PDB_L_SHIFT)
  336. #define DSA_PDB_N_MASK 0x7f
  337. struct dsa_sign_pdb {
  338. u32 sgf_ln; /* Use DSA_PDB_ defintions per above */
  339. u8 *q;
  340. u8 *r;
  341. u8 *g; /* or Gx,y */
  342. u8 *s;
  343. u8 *f;
  344. u8 *c;
  345. u8 *d;
  346. u8 *ab; /* ECC only */
  347. u8 *u;
  348. };
  349. struct dsa_verify_pdb {
  350. u32 sgf_ln;
  351. u8 *q;
  352. u8 *r;
  353. u8 *g; /* or Gx,y */
  354. u8 *w; /* or Wx,y */
  355. u8 *f;
  356. u8 *c;
  357. u8 *d;
  358. u8 *tmp; /* temporary data block */
  359. u8 *ab; /* only used if ECC processing */
  360. };
  361. #endif