pdb.h 7.8 KB

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