pkcs11n.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef _PKCS11N_H_
  5. #define _PKCS11N_H_
  6. /*
  7. * pkcs11n.h
  8. *
  9. * This file contains the NSS-specific type definitions for Cryptoki
  10. * (PKCS#11).
  11. */
  12. /*
  13. * NSSCK_VENDOR_NSS
  14. *
  15. * Cryptoki reserves the high half of all the number spaces for
  16. * vendor-defined use. I'd like to keep all of our NSS-
  17. * specific values together, but not in the oh-so-obvious
  18. * 0x80000001, 0x80000002, etc. area. So I've picked an offset,
  19. * and constructed values for the beginnings of our spaces.
  20. *
  21. * Note that some "historical" Netscape values don't fall within
  22. * this range.
  23. */
  24. #define NSSCK_VENDOR_NSS 0x4E534350 /* NSCP */
  25. /*
  26. * NSS-defined object classes
  27. *
  28. */
  29. #define CKO_NSS (CKO_VENDOR_DEFINED | NSSCK_VENDOR_NSS)
  30. #define CKO_NSS_CRL (CKO_NSS + 1)
  31. #define CKO_NSS_SMIME (CKO_NSS + 2)
  32. #define CKO_NSS_TRUST (CKO_NSS + 3)
  33. #define CKO_NSS_BUILTIN_ROOT_LIST (CKO_NSS + 4)
  34. #define CKO_NSS_NEWSLOT (CKO_NSS + 5)
  35. #define CKO_NSS_DELSLOT (CKO_NSS + 6)
  36. /*
  37. * NSS-defined key types
  38. *
  39. */
  40. #define CKK_NSS (CKK_VENDOR_DEFINED | NSSCK_VENDOR_NSS)
  41. #define CKK_NSS_PKCS8 (CKK_NSS + 1)
  42. #define CKK_NSS_JPAKE_ROUND1 (CKK_NSS + 2)
  43. #define CKK_NSS_JPAKE_ROUND2 (CKK_NSS + 3)
  44. #define CKK_NSS_CHACHA20 (CKK_NSS + 4)
  45. /*
  46. * NSS-defined certificate types
  47. *
  48. */
  49. #define CKC_NSS (CKC_VENDOR_DEFINED | NSSCK_VENDOR_NSS)
  50. /* FAKE PKCS #11 defines */
  51. #define CKA_DIGEST 0x81000000L
  52. #define CKA_NSS_MESSAGE 0x82000000L
  53. #define CKA_NSS_MESSAGE_MASK 0xff000000L
  54. #define CKA_FLAGS_ONLY 0 /* CKA_CLASS */
  55. /*
  56. * NSS-defined object attributes
  57. *
  58. */
  59. #define CKA_NSS (CKA_VENDOR_DEFINED | NSSCK_VENDOR_NSS)
  60. #define CKA_NSS_URL (CKA_NSS + 1)
  61. #define CKA_NSS_EMAIL (CKA_NSS + 2)
  62. #define CKA_NSS_SMIME_INFO (CKA_NSS + 3)
  63. #define CKA_NSS_SMIME_TIMESTAMP (CKA_NSS + 4)
  64. #define CKA_NSS_PKCS8_SALT (CKA_NSS + 5)
  65. #define CKA_NSS_PASSWORD_CHECK (CKA_NSS + 6)
  66. #define CKA_NSS_EXPIRES (CKA_NSS + 7)
  67. #define CKA_NSS_KRL (CKA_NSS + 8)
  68. #define CKA_NSS_PQG_COUNTER (CKA_NSS + 20)
  69. #define CKA_NSS_PQG_SEED (CKA_NSS + 21)
  70. #define CKA_NSS_PQG_H (CKA_NSS + 22)
  71. #define CKA_NSS_PQG_SEED_BITS (CKA_NSS + 23)
  72. #define CKA_NSS_MODULE_SPEC (CKA_NSS + 24)
  73. #define CKA_NSS_OVERRIDE_EXTENSIONS (CKA_NSS + 25)
  74. #define CKA_NSS_JPAKE_SIGNERID (CKA_NSS + 26)
  75. #define CKA_NSS_JPAKE_PEERID (CKA_NSS + 27)
  76. #define CKA_NSS_JPAKE_GX1 (CKA_NSS + 28)
  77. #define CKA_NSS_JPAKE_GX2 (CKA_NSS + 29)
  78. #define CKA_NSS_JPAKE_GX3 (CKA_NSS + 30)
  79. #define CKA_NSS_JPAKE_GX4 (CKA_NSS + 31)
  80. #define CKA_NSS_JPAKE_X2 (CKA_NSS + 32)
  81. #define CKA_NSS_JPAKE_X2S (CKA_NSS + 33)
  82. #define CKA_NSS_MOZILLA_CA_POLICY (CKA_NSS + 34)
  83. #define CKA_NSS_SERVER_DISTRUST_AFTER (CKA_NSS + 35)
  84. #define CKA_NSS_EMAIL_DISTRUST_AFTER (CKA_NSS + 36)
  85. /*
  86. * Trust attributes:
  87. *
  88. * If trust goes standard, these probably will too. So I'll
  89. * put them all in one place.
  90. */
  91. #define CKA_TRUST (CKA_NSS + 0x2000)
  92. /* "Usage" key information */
  93. #define CKA_TRUST_DIGITAL_SIGNATURE (CKA_TRUST + 1)
  94. #define CKA_TRUST_NON_REPUDIATION (CKA_TRUST + 2)
  95. #define CKA_TRUST_KEY_ENCIPHERMENT (CKA_TRUST + 3)
  96. #define CKA_TRUST_DATA_ENCIPHERMENT (CKA_TRUST + 4)
  97. #define CKA_TRUST_KEY_AGREEMENT (CKA_TRUST + 5)
  98. #define CKA_TRUST_KEY_CERT_SIGN (CKA_TRUST + 6)
  99. #define CKA_TRUST_CRL_SIGN (CKA_TRUST + 7)
  100. /* "Purpose" trust information */
  101. #define CKA_TRUST_SERVER_AUTH (CKA_TRUST + 8)
  102. #define CKA_TRUST_CLIENT_AUTH (CKA_TRUST + 9)
  103. #define CKA_TRUST_CODE_SIGNING (CKA_TRUST + 10)
  104. #define CKA_TRUST_EMAIL_PROTECTION (CKA_TRUST + 11)
  105. #define CKA_TRUST_IPSEC_END_SYSTEM (CKA_TRUST + 12)
  106. #define CKA_TRUST_IPSEC_TUNNEL (CKA_TRUST + 13)
  107. #define CKA_TRUST_IPSEC_USER (CKA_TRUST + 14)
  108. #define CKA_TRUST_TIME_STAMPING (CKA_TRUST + 15)
  109. #define CKA_TRUST_STEP_UP_APPROVED (CKA_TRUST + 16)
  110. #define CKA_CERT_SHA1_HASH (CKA_TRUST + 100)
  111. #define CKA_CERT_MD5_HASH (CKA_TRUST + 101)
  112. /* NSS trust stuff */
  113. /* HISTORICAL: define used to pass in the database key for DSA private keys */
  114. #define CKA_NSS_DB 0xD5A0DB00L
  115. #define CKA_NSS_TRUST 0x80000001L
  116. /* FAKE PKCS #11 defines */
  117. #define CKM_FAKE_RANDOM 0x80000efeUL
  118. #define CKM_INVALID_MECHANISM 0xffffffffUL
  119. #define CKT_INVALID_TYPE 0xffffffffUL
  120. /*
  121. * NSS-defined crypto mechanisms
  122. *
  123. */
  124. #define CKM_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS)
  125. #define CKM_NSS_AES_KEY_WRAP (CKM_NSS + 1)
  126. #define CKM_NSS_AES_KEY_WRAP_PAD (CKM_NSS + 2)
  127. /* HKDF key derivation mechanisms. See CK_NSS_HKDFParams for documentation. */
  128. #define CKM_NSS_HKDF_SHA1 (CKM_NSS + 3)
  129. #define CKM_NSS_HKDF_SHA256 (CKM_NSS + 4)
  130. #define CKM_NSS_HKDF_SHA384 (CKM_NSS + 5)
  131. #define CKM_NSS_HKDF_SHA512 (CKM_NSS + 6)
  132. /* J-PAKE round 1 key generation mechanisms.
  133. *
  134. * Required template attributes: CKA_PRIME, CKA_SUBPRIME, CKA_BASE,
  135. * CKA_NSS_JPAKE_SIGNERID
  136. * Output key type: CKK_NSS_JPAKE_ROUND1
  137. * Output key class: CKO_PRIVATE_KEY
  138. * Parameter type: CK_NSS_JPAKERound1Params
  139. *
  140. */
  141. #define CKM_NSS_JPAKE_ROUND1_SHA1 (CKM_NSS + 7)
  142. #define CKM_NSS_JPAKE_ROUND1_SHA256 (CKM_NSS + 8)
  143. #define CKM_NSS_JPAKE_ROUND1_SHA384 (CKM_NSS + 9)
  144. #define CKM_NSS_JPAKE_ROUND1_SHA512 (CKM_NSS + 10)
  145. /* J-PAKE round 2 key derivation mechanisms.
  146. *
  147. * Required template attributes: CKA_NSS_JPAKE_PEERID
  148. * Input key type: CKK_NSS_JPAKE_ROUND1
  149. * Output key type: CKK_NSS_JPAKE_ROUND2
  150. * Output key class: CKO_PRIVATE_KEY
  151. * Parameter type: CK_NSS_JPAKERound2Params
  152. */
  153. #define CKM_NSS_JPAKE_ROUND2_SHA1 (CKM_NSS + 11)
  154. #define CKM_NSS_JPAKE_ROUND2_SHA256 (CKM_NSS + 12)
  155. #define CKM_NSS_JPAKE_ROUND2_SHA384 (CKM_NSS + 13)
  156. #define CKM_NSS_JPAKE_ROUND2_SHA512 (CKM_NSS + 14)
  157. /* J-PAKE final key material derivation mechanisms
  158. *
  159. * Input key type: CKK_NSS_JPAKE_ROUND2
  160. * Output key type: CKK_GENERIC_SECRET
  161. * Output key class: CKO_SECRET_KEY
  162. * Parameter type: CK_NSS_JPAKEFinalParams
  163. *
  164. * You must apply a KDF (e.g. CKM_NSS_HKDF_*) to resultant keying material
  165. * to get a key with uniformly distributed bits.
  166. */
  167. #define CKM_NSS_JPAKE_FINAL_SHA1 (CKM_NSS + 15)
  168. #define CKM_NSS_JPAKE_FINAL_SHA256 (CKM_NSS + 16)
  169. #define CKM_NSS_JPAKE_FINAL_SHA384 (CKM_NSS + 17)
  170. #define CKM_NSS_JPAKE_FINAL_SHA512 (CKM_NSS + 18)
  171. /* Constant-time MAC mechanisms:
  172. *
  173. * These operations verify a padded, MAC-then-encrypt block of data in
  174. * constant-time. Because of the order of operations, the padding bytes are not
  175. * protected by the MAC. However, disclosing the value of the padding bytes
  176. * gives an attacker the ability to decrypt ciphertexts. Such disclosure can be
  177. * as subtle as taking slightly less time to perform the MAC when the padding
  178. * is one byte longer. See https://www.isg.rhul.ac.uk/tls/
  179. *
  180. * CKM_NSS_HMAC_CONSTANT_TIME: performs an HMAC authentication.
  181. * CKM_NSS_SSL3_MAC_CONSTANT_TIME: performs an authentication with SSLv3 MAC.
  182. *
  183. * Parameter type: CK_NSS_MAC_CONSTANT_TIME_PARAMS
  184. */
  185. #define CKM_NSS_HMAC_CONSTANT_TIME (CKM_NSS + 19)
  186. #define CKM_NSS_SSL3_MAC_CONSTANT_TIME (CKM_NSS + 20)
  187. /* TLS 1.2 mechanisms */
  188. #define CKM_NSS_TLS_PRF_GENERAL_SHA256 (CKM_NSS + 21)
  189. #define CKM_NSS_TLS_MASTER_KEY_DERIVE_SHA256 (CKM_NSS + 22)
  190. #define CKM_NSS_TLS_KEY_AND_MAC_DERIVE_SHA256 (CKM_NSS + 23)
  191. #define CKM_NSS_TLS_MASTER_KEY_DERIVE_DH_SHA256 (CKM_NSS + 24)
  192. /* TLS extended master secret derivation */
  193. #define CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE (CKM_NSS + 25)
  194. #define CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_DH (CKM_NSS + 26)
  195. #define CKM_NSS_CHACHA20_KEY_GEN (CKM_NSS + 27)
  196. #define CKM_NSS_CHACHA20_POLY1305 (CKM_NSS + 28)
  197. /* Additional PKCS #12 PBE algorithms defined in v1.1 */
  198. #define CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN (CKM_NSS + 29)
  199. #define CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN (CKM_NSS + 30)
  200. #define CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN (CKM_NSS + 31)
  201. #define CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN (CKM_NSS + 32)
  202. #define CKM_NSS_CHACHA20_CTR (CKM_NSS + 33)
  203. /* IKE mechanism (to be proposed to PKCS #11 */
  204. #define CKM_NSS_IKE_PRF_PLUS_DERIVE (CKM_NSS + 34)
  205. #define CKM_NSS_IKE_PRF_DERIVE (CKM_NSS + 35)
  206. #define CKM_NSS_IKE1_PRF_DERIVE (CKM_NSS + 36)
  207. #define CKM_NSS_IKE1_APP_B_PRF_DERIVE (CKM_NSS + 37)
  208. #define CKM_NSS_PUB_FROM_PRIV (CKM_NSS + 40)
  209. /* SP800-108 NSS mechanism with support for data object derivation */
  210. #define CKM_NSS_SP800_108_COUNTER_KDF_DERIVE_DATA (CKM_NSS + 42)
  211. #define CKM_NSS_SP800_108_FEEDBACK_KDF_DERIVE_DATA (CKM_NSS + 43)
  212. #define CKM_NSS_SP800_108_DOUBLE_PIPELINE_KDF_DERIVE_DATA (CKM_NSS + 44)
  213. /*
  214. * HISTORICAL:
  215. * Do not attempt to use these. They are only used by NSS's internal
  216. * PKCS #11 interface. Most of these are place holders for other mechanism
  217. * and will change in the future.
  218. */
  219. #define CKM_NSS_PBE_SHA1_DES_CBC 0x80000002UL
  220. #define CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC 0x80000003UL
  221. #define CKM_NSS_PBE_SHA1_40_BIT_RC2_CBC 0x80000004UL
  222. #define CKM_NSS_PBE_SHA1_128_BIT_RC2_CBC 0x80000005UL
  223. #define CKM_NSS_PBE_SHA1_40_BIT_RC4 0x80000006UL
  224. #define CKM_NSS_PBE_SHA1_128_BIT_RC4 0x80000007UL
  225. #define CKM_NSS_PBE_SHA1_FAULTY_3DES_CBC 0x80000008UL
  226. #define CKM_NSS_PBE_SHA1_HMAC_KEY_GEN 0x80000009UL
  227. #define CKM_NSS_PBE_MD5_HMAC_KEY_GEN 0x8000000aUL
  228. #define CKM_NSS_PBE_MD2_HMAC_KEY_GEN 0x8000000bUL
  229. #define CKM_TLS_PRF_GENERAL 0x80000373UL
  230. typedef struct CK_NSS_JPAKEPublicValue {
  231. CK_BYTE *pGX;
  232. CK_ULONG ulGXLen;
  233. CK_BYTE *pGV;
  234. CK_ULONG ulGVLen;
  235. CK_BYTE *pR;
  236. CK_ULONG ulRLen;
  237. } CK_NSS_JPAKEPublicValue;
  238. typedef struct CK_NSS_JPAKERound1Params {
  239. CK_NSS_JPAKEPublicValue gx1; /* out */
  240. CK_NSS_JPAKEPublicValue gx2; /* out */
  241. } CK_NSS_JPAKERound1Params;
  242. typedef struct CK_NSS_JPAKERound2Params {
  243. CK_BYTE *pSharedKey; /* in */
  244. CK_ULONG ulSharedKeyLen; /* in */
  245. CK_NSS_JPAKEPublicValue gx3; /* in */
  246. CK_NSS_JPAKEPublicValue gx4; /* in */
  247. CK_NSS_JPAKEPublicValue A; /* out */
  248. } CK_NSS_JPAKERound2Params;
  249. typedef struct CK_NSS_JPAKEFinalParams {
  250. CK_NSS_JPAKEPublicValue B; /* in */
  251. } CK_NSS_JPAKEFinalParams;
  252. /* macAlg: the MAC algorithm to use. This determines the hash function used in
  253. * the HMAC/SSLv3 MAC calculations.
  254. * ulBodyTotalLen: the total length of the data, including padding bytes and
  255. * padding length.
  256. * pHeader: points to a block of data that contains additional data to
  257. * authenticate. For TLS this includes the sequence number etc. For SSLv3,
  258. * this also includes the initial padding bytes.
  259. *
  260. * NOTE: the softoken's implementation of CKM_NSS_HMAC_CONSTANT_TIME and
  261. * CKM_NSS_SSL3_MAC_CONSTANT_TIME requires that the sum of ulBodyTotalLen
  262. * and ulHeaderLen be much smaller than 2^32 / 8 bytes because it uses an
  263. * unsigned int variable to represent the length in bits. This should not
  264. * be a problem because the SSL/TLS protocol limits the size of an SSL
  265. * record to something considerably less than 2^32 bytes.
  266. */
  267. typedef struct CK_NSS_MAC_CONSTANT_TIME_PARAMS {
  268. CK_MECHANISM_TYPE macAlg; /* in */
  269. CK_ULONG ulBodyTotalLen; /* in */
  270. CK_BYTE *pHeader; /* in */
  271. CK_ULONG ulHeaderLen; /* in */
  272. } CK_NSS_MAC_CONSTANT_TIME_PARAMS;
  273. typedef struct CK_NSS_AEAD_PARAMS {
  274. CK_BYTE_PTR pNonce;
  275. CK_ULONG ulNonceLen;
  276. CK_BYTE_PTR pAAD;
  277. CK_ULONG ulAADLen;
  278. CK_ULONG ulTagLen;
  279. } CK_NSS_AEAD_PARAMS;
  280. /*
  281. * NSS-defined return values
  282. *
  283. */
  284. #define CKR_NSS (CKM_VENDOR_DEFINED | NSSCK_VENDOR_NSS)
  285. #define CKR_NSS_CERTDB_FAILED (CKR_NSS + 1)
  286. #define CKR_NSS_KEYDB_FAILED (CKR_NSS + 2)
  287. /* Mandatory parameter for the CKM_NSS_HKDF_* key deriviation mechanisms.
  288. See RFC 5869.
  289. bExtract: If set, HKDF-Extract will be applied to the input key. If
  290. the optional salt is given, it is used; otherwise, the salt is
  291. set to a sequence of zeros equal in length to the HMAC output.
  292. If bExpand is not set, then the key template given to
  293. C_DeriveKey must indicate an output key size less than or equal
  294. to the output size of the HMAC.
  295. bExpand: If set, HKDF-Expand will be applied to the input key (if
  296. bExtract is not set) or to the result of HKDF-Extract (if
  297. bExtract is set). Any info given in the optional pInfo field will
  298. be included in the calculation.
  299. The size of the output key must be specified in the template passed to
  300. C_DeriveKey.
  301. */
  302. typedef struct CK_NSS_HKDFParams {
  303. CK_BBOOL bExtract;
  304. CK_BYTE_PTR pSalt;
  305. CK_ULONG ulSaltLen;
  306. CK_BBOOL bExpand;
  307. CK_BYTE_PTR pInfo;
  308. CK_ULONG ulInfoLen;
  309. } CK_NSS_HKDFParams;
  310. /*
  311. * CK_NSS_IKE_PRF_PLUS_PARAMS is a structure that provides the parameters to
  312. * the CKM_NSS_IKE_PRF_PLUS_DERIVE mechanism.
  313. * The fields of the structure have the following meanings:
  314. * prfMechanism underlying MAC mechanism used to generate the prf.
  315. * bHasSeedKey hSeed key is present.
  316. * hSeedKey optional seed from key
  317. * pSeedData optional seed from data.
  318. * ulSeedDataLen length of optional seed data.
  319. * If no seed data is present this value is NULL.
  320. */
  321. typedef struct CK_NSS_IKE_PRF_PLUS_DERIVE_PARAMS {
  322. CK_MECHANISM_TYPE prfMechanism;
  323. CK_BBOOL bHasSeedKey;
  324. CK_OBJECT_HANDLE hSeedKey;
  325. CK_BYTE_PTR pSeedData;
  326. CK_ULONG ulSeedDataLen;
  327. } CK_NSS_IKE_PRF_PLUS_DERIVE_PARAMS;
  328. /* CK_NSS_IKE_PRF_DERIVE_PARAMS is a structure that provides the parameters to
  329. * the CKM_NSS_IKE_PRF_DERIVE mechanism.
  330. *
  331. * The fields of the structure have the following meanings:
  332. * prfMechanism underlying MAC mechanism used to generate the prf.
  333. * bRekey hNewKey is present.
  334. * pNi Ni value
  335. * ulNiLen length of Ni
  336. * pNr Nr value
  337. * ulNrLen length of Nr
  338. * hNewKey New key value to drive the rekey.
  339. */
  340. typedef struct CK_NSS_IKE_PRF_DERIVE_PARAMS {
  341. CK_MECHANISM_TYPE prfMechanism;
  342. CK_BBOOL bDataAsKey;
  343. CK_BBOOL bRekey;
  344. CK_BYTE_PTR pNi;
  345. CK_ULONG ulNiLen;
  346. CK_BYTE_PTR pNr;
  347. CK_ULONG ulNrLen;
  348. CK_OBJECT_HANDLE hNewKey;
  349. } CK_NSS_IKE_PRF_DERIVE_PARAMS;
  350. /* CK_NSS_IKE1_PRF_DERIVE_PARAMS is a structure that provides the parameters
  351. * to the CKM_NSS_IKE_PRF_DERIVE mechanism.
  352. *
  353. * The fields of the structure have the following meanings:
  354. * prfMechanism underlying MAC mechanism used to generate the prf.
  355. * bRekey hNewKey is present.
  356. * pCKYi CKYi value
  357. * ulCKYiLen length of CKYi
  358. * pCKYr CKYr value
  359. * ulCKYrLen length of CKYr
  360. * hNewKey New key value to drive the rekey.
  361. */
  362. typedef struct CK_NSS_IKE1_PRF_DERIVE_PARAMS {
  363. CK_MECHANISM_TYPE prfMechanism;
  364. CK_BBOOL bHasPrevKey;
  365. CK_OBJECT_HANDLE hKeygxy;
  366. CK_OBJECT_HANDLE hPrevKey;
  367. CK_BYTE_PTR pCKYi;
  368. CK_ULONG ulCKYiLen;
  369. CK_BYTE_PTR pCKYr;
  370. CK_ULONG ulCKYrLen;
  371. CK_BYTE keyNumber;
  372. } CK_NSS_IKE1_PRF_DERIVE_PARAMS;
  373. /* CK_NSS_IKE1_APP_B_PRF_DERIVE_PARAMS is a structure that provides the
  374. * parameters to the CKM_NSS_IKE_APP_B_PRF_DERIVE mechanism.
  375. *
  376. * The fields of the structure have the following meanings:
  377. * prfMechanism underlying MAC mechanism used to generate the prf.
  378. * bHasKeygxy hKeygxy exists
  379. * hKeygxy optional key to hash in the prf
  380. * pExtraData optional extra data to hash in the prf
  381. * ulExtraData length of the optional extra data.
  382. *
  383. * CK_NSS_IKE_APP_B_PRF_DERIVE can take wither CK_NSS_IKE1_APP_B_PRF_DRIVE_PARAMS
  384. * or a single CK_MECHANISM_TYPE. In the latter cases bHashKeygx is assumed to
  385. * be false and ulExtraDataLen is assumed to be '0'.
  386. */
  387. typedef struct CK_NSS_IKE1_APP_B_PRF_DERIVE_PARAMS {
  388. CK_MECHANISM_TYPE prfMechanism;
  389. CK_BBOOL bHasKeygxy;
  390. CK_OBJECT_HANDLE hKeygxy;
  391. CK_BYTE_PTR pExtraData;
  392. CK_ULONG ulExtraDataLen;
  393. } CK_NSS_IKE1_APP_B_PRF_DERIVE_PARAMS;
  394. /*
  395. * Parameter for the TLS extended master secret key derivation mechanisms:
  396. *
  397. * * CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE
  398. * * CKM_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_DH
  399. *
  400. * For the TLS 1.2 PRF, the prfHashMechanism parameter determines the hash
  401. * function used. For earlier versions of the PRF, set the prfHashMechanism
  402. * value to CKM_TLS_PRF.
  403. *
  404. * The session hash input is expected to be the output of the same hash
  405. * function as the PRF uses (as required by draft-ietf-tls-session-hash). So
  406. * the ulSessionHashLen member must be equal the output length of the hash
  407. * function specified by the prfHashMechanism member (or, for pre-TLS 1.2 PRF,
  408. * the length of concatenated MD5 and SHA-1 digests).
  409. *
  410. */
  411. typedef struct CK_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_PARAMS {
  412. CK_MECHANISM_TYPE prfHashMechanism;
  413. CK_BYTE_PTR pSessionHash;
  414. CK_ULONG ulSessionHashLen;
  415. CK_VERSION_PTR pVersion;
  416. } CK_NSS_TLS_EXTENDED_MASTER_KEY_DERIVE_PARAMS;
  417. /*
  418. * Trust info
  419. *
  420. * This isn't part of the Cryptoki standard (yet), so I'm putting
  421. * all the definitions here. Some of this would move to nssckt.h
  422. * if trust info were made part of the standard. In view of this
  423. * possibility, I'm putting my (NSS) values in the NSS
  424. * vendor space, like everything else.
  425. */
  426. typedef CK_ULONG CK_TRUST;
  427. /* The following trust types are defined: */
  428. #define CKT_VENDOR_DEFINED 0x80000000
  429. #define CKT_NSS (CKT_VENDOR_DEFINED | NSSCK_VENDOR_NSS)
  430. /* If trust goes standard, these'll probably drop out of vendor space. */
  431. #define CKT_NSS_TRUSTED (CKT_NSS + 1)
  432. #define CKT_NSS_TRUSTED_DELEGATOR (CKT_NSS + 2)
  433. #define CKT_NSS_MUST_VERIFY_TRUST (CKT_NSS + 3)
  434. #define CKT_NSS_NOT_TRUSTED (CKT_NSS + 10)
  435. #define CKT_NSS_TRUST_UNKNOWN (CKT_NSS + 5) /* default */
  436. /*
  437. * These may well remain NSS-specific; I'm only using them
  438. * to cache resolution data.
  439. */
  440. #define CKT_NSS_VALID_DELEGATOR (CKT_NSS + 11)
  441. /*
  442. * old definitions. They still exist, but the plain meaning of the
  443. * labels have never been accurate to what was really implemented.
  444. * The new labels correctly reflect what the values effectively mean.
  445. */
  446. #if defined(__GNUC__) && (__GNUC__ > 3)
  447. /* make GCC warn when we use these #defines */
  448. /*
  449. * This is really painful because GCC doesn't allow us to mark random
  450. * #defines as deprecated. We can only mark the following:
  451. * functions, variables, and types.
  452. * const variables will create extra storage for everyone including this
  453. * header file, so it's undesirable.
  454. * functions could be inlined to prevent storage creation, but will fail
  455. * when constant values are expected (like switch statements).
  456. * enum types do not seem to pay attention to the deprecated attribute.
  457. *
  458. * That leaves typedefs. We declare new types that we then deprecate, then
  459. * cast the resulting value to the deprecated type in the #define, thus
  460. * producting the warning when the #define is used.
  461. */
  462. #if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5)
  463. /* The mac doesn't like the friendlier deprecate messages. I'm assuming this
  464. * is a gcc version issue rather than mac or ppc specific */
  465. typedef CK_TRUST __CKT_NSS_UNTRUSTED __attribute__((deprecated));
  466. typedef CK_TRUST __CKT_NSS_VALID __attribute__((deprecated));
  467. typedef CK_TRUST __CKT_NSS_MUST_VERIFY __attribute__((deprecated));
  468. #else
  469. /* when possible, get a full deprecation warning. This works on gcc 4.5
  470. * it may work on earlier versions of gcc */
  471. typedef CK_TRUST __CKT_NSS_UNTRUSTED __attribute__((deprecated("CKT_NSS_UNTRUSTED really means CKT_NSS_MUST_VERIFY_TRUST")));
  472. typedef CK_TRUST __CKT_NSS_VALID __attribute__((deprecated("CKT_NSS_VALID really means CKT_NSS_NOT_TRUSTED")));
  473. typedef CK_TRUST __CKT_NSS_MUST_VERIFY __attribute__((deprecated("CKT_NSS_MUST_VERIFY really functions as CKT_NSS_TRUST_UNKNOWN")));
  474. #endif
  475. #define CKT_NSS_UNTRUSTED ((__CKT_NSS_UNTRUSTED)CKT_NSS_MUST_VERIFY_TRUST)
  476. #define CKT_NSS_VALID ((__CKT_NSS_VALID)CKT_NSS_NOT_TRUSTED)
  477. /* keep the old value for compatibility reasons*/
  478. #define CKT_NSS_MUST_VERIFY ((__CKT_NSS_MUST_VERIFY)(CKT_NSS + 4))
  479. #else
  480. #ifdef _WIN32
  481. /* This magic gets the windows compiler to give us a deprecation
  482. * warning */
  483. #pragma deprecated(CKT_NSS_UNTRUSTED, CKT_NSS_MUST_VERIFY, CKT_NSS_VALID)
  484. #endif
  485. /* CKT_NSS_UNTRUSTED really means CKT_NSS_MUST_VERIFY_TRUST */
  486. #define CKT_NSS_UNTRUSTED CKT_NSS_MUST_VERIFY_TRUST
  487. /* CKT_NSS_VALID really means CKT_NSS_NOT_TRUSTED */
  488. #define CKT_NSS_VALID CKT_NSS_NOT_TRUSTED
  489. /* CKT_NSS_MUST_VERIFY was always treated as CKT_NSS_TRUST_UNKNOWN */
  490. #define CKT_NSS_MUST_VERIFY (CKT_NSS + 4) /*really means trust unknown*/
  491. #endif
  492. /*
  493. * These are not really PKCS #11 values specifically. They are the 'loadable'
  494. * module spec NSS uses. They are available for others to use as well, but not
  495. * part of the formal PKCS #11 spec.
  496. *
  497. * The function 'FIND' returns an array of PKCS #11 initialization strings
  498. * The function 'ADD' takes a PKCS #11 initialization string and stores it.
  499. * The function 'DEL' takes a 'name= library=' value and deletes the associated
  500. * string.
  501. * The function 'RELEASE' frees the array returned by 'FIND'
  502. */
  503. #define SECMOD_MODULE_DB_FUNCTION_FIND 0
  504. #define SECMOD_MODULE_DB_FUNCTION_ADD 1
  505. #define SECMOD_MODULE_DB_FUNCTION_DEL 2
  506. #define SECMOD_MODULE_DB_FUNCTION_RELEASE 3
  507. typedef char **(PR_CALLBACK *SECMODModuleDBFunc)(unsigned long function,
  508. char *parameters, void *moduleSpec);
  509. /* softoken slot ID's */
  510. #define SFTK_MIN_USER_SLOT_ID 4
  511. #define SFTK_MAX_USER_SLOT_ID 100
  512. #define SFTK_MIN_FIPS_USER_SLOT_ID 101
  513. #define SFTK_MAX_FIPS_USER_SLOT_ID 127
  514. /* Module Interface. This is the old NSS private module interface, now exported
  515. * as a PKCS #11 v3 interface. It's interface name is
  516. * "Vendor NSS Module Interface" */
  517. typedef char **(*CK_NSS_ModuleDBFunc)(unsigned long function,
  518. char *parameters, void *args);
  519. typedef struct CK_NSS_MODULE_FUNCTIONS {
  520. CK_VERSION version;
  521. CK_NSS_ModuleDBFunc NSC_ModuleDBFunc;
  522. } CK_NSS_MODULE_FUNCTIONS;
  523. /* There was an inconsistency between the spec and the header file in defining
  524. * the CK_GCM_PARAMS structure. The authoritative reference is the header file,
  525. * but NSS used the spec when adding it to its own header. In V3 we've
  526. * corrected it, but we need to handle the old case for devices that followed
  527. * us in using the incorrect specification. */
  528. typedef struct CK_NSS_GCM_PARAMS {
  529. CK_BYTE_PTR pIv;
  530. CK_ULONG ulIvLen;
  531. CK_BYTE_PTR pAAD;
  532. CK_ULONG ulAADLen;
  533. CK_ULONG ulTagBits;
  534. } CK_NSS_GCM_PARAMS;
  535. typedef CK_NSS_GCM_PARAMS CK_PTR CK_NSS_GCM_PARAMS_PTR;
  536. /* deprecated #defines. Drop in future NSS releases */
  537. #ifdef NSS_PKCS11_2_0_COMPAT
  538. /* defines that were changed between NSS's PKCS #11 and the Oasis headers */
  539. #define CKF_EC_FP CKF_EC_F_P
  540. #define CKO_KG_PARAMETERS CKO_DOMAIN_PARAMETERS
  541. #define CK_INVALID_SESSION CK_INVALID_HANDLE
  542. #define CKR_KEY_PARAMS_INVALID 0x0000006B
  543. /* use the old wrong CK_GCM_PARAMS is NSS_PCKS11_2_0_COMPAT is defined */
  544. typedef struct CK_NSS_GCM_PARAMS CK_GCM_PARAMS;
  545. typedef CK_NSS_GCM_PARAMS CK_PTR CK_GCM_PARAMS_PTR;
  546. /* don't leave old programs in a lurch just yet, give them the old NETSCAPE
  547. * synonym if NSS_PKCS11_2_0_COMPAT is defined*/
  548. #define CKO_NETSCAPE_CRL CKO_NSS_CRL
  549. #define CKO_NETSCAPE_SMIME CKO_NSS_SMIME
  550. #define CKO_NETSCAPE_TRUST CKO_NSS_TRUST
  551. #define CKO_NETSCAPE_BUILTIN_ROOT_LIST CKO_NSS_BUILTIN_ROOT_LIST
  552. #define CKO_NETSCAPE_NEWSLOT CKO_NSS_NEWSLOT
  553. #define CKO_NETSCAPE_DELSLOT CKO_NSS_DELSLOT
  554. #define CKK_NETSCAPE_PKCS8 CKK_NSS_PKCS8
  555. #define CKA_NETSCAPE_URL CKA_NSS_URL
  556. #define CKA_NETSCAPE_EMAIL CKA_NSS_EMAIL
  557. #define CKA_NETSCAPE_SMIME_INFO CKA_NSS_SMIME_INFO
  558. #define CKA_NETSCAPE_SMIME_TIMESTAMP CKA_NSS_SMIME_TIMESTAMP
  559. #define CKA_NETSCAPE_PKCS8_SALT CKA_NSS_PKCS8_SALT
  560. #define CKA_NETSCAPE_PASSWORD_CHECK CKA_NSS_PASSWORD_CHECK
  561. #define CKA_NETSCAPE_EXPIRES CKA_NSS_EXPIRES
  562. #define CKA_NETSCAPE_KRL CKA_NSS_KRL
  563. #define CKA_NETSCAPE_PQG_COUNTER CKA_NSS_PQG_COUNTER
  564. #define CKA_NETSCAPE_PQG_SEED CKA_NSS_PQG_SEED
  565. #define CKA_NETSCAPE_PQG_H CKA_NSS_PQG_H
  566. #define CKA_NETSCAPE_PQG_SEED_BITS CKA_NSS_PQG_SEED_BITS
  567. #define CKA_NETSCAPE_MODULE_SPEC CKA_NSS_MODULE_SPEC
  568. #define CKA_NETSCAPE_DB CKA_NSS_DB
  569. #define CKA_NETSCAPE_TRUST CKA_NSS_TRUST
  570. #define CKM_NETSCAPE_AES_KEY_WRAP CKM_NSS_AES_KEY_WRAP
  571. #define CKM_NETSCAPE_AES_KEY_WRAP_PAD CKM_NSS_AES_KEY_WRAP_PAD
  572. #define CKM_NETSCAPE_PBE_SHA1_DES_CBC CKM_NSS_PBE_SHA1_DES_CBC
  573. #define CKM_NETSCAPE_PBE_SHA1_TRIPLE_DES_CBC CKM_NSS_PBE_SHA1_TRIPLE_DES_CBC
  574. #define CKM_NETSCAPE_PBE_SHA1_40_BIT_RC2_CBC CKM_NSS_PBE_SHA1_40_BIT_RC2_CBC
  575. #define CKM_NETSCAPE_PBE_SHA1_128_BIT_RC2_CBC CKM_NSS_PBE_SHA1_128_BIT_RC2_CBC
  576. #define CKM_NETSCAPE_PBE_SHA1_40_BIT_RC4 CKM_NSS_PBE_SHA1_40_BIT_RC4
  577. #define CKM_NETSCAPE_PBE_SHA1_128_BIT_RC4 CKM_NSS_PBE_SHA1_128_BIT_RC4
  578. #define CKM_NETSCAPE_PBE_SHA1_FAULTY_3DES_CBC CKM_NSS_PBE_SHA1_FAULTY_3DES_CBC
  579. #define CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN CKM_NSS_PBE_SHA1_HMAC_KEY_GEN
  580. #define CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN CKM_NSS_PBE_MD5_HMAC_KEY_GEN
  581. #define CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN CKM_NSS_PBE_MD2_HMAC_KEY_GEN
  582. #define CKR_NETSCAPE_CERTDB_FAILED CKR_NSS_CERTDB_FAILED
  583. #define CKR_NETSCAPE_KEYDB_FAILED CKR_NSS_KEYDB_FAILED
  584. #define CKT_NETSCAPE_TRUSTED CKT_NSS_TRUSTED
  585. #define CKT_NETSCAPE_TRUSTED_DELEGATOR CKT_NSS_TRUSTED_DELEGATOR
  586. #define CKT_NETSCAPE_UNTRUSTED CKT_NSS_UNTRUSTED
  587. #define CKT_NETSCAPE_MUST_VERIFY CKT_NSS_MUST_VERIFY
  588. #define CKT_NETSCAPE_TRUST_UNKNOWN CKT_NSS_TRUST_UNKNOWN
  589. #define CKT_NETSCAPE_VALID CKT_NSS_VALID
  590. #define CKT_NETSCAPE_VALID_DELEGATOR CKT_NSS_VALID_DELEGATOR
  591. #else
  592. /* use the new CK_GCM_PARAMS if NSS_PKCS11_2_0_COMPAT is not defined */
  593. typedef struct CK_GCM_PARAMS_V3 CK_GCM_PARAMS;
  594. typedef CK_GCM_PARAMS_V3 CK_PTR CK_GCM_PARAMS_PTR;
  595. #endif
  596. #endif /* _PKCS11N_H_ */