pkcs11.h 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  1. /* pkcs11.h
  2. Copyright 2006, 2007 g10 Code GmbH
  3. Copyright 2006 Andreas Jellinghaus
  4. Copyright 2017 Red Hat, Inc.
  5. This file is free software; as a special exception the author gives
  6. unlimited permission to copy and/or distribute it, with or without
  7. modifications, as long as this notice is preserved.
  8. This file is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY, to the extent permitted by law; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. */
  12. /* Please submit any changes back to the p11-kit project at
  13. https://github.com/p11-glue/p11-kit/, so that
  14. they can be picked up by other projects from there as well. */
  15. /* This file is a modified implementation of the PKCS #11 standard by
  16. OASIS group. It is mostly a drop-in replacement, with the
  17. following change:
  18. This header file does not require any macro definitions by the user
  19. (like CK_DEFINE_FUNCTION etc). In fact, it defines those macros
  20. for you (if useful, some are missing, let me know if you need
  21. more).
  22. There is an additional API available that does comply better to the
  23. GNU coding standard. It can be switched on by defining
  24. CRYPTOKI_GNU before including this header file. For this, the
  25. following changes are made to the specification:
  26. All structure types are changed to a "struct ck_foo" where CK_FOO
  27. is the type name in PKCS #11.
  28. All non-structure types are changed to ck_foo_t where CK_FOO is the
  29. lowercase version of the type name in PKCS #11. The basic types
  30. (CK_ULONG et al.) are removed without substitute.
  31. All members of structures are modified in the following way: Type
  32. indication prefixes are removed, and underscore characters are
  33. inserted before words. Then the result is lowercased.
  34. Note that function names are still in the original case, as they
  35. need for ABI compatibility.
  36. CK_FALSE, CK_TRUE and NULL_PTR are removed without substitute. Use
  37. <stdbool.h>.
  38. If CRYPTOKI_COMPAT is defined before including this header file,
  39. then none of the API changes above take place, and the API is the
  40. one defined by the PKCS #11 standard. */
  41. #ifndef PKCS11_H
  42. #define PKCS11_H 1
  43. #if defined(__cplusplus)
  44. extern "C" {
  45. #endif
  46. /* The version of cryptoki we implement. The revision is changed with
  47. each modification of this file. */
  48. #define CRYPTOKI_VERSION_MAJOR 2
  49. #define CRYPTOKI_VERSION_MINOR 40
  50. #define P11_KIT_CRYPTOKI_VERSION_REVISION 0
  51. /* Compatibility interface is default, unless CRYPTOKI_GNU is
  52. given. */
  53. #ifndef CRYPTOKI_GNU
  54. #ifndef CRYPTOKI_COMPAT
  55. #define CRYPTOKI_COMPAT 1
  56. #endif
  57. #endif
  58. /* System dependencies. */
  59. #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32)
  60. /* There is a matching pop below. */
  61. #pragma pack(push, cryptoki, 1)
  62. #ifdef CRYPTOKI_EXPORTS
  63. #define CK_SPEC __declspec(dllexport)
  64. #else
  65. #define CK_SPEC __declspec(dllimport)
  66. #endif
  67. #else
  68. #define CK_SPEC
  69. #endif
  70. #ifdef CRYPTOKI_COMPAT
  71. /* If we are in compatibility mode, switch all exposed names to the
  72. PKCS #11 variant. There are corresponding #undefs below. */
  73. #define ck_flags_t CK_FLAGS
  74. #define ck_version _CK_VERSION
  75. #define ck_info _CK_INFO
  76. #define cryptoki_version cryptokiVersion
  77. #define manufacturer_id manufacturerID
  78. #define library_description libraryDescription
  79. #define library_version libraryVersion
  80. #define ck_notification_t CK_NOTIFICATION
  81. #define ck_slot_id_t CK_SLOT_ID
  82. #define ck_slot_info _CK_SLOT_INFO
  83. #define slot_description slotDescription
  84. #define hardware_version hardwareVersion
  85. #define firmware_version firmwareVersion
  86. #define ck_token_info _CK_TOKEN_INFO
  87. #define serial_number serialNumber
  88. #define max_session_count ulMaxSessionCount
  89. #define session_count ulSessionCount
  90. #define max_rw_session_count ulMaxRwSessionCount
  91. #define rw_session_count ulRwSessionCount
  92. #define max_pin_len ulMaxPinLen
  93. #define min_pin_len ulMinPinLen
  94. #define total_public_memory ulTotalPublicMemory
  95. #define free_public_memory ulFreePublicMemory
  96. #define total_private_memory ulTotalPrivateMemory
  97. #define free_private_memory ulFreePrivateMemory
  98. #define utc_time utcTime
  99. #define ck_session_handle_t CK_SESSION_HANDLE
  100. #define ck_user_type_t CK_USER_TYPE
  101. #define ck_state_t CK_STATE
  102. #define ck_session_info _CK_SESSION_INFO
  103. #define slot_id slotID
  104. #define device_error ulDeviceError
  105. #define ck_object_handle_t CK_OBJECT_HANDLE
  106. #define ck_object_class_t CK_OBJECT_CLASS
  107. #define ck_hw_feature_type_t CK_HW_FEATURE_TYPE
  108. #define ck_key_type_t CK_KEY_TYPE
  109. #define ck_certificate_type_t CK_CERTIFICATE_TYPE
  110. #define ck_attribute_type_t CK_ATTRIBUTE_TYPE
  111. #define ck_attribute _CK_ATTRIBUTE
  112. #define value pValue
  113. #define value_len ulValueLen
  114. #define count ulCount
  115. #define ck_date _CK_DATE
  116. #define ck_mechanism_type_t CK_MECHANISM_TYPE
  117. #define ck_mechanism _CK_MECHANISM
  118. #define parameter pParameter
  119. #define parameter_len ulParameterLen
  120. #define params pParams
  121. #define ck_mechanism_info _CK_MECHANISM_INFO
  122. #define min_key_size ulMinKeySize
  123. #define max_key_size ulMaxKeySize
  124. #define ck_param_type CK_PARAM_TYPE
  125. #define ck_otp_param CK_OTP_PARAM
  126. #define ck_otp_params CK_OTP_PARAMS
  127. #define ck_otp_signature_info CK_OTP_SIGNATURE_INFO
  128. #define ck_rv_t CK_RV
  129. #define ck_notify_t CK_NOTIFY
  130. #define ck_function_list _CK_FUNCTION_LIST
  131. #define ck_createmutex_t CK_CREATEMUTEX
  132. #define ck_destroymutex_t CK_DESTROYMUTEX
  133. #define ck_lockmutex_t CK_LOCKMUTEX
  134. #define ck_unlockmutex_t CK_UNLOCKMUTEX
  135. #define ck_c_initialize_args _CK_C_INITIALIZE_ARGS
  136. #define create_mutex CreateMutex
  137. #define destroy_mutex DestroyMutex
  138. #define lock_mutex LockMutex
  139. #define unlock_mutex UnlockMutex
  140. #define reserved pReserved
  141. #define ck_rsa_pkcs_mgf_type_t CK_RSA_PKCS_MGF_TYPE
  142. #define ck_rsa_pkcs_oaep_source_type_t CK_RSA_PKCS_OAEP_SOURCE_TYPE
  143. #define hash_alg hashAlg
  144. #define s_len sLen
  145. #define source_data pSourceData
  146. #define source_data_len ulSourceDataLen
  147. #define counter_bits ulCounterBits
  148. #define iv_ptr pIv
  149. #define iv_len ulIvLen
  150. #define iv_bits ulIvBits
  151. #define aad_ptr pAAD
  152. #define aad_len ulAADLen
  153. #define tag_bits ulTagBits
  154. #define shared_data_len ulSharedDataLen
  155. #define shared_data pSharedData
  156. #define public_data_len ulPublicDataLen
  157. #define public_data pPublicData
  158. #define string_data pData
  159. #define string_data_len ulLen
  160. #define data_params pData
  161. #endif /* CRYPTOKI_COMPAT */
  162. typedef unsigned long ck_flags_t;
  163. struct ck_version
  164. {
  165. unsigned char major;
  166. unsigned char minor;
  167. };
  168. struct ck_info
  169. {
  170. struct ck_version cryptoki_version;
  171. unsigned char manufacturer_id[32];
  172. ck_flags_t flags;
  173. unsigned char library_description[32];
  174. struct ck_version library_version;
  175. };
  176. typedef unsigned long ck_notification_t;
  177. #define CKN_SURRENDER (0UL)
  178. typedef unsigned long ck_slot_id_t;
  179. struct ck_slot_info
  180. {
  181. unsigned char slot_description[64];
  182. unsigned char manufacturer_id[32];
  183. ck_flags_t flags;
  184. struct ck_version hardware_version;
  185. struct ck_version firmware_version;
  186. };
  187. #define CKF_TOKEN_PRESENT (1UL << 0)
  188. #define CKF_REMOVABLE_DEVICE (1UL << 1)
  189. #define CKF_HW_SLOT (1UL << 2)
  190. #define CKF_ARRAY_ATTRIBUTE (1UL << 30)
  191. struct ck_token_info
  192. {
  193. unsigned char label[32];
  194. unsigned char manufacturer_id[32];
  195. unsigned char model[16];
  196. unsigned char serial_number[16];
  197. ck_flags_t flags;
  198. unsigned long max_session_count;
  199. unsigned long session_count;
  200. unsigned long max_rw_session_count;
  201. unsigned long rw_session_count;
  202. unsigned long max_pin_len;
  203. unsigned long min_pin_len;
  204. unsigned long total_public_memory;
  205. unsigned long free_public_memory;
  206. unsigned long total_private_memory;
  207. unsigned long free_private_memory;
  208. struct ck_version hardware_version;
  209. struct ck_version firmware_version;
  210. unsigned char utc_time[16];
  211. };
  212. #define CKF_RNG (1UL << 0)
  213. #define CKF_WRITE_PROTECTED (1UL << 1)
  214. #define CKF_LOGIN_REQUIRED (1UL << 2)
  215. #define CKF_USER_PIN_INITIALIZED (1UL << 3)
  216. #define CKF_RESTORE_KEY_NOT_NEEDED (1UL << 5)
  217. #define CKF_CLOCK_ON_TOKEN (1UL << 6)
  218. #define CKF_PROTECTED_AUTHENTICATION_PATH (1UL << 8)
  219. #define CKF_DUAL_CRYPTO_OPERATIONS (1UL << 9)
  220. #define CKF_TOKEN_INITIALIZED (1UL << 10)
  221. #define CKF_SECONDARY_AUTHENTICATION (1UL << 11)
  222. #define CKF_USER_PIN_COUNT_LOW (1UL << 16)
  223. #define CKF_USER_PIN_FINAL_TRY (1UL << 17)
  224. #define CKF_USER_PIN_LOCKED (1UL << 18)
  225. #define CKF_USER_PIN_TO_BE_CHANGED (1UL << 19)
  226. #define CKF_SO_PIN_COUNT_LOW (1UL << 20)
  227. #define CKF_SO_PIN_FINAL_TRY (1UL << 21)
  228. #define CKF_SO_PIN_LOCKED (1UL << 22)
  229. #define CKF_SO_PIN_TO_BE_CHANGED (1UL << 23)
  230. #define CK_UNAVAILABLE_INFORMATION ((unsigned long)-1L)
  231. #define CK_EFFECTIVELY_INFINITE (0UL)
  232. typedef unsigned long ck_session_handle_t;
  233. #define CK_INVALID_HANDLE (0UL)
  234. typedef unsigned long ck_user_type_t;
  235. #define CKU_SO (0UL)
  236. #define CKU_USER (1UL)
  237. #define CKU_CONTEXT_SPECIFIC (2UL)
  238. typedef unsigned long ck_state_t;
  239. #define CKS_RO_PUBLIC_SESSION (0UL)
  240. #define CKS_RO_USER_FUNCTIONS (1UL)
  241. #define CKS_RW_PUBLIC_SESSION (2UL)
  242. #define CKS_RW_USER_FUNCTIONS (3UL)
  243. #define CKS_RW_SO_FUNCTIONS (4UL)
  244. struct ck_session_info
  245. {
  246. ck_slot_id_t slot_id;
  247. ck_state_t state;
  248. ck_flags_t flags;
  249. unsigned long device_error;
  250. };
  251. #define CKF_RW_SESSION (1UL << 1)
  252. #define CKF_SERIAL_SESSION (1UL << 2)
  253. typedef unsigned long ck_object_handle_t;
  254. typedef unsigned long ck_object_class_t;
  255. #define CKO_DATA (0UL)
  256. #define CKO_CERTIFICATE (1UL)
  257. #define CKO_PUBLIC_KEY (2UL)
  258. #define CKO_PRIVATE_KEY (3UL)
  259. #define CKO_SECRET_KEY (4UL)
  260. #define CKO_HW_FEATURE (5UL)
  261. #define CKO_DOMAIN_PARAMETERS (6UL)
  262. #define CKO_MECHANISM (7UL)
  263. #define CKO_OTP_KEY (8UL)
  264. #define CKO_VENDOR_DEFINED ((unsigned long) (1UL << 31))
  265. typedef unsigned long ck_hw_feature_type_t;
  266. #define CKH_MONOTONIC_COUNTER (1UL)
  267. #define CKH_CLOCK (2UL)
  268. #define CKH_USER_INTERFACE (3UL)
  269. #define CKH_VENDOR_DEFINED ((unsigned long) (1UL << 31))
  270. typedef unsigned long ck_key_type_t;
  271. #define CKK_RSA (0UL)
  272. #define CKK_DSA (1UL)
  273. #define CKK_DH (2UL)
  274. #define CKK_ECDSA (3UL)
  275. #define CKK_EC (3UL)
  276. #define CKK_X9_42_DH (4UL)
  277. #define CKK_KEA (5UL)
  278. #define CKK_GENERIC_SECRET (0x10UL)
  279. #define CKK_RC2 (0x11UL)
  280. #define CKK_RC4 (0x12UL)
  281. #define CKK_DES (0x13UL)
  282. #define CKK_DES2 (0x14UL)
  283. #define CKK_DES3 (0x15UL)
  284. #define CKK_CAST (0x16UL)
  285. #define CKK_CAST3 (0x17UL)
  286. #define CKK_CAST128 (0x18UL)
  287. #define CKK_RC5 (0x19UL)
  288. #define CKK_IDEA (0x1aUL)
  289. #define CKK_SKIPJACK (0x1bUL)
  290. #define CKK_BATON (0x1cUL)
  291. #define CKK_JUNIPER (0x1dUL)
  292. #define CKK_CDMF (0x1eUL)
  293. #define CKK_AES (0x1fUL)
  294. #define CKK_BLOWFISH (0x20UL)
  295. #define CKK_TWOFISH (0x21UL)
  296. #define CKK_SECURID (0x22UL)
  297. #define CKK_HOTP (0x23UL)
  298. #define CKK_ACTI (0x24UL)
  299. #define CKK_CAMELLIA (0x25UL)
  300. #define CKK_ARIA (0x26UL)
  301. #define CKK_MD5_HMAC (0x27UL)
  302. #define CKK_SHA_1_HMAC (0x28UL)
  303. #define CKK_RIPEMD128_HMAC (0x29UL)
  304. #define CKK_RIPEMD160_HMAC (0x2aUL)
  305. #define CKK_SHA256_HMAC (0x2bUL)
  306. #define CKK_SHA384_HMAC (0x2cUL)
  307. #define CKK_SHA512_HMAC (0x2dUL)
  308. #define CKK_SHA224_HMAC (0x2eUL)
  309. #define CKK_SEED (0x2fUL)
  310. #define CKK_GOSTR3410 (0x30UL)
  311. #define CKK_GOSTR3411 (0x31UL)
  312. #define CKK_GOST28147 (0x32UL)
  313. #define CKK_EC_EDWARDS (0x40UL)
  314. #define CKK_VENDOR_DEFINED ((unsigned long) (1UL << 31))
  315. typedef unsigned long ck_certificate_type_t;
  316. #define CKC_X_509 (0UL)
  317. #define CKC_X_509_ATTR_CERT (1UL)
  318. #define CKC_WTLS (2UL)
  319. #define CKC_VENDOR_DEFINED ((unsigned long) (1UL << 31))
  320. #define CKC_OPENPGP (CKC_VENDOR_DEFINED|0x504750UL)
  321. typedef unsigned long ck_attribute_type_t;
  322. #define CKA_CLASS (0UL)
  323. #define CKA_TOKEN (1UL)
  324. #define CKA_PRIVATE (2UL)
  325. #define CKA_LABEL (3UL)
  326. #define CKA_APPLICATION (0x10UL)
  327. #define CKA_VALUE (0x11UL)
  328. #define CKA_OBJECT_ID (0x12UL)
  329. #define CKA_CERTIFICATE_TYPE (0x80UL)
  330. #define CKA_ISSUER (0x81UL)
  331. #define CKA_SERIAL_NUMBER (0x82UL)
  332. #define CKA_AC_ISSUER (0x83UL)
  333. #define CKA_OWNER (0x84UL)
  334. #define CKA_ATTR_TYPES (0x85UL)
  335. #define CKA_TRUSTED (0x86UL)
  336. #define CKA_CERTIFICATE_CATEGORY (0x87UL)
  337. #define CKA_JAVA_MIDP_SECURITY_DOMAIN (0x88UL)
  338. #define CKA_URL (0x89UL)
  339. #define CKA_HASH_OF_SUBJECT_PUBLIC_KEY (0x8aUL)
  340. #define CKA_HASH_OF_ISSUER_PUBLIC_KEY (0x8bUL)
  341. #define CKA_NAME_HASH_ALGORITHM (0x8cUL)
  342. #define CKA_CHECK_VALUE (0x90UL)
  343. #define CKA_KEY_TYPE (0x100UL)
  344. #define CKA_SUBJECT (0x101UL)
  345. #define CKA_ID (0x102UL)
  346. #define CKA_SENSITIVE (0x103UL)
  347. #define CKA_ENCRYPT (0x104UL)
  348. #define CKA_DECRYPT (0x105UL)
  349. #define CKA_WRAP (0x106UL)
  350. #define CKA_UNWRAP (0x107UL)
  351. #define CKA_SIGN (0x108UL)
  352. #define CKA_SIGN_RECOVER (0x109UL)
  353. #define CKA_VERIFY (0x10aUL)
  354. #define CKA_VERIFY_RECOVER (0x10bUL)
  355. #define CKA_DERIVE (0x10cUL)
  356. #define CKA_START_DATE (0x110UL)
  357. #define CKA_END_DATE (0x111UL)
  358. #define CKA_MODULUS (0x120UL)
  359. #define CKA_MODULUS_BITS (0x121UL)
  360. #define CKA_PUBLIC_EXPONENT (0x122UL)
  361. #define CKA_PRIVATE_EXPONENT (0x123UL)
  362. #define CKA_PRIME_1 (0x124UL)
  363. #define CKA_PRIME_2 (0x125UL)
  364. #define CKA_EXPONENT_1 (0x126UL)
  365. #define CKA_EXPONENT_2 (0x127UL)
  366. #define CKA_COEFFICIENT (0x128UL)
  367. #define CKA_PUBLIC_KEY_INFO (0x129UL)
  368. #define CKA_PRIME (0x130UL)
  369. #define CKA_SUBPRIME (0x131UL)
  370. #define CKA_BASE (0x132UL)
  371. #define CKA_PRIME_BITS (0x133UL)
  372. #define CKA_SUB_PRIME_BITS (0x134UL)
  373. #define CKA_VALUE_BITS (0x160UL)
  374. #define CKA_VALUE_LEN (0x161UL)
  375. #define CKA_EXTRACTABLE (0x162UL)
  376. #define CKA_LOCAL (0x163UL)
  377. #define CKA_NEVER_EXTRACTABLE (0x164UL)
  378. #define CKA_ALWAYS_SENSITIVE (0x165UL)
  379. #define CKA_KEY_GEN_MECHANISM (0x166UL)
  380. #define CKA_MODIFIABLE (0x170UL)
  381. #define CKA_COPYABLE (0x171UL)
  382. #define CKA_DESTROYABLE (0x172UL)
  383. #define CKA_ECDSA_PARAMS (0x180UL)
  384. #define CKA_EC_PARAMS (0x180UL)
  385. #define CKA_EC_POINT (0x181UL)
  386. #define CKA_SECONDARY_AUTH (0x200UL)
  387. #define CKA_AUTH_PIN_FLAGS (0x201UL)
  388. #define CKA_ALWAYS_AUTHENTICATE (0x202UL)
  389. #define CKA_WRAP_WITH_TRUSTED (0x210UL)
  390. #define CKA_OTP_FORMAT (0x220UL)
  391. #define CKA_OTP_LENGTH (0x221UL)
  392. #define CKA_OTP_TIME_INTERVAL (0x222UL)
  393. #define CKA_OTP_USER_FRIENDLY_MODE (0x223UL)
  394. #define CKA_OTP_CHALLENGE_REQUIREMENT (0x224UL)
  395. #define CKA_OTP_TIME_REQUIREMENT (0x225UL)
  396. #define CKA_OTP_COUNTER_REQUIREMENT (0x226UL)
  397. #define CKA_OTP_PIN_REQUIREMENT (0x227UL)
  398. #define CKA_OTP_USER_IDENTIFIER (0x22AUL)
  399. #define CKA_OTP_SERVICE_IDENTIFIER (0x22BUL)
  400. #define CKA_OTP_SERVICE_LOGO (0x22CUL)
  401. #define CKA_OTP_SERVICE_LOGO_TYPE (0x22DUL)
  402. #define CKA_OTP_COUNTER (0x22EUL)
  403. #define CKA_OTP_TIME (0x22FUL)
  404. #define CKA_GOSTR3410_PARAMS (0x250UL)
  405. #define CKA_GOSTR3411_PARAMS (0x251UL)
  406. #define CKA_GOST28147_PARAMS (0x252UL)
  407. #define CKA_HW_FEATURE_TYPE (0x300UL)
  408. #define CKA_RESET_ON_INIT (0x301UL)
  409. #define CKA_HAS_RESET (0x302UL)
  410. #define CKA_PIXEL_X (0x400UL)
  411. #define CKA_PIXEL_Y (0x401UL)
  412. #define CKA_RESOLUTION (0x402UL)
  413. #define CKA_CHAR_ROWS (0x403UL)
  414. #define CKA_CHAR_COLUMNS (0x404UL)
  415. #define CKA_COLOR (0x405UL)
  416. #define CKA_BITS_PER_PIXEL (0x406UL)
  417. #define CKA_CHAR_SETS (0x480UL)
  418. #define CKA_ENCODING_METHODS (0x481UL)
  419. #define CKA_MIME_TYPES (0x482UL)
  420. #define CKA_MECHANISM_TYPE (0x500UL)
  421. #define CKA_REQUIRED_CMS_ATTRIBUTES (0x501UL)
  422. #define CKA_DEFAULT_CMS_ATTRIBUTES (0x502UL)
  423. #define CKA_SUPPORTED_CMS_ATTRIBUTES (0x503UL)
  424. #define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x211UL)
  425. #define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x212UL)
  426. #define CKA_DERIVE_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x213UL)
  427. #define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x600UL)
  428. #define CKA_VENDOR_DEFINED ((unsigned long) (1UL << 31))
  429. struct ck_attribute
  430. {
  431. ck_attribute_type_t type;
  432. void *value;
  433. unsigned long value_len;
  434. };
  435. struct ck_date
  436. {
  437. unsigned char year[4];
  438. unsigned char month[2];
  439. unsigned char day[2];
  440. };
  441. typedef unsigned long ck_mechanism_type_t;
  442. #define CKM_RSA_PKCS_KEY_PAIR_GEN (0UL)
  443. #define CKM_RSA_PKCS (1UL)
  444. #define CKM_RSA_9796 (2UL)
  445. #define CKM_RSA_X_509 (3UL)
  446. #define CKM_MD2_RSA_PKCS (4UL)
  447. #define CKM_MD5_RSA_PKCS (5UL)
  448. #define CKM_SHA1_RSA_PKCS (6UL)
  449. #define CKM_RIPEMD128_RSA_PKCS (7UL)
  450. #define CKM_RIPEMD160_RSA_PKCS (8UL)
  451. #define CKM_RSA_PKCS_OAEP (9UL)
  452. #define CKM_RSA_X9_31_KEY_PAIR_GEN (0xaUL)
  453. #define CKM_RSA_X9_31 (0xbUL)
  454. #define CKM_SHA1_RSA_X9_31 (0xcUL)
  455. #define CKM_RSA_PKCS_PSS (0xdUL)
  456. #define CKM_SHA1_RSA_PKCS_PSS (0xeUL)
  457. #define CKM_DSA_KEY_PAIR_GEN (0x10UL)
  458. #define CKM_DSA (0x11UL)
  459. #define CKM_DSA_SHA1 (0x12UL)
  460. #define CKM_DSA_SHA224 (0x13UL)
  461. #define CKM_DSA_SHA256 (0x14UL)
  462. #define CKM_DSA_SHA384 (0x15UL)
  463. #define CKM_DSA_SHA512 (0x16UL)
  464. #define CKM_DH_PKCS_KEY_PAIR_GEN (0x20UL)
  465. #define CKM_DH_PKCS_DERIVE (0x21UL)
  466. #define CKM_X9_42_DH_KEY_PAIR_GEN (0x30UL)
  467. #define CKM_X9_42_DH_DERIVE (0x31UL)
  468. #define CKM_X9_42_DH_HYBRID_DERIVE (0x32UL)
  469. #define CKM_X9_42_MQV_DERIVE (0x33UL)
  470. #define CKM_SHA256_RSA_PKCS (0x40UL)
  471. #define CKM_SHA384_RSA_PKCS (0x41UL)
  472. #define CKM_SHA512_RSA_PKCS (0x42UL)
  473. #define CKM_SHA256_RSA_PKCS_PSS (0x43UL)
  474. #define CKM_SHA384_RSA_PKCS_PSS (0x44UL)
  475. #define CKM_SHA512_RSA_PKCS_PSS (0x45UL)
  476. #define CKM_SHA512_224 (0x48UL)
  477. #define CKM_SHA512_224_HMAC (0x49UL)
  478. #define CKM_SHA512_224_HMAC_GENERAL (0x4aUL)
  479. #define CKM_SHA512_224_KEY_DERIVATION (0x4bUL)
  480. #define CKM_SHA512_256 (0x4cUL)
  481. #define CKM_SHA512_256_HMAC (0x4dUL)
  482. #define CKM_SHA512_256_HMAC_GENERAL (0x4eUL)
  483. #define CKM_SHA512_256_KEY_DERIVATION (0x4fUL)
  484. #define CKM_SHA512_T (0x50UL)
  485. #define CKM_SHA512_T_HMAC (0x51UL)
  486. #define CKM_SHA512_T_HMAC_GENERAL (0x52UL)
  487. #define CKM_SHA512_T_KEY_DERIVATION (0x53UL)
  488. #define CKM_RC2_KEY_GEN (0x100UL)
  489. #define CKM_RC2_ECB (0x101UL)
  490. #define CKM_RC2_CBC (0x102UL)
  491. #define CKM_RC2_MAC (0x103UL)
  492. #define CKM_RC2_MAC_GENERAL (0x104UL)
  493. #define CKM_RC2_CBC_PAD (0x105UL)
  494. #define CKM_RC4_KEY_GEN (0x110UL)
  495. #define CKM_RC4 (0x111UL)
  496. #define CKM_DES_KEY_GEN (0x120UL)
  497. #define CKM_DES_ECB (0x121UL)
  498. #define CKM_DES_CBC (0x122UL)
  499. #define CKM_DES_MAC (0x123UL)
  500. #define CKM_DES_MAC_GENERAL (0x124UL)
  501. #define CKM_DES_CBC_PAD (0x125UL)
  502. #define CKM_DES2_KEY_GEN (0x130UL)
  503. #define CKM_DES3_KEY_GEN (0x131UL)
  504. #define CKM_DES3_ECB (0x132UL)
  505. #define CKM_DES3_CBC (0x133UL)
  506. #define CKM_DES3_MAC (0x134UL)
  507. #define CKM_DES3_MAC_GENERAL (0x135UL)
  508. #define CKM_DES3_CBC_PAD (0x136UL)
  509. #define CKM_DES3_CMAC_GENERAL (0x137UL)
  510. #define CKM_DES3_CMAC (0x138UL)
  511. #define CKM_CDMF_KEY_GEN (0x140UL)
  512. #define CKM_CDMF_ECB (0x141UL)
  513. #define CKM_CDMF_CBC (0x142UL)
  514. #define CKM_CDMF_MAC (0x143UL)
  515. #define CKM_CDMF_MAC_GENERAL (0x144UL)
  516. #define CKM_CDMF_CBC_PAD (0x145UL)
  517. #define CKM_DES_OFB64 (0x150UL)
  518. #define CKM_DES_OFB8 (0x151UL)
  519. #define CKM_DES_CFB64 (0x152UL)
  520. #define CKM_DES_CFB8 (0x153UL)
  521. #define CKM_MD2 (0x200UL)
  522. #define CKM_MD2_HMAC (0x201UL)
  523. #define CKM_MD2_HMAC_GENERAL (0x202UL)
  524. #define CKM_MD5 (0x210UL)
  525. #define CKM_MD5_HMAC (0x211UL)
  526. #define CKM_MD5_HMAC_GENERAL (0x212UL)
  527. #define CKM_SHA_1 (0x220UL)
  528. #define CKM_SHA_1_HMAC (0x221UL)
  529. #define CKM_SHA_1_HMAC_GENERAL (0x222UL)
  530. #define CKM_RIPEMD128 (0x230UL)
  531. #define CKM_RIPEMD128_HMAC (0x231UL)
  532. #define CKM_RIPEMD128_HMAC_GENERAL (0x232UL)
  533. #define CKM_RIPEMD160 (0x240UL)
  534. #define CKM_RIPEMD160_HMAC (0x241UL)
  535. #define CKM_RIPEMD160_HMAC_GENERAL (0x242UL)
  536. #define CKM_SHA256 (0x250UL)
  537. #define CKM_SHA256_HMAC (0x251UL)
  538. #define CKM_SHA256_HMAC_GENERAL (0x252UL)
  539. #define CKM_SHA384 (0x260UL)
  540. #define CKM_SHA384_HMAC (0x261UL)
  541. #define CKM_SHA384_HMAC_GENERAL (0x262UL)
  542. #define CKM_SHA512 (0x270UL)
  543. #define CKM_SHA512_HMAC (0x271UL)
  544. #define CKM_SHA512_HMAC_GENERAL (0x272UL)
  545. #define CKM_SECURID_KEY_GEN (0x280UL)
  546. #define CKM_SECURID (0x282UL)
  547. #define CKM_HOTP_KEY_GEN (0x290UL)
  548. #define CKM_HOTP (0x291UL)
  549. #define CKM_ACTI (0x2a0UL)
  550. #define CKM_ACTI_KEY_GEN (0x2a1UL)
  551. #define CKM_CAST_KEY_GEN (0x300UL)
  552. #define CKM_CAST_ECB (0x301UL)
  553. #define CKM_CAST_CBC (0x302UL)
  554. #define CKM_CAST_MAC (0x303UL)
  555. #define CKM_CAST_MAC_GENERAL (0x304UL)
  556. #define CKM_CAST_CBC_PAD (0x305UL)
  557. #define CKM_CAST3_KEY_GEN (0x310UL)
  558. #define CKM_CAST3_ECB (0x311UL)
  559. #define CKM_CAST3_CBC (0x312UL)
  560. #define CKM_CAST3_MAC (0x313UL)
  561. #define CKM_CAST3_MAC_GENERAL (0x314UL)
  562. #define CKM_CAST3_CBC_PAD (0x315UL)
  563. #define CKM_CAST5_KEY_GEN (0x320UL)
  564. #define CKM_CAST128_KEY_GEN (0x320UL)
  565. #define CKM_CAST5_ECB (0x321UL)
  566. #define CKM_CAST128_ECB (0x321UL)
  567. #define CKM_CAST5_CBC (0x322UL)
  568. #define CKM_CAST128_CBC (0x322UL)
  569. #define CKM_CAST5_MAC (0x323UL)
  570. #define CKM_CAST128_MAC (0x323UL)
  571. #define CKM_CAST5_MAC_GENERAL (0x324UL)
  572. #define CKM_CAST128_MAC_GENERAL (0x324UL)
  573. #define CKM_CAST5_CBC_PAD (0x325UL)
  574. #define CKM_CAST128_CBC_PAD (0x325UL)
  575. #define CKM_RC5_KEY_GEN (0x330UL)
  576. #define CKM_RC5_ECB (0x331UL)
  577. #define CKM_RC5_CBC (0x332UL)
  578. #define CKM_RC5_MAC (0x333UL)
  579. #define CKM_RC5_MAC_GENERAL (0x334UL)
  580. #define CKM_RC5_CBC_PAD (0x335UL)
  581. #define CKM_IDEA_KEY_GEN (0x340UL)
  582. #define CKM_IDEA_ECB (0x341UL)
  583. #define CKM_IDEA_CBC (0x342UL)
  584. #define CKM_IDEA_MAC (0x343UL)
  585. #define CKM_IDEA_MAC_GENERAL (0x344UL)
  586. #define CKM_IDEA_CBC_PAD (0x345UL)
  587. #define CKM_GENERIC_SECRET_KEY_GEN (0x350UL)
  588. #define CKM_CONCATENATE_BASE_AND_KEY (0x360UL)
  589. #define CKM_CONCATENATE_BASE_AND_DATA (0x362UL)
  590. #define CKM_CONCATENATE_DATA_AND_BASE (0x363UL)
  591. #define CKM_XOR_BASE_AND_DATA (0x364UL)
  592. #define CKM_EXTRACT_KEY_FROM_KEY (0x365UL)
  593. #define CKM_SSL3_PRE_MASTER_KEY_GEN (0x370UL)
  594. #define CKM_SSL3_MASTER_KEY_DERIVE (0x371UL)
  595. #define CKM_SSL3_KEY_AND_MAC_DERIVE (0x372UL)
  596. #define CKM_SSL3_MASTER_KEY_DERIVE_DH (0x373UL)
  597. #define CKM_TLS_PRE_MASTER_KEY_GEN (0x374UL)
  598. #define CKM_TLS_MASTER_KEY_DERIVE (0x375UL)
  599. #define CKM_TLS_KEY_AND_MAC_DERIVE (0x376UL)
  600. #define CKM_TLS_MASTER_KEY_DERIVE_DH (0x377UL)
  601. #define CKM_TLS_PRF (0x378UL)
  602. #define CKM_SSL3_MD5_MAC (0x380UL)
  603. #define CKM_SSL3_SHA1_MAC (0x381UL)
  604. #define CKM_MD5_KEY_DERIVATION (0x390UL)
  605. #define CKM_MD2_KEY_DERIVATION (0x391UL)
  606. #define CKM_SHA1_KEY_DERIVATION (0x392UL)
  607. #define CKM_SHA256_KEY_DERIVATION (0x393UL)
  608. #define CKM_SHA384_KEY_DERIVATION (0x394UL)
  609. #define CKM_SHA512_KEY_DERIVATION (0x395UL)
  610. #define CKM_PBE_MD2_DES_CBC (0x3a0UL)
  611. #define CKM_PBE_MD5_DES_CBC (0x3a1UL)
  612. #define CKM_PBE_MD5_CAST_CBC (0x3a2UL)
  613. #define CKM_PBE_MD5_CAST3_CBC (0x3a3UL)
  614. #define CKM_PBE_MD5_CAST5_CBC (0x3a4UL)
  615. #define CKM_PBE_MD5_CAST128_CBC (0x3a4UL)
  616. #define CKM_PBE_SHA1_CAST5_CBC (0x3a5UL)
  617. #define CKM_PBE_SHA1_CAST128_CBC (0x3a5UL)
  618. #define CKM_PBE_SHA1_RC4_128 (0x3a6UL)
  619. #define CKM_PBE_SHA1_RC4_40 (0x3a7UL)
  620. #define CKM_PBE_SHA1_DES3_EDE_CBC (0x3a8UL)
  621. #define CKM_PBE_SHA1_DES2_EDE_CBC (0x3a9UL)
  622. #define CKM_PBE_SHA1_RC2_128_CBC (0x3aaUL)
  623. #define CKM_PBE_SHA1_RC2_40_CBC (0x3abUL)
  624. #define CKM_PKCS5_PBKD2 (0x3b0UL)
  625. #define CKM_PBA_SHA1_WITH_SHA1_HMAC (0x3c0UL)
  626. #define CKM_WTLS_PRE_MASTER_KEY_GEN (0x3d0UL)
  627. #define CKM_WTLS_MASTER_KEY_DERIVE (0x3d1UL)
  628. #define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC (0x3d2UL)
  629. #define CKM_WTLS_PRF (0x3d3UL)
  630. #define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE (0x3d4UL)
  631. #define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE (0x3d5UL)
  632. #define CKM_TLS10_MAC_SERVER (0x3d6UL)
  633. #define CKM_TLS10_MAC_CLIENT (0x3d7UL)
  634. #define CKM_TLS12_MAC (0x3d8UL)
  635. #define CKM_TLS12_KDF (0x3d9UL)
  636. #define CKM_TLS12_MASTER_KEY_DERIVE (0x3e0UL)
  637. #define CKM_TLS12_KEY_AND_MAC_DERIVE (0x3e1UL)
  638. #define CKM_TLS12_MASTER_KEY_DERIVE_DH (0x3e2UL)
  639. #define CKM_TLS12_KEY_SAFE_DERIVE (0x3e3UL)
  640. #define CKM_TLS_MAC (0x3e4UL)
  641. #define CKM_TLS_KDF (0x3e5UL)
  642. #define CKM_KEY_WRAP_LYNKS (0x400UL)
  643. #define CKM_KEY_WRAP_SET_OAEP (0x401UL)
  644. #define CKM_CMS_SIG (0x500UL)
  645. #define CKM_KIP_DERIVE (0x510UL)
  646. #define CKM_KIP_WRAP (0x511UL)
  647. #define CKM_KIP_MAC (0x512UL)
  648. #define CKM_ARIA_KEY_GEN (0x560UL)
  649. #define CKM_ARIA_ECB (0x561UL)
  650. #define CKM_ARIA_CBC (0x562UL)
  651. #define CKM_ARIA_MAC (0x563UL)
  652. #define CKM_ARIA_MAC_GENERAL (0x564UL)
  653. #define CKM_ARIA_CBC_PAD (0x565UL)
  654. #define CKM_ARIA_ECB_ENCRYPT_DATA (0x566UL)
  655. #define CKM_ARIA_CBC_ENCRYPT_DATA (0x567UL)
  656. #define CKM_SEED_KEY_GEN (0x650UL)
  657. #define CKM_SEED_ECB (0x651UL)
  658. #define CKM_SEED_CBC (0x652UL)
  659. #define CKM_SEED_MAC (0x653UL)
  660. #define CKM_SEED_MAC_GENERAL (0x654UL)
  661. #define CKM_SEED_CBC_PAD (0x655UL)
  662. #define CKM_SEED_ECB_ENCRYPT_DATA (0x656UL)
  663. #define CKM_SEED_CBC_ENCRYPT_DATA (0x657UL)
  664. #define CKM_SKIPJACK_KEY_GEN (0x1000UL)
  665. #define CKM_SKIPJACK_ECB64 (0x1001UL)
  666. #define CKM_SKIPJACK_CBC64 (0x1002UL)
  667. #define CKM_SKIPJACK_OFB64 (0x1003UL)
  668. #define CKM_SKIPJACK_CFB64 (0x1004UL)
  669. #define CKM_SKIPJACK_CFB32 (0x1005UL)
  670. #define CKM_SKIPJACK_CFB16 (0x1006UL)
  671. #define CKM_SKIPJACK_CFB8 (0x1007UL)
  672. #define CKM_SKIPJACK_WRAP (0x1008UL)
  673. #define CKM_SKIPJACK_PRIVATE_WRAP (0x1009UL)
  674. #define CKM_SKIPJACK_RELAYX (0x100aUL)
  675. #define CKM_KEA_KEY_PAIR_GEN (0x1010UL)
  676. #define CKM_KEA_KEY_DERIVE (0x1011UL)
  677. #define CKM_FORTEZZA_TIMESTAMP (0x1020UL)
  678. #define CKM_BATON_KEY_GEN (0x1030UL)
  679. #define CKM_BATON_ECB128 (0x1031UL)
  680. #define CKM_BATON_ECB96 (0x1032UL)
  681. #define CKM_BATON_CBC128 (0x1033UL)
  682. #define CKM_BATON_COUNTER (0x1034UL)
  683. #define CKM_BATON_SHUFFLE (0x1035UL)
  684. #define CKM_BATON_WRAP (0x1036UL)
  685. #define CKM_ECDSA_KEY_PAIR_GEN (0x1040UL)
  686. #define CKM_EC_KEY_PAIR_GEN (0x1040UL)
  687. #define CKM_ECDSA (0x1041UL)
  688. #define CKM_ECDSA_SHA1 (0x1042UL)
  689. #define CKM_ECDSA_SHA224 (0x1043UL)
  690. #define CKM_ECDSA_SHA256 (0x1044UL)
  691. #define CKM_ECDSA_SHA384 (0x1045UL)
  692. #define CKM_ECDSA_SHA512 (0x1046UL)
  693. #define CKM_ECDH1_DERIVE (0x1050UL)
  694. #define CKM_ECDH1_COFACTOR_DERIVE (0x1051UL)
  695. #define CKM_ECMQV_DERIVE (0x1052UL)
  696. #define CKM_ECDH_AES_KEY_WRAP (0x1053UL)
  697. #define CKM_RSA_AES_KEY_WRAP (0x1054UL)
  698. #define CKM_JUNIPER_KEY_GEN (0x1060UL)
  699. #define CKM_JUNIPER_ECB128 (0x1061UL)
  700. #define CKM_JUNIPER_CBC128 (0x1062UL)
  701. #define CKM_JUNIPER_COUNTER (0x1063UL)
  702. #define CKM_JUNIPER_SHUFFLE (0x1064UL)
  703. #define CKM_JUNIPER_WRAP (0x1065UL)
  704. #define CKM_FASTHASH (0x1070UL)
  705. #define CKM_AES_KEY_GEN (0x1080UL)
  706. #define CKM_AES_ECB (0x1081UL)
  707. #define CKM_AES_CBC (0x1082UL)
  708. #define CKM_AES_MAC (0x1083UL)
  709. #define CKM_AES_MAC_GENERAL (0x1084UL)
  710. #define CKM_AES_CBC_PAD (0x1085UL)
  711. #define CKM_AES_CTR (0x1086UL)
  712. #define CKM_AES_GCM (0x1087UL)
  713. #define CKM_AES_CCM (0x1088UL)
  714. #define CKM_AES_CTS (0x1089UL)
  715. #define CKM_AES_CMAC (0x108aUL)
  716. #define CKM_AES_CMAC_GENERAL (0x108bUL)
  717. #define CKM_AES_XCBC_MAC (0x108cUL)
  718. #define CKM_AES_XCBC_MAC_96 (0x108dUL)
  719. #define CKM_AES_GMAC (0x108eUL)
  720. #define CKM_BLOWFISH_KEY_GEN (0x1090UL)
  721. #define CKM_BLOWFISH_CBC (0x1091UL)
  722. #define CKM_TWOFISH_KEY_GEN (0x1092UL)
  723. #define CKM_TWOFISH_CBC (0x1093UL)
  724. #define CKM_BLOWFISH_CBC_PAD (0x1094UL)
  725. #define CKM_TWOFISH_CBC_PAD (0x1095UL)
  726. #define CKM_DES_ECB_ENCRYPT_DATA (0x1100UL)
  727. #define CKM_DES_CBC_ENCRYPT_DATA (0x1101UL)
  728. #define CKM_DES3_ECB_ENCRYPT_DATA (0x1102UL)
  729. #define CKM_DES3_CBC_ENCRYPT_DATA (0x1103UL)
  730. #define CKM_AES_ECB_ENCRYPT_DATA (0x1104UL)
  731. #define CKM_AES_CBC_ENCRYPT_DATA (0x1105UL)
  732. #define CKM_GOSTR3410_KEY_PAIR_GEN (0x1200UL)
  733. #define CKM_GOSTR3410 (0x1201UL)
  734. #define CKM_GOSTR3410_WITH_GOSTR3411 (0x1202UL)
  735. #define CKM_GOSTR3410_KEY_WRAP (0x1203UL)
  736. #define CKM_GOSTR3410_DERIVE (0x1204UL)
  737. #define CKM_GOSTR3411 (0x1210UL)
  738. #define CKM_GOSTR3411_HMAC (0x1211UL)
  739. #define CKM_GOST28147_KEY_GEN (0x1220UL)
  740. #define CKM_GOST28147_ECB (0x1221UL)
  741. #define CKM_GOST28147 (0x1222UL)
  742. #define CKM_GOST28147_MAC (0x1223UL)
  743. #define CKM_GOST28147_KEY_WRAP (0x1224UL)
  744. #define CKM_DSA_PARAMETER_GEN (0x2000UL)
  745. #define CKM_DH_PKCS_PARAMETER_GEN (0x2001UL)
  746. #define CKM_X9_42_DH_PARAMETER_GEN (0x2002UL)
  747. #define CKM_DSA_PROBABLISTIC_PARAMETER_GEN (0x2003UL)
  748. #define CKM_DSA_SHAWE_TAYLOR_PARAMETER_GEN (0x2004UL)
  749. #define CKM_AES_OFB (0x2104UL)
  750. #define CKM_AES_CFB64 (0x2105UL)
  751. #define CKM_AES_CFB8 (0x2106UL)
  752. #define CKM_AES_CFB128 (0x2107UL)
  753. #define CKM_AES_CFB1 (0x2108UL)
  754. #define CKM_VENDOR_DEFINED ((unsigned long) (1UL << 31))
  755. /* Amendments */
  756. #define CKM_SHA224 (0x255UL)
  757. #define CKM_SHA224_HMAC (0x256UL)
  758. #define CKM_SHA224_HMAC_GENERAL (0x257UL)
  759. #define CKM_SHA224_RSA_PKCS (0x46UL)
  760. #define CKM_SHA224_RSA_PKCS_PSS (0x47UL)
  761. #define CKM_SHA224_KEY_DERIVATION (0x396UL)
  762. #define CKM_CAMELLIA_KEY_GEN (0x550UL)
  763. #define CKM_CAMELLIA_ECB (0x551UL)
  764. #define CKM_CAMELLIA_CBC (0x552UL)
  765. #define CKM_CAMELLIA_MAC (0x553UL)
  766. #define CKM_CAMELLIA_MAC_GENERAL (0x554UL)
  767. #define CKM_CAMELLIA_CBC_PAD (0x555UL)
  768. #define CKM_CAMELLIA_ECB_ENCRYPT_DATA (0x556UL)
  769. #define CKM_CAMELLIA_CBC_ENCRYPT_DATA (0x557UL)
  770. #define CKM_CAMELLIA_CTR (0x558UL)
  771. #define CKM_AES_KEY_WRAP (0x2109UL)
  772. #define CKM_AES_KEY_WRAP_PAD (0x210aUL)
  773. #define CKM_RSA_PKCS_TPM_1_1 (0x4001UL)
  774. #define CKM_RSA_PKCS_OAEP_TPM_1_1 (0x4002UL)
  775. /* From version 3.0 */
  776. #define CKM_EC_EDWARDS_KEY_PAIR_GEN (0x1055UL)
  777. #define CKM_EDDSA (0x1057UL)
  778. /* Attribute and other constants related to OTP */
  779. #define CK_OTP_FORMAT_DECIMAL (0UL)
  780. #define CK_OTP_FORMAT_HEXADECIMAL (1UL)
  781. #define CK_OTP_FORMAT_ALPHANUMERIC (2UL)
  782. #define CK_OTP_FORMAT_BINARY (3UL)
  783. #define CK_OTP_PARAM_IGNORED (0UL)
  784. #define CK_OTP_PARAM_OPTIONAL (1UL)
  785. #define CK_OTP_PARAM_MANDATORY (2UL)
  786. #define CK_OTP_VALUE (0UL)
  787. #define CK_OTP_PIN (1UL)
  788. #define CK_OTP_CHALLENGE (2UL)
  789. #define CK_OTP_TIME (3UL)
  790. #define CK_OTP_COUNTER (4UL)
  791. #define CK_OTP_FLAGS (5UL)
  792. #define CK_OTP_OUTPUT_LENGTH (6UL)
  793. #define CK_OTP_FORMAT (7UL)
  794. /* OTP mechanism flags */
  795. #define CKF_NEXT_OTP (0x01UL)
  796. #define CKF_EXCLUDE_TIME (0x02UL)
  797. #define CKF_EXCLUDE_COUNTER (0x04UL)
  798. #define CKF_EXCLUDE_CHALLENGE (0x08UL)
  799. #define CKF_EXCLUDE_PIN (0x10UL)
  800. #define CKF_USER_FRIENDLY_OTP (0x20UL)
  801. #define CKN_OTP_CHANGED (0x01UL)
  802. struct ck_mechanism
  803. {
  804. ck_mechanism_type_t mechanism;
  805. void *parameter;
  806. unsigned long parameter_len;
  807. };
  808. struct ck_mechanism_info
  809. {
  810. unsigned long min_key_size;
  811. unsigned long max_key_size;
  812. ck_flags_t flags;
  813. };
  814. typedef unsigned long ck_param_type;
  815. typedef struct ck_otp_param {
  816. ck_param_type type;
  817. void *value;
  818. unsigned long value_len;
  819. } ck_otp_param;
  820. typedef struct ck_otp_params {
  821. struct ck_otp_param *params;
  822. unsigned long count;
  823. } ck_otp_params;
  824. typedef struct ck_otp_signature_info
  825. {
  826. struct ck_otp_param *params;
  827. unsigned long count;
  828. } ck_otp_signature_info;
  829. #define CKG_MGF1_SHA1 0x00000001UL
  830. #define CKG_MGF1_SHA224 0x00000005UL
  831. #define CKG_MGF1_SHA256 0x00000002UL
  832. #define CKG_MGF1_SHA384 0x00000003UL
  833. #define CKG_MGF1_SHA512 0x00000004UL
  834. typedef unsigned long ck_rsa_pkcs_mgf_type_t;
  835. typedef ck_rsa_pkcs_mgf_type_t * CK_RSA_PKCS_MGF_TYPE_PTR;
  836. struct ck_rsa_pkcs_pss_params {
  837. ck_mechanism_type_t hash_alg;
  838. ck_rsa_pkcs_mgf_type_t mgf;
  839. unsigned long s_len;
  840. };
  841. typedef unsigned long ck_rsa_pkcs_oaep_source_type_t;
  842. struct ck_rsa_pkcs_oaep_params {
  843. ck_mechanism_type_t hash_alg;
  844. ck_rsa_pkcs_mgf_type_t mgf;
  845. ck_rsa_pkcs_oaep_source_type_t source;
  846. void *source_data;
  847. unsigned long source_data_len;
  848. };
  849. struct ck_aes_ctr_params {
  850. unsigned long counter_bits;
  851. unsigned char cb[16];
  852. };
  853. struct ck_gcm_params {
  854. unsigned char *iv_ptr;
  855. unsigned long iv_len;
  856. unsigned long iv_bits;
  857. unsigned char *aad_ptr;
  858. unsigned long aad_len;
  859. unsigned long tag_bits;
  860. };
  861. /* The following EC Key Derivation Functions are defined */
  862. #define CKD_NULL (0x01UL)
  863. #define CKD_SHA1_KDF (0x02UL)
  864. /* The following X9.42 DH key derivation functions are defined */
  865. #define CKD_SHA1_KDF_ASN1 (0x03UL)
  866. #define CKD_SHA1_KDF_CONCATENATE (0x04UL)
  867. #define CKD_SHA224_KDF (0x05UL)
  868. #define CKD_SHA256_KDF (0x06UL)
  869. #define CKD_SHA384_KDF (0x07UL)
  870. #define CKD_SHA512_KDF (0x08UL)
  871. #define CKD_CPDIVERSIFY_KDF (0x09UL)
  872. typedef unsigned long ck_ec_kdf_t;
  873. struct ck_ecdh1_derive_params {
  874. ck_ec_kdf_t kdf;
  875. unsigned long shared_data_len;
  876. unsigned char *shared_data;
  877. unsigned long public_data_len;
  878. unsigned char *public_data;
  879. };
  880. struct ck_key_derivation_string_data {
  881. unsigned char *string_data;
  882. unsigned long string_data_len;
  883. };
  884. struct ck_des_cbc_encrypt_data_params {
  885. unsigned char iv[8];
  886. unsigned char *data_params;
  887. unsigned long length;
  888. };
  889. struct ck_aes_cbc_encrypt_data_params {
  890. unsigned char iv[16];
  891. unsigned char *data_params;
  892. unsigned long length;
  893. };
  894. #define CKF_HW (1UL << 0)
  895. #define CKF_ENCRYPT (1UL << 8)
  896. #define CKF_DECRYPT (1UL << 9)
  897. #define CKF_DIGEST (1UL << 10)
  898. #define CKF_SIGN (1UL << 11)
  899. #define CKF_SIGN_RECOVER (1UL << 12)
  900. #define CKF_VERIFY (1UL << 13)
  901. #define CKF_VERIFY_RECOVER (1UL << 14)
  902. #define CKF_GENERATE (1UL << 15)
  903. #define CKF_GENERATE_KEY_PAIR (1UL << 16)
  904. #define CKF_WRAP (1UL << 17)
  905. #define CKF_UNWRAP (1UL << 18)
  906. #define CKF_DERIVE (1UL << 19)
  907. #define CKF_EXTENSION ((unsigned long) (1UL << 31))
  908. #define CKF_EC_F_P (1UL << 20)
  909. #define CKF_EC_NAMEDCURVE (1UL << 23)
  910. #define CKF_EC_UNCOMPRESS (1UL << 24)
  911. #define CKF_EC_COMPRESS (1UL << 25)
  912. /* Flags for C_WaitForSlotEvent. */
  913. #define CKF_DONT_BLOCK (1UL)
  914. typedef unsigned long ck_rv_t;
  915. typedef ck_rv_t (*ck_notify_t) (ck_session_handle_t session,
  916. ck_notification_t event, void *application);
  917. /* Forward reference. */
  918. struct ck_function_list;
  919. #define _CK_DECLARE_FUNCTION(name, args) \
  920. typedef ck_rv_t (*CK_ ## name) args; \
  921. ck_rv_t CK_SPEC name args
  922. _CK_DECLARE_FUNCTION (C_Initialize, (void *init_args));
  923. _CK_DECLARE_FUNCTION (C_Finalize, (void *reserved));
  924. _CK_DECLARE_FUNCTION (C_GetInfo, (struct ck_info *info));
  925. _CK_DECLARE_FUNCTION (C_GetFunctionList,
  926. (struct ck_function_list **function_list));
  927. _CK_DECLARE_FUNCTION (C_GetSlotList,
  928. (unsigned char token_present, ck_slot_id_t *slot_list,
  929. unsigned long *count));
  930. _CK_DECLARE_FUNCTION (C_GetSlotInfo,
  931. (ck_slot_id_t slot_id, struct ck_slot_info *info));
  932. _CK_DECLARE_FUNCTION (C_GetTokenInfo,
  933. (ck_slot_id_t slot_id, struct ck_token_info *info));
  934. _CK_DECLARE_FUNCTION (C_WaitForSlotEvent,
  935. (ck_flags_t flags, ck_slot_id_t *slot, void *reserved));
  936. _CK_DECLARE_FUNCTION (C_GetMechanismList,
  937. (ck_slot_id_t slot_id,
  938. ck_mechanism_type_t *mechanism_list,
  939. unsigned long *count));
  940. _CK_DECLARE_FUNCTION (C_GetMechanismInfo,
  941. (ck_slot_id_t slot_id, ck_mechanism_type_t type,
  942. struct ck_mechanism_info *info));
  943. _CK_DECLARE_FUNCTION (C_InitToken,
  944. (ck_slot_id_t slot_id, unsigned char *pin,
  945. unsigned long pin_len, unsigned char *label));
  946. _CK_DECLARE_FUNCTION (C_InitPIN,
  947. (ck_session_handle_t session, unsigned char *pin,
  948. unsigned long pin_len));
  949. _CK_DECLARE_FUNCTION (C_SetPIN,
  950. (ck_session_handle_t session, unsigned char *old_pin,
  951. unsigned long old_len, unsigned char *new_pin,
  952. unsigned long new_len));
  953. _CK_DECLARE_FUNCTION (C_OpenSession,
  954. (ck_slot_id_t slot_id, ck_flags_t flags,
  955. void *application, ck_notify_t notify,
  956. ck_session_handle_t *session));
  957. _CK_DECLARE_FUNCTION (C_CloseSession, (ck_session_handle_t session));
  958. _CK_DECLARE_FUNCTION (C_CloseAllSessions, (ck_slot_id_t slot_id));
  959. _CK_DECLARE_FUNCTION (C_GetSessionInfo,
  960. (ck_session_handle_t session,
  961. struct ck_session_info *info));
  962. _CK_DECLARE_FUNCTION (C_GetOperationState,
  963. (ck_session_handle_t session,
  964. unsigned char *operation_state,
  965. unsigned long *operation_state_len));
  966. _CK_DECLARE_FUNCTION (C_SetOperationState,
  967. (ck_session_handle_t session,
  968. unsigned char *operation_state,
  969. unsigned long operation_state_len,
  970. ck_object_handle_t encryption_key,
  971. ck_object_handle_t authentiation_key));
  972. _CK_DECLARE_FUNCTION (C_Login,
  973. (ck_session_handle_t session, ck_user_type_t user_type,
  974. unsigned char *pin, unsigned long pin_len));
  975. _CK_DECLARE_FUNCTION (C_Logout, (ck_session_handle_t session));
  976. _CK_DECLARE_FUNCTION (C_CreateObject,
  977. (ck_session_handle_t session,
  978. struct ck_attribute *templ,
  979. unsigned long count, ck_object_handle_t *object));
  980. _CK_DECLARE_FUNCTION (C_CopyObject,
  981. (ck_session_handle_t session, ck_object_handle_t object,
  982. struct ck_attribute *templ, unsigned long count,
  983. ck_object_handle_t *new_object));
  984. _CK_DECLARE_FUNCTION (C_DestroyObject,
  985. (ck_session_handle_t session,
  986. ck_object_handle_t object));
  987. _CK_DECLARE_FUNCTION (C_GetObjectSize,
  988. (ck_session_handle_t session,
  989. ck_object_handle_t object,
  990. unsigned long *size));
  991. _CK_DECLARE_FUNCTION (C_GetAttributeValue,
  992. (ck_session_handle_t session,
  993. ck_object_handle_t object,
  994. struct ck_attribute *templ,
  995. unsigned long count));
  996. _CK_DECLARE_FUNCTION (C_SetAttributeValue,
  997. (ck_session_handle_t session,
  998. ck_object_handle_t object,
  999. struct ck_attribute *templ,
  1000. unsigned long count));
  1001. _CK_DECLARE_FUNCTION (C_FindObjectsInit,
  1002. (ck_session_handle_t session,
  1003. struct ck_attribute *templ,
  1004. unsigned long count));
  1005. _CK_DECLARE_FUNCTION (C_FindObjects,
  1006. (ck_session_handle_t session,
  1007. ck_object_handle_t *object,
  1008. unsigned long max_object_count,
  1009. unsigned long *object_count));
  1010. _CK_DECLARE_FUNCTION (C_FindObjectsFinal,
  1011. (ck_session_handle_t session));
  1012. _CK_DECLARE_FUNCTION (C_EncryptInit,
  1013. (ck_session_handle_t session,
  1014. struct ck_mechanism *mechanism,
  1015. ck_object_handle_t key));
  1016. _CK_DECLARE_FUNCTION (C_Encrypt,
  1017. (ck_session_handle_t session,
  1018. unsigned char *data, unsigned long data_len,
  1019. unsigned char *encrypted_data,
  1020. unsigned long *encrypted_data_len));
  1021. _CK_DECLARE_FUNCTION (C_EncryptUpdate,
  1022. (ck_session_handle_t session,
  1023. unsigned char *part, unsigned long part_len,
  1024. unsigned char *encrypted_part,
  1025. unsigned long *encrypted_part_len));
  1026. _CK_DECLARE_FUNCTION (C_EncryptFinal,
  1027. (ck_session_handle_t session,
  1028. unsigned char *last_encrypted_part,
  1029. unsigned long *last_encrypted_part_len));
  1030. _CK_DECLARE_FUNCTION (C_DecryptInit,
  1031. (ck_session_handle_t session,
  1032. struct ck_mechanism *mechanism,
  1033. ck_object_handle_t key));
  1034. _CK_DECLARE_FUNCTION (C_Decrypt,
  1035. (ck_session_handle_t session,
  1036. unsigned char *encrypted_data,
  1037. unsigned long encrypted_data_len,
  1038. unsigned char *data, unsigned long *data_len));
  1039. _CK_DECLARE_FUNCTION (C_DecryptUpdate,
  1040. (ck_session_handle_t session,
  1041. unsigned char *encrypted_part,
  1042. unsigned long encrypted_part_len,
  1043. unsigned char *part, unsigned long *part_len));
  1044. _CK_DECLARE_FUNCTION (C_DecryptFinal,
  1045. (ck_session_handle_t session,
  1046. unsigned char *last_part,
  1047. unsigned long *last_part_len));
  1048. _CK_DECLARE_FUNCTION (C_DigestInit,
  1049. (ck_session_handle_t session,
  1050. struct ck_mechanism *mechanism));
  1051. _CK_DECLARE_FUNCTION (C_Digest,
  1052. (ck_session_handle_t session,
  1053. unsigned char *data, unsigned long data_len,
  1054. unsigned char *digest,
  1055. unsigned long *digest_len));
  1056. _CK_DECLARE_FUNCTION (C_DigestUpdate,
  1057. (ck_session_handle_t session,
  1058. unsigned char *part, unsigned long part_len));
  1059. _CK_DECLARE_FUNCTION (C_DigestKey,
  1060. (ck_session_handle_t session, ck_object_handle_t key));
  1061. _CK_DECLARE_FUNCTION (C_DigestFinal,
  1062. (ck_session_handle_t session,
  1063. unsigned char *digest,
  1064. unsigned long *digest_len));
  1065. _CK_DECLARE_FUNCTION (C_SignInit,
  1066. (ck_session_handle_t session,
  1067. struct ck_mechanism *mechanism,
  1068. ck_object_handle_t key));
  1069. _CK_DECLARE_FUNCTION (C_Sign,
  1070. (ck_session_handle_t session,
  1071. unsigned char *data, unsigned long data_len,
  1072. unsigned char *signature,
  1073. unsigned long *signature_len));
  1074. _CK_DECLARE_FUNCTION (C_SignUpdate,
  1075. (ck_session_handle_t session,
  1076. unsigned char *part, unsigned long part_len));
  1077. _CK_DECLARE_FUNCTION (C_SignFinal,
  1078. (ck_session_handle_t session,
  1079. unsigned char *signature,
  1080. unsigned long *signature_len));
  1081. _CK_DECLARE_FUNCTION (C_SignRecoverInit,
  1082. (ck_session_handle_t session,
  1083. struct ck_mechanism *mechanism,
  1084. ck_object_handle_t key));
  1085. _CK_DECLARE_FUNCTION (C_SignRecover,
  1086. (ck_session_handle_t session,
  1087. unsigned char *data, unsigned long data_len,
  1088. unsigned char *signature,
  1089. unsigned long *signature_len));
  1090. _CK_DECLARE_FUNCTION (C_VerifyInit,
  1091. (ck_session_handle_t session,
  1092. struct ck_mechanism *mechanism,
  1093. ck_object_handle_t key));
  1094. _CK_DECLARE_FUNCTION (C_Verify,
  1095. (ck_session_handle_t session,
  1096. unsigned char *data, unsigned long data_len,
  1097. unsigned char *signature,
  1098. unsigned long signature_len));
  1099. _CK_DECLARE_FUNCTION (C_VerifyUpdate,
  1100. (ck_session_handle_t session,
  1101. unsigned char *part, unsigned long part_len));
  1102. _CK_DECLARE_FUNCTION (C_VerifyFinal,
  1103. (ck_session_handle_t session,
  1104. unsigned char *signature,
  1105. unsigned long signature_len));
  1106. _CK_DECLARE_FUNCTION (C_VerifyRecoverInit,
  1107. (ck_session_handle_t session,
  1108. struct ck_mechanism *mechanism,
  1109. ck_object_handle_t key));
  1110. _CK_DECLARE_FUNCTION (C_VerifyRecover,
  1111. (ck_session_handle_t session,
  1112. unsigned char *signature,
  1113. unsigned long signature_len,
  1114. unsigned char *data,
  1115. unsigned long *data_len));
  1116. _CK_DECLARE_FUNCTION (C_DigestEncryptUpdate,
  1117. (ck_session_handle_t session,
  1118. unsigned char *part, unsigned long part_len,
  1119. unsigned char *encrypted_part,
  1120. unsigned long *encrypted_part_len));
  1121. _CK_DECLARE_FUNCTION (C_DecryptDigestUpdate,
  1122. (ck_session_handle_t session,
  1123. unsigned char *encrypted_part,
  1124. unsigned long encrypted_part_len,
  1125. unsigned char *part,
  1126. unsigned long *part_len));
  1127. _CK_DECLARE_FUNCTION (C_SignEncryptUpdate,
  1128. (ck_session_handle_t session,
  1129. unsigned char *part, unsigned long part_len,
  1130. unsigned char *encrypted_part,
  1131. unsigned long *encrypted_part_len));
  1132. _CK_DECLARE_FUNCTION (C_DecryptVerifyUpdate,
  1133. (ck_session_handle_t session,
  1134. unsigned char *encrypted_part,
  1135. unsigned long encrypted_part_len,
  1136. unsigned char *part,
  1137. unsigned long *part_len));
  1138. _CK_DECLARE_FUNCTION (C_GenerateKey,
  1139. (ck_session_handle_t session,
  1140. struct ck_mechanism *mechanism,
  1141. struct ck_attribute *templ,
  1142. unsigned long count,
  1143. ck_object_handle_t *key));
  1144. _CK_DECLARE_FUNCTION (C_GenerateKeyPair,
  1145. (ck_session_handle_t session,
  1146. struct ck_mechanism *mechanism,
  1147. struct ck_attribute *public_key_template,
  1148. unsigned long public_key_attribute_count,
  1149. struct ck_attribute *private_key_template,
  1150. unsigned long private_key_attribute_count,
  1151. ck_object_handle_t *public_key,
  1152. ck_object_handle_t *private_key));
  1153. _CK_DECLARE_FUNCTION (C_WrapKey,
  1154. (ck_session_handle_t session,
  1155. struct ck_mechanism *mechanism,
  1156. ck_object_handle_t wrapping_key,
  1157. ck_object_handle_t key,
  1158. unsigned char *wrapped_key,
  1159. unsigned long *wrapped_key_len));
  1160. _CK_DECLARE_FUNCTION (C_UnwrapKey,
  1161. (ck_session_handle_t session,
  1162. struct ck_mechanism *mechanism,
  1163. ck_object_handle_t unwrapping_key,
  1164. unsigned char *wrapped_key,
  1165. unsigned long wrapped_key_len,
  1166. struct ck_attribute *templ,
  1167. unsigned long attribute_count,
  1168. ck_object_handle_t *key));
  1169. _CK_DECLARE_FUNCTION (C_DeriveKey,
  1170. (ck_session_handle_t session,
  1171. struct ck_mechanism *mechanism,
  1172. ck_object_handle_t base_key,
  1173. struct ck_attribute *templ,
  1174. unsigned long attribute_count,
  1175. ck_object_handle_t *key));
  1176. _CK_DECLARE_FUNCTION (C_SeedRandom,
  1177. (ck_session_handle_t session, unsigned char *seed,
  1178. unsigned long seed_len));
  1179. _CK_DECLARE_FUNCTION (C_GenerateRandom,
  1180. (ck_session_handle_t session,
  1181. unsigned char *random_data,
  1182. unsigned long random_len));
  1183. _CK_DECLARE_FUNCTION (C_GetFunctionStatus, (ck_session_handle_t session));
  1184. _CK_DECLARE_FUNCTION (C_CancelFunction, (ck_session_handle_t session));
  1185. struct ck_function_list
  1186. {
  1187. struct ck_version version;
  1188. CK_C_Initialize C_Initialize;
  1189. CK_C_Finalize C_Finalize;
  1190. CK_C_GetInfo C_GetInfo;
  1191. CK_C_GetFunctionList C_GetFunctionList;
  1192. CK_C_GetSlotList C_GetSlotList;
  1193. CK_C_GetSlotInfo C_GetSlotInfo;
  1194. CK_C_GetTokenInfo C_GetTokenInfo;
  1195. CK_C_GetMechanismList C_GetMechanismList;
  1196. CK_C_GetMechanismInfo C_GetMechanismInfo;
  1197. CK_C_InitToken C_InitToken;
  1198. CK_C_InitPIN C_InitPIN;
  1199. CK_C_SetPIN C_SetPIN;
  1200. CK_C_OpenSession C_OpenSession;
  1201. CK_C_CloseSession C_CloseSession;
  1202. CK_C_CloseAllSessions C_CloseAllSessions;
  1203. CK_C_GetSessionInfo C_GetSessionInfo;
  1204. CK_C_GetOperationState C_GetOperationState;
  1205. CK_C_SetOperationState C_SetOperationState;
  1206. CK_C_Login C_Login;
  1207. CK_C_Logout C_Logout;
  1208. CK_C_CreateObject C_CreateObject;
  1209. CK_C_CopyObject C_CopyObject;
  1210. CK_C_DestroyObject C_DestroyObject;
  1211. CK_C_GetObjectSize C_GetObjectSize;
  1212. CK_C_GetAttributeValue C_GetAttributeValue;
  1213. CK_C_SetAttributeValue C_SetAttributeValue;
  1214. CK_C_FindObjectsInit C_FindObjectsInit;
  1215. CK_C_FindObjects C_FindObjects;
  1216. CK_C_FindObjectsFinal C_FindObjectsFinal;
  1217. CK_C_EncryptInit C_EncryptInit;
  1218. CK_C_Encrypt C_Encrypt;
  1219. CK_C_EncryptUpdate C_EncryptUpdate;
  1220. CK_C_EncryptFinal C_EncryptFinal;
  1221. CK_C_DecryptInit C_DecryptInit;
  1222. CK_C_Decrypt C_Decrypt;
  1223. CK_C_DecryptUpdate C_DecryptUpdate;
  1224. CK_C_DecryptFinal C_DecryptFinal;
  1225. CK_C_DigestInit C_DigestInit;
  1226. CK_C_Digest C_Digest;
  1227. CK_C_DigestUpdate C_DigestUpdate;
  1228. CK_C_DigestKey C_DigestKey;
  1229. CK_C_DigestFinal C_DigestFinal;
  1230. CK_C_SignInit C_SignInit;
  1231. CK_C_Sign C_Sign;
  1232. CK_C_SignUpdate C_SignUpdate;
  1233. CK_C_SignFinal C_SignFinal;
  1234. CK_C_SignRecoverInit C_SignRecoverInit;
  1235. CK_C_SignRecover C_SignRecover;
  1236. CK_C_VerifyInit C_VerifyInit;
  1237. CK_C_Verify C_Verify;
  1238. CK_C_VerifyUpdate C_VerifyUpdate;
  1239. CK_C_VerifyFinal C_VerifyFinal;
  1240. CK_C_VerifyRecoverInit C_VerifyRecoverInit;
  1241. CK_C_VerifyRecover C_VerifyRecover;
  1242. CK_C_DigestEncryptUpdate C_DigestEncryptUpdate;
  1243. CK_C_DecryptDigestUpdate C_DecryptDigestUpdate;
  1244. CK_C_SignEncryptUpdate C_SignEncryptUpdate;
  1245. CK_C_DecryptVerifyUpdate C_DecryptVerifyUpdate;
  1246. CK_C_GenerateKey C_GenerateKey;
  1247. CK_C_GenerateKeyPair C_GenerateKeyPair;
  1248. CK_C_WrapKey C_WrapKey;
  1249. CK_C_UnwrapKey C_UnwrapKey;
  1250. CK_C_DeriveKey C_DeriveKey;
  1251. CK_C_SeedRandom C_SeedRandom;
  1252. CK_C_GenerateRandom C_GenerateRandom;
  1253. CK_C_GetFunctionStatus C_GetFunctionStatus;
  1254. CK_C_CancelFunction C_CancelFunction;
  1255. CK_C_WaitForSlotEvent C_WaitForSlotEvent;
  1256. };
  1257. typedef ck_rv_t (*ck_createmutex_t) (void **mutex);
  1258. typedef ck_rv_t (*ck_destroymutex_t) (void *mutex);
  1259. typedef ck_rv_t (*ck_lockmutex_t) (void *mutex);
  1260. typedef ck_rv_t (*ck_unlockmutex_t) (void *mutex);
  1261. struct ck_c_initialize_args
  1262. {
  1263. ck_createmutex_t create_mutex;
  1264. ck_destroymutex_t destroy_mutex;
  1265. ck_lockmutex_t lock_mutex;
  1266. ck_unlockmutex_t unlock_mutex;
  1267. ck_flags_t flags;
  1268. void *reserved;
  1269. };
  1270. #define CKF_LIBRARY_CANT_CREATE_OS_THREADS (1UL << 0)
  1271. #define CKF_OS_LOCKING_OK (1UL << 1)
  1272. #define CKR_OK (0UL)
  1273. #define CKR_CANCEL (1UL)
  1274. #define CKR_HOST_MEMORY (2UL)
  1275. #define CKR_SLOT_ID_INVALID (3UL)
  1276. #define CKR_GENERAL_ERROR (5UL)
  1277. #define CKR_FUNCTION_FAILED (6UL)
  1278. #define CKR_ARGUMENTS_BAD (7UL)
  1279. #define CKR_NO_EVENT (8UL)
  1280. #define CKR_NEED_TO_CREATE_THREADS (9UL)
  1281. #define CKR_CANT_LOCK (0xaUL)
  1282. #define CKR_ATTRIBUTE_READ_ONLY (0x10UL)
  1283. #define CKR_ATTRIBUTE_SENSITIVE (0x11UL)
  1284. #define CKR_ATTRIBUTE_TYPE_INVALID (0x12UL)
  1285. #define CKR_ATTRIBUTE_VALUE_INVALID (0x13UL)
  1286. #define CKR_ACTION_PROHIBITED (0x1BUL)
  1287. #define CKR_DATA_INVALID (0x20UL)
  1288. #define CKR_DATA_LEN_RANGE (0x21UL)
  1289. #define CKR_DEVICE_ERROR (0x30UL)
  1290. #define CKR_DEVICE_MEMORY (0x31UL)
  1291. #define CKR_DEVICE_REMOVED (0x32UL)
  1292. #define CKR_ENCRYPTED_DATA_INVALID (0x40UL)
  1293. #define CKR_ENCRYPTED_DATA_LEN_RANGE (0x41UL)
  1294. #define CKR_FUNCTION_CANCELED (0x50UL)
  1295. #define CKR_FUNCTION_NOT_PARALLEL (0x51UL)
  1296. #define CKR_FUNCTION_NOT_SUPPORTED (0x54UL)
  1297. #define CKR_KEY_HANDLE_INVALID (0x60UL)
  1298. #define CKR_KEY_SIZE_RANGE (0x62UL)
  1299. #define CKR_KEY_TYPE_INCONSISTENT (0x63UL)
  1300. #define CKR_KEY_NOT_NEEDED (0x64UL)
  1301. #define CKR_KEY_CHANGED (0x65UL)
  1302. #define CKR_KEY_NEEDED (0x66UL)
  1303. #define CKR_KEY_INDIGESTIBLE (0x67UL)
  1304. #define CKR_KEY_FUNCTION_NOT_PERMITTED (0x68UL)
  1305. #define CKR_KEY_NOT_WRAPPABLE (0x69UL)
  1306. #define CKR_KEY_UNEXTRACTABLE (0x6aUL)
  1307. #define CKR_MECHANISM_INVALID (0x70UL)
  1308. #define CKR_MECHANISM_PARAM_INVALID (0x71UL)
  1309. #define CKR_OBJECT_HANDLE_INVALID (0x82UL)
  1310. #define CKR_OPERATION_ACTIVE (0x90UL)
  1311. #define CKR_OPERATION_NOT_INITIALIZED (0x91UL)
  1312. #define CKR_PIN_INCORRECT (0xa0UL)
  1313. #define CKR_PIN_INVALID (0xa1UL)
  1314. #define CKR_PIN_LEN_RANGE (0xa2UL)
  1315. #define CKR_PIN_EXPIRED (0xa3UL)
  1316. #define CKR_PIN_LOCKED (0xa4UL)
  1317. #define CKR_SESSION_CLOSED (0xb0UL)
  1318. #define CKR_SESSION_COUNT (0xb1UL)
  1319. #define CKR_SESSION_HANDLE_INVALID (0xb3UL)
  1320. #define CKR_SESSION_PARALLEL_NOT_SUPPORTED (0xb4UL)
  1321. #define CKR_SESSION_READ_ONLY (0xb5UL)
  1322. #define CKR_SESSION_EXISTS (0xb6UL)
  1323. #define CKR_SESSION_READ_ONLY_EXISTS (0xb7UL)
  1324. #define CKR_SESSION_READ_WRITE_SO_EXISTS (0xb8UL)
  1325. #define CKR_SIGNATURE_INVALID (0xc0UL)
  1326. #define CKR_SIGNATURE_LEN_RANGE (0xc1UL)
  1327. #define CKR_TEMPLATE_INCOMPLETE (0xd0UL)
  1328. #define CKR_TEMPLATE_INCONSISTENT (0xd1UL)
  1329. #define CKR_TOKEN_NOT_PRESENT (0xe0UL)
  1330. #define CKR_TOKEN_NOT_RECOGNIZED (0xe1UL)
  1331. #define CKR_TOKEN_WRITE_PROTECTED (0xe2UL)
  1332. #define CKR_UNWRAPPING_KEY_HANDLE_INVALID (0xf0UL)
  1333. #define CKR_UNWRAPPING_KEY_SIZE_RANGE (0xf1UL)
  1334. #define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT (0xf2UL)
  1335. #define CKR_USER_ALREADY_LOGGED_IN (0x100UL)
  1336. #define CKR_USER_NOT_LOGGED_IN (0x101UL)
  1337. #define CKR_USER_PIN_NOT_INITIALIZED (0x102UL)
  1338. #define CKR_USER_TYPE_INVALID (0x103UL)
  1339. #define CKR_USER_ANOTHER_ALREADY_LOGGED_IN (0x104UL)
  1340. #define CKR_USER_TOO_MANY_TYPES (0x105UL)
  1341. #define CKR_WRAPPED_KEY_INVALID (0x110UL)
  1342. #define CKR_WRAPPED_KEY_LEN_RANGE (0x112UL)
  1343. #define CKR_WRAPPING_KEY_HANDLE_INVALID (0x113UL)
  1344. #define CKR_WRAPPING_KEY_SIZE_RANGE (0x114UL)
  1345. #define CKR_WRAPPING_KEY_TYPE_INCONSISTENT (0x115UL)
  1346. #define CKR_RANDOM_SEED_NOT_SUPPORTED (0x120UL)
  1347. #define CKR_RANDOM_NO_RNG (0x121UL)
  1348. #define CKR_DOMAIN_PARAMS_INVALID (0x130UL)
  1349. #define CKR_CURVE_NOT_SUPPORTED (0x140UL)
  1350. #define CKR_BUFFER_TOO_SMALL (0x150UL)
  1351. #define CKR_SAVED_STATE_INVALID (0x160UL)
  1352. #define CKR_INFORMATION_SENSITIVE (0x170UL)
  1353. #define CKR_STATE_UNSAVEABLE (0x180UL)
  1354. #define CKR_CRYPTOKI_NOT_INITIALIZED (0x190UL)
  1355. #define CKR_CRYPTOKI_ALREADY_INITIALIZED (0x191UL)
  1356. #define CKR_MUTEX_BAD (0x1a0UL)
  1357. #define CKR_MUTEX_NOT_LOCKED (0x1a1UL)
  1358. #define CKR_NEW_PIN_MODE (0x1b0UL)
  1359. #define CKR_NEXT_OTP (0x1b1UL)
  1360. #define CKR_EXCEEDED_MAX_ITERATIONS (0x1c0UL)
  1361. #define CKR_FIPS_SELF_TEST_FAILED (0x1c1UL)
  1362. #define CKR_LIBRARY_LOAD_FAILED (0x1c2UL)
  1363. #define CKR_PIN_TOO_WEAK (0x1c3UL)
  1364. #define CKR_PUBLIC_KEY_INVALID (0x1c4UL)
  1365. #define CKR_FUNCTION_REJECTED (0x200UL)
  1366. #define CKR_VENDOR_DEFINED ((unsigned long) (1UL << 31))
  1367. #define CKZ_DATA_SPECIFIED (0x01UL)
  1368. /* Compatibility layer. */
  1369. #ifdef CRYPTOKI_COMPAT
  1370. #undef CK_DEFINE_FUNCTION
  1371. #define CK_DEFINE_FUNCTION(retval, name) retval CK_SPEC name
  1372. /* For NULL. */
  1373. #include <stddef.h>
  1374. typedef unsigned char CK_BYTE;
  1375. typedef unsigned char CK_CHAR;
  1376. typedef unsigned char CK_UTF8CHAR;
  1377. typedef unsigned char CK_BBOOL;
  1378. typedef unsigned long int CK_ULONG;
  1379. typedef long int CK_LONG;
  1380. typedef CK_BYTE *CK_BYTE_PTR;
  1381. typedef CK_CHAR *CK_CHAR_PTR;
  1382. typedef CK_UTF8CHAR *CK_UTF8CHAR_PTR;
  1383. typedef CK_ULONG *CK_ULONG_PTR;
  1384. typedef void *CK_VOID_PTR;
  1385. typedef void **CK_VOID_PTR_PTR;
  1386. #define CK_FALSE 0
  1387. #define CK_TRUE 1
  1388. #ifndef CK_DISABLE_TRUE_FALSE
  1389. #ifndef FALSE
  1390. #define FALSE 0
  1391. #endif
  1392. #ifndef TRUE
  1393. #define TRUE 1
  1394. #endif
  1395. #endif
  1396. typedef struct ck_version CK_VERSION;
  1397. typedef struct ck_version *CK_VERSION_PTR;
  1398. typedef struct ck_info CK_INFO;
  1399. typedef struct ck_info *CK_INFO_PTR;
  1400. typedef ck_slot_id_t *CK_SLOT_ID_PTR;
  1401. typedef struct ck_slot_info CK_SLOT_INFO;
  1402. typedef struct ck_slot_info *CK_SLOT_INFO_PTR;
  1403. typedef struct ck_token_info CK_TOKEN_INFO;
  1404. typedef struct ck_token_info *CK_TOKEN_INFO_PTR;
  1405. typedef ck_session_handle_t *CK_SESSION_HANDLE_PTR;
  1406. typedef struct ck_session_info CK_SESSION_INFO;
  1407. typedef struct ck_session_info *CK_SESSION_INFO_PTR;
  1408. typedef ck_object_handle_t *CK_OBJECT_HANDLE_PTR;
  1409. typedef ck_object_class_t *CK_OBJECT_CLASS_PTR;
  1410. typedef struct ck_attribute CK_ATTRIBUTE;
  1411. typedef struct ck_attribute *CK_ATTRIBUTE_PTR;
  1412. typedef struct ck_date CK_DATE;
  1413. typedef struct ck_date *CK_DATE_PTR;
  1414. typedef ck_mechanism_type_t *CK_MECHANISM_TYPE_PTR;
  1415. typedef struct ck_mechanism CK_MECHANISM;
  1416. typedef struct ck_mechanism *CK_MECHANISM_PTR;
  1417. typedef struct ck_mechanism_info CK_MECHANISM_INFO;
  1418. typedef struct ck_mechanism_info *CK_MECHANISM_INFO_PTR;
  1419. typedef struct ck_otp_mechanism_info CK_OTP_MECHANISM_INFO;
  1420. typedef struct ck_otp_mechanism_info *CK_OTP_MECHANISM_INFO_PTR;
  1421. typedef struct ck_function_list CK_FUNCTION_LIST;
  1422. typedef struct ck_function_list *CK_FUNCTION_LIST_PTR;
  1423. typedef struct ck_function_list **CK_FUNCTION_LIST_PTR_PTR;
  1424. typedef struct ck_c_initialize_args CK_C_INITIALIZE_ARGS;
  1425. typedef struct ck_c_initialize_args *CK_C_INITIALIZE_ARGS_PTR;
  1426. typedef struct ck_rsa_pkcs_pss_params CK_RSA_PKCS_PSS_PARAMS;
  1427. typedef struct ck_rsa_pkcs_pss_params *CK_RSA_PKCS_PSS_PARAMS_PTR;
  1428. typedef struct ck_rsa_pkcs_oaep_params CK_RSA_PKCS_OAEP_PARAMS;
  1429. typedef struct ck_rsa_pkcs_oaep_params *CK_RSA_PKCS_OAEP_PARAMS_PTR;
  1430. typedef struct ck_aes_ctr_params CK_AES_CTR_PARAMS;
  1431. typedef struct ck_aes_ctr_params *CK_AES_CTR_PARAMS_PTR;
  1432. typedef struct ck_gcm_params CK_GCM_PARAMS;
  1433. typedef struct ck_gcm_params *CK_GCM_PARAMS_PTR;
  1434. typedef struct ck_ecdh1_derive_params CK_ECDH1_DERIVE_PARAMS;
  1435. typedef struct ck_ecdh1_derive_params *CK_ECDH1_DERIVE_PARAMS_PTR;
  1436. typedef struct ck_key_derivation_string_data CK_KEY_DERIVATION_STRING_DATA;
  1437. typedef struct ck_key_derivation_string_data *CK_KEY_DERIVATION_STRING_DATA_PTR;
  1438. typedef struct ck_des_cbc_encrypt_data_params CK_DES_CBC_ENCRYPT_DATA_PARAMS;
  1439. typedef struct ck_des_cbc_encrypt_data_params *CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR;
  1440. typedef struct ck_aes_cbc_encrypt_data_params CK_AES_CBC_ENCRYPT_DATA_PARAMS;
  1441. typedef struct ck_aes_cbc_encrypt_data_params *CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR;
  1442. #ifndef NULL_PTR
  1443. #define NULL_PTR NULL
  1444. #endif
  1445. /* Delete the helper macros defined at the top of the file. */
  1446. #undef ck_flags_t
  1447. #undef ck_version
  1448. #undef ck_info
  1449. #undef cryptoki_version
  1450. #undef manufacturer_id
  1451. #undef library_description
  1452. #undef library_version
  1453. #undef ck_notification_t
  1454. #undef ck_slot_id_t
  1455. #undef ck_slot_info
  1456. #undef slot_description
  1457. #undef hardware_version
  1458. #undef firmware_version
  1459. #undef ck_token_info
  1460. #undef serial_number
  1461. #undef max_session_count
  1462. #undef session_count
  1463. #undef max_rw_session_count
  1464. #undef rw_session_count
  1465. #undef max_pin_len
  1466. #undef min_pin_len
  1467. #undef total_public_memory
  1468. #undef free_public_memory
  1469. #undef total_private_memory
  1470. #undef free_private_memory
  1471. #undef utc_time
  1472. #undef ck_session_handle_t
  1473. #undef ck_user_type_t
  1474. #undef ck_state_t
  1475. #undef ck_session_info
  1476. #undef slot_id
  1477. #undef device_error
  1478. #undef ck_object_handle_t
  1479. #undef ck_object_class_t
  1480. #undef ck_hw_feature_type_t
  1481. #undef ck_key_type_t
  1482. #undef ck_certificate_type_t
  1483. #undef ck_attribute_type_t
  1484. #undef ck_attribute
  1485. #undef value
  1486. #undef value_len
  1487. #undef params
  1488. #undef count
  1489. #undef ck_date
  1490. #undef ck_mechanism_type_t
  1491. #undef ck_mechanism
  1492. #undef parameter
  1493. #undef parameter_len
  1494. #undef ck_mechanism_info
  1495. #undef ck_param_type
  1496. #undef ck_otp_param
  1497. #undef ck_otp_params
  1498. #undef ck_otp_signature_info
  1499. #undef min_key_size
  1500. #undef max_key_size
  1501. #undef ck_rv_t
  1502. #undef ck_notify_t
  1503. #undef ck_function_list
  1504. #undef ck_createmutex_t
  1505. #undef ck_destroymutex_t
  1506. #undef ck_lockmutex_t
  1507. #undef ck_unlockmutex_t
  1508. #undef ck_c_initialize_args
  1509. #undef create_mutex
  1510. #undef destroy_mutex
  1511. #undef lock_mutex
  1512. #undef unlock_mutex
  1513. #undef reserved
  1514. #endif /* CRYPTOKI_COMPAT */
  1515. /* System dependencies. */
  1516. #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32)
  1517. #pragma pack(pop, cryptoki)
  1518. #endif
  1519. #if defined(__cplusplus)
  1520. }
  1521. #endif
  1522. #endif /* PKCS11_H */