PageRenderTime 42ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/security/nss/cmd/lib/pk11table.c

http://github.com/zpao/v8monkey
C | 1448 lines | 1379 code | 34 blank | 35 comment | 12 complexity | 5a1364245114790a084354be2786f161 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, AGPL-1.0, LGPL-2.1, BSD-3-Clause, GPL-2.0, JSON, Apache-2.0, 0BSD
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is the Netscape security libraries.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Netscape Communications Corporation.
  18. * Portions created by the Initial Developer are Copyright (C) 1994-2000
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. *
  23. * Alternatively, the contents of this file may be used under the terms of
  24. * either the GNU General Public License Version 2 or later (the "GPL"), or
  25. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26. * in which case the provisions of the GPL or the LGPL are applicable instead
  27. * of those above. If you wish to allow use of your version of this file only
  28. * under the terms of either the GPL or the LGPL, and not to allow others to
  29. * use your version of this file under the terms of the MPL, indicate your
  30. * decision by deleting the provisions above and replace them with the notice
  31. * and other provisions required by the GPL or the LGPL. If you do not delete
  32. * the provisions above, a recipient may use your version of this file under
  33. * the terms of any one of the MPL, the GPL or the LGPL.
  34. *
  35. * ***** END LICENSE BLOCK ***** */
  36. #include "pk11table.h"
  37. const char *_valueString[] = {
  38. "None",
  39. "Variable",
  40. "CK_ULONG",
  41. "Data",
  42. "UTF8",
  43. "CK_INFO",
  44. "CK_SLOT_INFO",
  45. "CK_TOKEN_INFO",
  46. "CK_SESSION_INFO",
  47. "CK_ATTRIBUTE",
  48. "CK_MECHANISM",
  49. "CK_MECHANISM_INFO",
  50. "CK_C_INITIALIZE_ARGS",
  51. "CK_FUNCTION_LIST"
  52. };
  53. const char **valueString = &_valueString[0];
  54. const int valueCount = sizeof(_valueString)/sizeof(_valueString[0]);
  55. const char *_constTypeString[] = {
  56. "None",
  57. "Bool",
  58. "InfoFlags",
  59. "SlotFlags",
  60. "TokenFlags",
  61. "SessionFlags",
  62. "MechanismFlags",
  63. "InitializeFlags",
  64. "Users",
  65. "SessionState",
  66. "Object",
  67. "Hardware",
  68. "KeyType",
  69. "CertificateType",
  70. "Attribute",
  71. "Mechanism",
  72. "Result",
  73. "Trust",
  74. "AvailableSizes",
  75. "CurrentSize"
  76. };
  77. const char **constTypeString = &_constTypeString[0];
  78. const int constTypeCount = sizeof(_constTypeString)/sizeof(_constTypeString[0]);
  79. #define mkEntry(x,t) { #x, x, Const##t, ConstNone }
  80. #define mkEntry2(x,t,t2) { #x, x, Const##t, Const##t2 }
  81. const Constant _consts[] = {
  82. mkEntry(CK_FALSE, Bool),
  83. mkEntry(CK_TRUE, Bool),
  84. mkEntry(CKF_TOKEN_PRESENT, SlotFlags),
  85. mkEntry(CKF_REMOVABLE_DEVICE, SlotFlags),
  86. mkEntry(CKF_HW_SLOT, SlotFlags),
  87. mkEntry(CKF_RNG, TokenFlags),
  88. mkEntry(CKF_WRITE_PROTECTED, TokenFlags),
  89. mkEntry(CKF_LOGIN_REQUIRED, TokenFlags),
  90. mkEntry(CKF_USER_PIN_INITIALIZED, TokenFlags),
  91. mkEntry(CKF_RESTORE_KEY_NOT_NEEDED, TokenFlags),
  92. mkEntry(CKF_CLOCK_ON_TOKEN, TokenFlags),
  93. mkEntry(CKF_PROTECTED_AUTHENTICATION_PATH, TokenFlags),
  94. mkEntry(CKF_DUAL_CRYPTO_OPERATIONS, TokenFlags),
  95. mkEntry(CKF_TOKEN_INITIALIZED, TokenFlags),
  96. mkEntry(CKF_SECONDARY_AUTHENTICATION, TokenFlags),
  97. mkEntry(CKF_USER_PIN_COUNT_LOW, TokenFlags),
  98. mkEntry(CKF_USER_PIN_FINAL_TRY, TokenFlags),
  99. mkEntry(CKF_USER_PIN_LOCKED, TokenFlags),
  100. mkEntry(CKF_USER_PIN_TO_BE_CHANGED, TokenFlags),
  101. mkEntry(CKF_SO_PIN_COUNT_LOW, TokenFlags),
  102. mkEntry(CKF_SO_PIN_FINAL_TRY, TokenFlags),
  103. mkEntry(CKF_SO_PIN_LOCKED, TokenFlags),
  104. mkEntry(CKF_SO_PIN_TO_BE_CHANGED, TokenFlags),
  105. mkEntry(CKF_RW_SESSION, SessionFlags),
  106. mkEntry(CKF_SERIAL_SESSION, SessionFlags),
  107. mkEntry(CKF_HW, MechanismFlags),
  108. mkEntry(CKF_ENCRYPT, MechanismFlags),
  109. mkEntry(CKF_DECRYPT, MechanismFlags),
  110. mkEntry(CKF_DIGEST, MechanismFlags),
  111. mkEntry(CKF_SIGN, MechanismFlags),
  112. mkEntry(CKF_SIGN_RECOVER, MechanismFlags),
  113. mkEntry(CKF_VERIFY, MechanismFlags),
  114. mkEntry(CKF_VERIFY_RECOVER, MechanismFlags),
  115. mkEntry(CKF_GENERATE, MechanismFlags),
  116. mkEntry(CKF_GENERATE_KEY_PAIR, MechanismFlags),
  117. mkEntry(CKF_WRAP, MechanismFlags),
  118. mkEntry(CKF_UNWRAP, MechanismFlags),
  119. mkEntry(CKF_DERIVE, MechanismFlags),
  120. mkEntry(CKF_EC_FP, MechanismFlags),
  121. mkEntry(CKF_EC_F_2M, MechanismFlags),
  122. mkEntry(CKF_EC_ECPARAMETERS, MechanismFlags),
  123. mkEntry(CKF_EC_NAMEDCURVE, MechanismFlags),
  124. mkEntry(CKF_EC_UNCOMPRESS, MechanismFlags),
  125. mkEntry(CKF_EC_COMPRESS, MechanismFlags),
  126. mkEntry(CKF_LIBRARY_CANT_CREATE_OS_THREADS, InitializeFlags),
  127. mkEntry(CKF_OS_LOCKING_OK, InitializeFlags),
  128. mkEntry(CKU_SO, Users),
  129. mkEntry(CKU_USER, Users),
  130. mkEntry(CKS_RO_PUBLIC_SESSION, SessionState),
  131. mkEntry(CKS_RO_USER_FUNCTIONS, SessionState),
  132. mkEntry(CKS_RW_PUBLIC_SESSION, SessionState),
  133. mkEntry(CKS_RW_USER_FUNCTIONS, SessionState),
  134. mkEntry(CKS_RW_SO_FUNCTIONS, SessionState),
  135. mkEntry(CKO_DATA, Object),
  136. mkEntry(CKO_CERTIFICATE, Object),
  137. mkEntry(CKO_PUBLIC_KEY, Object),
  138. mkEntry(CKO_PRIVATE_KEY, Object),
  139. mkEntry(CKO_SECRET_KEY, Object),
  140. mkEntry(CKO_HW_FEATURE, Object),
  141. mkEntry(CKO_DOMAIN_PARAMETERS, Object),
  142. mkEntry(CKO_KG_PARAMETERS, Object),
  143. mkEntry(CKO_NSS_CRL, Object),
  144. mkEntry(CKO_NSS_SMIME, Object),
  145. mkEntry(CKO_NSS_TRUST, Object),
  146. mkEntry(CKO_NSS_BUILTIN_ROOT_LIST, Object),
  147. mkEntry(CKH_MONOTONIC_COUNTER, Hardware),
  148. mkEntry(CKH_CLOCK, Hardware),
  149. mkEntry(CKK_RSA, KeyType),
  150. mkEntry(CKK_DSA, KeyType),
  151. mkEntry(CKK_DH, KeyType),
  152. mkEntry(CKK_ECDSA, KeyType),
  153. mkEntry(CKK_EC, KeyType),
  154. mkEntry(CKK_X9_42_DH, KeyType),
  155. mkEntry(CKK_KEA, KeyType),
  156. mkEntry(CKK_GENERIC_SECRET, KeyType),
  157. mkEntry(CKK_RC2, KeyType),
  158. mkEntry(CKK_RC4, KeyType),
  159. mkEntry(CKK_DES, KeyType),
  160. mkEntry(CKK_DES2, KeyType),
  161. mkEntry(CKK_DES3, KeyType),
  162. mkEntry(CKK_CAST, KeyType),
  163. mkEntry(CKK_CAST3, KeyType),
  164. mkEntry(CKK_CAST5, KeyType),
  165. mkEntry(CKK_CAST128, KeyType),
  166. mkEntry(CKK_RC5, KeyType),
  167. mkEntry(CKK_IDEA, KeyType),
  168. mkEntry(CKK_SKIPJACK, KeyType),
  169. mkEntry(CKK_BATON, KeyType),
  170. mkEntry(CKK_JUNIPER, KeyType),
  171. mkEntry(CKK_CDMF, KeyType),
  172. mkEntry(CKK_AES, KeyType),
  173. mkEntry(CKK_CAMELLIA, KeyType),
  174. mkEntry(CKK_NSS_PKCS8, KeyType),
  175. mkEntry(CKC_X_509, CertType),
  176. mkEntry(CKC_X_509_ATTR_CERT, CertType),
  177. mkEntry2(CKA_CLASS, Attribute, Object),
  178. mkEntry2(CKA_TOKEN, Attribute, Bool),
  179. mkEntry2(CKA_PRIVATE, Attribute, Bool),
  180. mkEntry2(CKA_LABEL, Attribute, None),
  181. mkEntry2(CKA_APPLICATION, Attribute, None),
  182. mkEntry2(CKA_VALUE, Attribute, None),
  183. mkEntry2(CKA_OBJECT_ID, Attribute, None),
  184. mkEntry2(CKA_CERTIFICATE_TYPE, Attribute, CertType),
  185. mkEntry2(CKA_ISSUER, Attribute, None),
  186. mkEntry2(CKA_SERIAL_NUMBER, Attribute, None),
  187. mkEntry2(CKA_AC_ISSUER, Attribute, None),
  188. mkEntry2(CKA_OWNER, Attribute, None),
  189. mkEntry2(CKA_ATTR_TYPES, Attribute, None),
  190. mkEntry2(CKA_TRUSTED, Attribute, Bool),
  191. mkEntry2(CKA_KEY_TYPE, Attribute, KeyType),
  192. mkEntry2(CKA_SUBJECT, Attribute, None),
  193. mkEntry2(CKA_ID, Attribute, None),
  194. mkEntry2(CKA_SENSITIVE, Attribute, Bool),
  195. mkEntry2(CKA_ENCRYPT, Attribute, Bool),
  196. mkEntry2(CKA_DECRYPT, Attribute, Bool),
  197. mkEntry2(CKA_WRAP, Attribute, Bool),
  198. mkEntry2(CKA_UNWRAP, Attribute, Bool),
  199. mkEntry2(CKA_SIGN, Attribute, Bool),
  200. mkEntry2(CKA_SIGN_RECOVER, Attribute, Bool),
  201. mkEntry2(CKA_VERIFY, Attribute, Bool),
  202. mkEntry2(CKA_VERIFY_RECOVER, Attribute, Bool),
  203. mkEntry2(CKA_DERIVE, Attribute, Bool),
  204. mkEntry2(CKA_START_DATE, Attribute, None),
  205. mkEntry2(CKA_END_DATE, Attribute, None),
  206. mkEntry2(CKA_MODULUS, Attribute, None),
  207. mkEntry2(CKA_MODULUS_BITS, Attribute, None),
  208. mkEntry2(CKA_PUBLIC_EXPONENT, Attribute, None),
  209. mkEntry2(CKA_PRIVATE_EXPONENT, Attribute, None),
  210. mkEntry2(CKA_PRIME_1, Attribute, None),
  211. mkEntry2(CKA_PRIME_2, Attribute, None),
  212. mkEntry2(CKA_EXPONENT_1, Attribute, None),
  213. mkEntry2(CKA_EXPONENT_2, Attribute, None),
  214. mkEntry2(CKA_COEFFICIENT, Attribute, None),
  215. mkEntry2(CKA_PRIME, Attribute, None),
  216. mkEntry2(CKA_SUBPRIME, Attribute, None),
  217. mkEntry2(CKA_BASE, Attribute, None),
  218. mkEntry2(CKA_PRIME_BITS, Attribute, None),
  219. mkEntry2(CKA_SUB_PRIME_BITS, Attribute, None),
  220. mkEntry2(CKA_VALUE_BITS, Attribute, None),
  221. mkEntry2(CKA_VALUE_LEN, Attribute, None),
  222. mkEntry2(CKA_EXTRACTABLE, Attribute, Bool),
  223. mkEntry2(CKA_LOCAL, Attribute, Bool),
  224. mkEntry2(CKA_NEVER_EXTRACTABLE, Attribute, Bool),
  225. mkEntry2(CKA_ALWAYS_SENSITIVE, Attribute, Bool),
  226. mkEntry2(CKA_KEY_GEN_MECHANISM, Attribute, Mechanism),
  227. mkEntry2(CKA_MODIFIABLE, Attribute, Bool),
  228. mkEntry2(CKA_ECDSA_PARAMS, Attribute, None),
  229. mkEntry2(CKA_EC_PARAMS, Attribute, None),
  230. mkEntry2(CKA_EC_POINT, Attribute, None),
  231. mkEntry2(CKA_SECONDARY_AUTH, Attribute, None),
  232. mkEntry2(CKA_AUTH_PIN_FLAGS, Attribute, None),
  233. mkEntry2(CKA_HW_FEATURE_TYPE, Attribute, Hardware),
  234. mkEntry2(CKA_RESET_ON_INIT, Attribute, Bool),
  235. mkEntry2(CKA_HAS_RESET, Attribute, Bool),
  236. mkEntry2(CKA_NSS_URL, Attribute, None),
  237. mkEntry2(CKA_NSS_EMAIL, Attribute, None),
  238. mkEntry2(CKA_NSS_SMIME_INFO, Attribute, None),
  239. mkEntry2(CKA_NSS_SMIME_TIMESTAMP, Attribute, None),
  240. mkEntry2(CKA_NSS_PKCS8_SALT, Attribute, None),
  241. mkEntry2(CKA_NSS_PASSWORD_CHECK, Attribute, None),
  242. mkEntry2(CKA_NSS_EXPIRES, Attribute, None),
  243. mkEntry2(CKA_NSS_KRL, Attribute, None),
  244. mkEntry2(CKA_NSS_PQG_COUNTER, Attribute, None),
  245. mkEntry2(CKA_NSS_PQG_SEED, Attribute, None),
  246. mkEntry2(CKA_NSS_PQG_H, Attribute, None),
  247. mkEntry2(CKA_NSS_PQG_SEED_BITS, Attribute, None),
  248. mkEntry2(CKA_TRUST_DIGITAL_SIGNATURE, Attribute, Trust),
  249. mkEntry2(CKA_TRUST_NON_REPUDIATION, Attribute, Trust),
  250. mkEntry2(CKA_TRUST_KEY_ENCIPHERMENT, Attribute, Trust),
  251. mkEntry2(CKA_TRUST_DATA_ENCIPHERMENT, Attribute, Trust),
  252. mkEntry2(CKA_TRUST_KEY_AGREEMENT, Attribute, Trust),
  253. mkEntry2(CKA_TRUST_KEY_CERT_SIGN, Attribute, Trust),
  254. mkEntry2(CKA_TRUST_CRL_SIGN, Attribute, Trust),
  255. mkEntry2(CKA_TRUST_SERVER_AUTH, Attribute, Trust),
  256. mkEntry2(CKA_TRUST_CLIENT_AUTH, Attribute, Trust),
  257. mkEntry2(CKA_TRUST_CODE_SIGNING, Attribute, Trust),
  258. mkEntry2(CKA_TRUST_EMAIL_PROTECTION, Attribute, Trust),
  259. mkEntry2(CKA_TRUST_IPSEC_END_SYSTEM, Attribute, Trust),
  260. mkEntry2(CKA_TRUST_IPSEC_TUNNEL, Attribute, Trust),
  261. mkEntry2(CKA_TRUST_IPSEC_USER, Attribute, Trust),
  262. mkEntry2(CKA_TRUST_TIME_STAMPING, Attribute, Trust),
  263. mkEntry2(CKA_CERT_SHA1_HASH, Attribute, None),
  264. mkEntry2(CKA_CERT_MD5_HASH, Attribute, None),
  265. mkEntry2(CKA_NETSCAPE_DB, Attribute, None),
  266. mkEntry2(CKA_NETSCAPE_TRUST, Attribute, Trust),
  267. mkEntry(CKM_RSA_PKCS, Mechanism),
  268. mkEntry(CKM_RSA_9796, Mechanism),
  269. mkEntry(CKM_RSA_X_509, Mechanism),
  270. mkEntry(CKM_RSA_PKCS_KEY_PAIR_GEN, Mechanism),
  271. mkEntry(CKM_MD2_RSA_PKCS, Mechanism),
  272. mkEntry(CKM_MD5_RSA_PKCS, Mechanism),
  273. mkEntry(CKM_SHA1_RSA_PKCS, Mechanism),
  274. mkEntry(CKM_RIPEMD128_RSA_PKCS, Mechanism),
  275. mkEntry(CKM_RIPEMD160_RSA_PKCS, Mechanism),
  276. mkEntry(CKM_RSA_PKCS_OAEP, Mechanism),
  277. mkEntry(CKM_RSA_X9_31_KEY_PAIR_GEN, Mechanism),
  278. mkEntry(CKM_RSA_X9_31, Mechanism),
  279. mkEntry(CKM_SHA1_RSA_X9_31, Mechanism),
  280. mkEntry(CKM_DSA_KEY_PAIR_GEN, Mechanism),
  281. mkEntry(CKM_DSA, Mechanism),
  282. mkEntry(CKM_DSA_SHA1, Mechanism),
  283. mkEntry(CKM_DH_PKCS_KEY_PAIR_GEN, Mechanism),
  284. mkEntry(CKM_DH_PKCS_DERIVE, Mechanism),
  285. mkEntry(CKM_X9_42_DH_DERIVE, Mechanism),
  286. mkEntry(CKM_X9_42_DH_HYBRID_DERIVE, Mechanism),
  287. mkEntry(CKM_X9_42_MQV_DERIVE, Mechanism),
  288. mkEntry(CKM_SHA256_RSA_PKCS, Mechanism),
  289. mkEntry(CKM_SHA384_RSA_PKCS, Mechanism),
  290. mkEntry(CKM_SHA512_RSA_PKCS, Mechanism),
  291. mkEntry(CKM_RC2_KEY_GEN, Mechanism),
  292. mkEntry(CKM_RC2_ECB, Mechanism),
  293. mkEntry(CKM_RC2_CBC, Mechanism),
  294. mkEntry(CKM_RC2_MAC, Mechanism),
  295. mkEntry(CKM_RC2_MAC_GENERAL, Mechanism),
  296. mkEntry(CKM_RC2_CBC_PAD, Mechanism),
  297. mkEntry(CKM_RC4_KEY_GEN, Mechanism),
  298. mkEntry(CKM_RC4, Mechanism),
  299. mkEntry(CKM_DES_KEY_GEN, Mechanism),
  300. mkEntry(CKM_DES_ECB, Mechanism),
  301. mkEntry(CKM_DES_CBC, Mechanism),
  302. mkEntry(CKM_DES_MAC, Mechanism),
  303. mkEntry(CKM_DES_MAC_GENERAL, Mechanism),
  304. mkEntry(CKM_DES_CBC_PAD, Mechanism),
  305. mkEntry(CKM_DES2_KEY_GEN, Mechanism),
  306. mkEntry(CKM_DES3_KEY_GEN, Mechanism),
  307. mkEntry(CKM_DES3_ECB, Mechanism),
  308. mkEntry(CKM_DES3_CBC, Mechanism),
  309. mkEntry(CKM_DES3_MAC, Mechanism),
  310. mkEntry(CKM_DES3_MAC_GENERAL, Mechanism),
  311. mkEntry(CKM_DES3_CBC_PAD, Mechanism),
  312. mkEntry(CKM_CDMF_KEY_GEN, Mechanism),
  313. mkEntry(CKM_CDMF_ECB, Mechanism),
  314. mkEntry(CKM_CDMF_CBC, Mechanism),
  315. mkEntry(CKM_CDMF_MAC, Mechanism),
  316. mkEntry(CKM_CDMF_MAC_GENERAL, Mechanism),
  317. mkEntry(CKM_CDMF_CBC_PAD, Mechanism),
  318. mkEntry(CKM_MD2, Mechanism),
  319. mkEntry(CKM_MD2_HMAC, Mechanism),
  320. mkEntry(CKM_MD2_HMAC_GENERAL, Mechanism),
  321. mkEntry(CKM_MD5, Mechanism),
  322. mkEntry(CKM_MD5_HMAC, Mechanism),
  323. mkEntry(CKM_MD5_HMAC_GENERAL, Mechanism),
  324. mkEntry(CKM_SHA_1, Mechanism),
  325. mkEntry(CKM_SHA_1_HMAC, Mechanism),
  326. mkEntry(CKM_SHA_1_HMAC_GENERAL, Mechanism),
  327. mkEntry(CKM_RIPEMD128, Mechanism),
  328. mkEntry(CKM_RIPEMD128_HMAC, Mechanism),
  329. mkEntry(CKM_RIPEMD128_HMAC_GENERAL, Mechanism),
  330. mkEntry(CKM_RIPEMD160, Mechanism),
  331. mkEntry(CKM_RIPEMD160_HMAC, Mechanism),
  332. mkEntry(CKM_RIPEMD160_HMAC_GENERAL, Mechanism),
  333. mkEntry(CKM_SHA256, Mechanism),
  334. mkEntry(CKM_SHA256_HMAC_GENERAL, Mechanism),
  335. mkEntry(CKM_SHA256_HMAC, Mechanism),
  336. mkEntry(CKM_SHA384, Mechanism),
  337. mkEntry(CKM_SHA384_HMAC_GENERAL, Mechanism),
  338. mkEntry(CKM_SHA384_HMAC, Mechanism),
  339. mkEntry(CKM_SHA512, Mechanism),
  340. mkEntry(CKM_SHA512_HMAC_GENERAL, Mechanism),
  341. mkEntry(CKM_SHA512_HMAC, Mechanism),
  342. mkEntry(CKM_CAST_KEY_GEN, Mechanism),
  343. mkEntry(CKM_CAST_ECB, Mechanism),
  344. mkEntry(CKM_CAST_CBC, Mechanism),
  345. mkEntry(CKM_CAST_MAC, Mechanism),
  346. mkEntry(CKM_CAST_MAC_GENERAL, Mechanism),
  347. mkEntry(CKM_CAST_CBC_PAD, Mechanism),
  348. mkEntry(CKM_CAST3_KEY_GEN, Mechanism),
  349. mkEntry(CKM_CAST3_ECB, Mechanism),
  350. mkEntry(CKM_CAST3_CBC, Mechanism),
  351. mkEntry(CKM_CAST3_MAC, Mechanism),
  352. mkEntry(CKM_CAST3_MAC_GENERAL, Mechanism),
  353. mkEntry(CKM_CAST3_CBC_PAD, Mechanism),
  354. mkEntry(CKM_CAST5_KEY_GEN, Mechanism),
  355. mkEntry(CKM_CAST128_KEY_GEN, Mechanism),
  356. mkEntry(CKM_CAST5_ECB, Mechanism),
  357. mkEntry(CKM_CAST128_ECB, Mechanism),
  358. mkEntry(CKM_CAST5_CBC, Mechanism),
  359. mkEntry(CKM_CAST128_CBC, Mechanism),
  360. mkEntry(CKM_CAST5_MAC, Mechanism),
  361. mkEntry(CKM_CAST128_MAC, Mechanism),
  362. mkEntry(CKM_CAST5_MAC_GENERAL, Mechanism),
  363. mkEntry(CKM_CAST128_MAC_GENERAL, Mechanism),
  364. mkEntry(CKM_CAST5_CBC_PAD, Mechanism),
  365. mkEntry(CKM_CAST128_CBC_PAD, Mechanism),
  366. mkEntry(CKM_RC5_KEY_GEN, Mechanism),
  367. mkEntry(CKM_RC5_ECB, Mechanism),
  368. mkEntry(CKM_RC5_CBC, Mechanism),
  369. mkEntry(CKM_RC5_MAC, Mechanism),
  370. mkEntry(CKM_RC5_MAC_GENERAL, Mechanism),
  371. mkEntry(CKM_RC5_CBC_PAD, Mechanism),
  372. mkEntry(CKM_IDEA_KEY_GEN, Mechanism),
  373. mkEntry(CKM_IDEA_ECB, Mechanism),
  374. mkEntry(CKM_IDEA_CBC, Mechanism),
  375. mkEntry(CKM_IDEA_MAC, Mechanism),
  376. mkEntry(CKM_IDEA_MAC_GENERAL, Mechanism),
  377. mkEntry(CKM_IDEA_CBC_PAD, Mechanism),
  378. mkEntry(CKM_GENERIC_SECRET_KEY_GEN, Mechanism),
  379. mkEntry(CKM_CONCATENATE_BASE_AND_KEY, Mechanism),
  380. mkEntry(CKM_CONCATENATE_BASE_AND_DATA, Mechanism),
  381. mkEntry(CKM_CONCATENATE_DATA_AND_BASE, Mechanism),
  382. mkEntry(CKM_XOR_BASE_AND_DATA, Mechanism),
  383. mkEntry(CKM_EXTRACT_KEY_FROM_KEY, Mechanism),
  384. mkEntry(CKM_SSL3_PRE_MASTER_KEY_GEN, Mechanism),
  385. mkEntry(CKM_SSL3_MASTER_KEY_DERIVE, Mechanism),
  386. mkEntry(CKM_SSL3_KEY_AND_MAC_DERIVE, Mechanism),
  387. mkEntry(CKM_SSL3_MASTER_KEY_DERIVE_DH, Mechanism),
  388. mkEntry(CKM_TLS_PRE_MASTER_KEY_GEN, Mechanism),
  389. mkEntry(CKM_TLS_MASTER_KEY_DERIVE, Mechanism),
  390. mkEntry(CKM_TLS_KEY_AND_MAC_DERIVE, Mechanism),
  391. mkEntry(CKM_TLS_MASTER_KEY_DERIVE_DH, Mechanism),
  392. mkEntry(CKM_SSL3_MD5_MAC, Mechanism),
  393. mkEntry(CKM_SSL3_SHA1_MAC, Mechanism),
  394. mkEntry(CKM_MD5_KEY_DERIVATION, Mechanism),
  395. mkEntry(CKM_MD2_KEY_DERIVATION, Mechanism),
  396. mkEntry(CKM_SHA1_KEY_DERIVATION, Mechanism),
  397. mkEntry(CKM_SHA256_KEY_DERIVATION, Mechanism),
  398. mkEntry(CKM_SHA384_KEY_DERIVATION, Mechanism),
  399. mkEntry(CKM_SHA512_KEY_DERIVATION, Mechanism),
  400. mkEntry(CKM_PBE_MD2_DES_CBC, Mechanism),
  401. mkEntry(CKM_PBE_MD5_DES_CBC, Mechanism),
  402. mkEntry(CKM_PBE_MD5_CAST_CBC, Mechanism),
  403. mkEntry(CKM_PBE_MD5_CAST3_CBC, Mechanism),
  404. mkEntry(CKM_PBE_MD5_CAST5_CBC, Mechanism),
  405. mkEntry(CKM_PBE_MD5_CAST128_CBC, Mechanism),
  406. mkEntry(CKM_PBE_SHA1_CAST5_CBC, Mechanism),
  407. mkEntry(CKM_PBE_SHA1_CAST128_CBC, Mechanism),
  408. mkEntry(CKM_PBE_SHA1_RC4_128, Mechanism),
  409. mkEntry(CKM_PBE_SHA1_RC4_40, Mechanism),
  410. mkEntry(CKM_PBE_SHA1_DES3_EDE_CBC, Mechanism),
  411. mkEntry(CKM_PBE_SHA1_DES2_EDE_CBC, Mechanism),
  412. mkEntry(CKM_PBE_SHA1_RC2_128_CBC, Mechanism),
  413. mkEntry(CKM_PBE_SHA1_RC2_40_CBC, Mechanism),
  414. mkEntry(CKM_PKCS5_PBKD2, Mechanism),
  415. mkEntry(CKM_PBA_SHA1_WITH_SHA1_HMAC, Mechanism),
  416. mkEntry(CKM_KEY_WRAP_LYNKS, Mechanism),
  417. mkEntry(CKM_KEY_WRAP_SET_OAEP, Mechanism),
  418. mkEntry(CKM_SKIPJACK_KEY_GEN, Mechanism),
  419. mkEntry(CKM_SKIPJACK_ECB64, Mechanism),
  420. mkEntry(CKM_SKIPJACK_CBC64, Mechanism),
  421. mkEntry(CKM_SKIPJACK_OFB64, Mechanism),
  422. mkEntry(CKM_SKIPJACK_CFB64, Mechanism),
  423. mkEntry(CKM_SKIPJACK_CFB32, Mechanism),
  424. mkEntry(CKM_SKIPJACK_CFB16, Mechanism),
  425. mkEntry(CKM_SKIPJACK_CFB8, Mechanism),
  426. mkEntry(CKM_SKIPJACK_WRAP, Mechanism),
  427. mkEntry(CKM_SKIPJACK_PRIVATE_WRAP, Mechanism),
  428. mkEntry(CKM_SKIPJACK_RELAYX, Mechanism),
  429. mkEntry(CKM_KEA_KEY_PAIR_GEN, Mechanism),
  430. mkEntry(CKM_KEA_KEY_DERIVE, Mechanism),
  431. mkEntry(CKM_FORTEZZA_TIMESTAMP, Mechanism),
  432. mkEntry(CKM_BATON_KEY_GEN, Mechanism),
  433. mkEntry(CKM_BATON_ECB128, Mechanism),
  434. mkEntry(CKM_BATON_ECB96, Mechanism),
  435. mkEntry(CKM_BATON_CBC128, Mechanism),
  436. mkEntry(CKM_BATON_COUNTER, Mechanism),
  437. mkEntry(CKM_BATON_SHUFFLE, Mechanism),
  438. mkEntry(CKM_BATON_WRAP, Mechanism),
  439. mkEntry(CKM_ECDSA_KEY_PAIR_GEN, Mechanism),
  440. mkEntry(CKM_EC_KEY_PAIR_GEN, Mechanism),
  441. mkEntry(CKM_ECDSA, Mechanism),
  442. mkEntry(CKM_ECDSA_SHA1, Mechanism),
  443. mkEntry(CKM_ECDH1_DERIVE, Mechanism),
  444. mkEntry(CKM_ECDH1_COFACTOR_DERIVE, Mechanism),
  445. mkEntry(CKM_ECMQV_DERIVE, Mechanism),
  446. mkEntry(CKM_JUNIPER_KEY_GEN, Mechanism),
  447. mkEntry(CKM_JUNIPER_ECB128, Mechanism),
  448. mkEntry(CKM_JUNIPER_CBC128, Mechanism),
  449. mkEntry(CKM_JUNIPER_COUNTER, Mechanism),
  450. mkEntry(CKM_JUNIPER_SHUFFLE, Mechanism),
  451. mkEntry(CKM_JUNIPER_WRAP, Mechanism),
  452. mkEntry(CKM_FASTHASH, Mechanism),
  453. mkEntry(CKM_AES_KEY_GEN, Mechanism),
  454. mkEntry(CKM_AES_ECB, Mechanism),
  455. mkEntry(CKM_AES_CBC, Mechanism),
  456. mkEntry(CKM_AES_MAC, Mechanism),
  457. mkEntry(CKM_AES_MAC_GENERAL, Mechanism),
  458. mkEntry(CKM_AES_CBC_PAD, Mechanism),
  459. mkEntry(CKM_CAMELLIA_KEY_GEN, Mechanism),
  460. mkEntry(CKM_CAMELLIA_ECB, Mechanism),
  461. mkEntry(CKM_CAMELLIA_CBC, Mechanism),
  462. mkEntry(CKM_CAMELLIA_MAC, Mechanism),
  463. mkEntry(CKM_CAMELLIA_MAC_GENERAL, Mechanism),
  464. mkEntry(CKM_CAMELLIA_CBC_PAD, Mechanism),
  465. mkEntry(CKM_SEED_KEY_GEN, Mechanism),
  466. mkEntry(CKM_SEED_ECB, Mechanism),
  467. mkEntry(CKM_SEED_CBC, Mechanism),
  468. mkEntry(CKM_SEED_MAC, Mechanism),
  469. mkEntry(CKM_SEED_MAC_GENERAL, Mechanism),
  470. mkEntry(CKM_SEED_CBC_PAD, Mechanism),
  471. mkEntry(CKM_SEED_ECB_ENCRYPT_DATA, Mechanism),
  472. mkEntry(CKM_SEED_CBC_ENCRYPT_DATA, Mechanism),
  473. mkEntry(CKM_DSA_PARAMETER_GEN, Mechanism),
  474. mkEntry(CKM_DH_PKCS_PARAMETER_GEN, Mechanism),
  475. mkEntry(CKM_NSS_AES_KEY_WRAP, Mechanism),
  476. mkEntry(CKM_NSS_AES_KEY_WRAP_PAD, Mechanism),
  477. mkEntry(CKM_NETSCAPE_PBE_SHA1_DES_CBC, Mechanism),
  478. mkEntry(CKM_NETSCAPE_PBE_SHA1_TRIPLE_DES_CBC, Mechanism),
  479. mkEntry(CKM_NETSCAPE_PBE_SHA1_40_BIT_RC2_CBC, Mechanism),
  480. mkEntry(CKM_NETSCAPE_PBE_SHA1_128_BIT_RC2_CBC, Mechanism),
  481. mkEntry(CKM_NETSCAPE_PBE_SHA1_40_BIT_RC4, Mechanism),
  482. mkEntry(CKM_NETSCAPE_PBE_SHA1_128_BIT_RC4, Mechanism),
  483. mkEntry(CKM_NETSCAPE_PBE_SHA1_FAULTY_3DES_CBC, Mechanism),
  484. mkEntry(CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN, Mechanism),
  485. mkEntry(CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN, Mechanism),
  486. mkEntry(CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN, Mechanism),
  487. mkEntry(CKM_TLS_PRF_GENERAL, Mechanism),
  488. mkEntry(CKR_OK, Result),
  489. mkEntry(CKR_CANCEL, Result),
  490. mkEntry(CKR_HOST_MEMORY, Result),
  491. mkEntry(CKR_SLOT_ID_INVALID, Result),
  492. mkEntry(CKR_GENERAL_ERROR, Result),
  493. mkEntry(CKR_FUNCTION_FAILED, Result),
  494. mkEntry(CKR_ARGUMENTS_BAD, Result),
  495. mkEntry(CKR_NO_EVENT, Result),
  496. mkEntry(CKR_NEED_TO_CREATE_THREADS, Result),
  497. mkEntry(CKR_CANT_LOCK, Result),
  498. mkEntry(CKR_ATTRIBUTE_READ_ONLY, Result),
  499. mkEntry(CKR_ATTRIBUTE_SENSITIVE, Result),
  500. mkEntry(CKR_ATTRIBUTE_TYPE_INVALID, Result),
  501. mkEntry(CKR_ATTRIBUTE_VALUE_INVALID, Result),
  502. mkEntry(CKR_DATA_INVALID, Result),
  503. mkEntry(CKR_DATA_LEN_RANGE, Result),
  504. mkEntry(CKR_DEVICE_ERROR, Result),
  505. mkEntry(CKR_DEVICE_MEMORY, Result),
  506. mkEntry(CKR_DEVICE_REMOVED, Result),
  507. mkEntry(CKR_ENCRYPTED_DATA_INVALID, Result),
  508. mkEntry(CKR_ENCRYPTED_DATA_LEN_RANGE, Result),
  509. mkEntry(CKR_FUNCTION_CANCELED, Result),
  510. mkEntry(CKR_FUNCTION_NOT_PARALLEL, Result),
  511. mkEntry(CKR_FUNCTION_NOT_SUPPORTED, Result),
  512. mkEntry(CKR_KEY_HANDLE_INVALID, Result),
  513. mkEntry(CKR_KEY_SIZE_RANGE, Result),
  514. mkEntry(CKR_KEY_TYPE_INCONSISTENT, Result),
  515. mkEntry(CKR_KEY_NOT_NEEDED, Result),
  516. mkEntry(CKR_KEY_CHANGED, Result),
  517. mkEntry(CKR_KEY_NEEDED, Result),
  518. mkEntry(CKR_KEY_INDIGESTIBLE, Result),
  519. mkEntry(CKR_KEY_FUNCTION_NOT_PERMITTED, Result),
  520. mkEntry(CKR_KEY_NOT_WRAPPABLE, Result),
  521. mkEntry(CKR_KEY_UNEXTRACTABLE, Result),
  522. mkEntry(CKR_KEY_PARAMS_INVALID, Result),
  523. mkEntry(CKR_MECHANISM_INVALID, Result),
  524. mkEntry(CKR_MECHANISM_PARAM_INVALID, Result),
  525. mkEntry(CKR_OBJECT_HANDLE_INVALID, Result),
  526. mkEntry(CKR_OPERATION_ACTIVE, Result),
  527. mkEntry(CKR_OPERATION_NOT_INITIALIZED, Result),
  528. mkEntry(CKR_PIN_INCORRECT, Result),
  529. mkEntry(CKR_PIN_INVALID, Result),
  530. mkEntry(CKR_PIN_LEN_RANGE, Result),
  531. mkEntry(CKR_PIN_EXPIRED, Result),
  532. mkEntry(CKR_PIN_LOCKED, Result),
  533. mkEntry(CKR_SESSION_CLOSED, Result),
  534. mkEntry(CKR_SESSION_COUNT, Result),
  535. mkEntry(CKR_SESSION_HANDLE_INVALID, Result),
  536. mkEntry(CKR_SESSION_PARALLEL_NOT_SUPPORTED, Result),
  537. mkEntry(CKR_SESSION_READ_ONLY, Result),
  538. mkEntry(CKR_SESSION_EXISTS, Result),
  539. mkEntry(CKR_SESSION_READ_ONLY_EXISTS, Result),
  540. mkEntry(CKR_SESSION_READ_WRITE_SO_EXISTS, Result),
  541. mkEntry(CKR_SIGNATURE_INVALID, Result),
  542. mkEntry(CKR_SIGNATURE_LEN_RANGE, Result),
  543. mkEntry(CKR_TEMPLATE_INCOMPLETE, Result),
  544. mkEntry(CKR_TEMPLATE_INCONSISTENT, Result),
  545. mkEntry(CKR_TOKEN_NOT_PRESENT, Result),
  546. mkEntry(CKR_TOKEN_NOT_RECOGNIZED, Result),
  547. mkEntry(CKR_TOKEN_WRITE_PROTECTED, Result),
  548. mkEntry(CKR_UNWRAPPING_KEY_HANDLE_INVALID, Result),
  549. mkEntry(CKR_UNWRAPPING_KEY_SIZE_RANGE, Result),
  550. mkEntry(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT, Result),
  551. mkEntry(CKR_USER_ALREADY_LOGGED_IN, Result),
  552. mkEntry(CKR_USER_NOT_LOGGED_IN, Result),
  553. mkEntry(CKR_USER_PIN_NOT_INITIALIZED, Result),
  554. mkEntry(CKR_USER_TYPE_INVALID, Result),
  555. mkEntry(CKR_USER_ANOTHER_ALREADY_LOGGED_IN, Result),
  556. mkEntry(CKR_USER_TOO_MANY_TYPES, Result),
  557. mkEntry(CKR_WRAPPED_KEY_INVALID, Result),
  558. mkEntry(CKR_WRAPPED_KEY_LEN_RANGE, Result),
  559. mkEntry(CKR_WRAPPING_KEY_HANDLE_INVALID, Result),
  560. mkEntry(CKR_WRAPPING_KEY_SIZE_RANGE, Result),
  561. mkEntry(CKR_WRAPPING_KEY_TYPE_INCONSISTENT, Result),
  562. mkEntry(CKR_RANDOM_SEED_NOT_SUPPORTED, Result),
  563. mkEntry(CKR_RANDOM_NO_RNG, Result),
  564. mkEntry(CKR_DOMAIN_PARAMS_INVALID, Result),
  565. mkEntry(CKR_BUFFER_TOO_SMALL, Result),
  566. mkEntry(CKR_SAVED_STATE_INVALID, Result),
  567. mkEntry(CKR_INFORMATION_SENSITIVE, Result),
  568. mkEntry(CKR_STATE_UNSAVEABLE, Result),
  569. mkEntry(CKR_CRYPTOKI_NOT_INITIALIZED, Result),
  570. mkEntry(CKR_CRYPTOKI_ALREADY_INITIALIZED, Result),
  571. mkEntry(CKR_MUTEX_BAD, Result),
  572. mkEntry(CKR_MUTEX_NOT_LOCKED, Result),
  573. mkEntry(CKR_VENDOR_DEFINED, Result),
  574. mkEntry(CKT_NSS_TRUSTED, Trust),
  575. mkEntry(CKT_NSS_TRUSTED_DELEGATOR, Trust),
  576. mkEntry(CKT_NSS_NOT_TRUSTED, Trust),
  577. mkEntry(CKT_NSS_MUST_VERIFY_TRUST, Trust),
  578. mkEntry(CKT_NSS_TRUST_UNKNOWN, Trust),
  579. mkEntry(CKT_NSS_VALID_DELEGATOR, Trust),
  580. mkEntry(CK_EFFECTIVELY_INFINITE, AvailableSizes),
  581. mkEntry(CK_UNAVAILABLE_INFORMATION, CurrentSize),
  582. };
  583. const Constant *consts = &_consts[0];
  584. const int constCount = sizeof(_consts)/sizeof(_consts[0]);
  585. const Commands _commands[] = {
  586. {"C_Initialize", F_C_Initialize,
  587. "C_Initialize pInitArgs\n\n"
  588. "C_Initialize initializes the PKCS #11 library.\n"
  589. " pInitArgs if this is not NULL_PTR it gets cast to and dereferenced\n",
  590. {ArgInitializeArgs, ArgNone, ArgNone, ArgNone, ArgNone,
  591. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  592. {"C_Finalize", F_C_Finalize,
  593. "C_Finalize pReserved\n\n"
  594. "C_Finalize indicates that an application is done with the PKCS #11 library.\n"
  595. " pReserved reserved. Should be NULL_PTR\n",
  596. {ArgInitializeArgs, ArgNone, ArgNone, ArgNone, ArgNone,
  597. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  598. {"C_GetInfo", F_C_GetInfo,
  599. "C_GetInfo pInfo\n\n"
  600. "C_GetInfo returns general information about PKCS #11.\n"
  601. " pInfo location that receives information\n",
  602. {ArgInfo|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone,
  603. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  604. {"C_GetFunctionList", F_C_GetFunctionList,
  605. "C_GetFunctionList ppFunctionList\n\n"
  606. "C_GetFunctionList returns the function list.\n"
  607. " ppFunctionList receives pointer to function list\n",
  608. {ArgFunctionList|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone,
  609. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  610. {"C_GetSlotList", F_C_GetSlotList,
  611. "C_GetSlotList tokenPresent pSlotList pulCount\n\n"
  612. "C_GetSlotList obtains a list of slots in the system.\n"
  613. " tokenPresent only slots with tokens?\n"
  614. " pSlotList receives array of slot IDs\n"
  615. " pulCount receives number of slots\n",
  616. {ArgULong, ArgULong|ArgArray|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  617. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  618. {"C_GetSlotInfo", F_C_GetSlotInfo,
  619. "C_GetSlotInfo slotID pInfo\n\n"
  620. "C_GetSlotInfo obtains information about a particular slot in the system.\n"
  621. " slotID the ID of the slot\n"
  622. " pInfo receives the slot information\n",
  623. {ArgULong, ArgSlotInfo|ArgOut, ArgNone, ArgNone, ArgNone,
  624. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  625. {"C_GetTokenInfo", F_C_GetTokenInfo,
  626. "C_GetTokenInfo slotID pInfo\n\n"
  627. "C_GetTokenInfo obtains information about a particular token in the system.\n"
  628. " slotID ID of the token's slot\n"
  629. " pInfo receives the token information\n",
  630. {ArgULong, ArgTokenInfo|ArgOut, ArgNone, ArgNone, ArgNone,
  631. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  632. {"C_GetMechanismList", F_C_GetMechanismList,
  633. "C_GetMechanismList slotID pMechanismList pulCount\n\n"
  634. "C_GetMechanismList obtains a list of mechanism types supported by a token.\n"
  635. " slotID ID of token's slot\n"
  636. " pMechanismList gets mech. array\n"
  637. " pulCount gets # of mechs.\n",
  638. {ArgULong, ArgULong|ArgArray|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  639. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  640. {"C_GetMechanismInfo", F_C_GetMechanismInfo,
  641. "C_GetMechanismInfo slotID type pInfo\n\n"
  642. "C_GetMechanismInfo obtains information about a particular mechanism possibly\n"
  643. "supported by a token.\n"
  644. " slotID ID of the token's slot\n"
  645. " type type of mechanism\n"
  646. " pInfo receives mechanism info\n",
  647. {ArgULong, ArgULong, ArgMechanismInfo|ArgOut, ArgNone, ArgNone,
  648. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  649. {"C_InitToken", F_C_InitToken,
  650. "C_InitToken slotID pPin ulPinLen pLabel\n\n"
  651. "C_InitToken initializes a token.\n"
  652. " slotID ID of the token's slot\n"
  653. " pPin the SO's initial PIN\n"
  654. " ulPinLen length in bytes of the PIN\n"
  655. " pLabel 32-byte token label (blank padded)\n",
  656. {ArgULong, ArgUTF8, ArgULong, ArgUTF8, ArgNone,
  657. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  658. {"C_InitPIN", F_C_InitPIN,
  659. "C_InitPIN hSession pPin ulPinLen\n\n"
  660. "C_InitPIN initializes the normal user's PIN.\n"
  661. " hSession the session's handle\n"
  662. " pPin the normal user's PIN\n"
  663. " ulPinLen length in bytes of the PIN\n",
  664. {ArgULong, ArgUTF8, ArgULong, ArgNone, ArgNone,
  665. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  666. {"C_SetPIN", F_C_SetPIN,
  667. "C_SetPIN hSession pOldPin ulOldLen pNewPin ulNewLen\n\n"
  668. "C_SetPIN modifies the PIN of the user who is logged in.\n"
  669. " hSession the session's handle\n"
  670. " pOldPin the old PIN\n"
  671. " ulOldLen length of the old PIN\n"
  672. " pNewPin the new PIN\n"
  673. " ulNewLen length of the new PIN\n",
  674. {ArgULong, ArgUTF8, ArgULong, ArgUTF8, ArgULong,
  675. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  676. {"C_OpenSession", F_C_OpenSession,
  677. "C_OpenSession slotID flags phSession\n\n"
  678. "C_OpenSession opens a session between an application and a token.\n"
  679. " slotID the slot's ID\n"
  680. " flags from\n"
  681. " phSession gets session handle\n",
  682. {ArgULong, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone,
  683. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  684. {"C_CloseSession", F_C_CloseSession,
  685. "C_CloseSession hSession\n\n"
  686. "C_CloseSession closes a session between an application and a token.\n"
  687. " hSession the session's handle\n",
  688. {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone,
  689. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  690. {"C_CloseAllSessions", F_C_CloseAllSessions,
  691. "C_CloseAllSessions slotID\n\n"
  692. "C_CloseAllSessions closes all sessions with a token.\n"
  693. " slotID the token's slot\n",
  694. {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone,
  695. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  696. {"C_GetSessionInfo", F_C_GetSessionInfo,
  697. "C_GetSessionInfo hSession pInfo\n\n"
  698. "C_GetSessionInfo obtains information about the session.\n"
  699. " hSession the session's handle\n"
  700. " pInfo receives session info\n",
  701. {ArgULong, ArgSessionInfo|ArgOut, ArgNone, ArgNone, ArgNone,
  702. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  703. {"C_GetOperationState", F_C_GetOperationState,
  704. "C_GetOperationState hSession pOpState pulOpStateLen\n\n"
  705. "C_GetOperationState obtains the state of the cryptographic operation in a\n"
  706. "session.\n"
  707. " hSession session's handle\n"
  708. " pOpState gets state\n"
  709. " pulOpStateLen gets state length\n",
  710. {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  711. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  712. {"C_SetOperationState", F_C_SetOperationState,
  713. "C_SetOperationState hSession pOpState ulOpStateLen hEncKey hAuthKey\n\n"
  714. "C_SetOperationState restores the state of the cryptographic operation in a\n"
  715. "session.\n"
  716. " hSession session's handle\n"
  717. " pOpState holds state\n"
  718. " ulOpStateLen holds state length\n"
  719. " hEncKey en/decryption key\n"
  720. " hAuthnKey sign/verify key\n",
  721. {ArgULong, ArgChar|ArgOut, ArgULong, ArgULong, ArgULong,
  722. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  723. {"C_Login", F_C_Login,
  724. "C_Login hSession userType pPin ulPinLen\n\n"
  725. "C_Login logs a user into a token.\n"
  726. " hSession the session's handle\n"
  727. " userType the user type\n"
  728. " pPin the user's PIN\n"
  729. " ulPinLen the length of the PIN\n",
  730. {ArgULong, ArgULong, ArgVar, ArgULong, ArgNone,
  731. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  732. {"C_Logout", F_C_Logout,
  733. "C_Logout hSession\n\n"
  734. "C_Logout logs a user out from a token.\n"
  735. " hSession the session's handle\n",
  736. {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone,
  737. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  738. {"C_CreateObject", F_C_CreateObject,
  739. "C_CreateObject hSession pTemplate ulCount phObject\n\n"
  740. "C_CreateObject creates a new object.\n"
  741. " hSession the session's handle\n"
  742. " pTemplate the object's template\n"
  743. " ulCount attributes in template\n"
  744. " phObject gets new object's handle.\n",
  745. {ArgULong, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgNone,
  746. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  747. {"C_CopyObject", F_C_CopyObject,
  748. "C_CopyObject hSession hObject pTemplate ulCount phNewObject\n\n"
  749. "C_CopyObject copies an object creating a new object for the copy.\n"
  750. " hSession the session's handle\n"
  751. " hObject the object's handle\n"
  752. " pTemplate template for new object\n"
  753. " ulCount attributes in template\n"
  754. " phNewObject receives handle of copy\n",
  755. {ArgULong, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut,
  756. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  757. {"C_DestroyObject", F_C_DestroyObject,
  758. "C_DestroyObject hSession hObject\n\n"
  759. "C_DestroyObject destroys an object.\n"
  760. " hSession the session's handle\n"
  761. " hObject the object's handle\n",
  762. {ArgULong, ArgULong, ArgNone, ArgNone, ArgNone,
  763. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  764. {"C_GetObjectSize", F_C_GetObjectSize,
  765. "C_GetObjectSize hSession hObject pulSize\n\n"
  766. "C_GetObjectSize gets the size of an object in bytes.\n"
  767. " hSession the session's handle\n"
  768. " hObject the object's handle\n"
  769. " pulSize receives size of object\n",
  770. {ArgULong, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone,
  771. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  772. {"C_GetAttributeValue", F_C_GetAttributeValue,
  773. "C_GetAttributeValue hSession hObject pTemplate ulCount\n\n"
  774. "C_GetAttributeValue obtains the value of one or more object attributes.\n"
  775. " hSession the session's handle\n"
  776. " hObject the object's handle\n"
  777. " pTemplate specifies attrs; gets vals\n"
  778. " ulCount attributes in template\n",
  779. {ArgULong, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgNone,
  780. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  781. {"C_SetAttributeValue", F_C_SetAttributeValue,
  782. "C_SetAttributeValue hSession hObject pTemplate ulCount\n\n"
  783. "C_SetAttributeValue modifies the value of one or more object attributes\n"
  784. " hSession the session's handle\n"
  785. " hObject the object's handle\n"
  786. " pTemplate specifies attrs and values\n"
  787. " ulCount attributes in template\n",
  788. {ArgULong, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgNone,
  789. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  790. {"C_FindObjectsInit", F_C_FindObjectsInit,
  791. "C_FindObjectsInit hSession pTemplate ulCount\n\n"
  792. "C_FindObjectsInit initializes a search for token and session objects that\n"
  793. "match a template.\n"
  794. " hSession the session's handle\n"
  795. " pTemplate attribute values to match\n"
  796. " ulCount attrs in search template\n",
  797. {ArgULong, ArgAttribute|ArgArray, ArgULong, ArgNone, ArgNone,
  798. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  799. {"C_FindObjectsFinal", F_C_FindObjectsFinal,
  800. "C_FindObjectsFinal hSession\n\n"
  801. "C_FindObjectsFinal finishes a search for token and session objects.\n"
  802. " hSession the session's handle\n",
  803. {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone,
  804. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  805. {"C_FindObjects", F_C_FindObjects,
  806. "C_FindObjects hSession phObject ulMaxObjectCount pulObjectCount\n\n"
  807. "C_FindObjects continues a search for token and session objects that match\n"
  808. "a template obtaining additional object handles.\n"
  809. " hSession session's handle\n"
  810. " phObject gets obj. handles\n"
  811. " ulMaxObjectCount max handles to get\n"
  812. " pulObjectCount actual # returned\n",
  813. {ArgULong, ArgULong|ArgOut, ArgULong, ArgULong|ArgOut, ArgNone,
  814. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  815. {"C_EncryptInit", F_C_EncryptInit,
  816. "C_EncryptInit hSession pMechanism hKey\n\n"
  817. "C_EncryptInit initializes an encryption operation.\n"
  818. " hSession the session's handle\n"
  819. " pMechanism the encryption mechanism\n"
  820. " hKey handle of encryption key\n",
  821. {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone,
  822. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  823. {"C_EncryptUpdate", F_C_EncryptUpdate,
  824. "C_EncryptUpdate hSession pPart ulPartLen pEncryptedPart pulEncryptedPartLen\n"
  825. "\n"
  826. "C_EncryptUpdate continues a multiple-part encryption operation.\n"
  827. " hSession session's handle\n"
  828. " pPart the plaintext data\n"
  829. " ulPartLen plaintext data len\n"
  830. " pEncryptedPart gets ciphertext\n"
  831. " pulEncryptedPartLen gets c-text size\n",
  832. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  833. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  834. {"C_EncryptFinal", F_C_EncryptFinal,
  835. "C_EncryptFinal hSession pLastEncryptedPart pulLastEncryptedPartLen\n\n"
  836. "C_EncryptFinal finishes a multiple-part encryption operation.\n"
  837. " hSession session handle\n"
  838. " pLastEncryptedPart last c-text\n"
  839. " pulLastEncryptedPartLen gets last size\n",
  840. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  841. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  842. {"C_Encrypt", F_C_Encrypt,
  843. "C_Encrypt hSession pData ulDataLen pEncryptedData pulEncryptedDataLen\n\n"
  844. "C_Encrypt encrypts single-part data.\n"
  845. " hSession session's handle\n"
  846. " pData the plaintext data\n"
  847. " ulDataLen bytes of plaintext\n"
  848. " pEncryptedData gets ciphertext\n"
  849. " pulEncryptedDataLen gets c-text size\n",
  850. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  851. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  852. {"C_DecryptInit", F_C_DecryptInit,
  853. "C_DecryptInit hSession pMechanism hKey\n\n"
  854. "C_DecryptInit initializes a decryption operation.\n"
  855. " hSession the session's handle\n"
  856. " pMechanism the decryption mechanism\n"
  857. " hKey handle of decryption key\n",
  858. {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone,
  859. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  860. {"C_DecryptUpdate", F_C_DecryptUpdate,
  861. "C_DecryptUpdate hSession pEncryptedPart ulEncryptedPartLen pPart pulPartLen\n"
  862. "\n"
  863. "C_DecryptUpdate continues a multiple-part decryption operation.\n"
  864. " hSession session's handle\n"
  865. " pEncryptedPart encrypted data\n"
  866. " ulEncryptedPartLen input length\n"
  867. " pPart gets plaintext\n"
  868. " pulPartLen p-text size\n",
  869. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  870. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  871. {"C_DecryptFinal", F_C_DecryptFinal,
  872. "C_DecryptFinal hSession pLastPart pulLastPartLen\n\n"
  873. "C_DecryptFinal finishes a multiple-part decryption operation.\n"
  874. " hSession the session's handle\n"
  875. " pLastPart gets plaintext\n"
  876. " pulLastPartLen p-text size\n",
  877. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  878. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  879. {"C_Decrypt", F_C_Decrypt,
  880. "C_Decrypt hSession pEncryptedData ulEncryptedDataLen pData pulDataLen\n\n"
  881. "C_Decrypt decrypts encrypted data in a single part.\n"
  882. " hSession session's handle\n"
  883. " pEncryptedData ciphertext\n"
  884. " ulEncryptedDataLen ciphertext length\n"
  885. " pData gets plaintext\n"
  886. " pulDataLen gets p-text size\n",
  887. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  888. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  889. {"C_DigestInit", F_C_DigestInit,
  890. "C_DigestInit hSession pMechanism\n\n"
  891. "C_DigestInit initializes a message-digesting operation.\n"
  892. " hSession the session's handle\n"
  893. " pMechanism the digesting mechanism\n",
  894. {ArgULong, ArgMechanism, ArgNone, ArgNone, ArgNone,
  895. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  896. {"C_DigestUpdate", F_C_DigestUpdate,
  897. "C_DigestUpdate hSession pPart ulPartLen\n\n"
  898. "C_DigestUpdate continues a multiple-part message-digesting operation.\n"
  899. " hSession the session's handle\n"
  900. " pPart data to be digested\n"
  901. " ulPartLen bytes of data to be digested\n",
  902. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  903. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  904. {"C_DigestKey", F_C_DigestKey,
  905. "C_DigestKey hSession hKey\n\n"
  906. "C_DigestKey continues a multi-part message-digesting operation by digesting\n"
  907. "the value of a secret key as part of the data already digested.\n"
  908. " hSession the session's handle\n"
  909. " hKey secret key to digest\n",
  910. {ArgULong, ArgULong, ArgNone, ArgNone, ArgNone,
  911. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  912. {"C_DigestFinal", F_C_DigestFinal,
  913. "C_DigestFinal hSession pDigest pulDigestLen\n\n"
  914. "C_DigestFinal finishes a multiple-part message-digesting operation.\n"
  915. " hSession the session's handle\n"
  916. " pDigest gets the message digest\n"
  917. " pulDigestLen gets byte count of digest\n",
  918. {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  919. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  920. {"C_Digest", F_C_Digest,
  921. "C_Digest hSession pData ulDataLen pDigest pulDigestLen\n\n"
  922. "C_Digest digests data in a single part.\n"
  923. " hSession the session's handle\n"
  924. " pData data to be digested\n"
  925. " ulDataLen bytes of data to digest\n"
  926. " pDigest gets the message digest\n"
  927. " pulDigestLen gets digest length\n",
  928. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  929. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  930. {"C_SignInit", F_C_SignInit,
  931. "C_SignInit hSession pMechanism hKey\n\n"
  932. "C_SignInit initializes a signature (private key encryption operation where\n"
  933. "the signature is (will be) an appendix to the data and plaintext cannot be\n"
  934. "recovered from the signature.\n"
  935. " hSession the session's handle\n"
  936. " pMechanism the signature mechanism\n"
  937. " hKey handle of signature key\n",
  938. {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone,
  939. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  940. {"C_SignUpdate", F_C_SignUpdate,
  941. "C_SignUpdate hSession pPart ulPartLen\n\n"
  942. "C_SignUpdate continues a multiple-part signature operation where the\n"
  943. "signature is (will be) an appendix to the data and plaintext cannot be\n"
  944. "recovered from the signature.\n"
  945. " hSession the session's handle\n"
  946. " pPart the data to sign\n"
  947. " ulPartLen count of bytes to sign\n",
  948. {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  949. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  950. {"C_SignFinal", F_C_SignFinal,
  951. "C_SignFinal hSession pSignature pulSignatureLen\n\n"
  952. "C_SignFinal finishes a multiple-part signature operation returning the\n"
  953. "signature.\n"
  954. " hSession the session's handle\n"
  955. " pSignature gets the signature\n"
  956. " pulSignatureLen gets signature length\n",
  957. {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  958. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  959. {"C_SignRecoverInit", F_C_SignRecoverInit,
  960. "C_SignRecoverInit hSession pMechanism hKey\n\n"
  961. "C_SignRecoverInit initializes a signature operation where the data can be\n"
  962. "recovered from the signature.\n"
  963. " hSession the session's handle\n"
  964. " pMechanism the signature mechanism\n"
  965. " hKey handle of the signature key\n",
  966. {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone,
  967. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  968. {"C_SignRecover", F_C_SignRecover,
  969. "C_SignRecover hSession pData ulDataLen pSignature pulSignatureLen\n\n"
  970. "C_SignRecover signs data in a single operation where the data can be\n"
  971. "recovered from the signature.\n"
  972. " hSession the session's handle\n"
  973. " pData the data to sign\n"
  974. " ulDataLen count of bytes to sign\n"
  975. " pSignature gets the signature\n"
  976. " pulSignatureLen gets signature length\n",
  977. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  978. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  979. {"C_Sign", F_C_Sign,
  980. "C_Sign hSession pData ulDataLen pSignature pulSignatureLen\n\n"
  981. "C_Sign signs (encrypts with private key) data in a single part where the\n"
  982. "signature is (will be) an appendix to the data and plaintext cannot be\n"
  983. "recovered from the signature.\n"
  984. " hSession the session's handle\n"
  985. " pData the data to sign\n"
  986. " ulDataLen count of bytes to sign\n"
  987. " pSignature gets the signature\n"
  988. " pulSignatureLen gets signature length\n",
  989. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  990. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  991. {"C_VerifyInit", F_C_VerifyInit,
  992. "C_VerifyInit hSession pMechanism hKey\n\n"
  993. "C_VerifyInit initializes a verification operation where the signature is an\n"
  994. "appendix to the data and plaintext cannot cannot be recovered from the\n"
  995. "signature (e.g. DSA).\n"
  996. " hSession the session's handle\n"
  997. " pMechanism the verification mechanism\n"
  998. " hKey verification key\n",
  999. {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone,
  1000. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1001. {"C_VerifyUpdate", F_C_VerifyUpdate,
  1002. "C_VerifyUpdate hSession pPart ulPartLen\n\n"
  1003. "C_VerifyUpdate continues a multiple-part verification operation where the\n"
  1004. "signature is an appendix to the data and plaintext cannot be recovered from\n"
  1005. "the signature.\n"
  1006. " hSession the session's handle\n"
  1007. " pPart signed data\n"
  1008. " ulPartLen length of signed data\n",
  1009. {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  1010. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1011. {"C_VerifyFinal", F_C_VerifyFinal,
  1012. "C_VerifyFinal hSession pSignature ulSignatureLen\n\n"
  1013. "C_VerifyFinal finishes a multiple-part verification operation checking the\n"
  1014. "signature.\n"
  1015. " hSession the session's handle\n"
  1016. " pSignature signature to verify\n"
  1017. " ulSignatureLen signature length\n",
  1018. {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone,
  1019. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1020. {"C_VerifyRecoverInit", F_C_VerifyRecoverInit,
  1021. "C_VerifyRecoverInit hSession pMechanism hKey\n\n"
  1022. "C_VerifyRecoverInit initializes a signature verification operation where the\n"
  1023. "data is recovered from the signature.\n"
  1024. " hSession the session's handle\n"
  1025. " pMechanism the verification mechanism\n"
  1026. " hKey verification key\n",
  1027. {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone,
  1028. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1029. {"C_VerifyRecover", F_C_VerifyRecover,
  1030. "C_VerifyRecover hSession pSignature ulSignatureLen pData pulDataLen\n\n"
  1031. "C_VerifyRecover verifies a signature in a single-part operation where the\n"
  1032. "data is recovered from the signature.\n"
  1033. " hSession the session's handle\n"
  1034. " pSignature signature to verify\n"
  1035. " ulSignatureLen signature length\n"
  1036. " pData gets signed data\n"
  1037. " pulDataLen gets signed data len\n",
  1038. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  1039. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1040. {"C_Verify", F_C_Verify,
  1041. "C_Verify hSession pData ulDataLen pSignature ulSignatureLen\n\n"
  1042. "C_Verify verifies a signature in a single-part operation where the signature\n"
  1043. "is an appendix to the data and plaintext cannot be recovered from the\n"
  1044. "signature.\n"
  1045. " hSession the session's handle\n"
  1046. " pData signed data\n"
  1047. " ulDataLen length of signed data\n"
  1048. " pSignature signature\n"
  1049. " ulSignatureLen signature length*/\n",
  1050. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  1051. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1052. {"C_DigestEncryptUpdate", F_C_DigestEncryptUpdate,
  1053. "C_DigestEncryptUpdate hSession pPart ulPartLen pEncryptedPart \\\n"
  1054. " pulEncryptedPartLen\n\n"
  1055. "C_DigestEncryptUpdate continues a multiple-part digesting and encryption\n"
  1056. "operation.\n"
  1057. " hSession session's handle\n"
  1058. " pPart the plaintext data\n"
  1059. " ulPartLen plaintext length\n"
  1060. " pEncryptedPart gets ciphertext\n"
  1061. " pulEncryptedPartLen gets c-text length\n",
  1062. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  1063. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1064. {"C_DecryptDigestUpdate", F_C_DecryptDigestUpdate,
  1065. "C_DecryptDigestUpdate hSession pEncryptedPart ulEncryptedPartLen pPart \\\n"
  1066. " pulPartLen\n\n"
  1067. "C_DecryptDigestUpdate continues a multiple-part decryption and digesting\n"
  1068. "operation.\n"
  1069. " hSession session's handle\n"
  1070. " pEncryptedPart ciphertext\n"
  1071. " ulEncryptedPartLen ciphertext length\n"
  1072. " pPart gets plaintext\n"
  1073. " pulPartLen gets plaintext len\n",
  1074. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  1075. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1076. {"C_SignEncryptUpdate", F_C_SignEncryptUpdate,
  1077. "C_SignEncryptUpdate hSession pPart ulPartLen pEncryptedPart \\\n"
  1078. " pulEncryptedPartLen\n\n"
  1079. "C_SignEncryptUpdate continues a multiple-part signing and encryption\n"
  1080. "operation.\n"
  1081. " hSession session's handle\n"
  1082. " pPart the plaintext data\n"
  1083. " ulPartLen plaintext length\n"
  1084. " pEncryptedPart gets ciphertext\n"
  1085. " pulEncryptedPartLen gets c-text length\n",
  1086. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  1087. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1088. {"C_DecryptVerifyUpdate", F_C_DecryptVerifyUpdate,
  1089. "C_DecryptVerifyUpdate hSession pEncryptedPart ulEncryptedPartLen pPart \\\n"
  1090. " pulPartLen\n\n"
  1091. "C_DecryptVerifyUpdate continues a multiple-part decryption and verify\n"
  1092. "operation.\n"
  1093. " hSession session's handle\n"
  1094. " pEncryptedPart ciphertext\n"
  1095. " ulEncryptedPartLen ciphertext length\n"
  1096. " pPart gets plaintext\n"
  1097. " pulPartLen gets p-text length\n",
  1098. {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut,
  1099. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1100. {"C_GenerateKeyPair", F_C_GenerateKeyPair,
  1101. "C_GenerateKeyPair hSession pMechanism pPublicKeyTemplate \\\n"
  1102. " ulPublicKeyAttributeCount pPrivateKeyTemplate ulPrivateKeyAttributeCount \\\n"
  1103. " phPublicKey phPrivateKey\n\n"
  1104. "C_GenerateKeyPair generates a public-key/private-key pair creating new key\n"
  1105. "objects.\n"
  1106. " hSession sessionhandle\n"
  1107. " pMechanism key-genmech.\n"
  1108. " pPublicKeyTemplate templatefor pub. key\n"
  1109. " ulPublicKeyAttributeCount # pub. attrs.\n"
  1110. " pPrivateKeyTemplate templatefor priv. key\n"
  1111. " ulPrivateKeyAttributeCount # priv. attrs.\n"
  1112. " phPublicKey gets pub. keyhandle\n"
  1113. " phPrivateKey getspriv. keyhandle\n",
  1114. {ArgULong, ArgMechanism, ArgAttribute|ArgArray, ArgULong,
  1115. ArgAttribute|ArgArray,
  1116. ArgULong, ArgULong|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone }},
  1117. {"C_GenerateKey", F_C_GenerateKey,
  1118. "C_GenerateKey hSession pMechanism pTemplate ulCount phKey\n\n"
  1119. "C_GenerateKey generates a secret key creating a new key object.\n"
  1120. " hSession the session's handle\n"
  1121. " pMechanism key generation mech.\n"
  1122. " pTemplate template for new key\n"
  1123. " ulCount # of attrs in template\n"
  1124. " phKey gets handle of new key\n",
  1125. {ArgULong, ArgMechanism, ArgAttribute|ArgArray, ArgULong,
  1126. ArgULong|ArgOut,
  1127. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1128. {"C_WrapKey", F_C_WrapKey,
  1129. "C_WrapKey hSession pMechanism hWrappingKey hKey pWrappedKey pulWrappedKeyLen\n\n"
  1130. "C_WrapKey wraps (i.e. encrypts) a key.\n"
  1131. " hSession the session's handle\n"
  1132. " pMechanism the wrapping mechanism\n"
  1133. " hWrappingKey wrapping key\n"
  1134. " hKey key to be wrapped\n"
  1135. " pWrappedKey gets wrapped key\n"
  1136. " pulWrappedKeyLen gets wrapped key size\n",
  1137. {ArgULong, ArgMechanism, ArgULong, ArgULong, ArgULong,
  1138. ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone }},
  1139. {"C_UnwrapKey", F_C_UnwrapKey,
  1140. "C_UnwrapKey hSession pMechanism hUnwrappingKey pWrappedKey ulWrappedKeyLen \\\n"
  1141. " pTemplate ulAttributeCount phKey\n\n"
  1142. "C_UnwrapKey unwraps (decrypts) a wrapped key creating a new key object.\n"
  1143. " hSession session's handle\n"
  1144. " pMechanism unwrapping mech.\n"
  1145. " hUnwrappingKey unwrapping key\n"
  1146. " pWrappedKey the wrapped key\n"
  1147. " ulWrappedKeyLen wrapped key len\n"
  1148. " pTemplate new key template\n"
  1149. " ulAttributeCount template length\n"
  1150. " phKey gets new handle\n",
  1151. {ArgULong, ArgMechanism, ArgULong, ArgChar, ArgULong,
  1152. ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone }},
  1153. {"C_DeriveKey", F_C_DeriveKey,
  1154. "C_DeriveKey hSession pMechanism hBaseKey pTemplate ulAttributeCount phKey\n\n"
  1155. "C_DeriveKey derives a key from a base key creating a new key object.\n"
  1156. " hSession session's handle\n"
  1157. " pMechanism key deriv. mech.\n"
  1158. " hBaseKey base key\n"
  1159. " pTemplate new key template\n"
  1160. " ulAttributeCount template length\n"
  1161. " phKey gets new handle\n",
  1162. {ArgULong, ArgMechanism, ArgULong, ArgAttribute|ArgArray, ArgULong,
  1163. ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone }},
  1164. {"C_SeedRandom", F_C_SeedRandom,
  1165. "C_SeedRandom hSession pSeed ulSeedLen\n\n"
  1166. "C_SeedRandom mixes additional seed material into the token's random number\n"
  1167. "generator.\n"
  1168. " hSession the session's handle\n"
  1169. " pSeed the seed material\n"
  1170. " ulSeedLen length of seed material\n",
  1171. {ArgULong, ArgChar, ArgULong, ArgNone, ArgNone,
  1172. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1173. {"C_GenerateRandom", F_C_GenerateRandom,
  1174. "C_GenerateRandom hSession RandomData ulRandomLen\n\n"
  1175. "C_GenerateRandom generates random data.\n"
  1176. " hSession the session's handle\n"
  1177. " RandomData receives the random data\n"
  1178. " ulRandomLen # of bytes to generate\n",
  1179. {ArgULong, ArgChar, ArgULong, ArgNone, ArgNone,
  1180. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1181. {"C_GetFunctionStatus", F_C_GetFunctionStatus,
  1182. "C_GetFunctionStatus hSession\n\n"
  1183. "C_GetFunctionStatus is a legacy function; it obtains an updated status of\n"
  1184. "a function running in parallel with an application.\n"
  1185. " hSession the session's handle\n",
  1186. {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone,
  1187. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1188. {"C_CancelFunction", F_C_CancelFunction,
  1189. "C_CancelFunction hSession\n\n"
  1190. "C_CancelFunction is a legacy function; it cancels a function running in\n"
  1191. "parallel.\n"
  1192. " hSession the session's handle\n",
  1193. {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone,
  1194. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1195. {"C_WaitForSlotEvent", F_C_WaitForSlotEvent,
  1196. "C_WaitForSlotEvent flags pSlot pRserved\n\n"
  1197. "C_WaitForSlotEvent waits for a slot event (token insertion removal etc.)\n"
  1198. "to occur.\n"
  1199. " flags blocking/nonblocking flag\n"
  1200. " pSlot location that receives the slot ID\n"
  1201. " pRserved reserved. Should be NULL_PTR\n",
  1202. {ArgULong, ArgULong|ArgArray, ArgVar, ArgNone, ArgNone,
  1203. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1204. {"NewArray", F_NewArray,
  1205. "NewArray varName varType array size\n\n"
  1206. "Creates a new array variable.\n"
  1207. " varName variable name of the new array\n"
  1208. " varType data type of the new array\n"
  1209. " size number of elements in the array\n",
  1210. {ArgVar|ArgNew, ArgVar, ArgULong, ArgNone, ArgNone,
  1211. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1212. {"NewInitArg", F_NewInitializeArgs,
  1213. "NewInitArg varName flags string\n\n"
  1214. "Creates a new init variable.\n"
  1215. " varName variable name of the new initArg\n"
  1216. " flags value to set the flags field\n"
  1217. " string string parameter for init arg\n",
  1218. {ArgVar|ArgNew, ArgULong, ArgVar|ArgNew, ArgNone, ArgNone,
  1219. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1220. {"NewTemplate", F_NewTemplate,
  1221. "NewTemplate varName attributeList\n\n"
  1222. "Create a new empty template and populate the attribute list\n"
  1223. " varName variable name of the new template\n"
  1224. " attributeList comma separated list of CKA_ATTRIBUTE types\n",
  1225. {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone,
  1226. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1227. {"NewMechanism", F_NewMechanism,
  1228. "NewMechanism varName mechanismType\n\n"
  1229. "Create a new CK_MECHANISM object with type NULL parameters and specified type\n"
  1230. " varName variable name of the new mechansim\n"
  1231. " mechanismType CKM_ mechanism type value to set int the type field\n",
  1232. {ArgVar|ArgNew, ArgULong, ArgNone, ArgNone, ArgNone,
  1233. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1234. {"BuildTemplate", F_BuildTemplate,
  1235. "BuildTemplate template\n\n"
  1236. "Allocates space for the value in a template which has the sizes filled in,\n"
  1237. "but no values allocated yet.\n"
  1238. " template variable name of the template\n",
  1239. {ArgAttribute, ArgNone, ArgNone, ArgNone, ArgNone,
  1240. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1241. {"SetTemplate", F_SetTemplate,
  1242. "SetTemplate template index value\n\n"
  1243. "Sets a particular element of a template to a CK_ULONG\n"
  1244. " template variable name of the template\n"
  1245. " index index into the template to the element to change\n"
  1246. " value 32 bit value to set in the template\n",
  1247. {ArgAttribute, ArgULong, ArgULong, ArgNone, ArgNone,
  1248. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1249. {"SetString", F_SetStringVar,
  1250. "SetString varName string\n\n"
  1251. "Sets a particular variable to a string value\n"
  1252. " variable variable name of new string\n"
  1253. " string String to set the variable to\n",
  1254. {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone,
  1255. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1256. {"Set", F_SetVar,
  1257. "Set varName value\n\n"
  1258. "Sets a particular variable to CK_ULONG\n"
  1259. " variable name of the new variable\n"
  1260. " value 32 bit value to set variable to\n",
  1261. {ArgVar|ArgNew, ArgULong, ArgNone, ArgNone, ArgNone,
  1262. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1263. {"Print", F_Print,
  1264. "Print varName\n\n"
  1265. "prints a variable\n"
  1266. " variable name of the variable to print\n",
  1267. {ArgVar, ArgNone, ArgNone, ArgNone, ArgNone,
  1268. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1269. {"Delete", F_Delete,
  1270. "Delete varName\n\n"
  1271. "delete a variable\n"
  1272. " variable name of the variable to delete\n",
  1273. {ArgVar|ArgNew, ArgNone, ArgNone, ArgNone, ArgNone,
  1274. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1275. {"Load", F_Load,
  1276. "load libraryName\n\n"
  1277. "load a pkcs #11 module\n"
  1278. " libraryName Name of a shared library\n",
  1279. {ArgVar, ArgNone, ArgNone, ArgNone, ArgNone,
  1280. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1281. {"Save", F_SaveVar,
  1282. "Save filename variable\n\n"
  1283. "Saves the binary value of 'variable' in file 'filename'\n"
  1284. " fileName target file to save the variable in\n"
  1285. " variable variable to save\n",
  1286. {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone,
  1287. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1288. {"Restore", F_RestoreVar,
  1289. "Restore filename variable\n\n"
  1290. "Restores a variable from a file\n"
  1291. " fileName target file to restore the variable from\n"
  1292. " variable variable to restore\n",
  1293. {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone,
  1294. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1295. {"Increment", F_Increment,
  1296. "Increment variable value\n\n"
  1297. "Increment a variable by value\n",
  1298. {ArgVar, ArgULong, ArgNone, ArgNone, ArgNone,
  1299. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1300. {"Decrement", F_Decrement,
  1301. "Decrement variable value\n\n"
  1302. "Decrement a variable by value\n",
  1303. {ArgVar, ArgULong, ArgNone, ArgNone, ArgNone,
  1304. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1305. {"List", F_List,
  1306. "List all the variables\n",
  1307. {ArgNone, ArgNone, ArgNone, ArgNone, ArgNone,
  1308. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1309. {"Unload", F_Unload,
  1310. "Unload the currrently loaded PKCS #11 library\n",
  1311. {ArgNone, ArgNone, ArgNone, ArgNone, ArgNone,
  1312. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1313. {"Run", F_Run,
  1314. "Run filename\n\n"
  1315. "reads filename as script of commands to execute\n",
  1316. {ArgVar|ArgNew, ArgNone, ArgNone, ArgNone, ArgNone,
  1317. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1318. {"Time", F_Time,
  1319. "Time pkcs11 command\n\n"
  1320. "Execute a pkcs #11 command and time the results\n",
  1321. {ArgVar|ArgFull, ArgNone, ArgNone, ArgNone, ArgNone,
  1322. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1323. {"System", F_System,
  1324. "Set System Flag",
  1325. {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone,
  1326. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1327. {"LoopRun", F_Loop,
  1328. "LoopRun filename var start end step\n\n"
  1329. "Run in a loop. Loop exit if scrip does and explicit quit (Quit QuitIf etc.)",
  1330. {ArgVar|ArgNew, ArgVar|ArgNew, ArgULong, ArgULong, ArgULong,
  1331. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1332. {"Help", F_Help,
  1333. "Help [command]\n\n"
  1334. "print general help, or help for a specific command\n",
  1335. {ArgVar|ArgOpt, ArgNone, ArgNone, ArgNone, ArgNone,
  1336. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1337. {"QuitIf", F_QuitIf,
  1338. "QuitIf arg1 comparator arg2\n\n"
  1339. "Exit from this program if Condition is valid, valid comparators:\n"
  1340. " < > <= >= = !=\n",
  1341. {ArgULong, ArgVar|ArgNew, ArgULong, ArgNone, ArgNone,
  1342. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1343. {"QuitIfString", F_QuitIfString,
  1344. "QuitIfString arg1 comparator arg2\n\n"
  1345. "Exit from this program if Condition is valid, valid comparators:\n"
  1346. " = !=\n",
  1347. {ArgVar|ArgNew, ArgVar|ArgNew, ArgVar|ArgNew, ArgNone, ArgNone,
  1348. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1349. {"Quit", F_Quit,
  1350. "Exit from this program",
  1351. {ArgNone, ArgNone, ArgNone, ArgNone, ArgNone,
  1352. ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }},
  1353. };
  1354. const Commands *commands= &_commands[0];
  1355. const int commandCount = sizeof(_commands) / sizeof(_commands[0]);
  1356. const Topics _topics[] = {
  1357. { "variables",
  1358. "Variables are random strings of characters. These should begin with alpha\n"
  1359. " characters, and should not contain any spaces, nor should they match any\n"
  1360. " built-in constants. There is some checking in the code for these things,\n"
  1361. " but it's not 100% and using invalid variable names can cause problems.\n"
  1362. " Variables are created by any 'OUT' parameter. If the variable does not\n"
  1363. " exist, it will be created. For in parameters variables must already exist.\n"
  1364. },
  1365. { "constants",
  1366. "pk11util recognizes *lots* of constants. All CKA_, CKF_, CKO_, CKU_, CKS_,\n"
  1367. " CKC_, CKK_, CKH_, CKM_, CKT_ values from the PKCS #11 spec are recognized.\n"
  1368. " Constants can be specified with their fully qualified CK?_ value, or the\n"
  1369. " prefix can be dropped. Constants are matched case insensitve.\n"
  1370. },
  1371. { "arrays",
  1372. "Arrays are special variables which represent 'C' arrays. Each array \n"
  1373. " variable can be referenced as a group (using just the name), or as \n"
  1374. " individual elements (with the [int] operator). Example:\n"
  1375. " print myArray # prints the full array.\n"
  1376. " print myArray[3] # prints the 3rd elemement of the array \n"
  1377. },
  1378. { "sizes",
  1379. "Size operaters returns the size in bytes of a variable, or the number of\n"
  1380. " elements in an array.\n"
  1381. " size(var) and sizeof(var) return the size of var in bytes.\n"
  1382. " sizea(var) and sizeofarray(var) return the number of elements in var.\n"
  1383. " If var is not an array, sizea(var) returns 1.\n"
  1384. },
  1385. };
  1386. const Topics *topics= &_topics[0];
  1387. const int topicCount = sizeof(_topics) / sizeof(_topics[0]);
  1388. const char *
  1389. getName(CK_ULONG value, ConstType type)
  1390. {
  1391. int i;
  1392. for (i=0; i < constCount; i++) {
  1393. if (consts[i].type == type && consts[i].value == value) {
  1394. return consts[i].name;
  1395. }
  1396. if (type == ConstNone && consts[i].value == value) {
  1397. return consts[i].name;
  1398. }
  1399. }
  1400. return NULL;
  1401. }
  1402. const char *
  1403. getNameFromAttribute(CK_ATTRIBUTE_TYPE type)
  1404. {
  1405. return getName(type, ConstAttribute);
  1406. }
  1407. int totalKnownType(ConstType type) {
  1408. int count = 0;
  1409. int i;
  1410. for (i=0; i < constCount; i++) {
  1411. if (consts[i].type == type) count++;
  1412. }
  1413. return count;
  1414. }