cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
cryptlib.h
Go to the documentation of this file.
1 /****************************************************************************
2 * *
3 * cryptlib Header File *
4 * Copyright Peter Gutmann 1992-2011 *
5 * *
6 ****************************************************************************/
7 
8 #ifndef _CRYPTLIB_DEFINED
9 
10 #define _CRYPTLIB_DEFINED
11 
12 /* The current cryptlib version: 3.4.1 */
13 
14 #define CRYPTLIB_VERSION 3410
15 
16 /* Fixup for Windows support. We need to include windows.h for various types
17  and prototypes needed for DLL's. In addition wincrypt.h defines some
18  values with the same names as cryptlib ones, so we need to check for this
19  and issue a warning not to mix cryptlib with CryptoAPI (that's like taking
20  a bank vault and making one side out of papier mache).
21 
22  A second, less likely condition can occur when wincrypt.h is included
23  after cryptlib.h, which shouldn't happen if developers follow the
24  convention of including local headers after system headers, but can occur
25  if they ignore this convention. The NOCRYPT doesn't fix this since
26  wincrypt.h can be pulled in indirectly and unconditionally, for example
27  via winldap.h -> schnlsp.h -> schannel.h -> wincrypt.h. To fix this, we
28  create a redundant define for CRYPT_MODE_ECB which produces a compile
29  error if wincrypt.h is included after cryptlib.h. Since thie will
30  conflict with the enum, we have to place it after the CRYPT_MODE_xxx
31  enums */
32 
33 #if ( defined( _WINDOWS ) || defined( WIN32 ) || defined( _WIN32 ) || \
34  defined( __WIN32__ ) || defined( _WIN32_WCE ) ) && \
35  !defined( _SCCTK ) && !defined( _CVI_ )
36  #ifndef WIN32_LEAN_AND_MEAN
37  #define WIN32_LEAN_AND_MEAN /* Skip RPC, OLE, Multimedia, etc */
38  #endif /* WIN32_LEAN_AND_MEAN */
39  #define NOCRYPT /* Disable include of wincrypt.h */
40  #include <windows.h>
41 
42  /* Catch use of CryptoAPI and cryptlib at the same time. wxWidgets
43  includes wincrypt.h by default so we undefine the conflicting values
44  and assume that the warning above will let users know that CryptoAPI
45  use isn't going to work properly, for anything else we require that the
46  user explicitly fix things */
47  #if defined( CRYPT_MODE_ECB )
48  #pragma message( "Warning: Both cryptlib.h and wincrypt.h have been included into the same source file." )
49  #pragma message( " These contain conflicting type names that prevent both from being used simultaneously." )
50  #ifdef __WXWINDOWS__
51  #pragma message( " To allow compilation to proceed the wincrypt.h encryption modes have been undefined." )
52  #undef CRYPT_MODE_ECB
53  #undef CRYPT_MODE_CBC
54  #undef CRYPT_MODE_CFB
55  #undef CRYPT_MODE_OFB
56  #else
57  #pragma message( " To allow compilation to proceed you need to avoid including wincrypt.h in your code." )
58  #error "cryptlib.h and wincrypt.h can't both be used at the same time due to conflicting type names"
59  #endif /* __WXWINDOWS__ */
60  #endif /* Clash with wincrypt.h defines */
61 #endif /* Windows other than a cross-development environment */
62 
63 /* Machine-dependant types to allow use in special library types such as
64  DLL's. Under Win32 and BeOS we need to use the dllimport and dllexport
65  directives for the DLL/shared-lib version so we define the type used for
66  functions depending on whether we're being included via the cryptlib-
67  internal crypt.h or not */
68 
69 #if ( defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || \
70  defined( _WIN32_WCE ) ) && !( defined( STATIC_LIB ) || defined( _SCCTK ) )
71  #define C_PTR * /* General pointer */
72  #if defined( _WIN32_WCE )
73  /* Rather than relying on _UNICODE being defined (which would cause
74  problems if cryptlib is built with char * but the calling app is built
75  with wchar_t *), we always use the default native char type, which is
76  ASCII (or at least 8-bit) under Win32 and Unicode under WinCE */
77  #define C_CHR wchar_t
78  #else
79  #define C_CHR char
80  #endif /* WinCE vs. Win32 */
81  #define C_STR C_CHR *
82  #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x500 )
83  #ifdef _CRYPT_DEFINED
84  #define C_RET int _export _stdcall /* BC++ DLL export ret.val.*/
85  #else
86  #define C_RET int _import _stdcall /* BC++ DLL import ret.val.*/
87  #endif /* CRYPT_DEFINED */
88  #else
89  #ifdef _CRYPT_DEFINED
90  #define C_RET __declspec( dllexport ) int __stdcall /* DLL export ret.val.*/
91  #else
92  #define C_RET __declspec( dllimport ) int __stdcall /* DLL import ret.val.*/
93  #endif /* CRYPT_DEFINED */
94  #endif /* BC++ vs.VC++ DLL functions */
95 #elif defined( _WINDOWS ) && !defined( STATIC_LIB )
96  #define C_PTR FAR * /* DLL pointer */
97  #define C_CHR char
98  #define C_STR C_CHR FAR * /* DLL string pointer */
99  #define C_RET int FAR PASCAL _export /* DLL return value */
100 #elif defined( __BEOS__ )
101 /* #include <BeBuild.h> // _EXPORT/_IMPORT defines */
102  #define C_PTR *
103  #define C_CHR char
104  #define C_STR C_CHR *
105  #ifdef _STATIC_LINKING
106  #define C_RET int
107  #else
108  #ifdef _CRYPT_DEFINED
109  #define C_RET __declspec( dllexport ) int /* Shared lib export ret.val.*/
110  #else
111  #define C_RET __declspec( dllimport ) int /* Shared lib import ret.val.*/
112  #endif /* CRYPT_DEFINED */
113  #endif /* Static vs. shared lib */
114 #elif defined( __SYMBIAN32__ )
115  #ifdef _CRYPT_DEFINED
116  #define C_RET EXPORT_C /* DLL export ret.val.*/
117  #else
118  #define C_RET IMPORT_C /* DLL import ret.val.*/
119  #endif /* CRYPT_DEFINED */
120 #else
121  #define C_PTR *
122  #define C_CHR char
123  #define C_STR C_CHR *
124  #define C_RET int
125 #endif /* Windows vs.everything else function types */
126 
127 /* Symbolic defines to make it clearer how the function parameters behave */
128 
129 #define C_IN const /* Input-only */
130 #define C_IN_OPT const /* Input-only, may be NULL */
131 #define C_OUT /* Output-only */
132 #define C_OUT_OPT /* Output-only, may be NULL */
133 #define C_INOUT /* Modified in-place */
134 
135 /* Additional defines for compilers that provide extended function and
136  function-parameter checking */
137 
138 #if defined( __GNUC__ ) && ( __GNUC__ >= 4 )
139  #define C_CHECK_RETVAL __attribute__(( warn_unused_result ))
140  #ifdef _CRYPT_DEFINED
141  #define C_NONNULL_ARG( argIndex ) /* Too dangerous to use inside clib */
142  #else
143  #define C_NONNULL_ARG( argIndex ) __attribute__(( nonnull argIndex ))
144  #endif /* _CRYPT_DEFINED */
145 #elif defined( _MSC_VER ) && defined( _PREFAST_ )
146  #ifdef __ATTR_SAL /* Attribute SAL */
147  #define C_CHECK_RETVAL _Check_return_ \
148  _Success_( result == CRYPT_OK )
149  #define C_NONNULL_ARG( argIndex )
150  #undef C_IN_OPT
151  #define C_IN_OPT _In_opt_ const
152  #undef C_OUT_OPT
153  #define C_OUT_OPT _Out_opt_
154  #undef C_INOUT
155  #define C_INOUT _Inout_
156  #else
157  #define C_CHECK_RETVAL __checkReturn \
158  __success( result == CRYPT_OK ) \
159  __range( MAX_ERROR, CRYPT_OK )
160  #define C_NONNULL_ARG( argIndex )
161  #undef C_IN_OPT
162  #define C_IN_OPT __in_opt const
163  #undef C_OUT_OPT
164  #define C_OUT_OPT __out_opt
165  #undef C_INOUT
166  #define C_INOUT __inout
167  #endif /* Declspec vs. Attribute SAL */
168 #else
169  #define C_CHECK_RETVAL
170  #define C_NONNULL_ARG( argIndex )
171 #endif /* Compiler-specific annotations */
172 
173 #ifdef _CRYPTLIB_DEFINED /* Disable use in non-C versions of header */
174 
175 /* Alongside the externally visible types, cryptlib also has various internal
176  types that are extended forms of the external types that are invisible
177  to the user (e.g. SignedPublicKeyAndChallenge == certRequest). These can
178  only be used internally and are blocked by the security kernel, so they
179  can never be accessed from outside cryptlib (in fact for good measure
180  they're blocked before they even get to the kernel by preliminary range
181  checks in the API wrapper functions). The only reason they're defined
182  here is because it's not possible to extend an enum outside the point
183  where it's originally defined */
184 
185 #endif /* _CRYPTLIB_DEFINED */
186 
187 /****************************************************************************
188 * *
189 * Algorithm and Object Types *
190 * *
191 ****************************************************************************/
192 
193 /* Algorithm and mode types */
194 
195 typedef enum { /* Algorithms */
196  /* No encryption */
197  CRYPT_ALGO_NONE, /* No encryption */
198 
199  /* Conventional encryption */
200  CRYPT_ALGO_DES, /* DES */
201  CRYPT_ALGO_3DES, /* Triple DES */
202  CRYPT_ALGO_IDEA, /* IDEA (only used for PGP 2.x) */
203  CRYPT_ALGO_RESERVED1, /* Formerly CAST-128 */
204  CRYPT_ALGO_RC2, /* RC2 (disabled by default) */
205  CRYPT_ALGO_RC4, /* RC4 */
206  CRYPT_ALGO_RC5, /* RC5 */
207  CRYPT_ALGO_AES, /* AES */
208  CRYPT_ALGO_BLOWFISH, /* Blowfish */
209  CRYPT_ALGO_RESERVED2, /* Formerly Skipjack */
210 
211  /* Public-key encryption */
212  CRYPT_ALGO_DH = 100, /* Diffie-Hellman */
213  CRYPT_ALGO_RSA, /* RSA */
214  CRYPT_ALGO_DSA, /* DSA */
215  CRYPT_ALGO_ELGAMAL, /* ElGamal */
216  CRYPT_ALGO_RESERVED3, /* Formerly KEA */
217  CRYPT_ALGO_ECDSA, /* ECDSA */
218  CRYPT_ALGO_ECDH, /* ECDH */
219 
220  /* Hash algorithms */
221  CRYPT_ALGO_RESERVED4 = 200, /* Formerly MD2 */
222  CRYPT_ALGO_RESERVED5, /* Formerly MD4 */
223  CRYPT_ALGO_MD5, /* MD5 */
224  CRYPT_ALGO_SHA1, /* SHA/SHA1 */
225  CRYPT_ALGO_SHA = CRYPT_ALGO_SHA1, /* Older form */
226  CRYPT_ALGO_RIPEMD160, /* RIPE-MD 160 */
227  CRYPT_ALGO_SHA2, /* SHA-256 */
228  CRYPT_ALGO_SHA256 = CRYPT_ALGO_SHA2,/* Alternate name */
229  CRYPT_ALGO_SHAng, /* Future SHA-nextgen standard */
230 
231  /* MAC's */
232  CRYPT_ALGO_HMAC_MD5 = 300, /* HMAC-MD5 */
233  CRYPT_ALGO_HMAC_SHA1, /* HMAC-SHA */
235  CRYPT_ALGO_HMAC_RIPEMD160, /* HMAC-RIPEMD-160 */
236  CRYPT_ALGO_HMAC_SHA2, /* HMAC-SHA2 */
237  CRYPT_ALGO_HMAC_SHAng, /* HMAC-future-SHA-nextgen */
238 
239 #ifdef _CRYPT_DEFINED
240  /* Alongside the usual types we also need a generic secret-key store
241  for use with mechanisms that convert a single secret value into
242  multiple derived keying values like encryption keys, MAC keys,
243  IVs, and so on. The following algorithm type implements this
244  generic-secret crypto object */
245  CRYPT_IALGO_GENERIC_SECRET = 1000,/* Generic-secret object */
246 #endif /* _CRYPT_DEFINED */
247 
248  /* Vendors may want to use their own algorithms that aren't part of the
249  general cryptlib suite. The following values are for vendor-defined
250  algorithms, and can be used just like the named algorithm types (it's
251  up to the vendor to keep track of what _VENDOR1 actually corresponds
252  to) */
253 #ifdef USE_VENDOR_ALGOS
254  CRYPT_ALGO_VENDOR1 = 10000, CRYPT_ALGO_VENDOR2, CRYPT_ALGO_VENDOR3,
255 #endif /* USE_VENDOR_ALGOS */
256 
257  CRYPT_ALGO_LAST, /* Last possible crypt algo value */
258 #ifdef _CRYPT_DEFINED
259  CRYPT_ALGO_LAST_EXTERNAL = CRYPT_ALGO_HMAC_SHAng + 1,
260 #endif /* _CRYPT_DEFINED */
261 
262  /* In order that we can scan through a range of algorithms with
263  cryptQueryCapability(), we define the following boundary points for
264  each algorithm class */
273  } CRYPT_ALGO_TYPE;
274 
275 typedef enum { /* Block cipher modes */
276  CRYPT_MODE_NONE, /* No encryption mode */
277  CRYPT_MODE_ECB, /* ECB */
278  CRYPT_MODE_CBC, /* CBC */
279  CRYPT_MODE_CFB, /* CFB */
280  CRYPT_MODE_OFB, /* OFB */
281  CRYPT_MODE_GCM, /* GCM */
282  CRYPT_MODE_LAST /* Last possible crypt mode value */
283  } CRYPT_MODE_TYPE;
284 
285 #if ( defined( _WINDOWS ) || defined( WIN32 ) || defined( _WIN32 ) || \
286  defined( __WIN32__ ) ) && !defined( _SCCTK )
287  /* Force an error if wincrypt.h is included after cryptlib.h, see note at
288  the start of the file */
289  #define CRYPT_MODE_ECB 1
290 #endif /* Windows other than a cross-development environment */
291 
292 /* Keyset subtypes */
293 
294 typedef enum { /* Keyset types */
295  CRYPT_KEYSET_NONE, /* No keyset type */
296  CRYPT_KEYSET_FILE, /* Generic flat file keyset */
297  CRYPT_KEYSET_HTTP, /* Web page containing cert/CRL */
298  CRYPT_KEYSET_LDAP, /* LDAP directory service */
299  CRYPT_KEYSET_ODBC, /* Generic ODBC interface */
300  CRYPT_KEYSET_DATABASE, /* Generic RDBMS interface */
301  CRYPT_KEYSET_ODBC_STORE, /* ODBC certificate store */
302  CRYPT_KEYSET_DATABASE_STORE, /* Database certificate store */
303  CRYPT_KEYSET_LAST /* Last possible keyset type */
304 
305 #ifdef _CRYPT_DEFINED
306  /* Useful defines used internally for range checking */
307  , CRYPT_FIRST_RDBMS = CRYPT_KEYSET_ODBC,
308  CRYPT_LAST_RDBMS = CRYPT_KEYSET_DATABASE_STORE
309 #endif /* _CRYPT_DEFINED */
311 
312 /* Device subtypes */
313 
314 typedef enum { /* Crypto device types */
315  CRYPT_DEVICE_NONE, /* No crypto device */
316  CRYPT_DEVICE_FORTEZZA, /* Fortezza card - Placeholder only */
317  CRYPT_DEVICE_PKCS11, /* PKCS #11 crypto token */
318  CRYPT_DEVICE_CRYPTOAPI, /* Microsoft CryptoAPI */
319  CRYPT_DEVICE_HARDWARE, /* Generic crypo HW plugin */
320  CRYPT_DEVICE_LAST /* Last possible crypto device type */
322 
323 /* Certificate subtypes */
324 
325 typedef enum { /* Certificate object types */
326  CRYPT_CERTTYPE_NONE, /* No certificate type */
327  CRYPT_CERTTYPE_CERTIFICATE, /* Certificate */
328  CRYPT_CERTTYPE_ATTRIBUTE_CERT, /* Attribute certificate */
329  CRYPT_CERTTYPE_CERTCHAIN, /* PKCS #7 certificate chain */
330  CRYPT_CERTTYPE_CERTREQUEST, /* PKCS #10 certification request */
331  CRYPT_CERTTYPE_REQUEST_CERT, /* CRMF certification request */
332  CRYPT_CERTTYPE_REQUEST_REVOCATION, /* CRMF revocation request */
334  CRYPT_CERTTYPE_CMS_ATTRIBUTES, /* CMS attributes */
335  CRYPT_CERTTYPE_RTCS_REQUEST, /* RTCS request */
336  CRYPT_CERTTYPE_RTCS_RESPONSE, /* RTCS response */
337  CRYPT_CERTTYPE_OCSP_REQUEST, /* OCSP request */
338  CRYPT_CERTTYPE_OCSP_RESPONSE, /* OCSP response */
339  CRYPT_CERTTYPE_PKIUSER, /* PKI user information */
340 #ifdef _CRYPT_DEFINED
341  /* Alongside the usual types we can also wind up with various
342  certificate-bagging schemes such as cert chains and sequences that
343  can't be exported in this format and therefore aren't visible to the
344  user, but that need to be distinguished internally. The following
345  types are only visible internally */
346  CRYPT_ICERTTYPE_CMS_CERTSET, /* CMS SET OF Certificate = cert chain */
347  CRYPT_ICERTTYPE_SSL_CERTCHAIN, /* SSL certificate chain = cert chain */
348  CRYPT_ICERTTYPE_CTL, /* Cert.trust list (data-only cert chain) */
349  CRYPT_ICERTTYPE_REVINFO, /* Revocation info/single CRL entry */
350 
351  /* CRYPT_ICERTTYPE_DATAONLY is a special value that doesn't specifically
352  contain a data format hint but indicates that the certificate should
353  be instantiated without creating a corresponding context to contain
354  the associated public key. This value is used by certs associated
355  with private-key objects and by contained in cert chains for which
356  only the leaf cert actually needs to have a context instantiated.
357  Technically this is simply a modifier for CRYPT_CERTTYPE_CERTIFICATE,
358  but there's no easy way to pass this flag down, so we give it its own
359  pseudo-type instead */
360  CRYPT_ICERTTYPE_DATAONLY, /* Data-only cert */
361 #endif /* _CRYPT_DEFINED */
362  CRYPT_CERTTYPE_LAST /* Last possible cert.type */
363 #ifdef _CRYPT_DEFINED
364  , CRYPT_CERTTYPE_LAST_EXTERNAL = CRYPT_CERTTYPE_PKIUSER + 1
365 #endif /* _CRYPT_DEFINED */
367 
368 /* Envelope/data format subtypes */
369 
370 typedef enum {
371  CRYPT_FORMAT_NONE, /* No format type */
372  CRYPT_FORMAT_AUTO, /* Deenv, auto-determine type */
373  CRYPT_FORMAT_CRYPTLIB, /* cryptlib native format */
374  CRYPT_FORMAT_CMS, /* PKCS #7 / CMS / S/MIME fmt.*/
376  CRYPT_FORMAT_SMIME, /* As CMS with MSG-style behaviour */
377  CRYPT_FORMAT_PGP, /* PGP format */
378 #ifdef _CRYPT_DEFINED
379  /* Alongside the usual types we can also wind up with various protocol-
380  specific format types such as SSL and SSH. The following types are
381  only visible internally */
382  CRYPT_IFORMAT_SSL, /* SSL/TLS format */
383  CRYPT_IFORMAT_TLS12, /* TLS 1.2 format */
384  CRYPT_IFORMAT_SSH, /* SSH format */
385 #endif /* _CRYPT_DEFINED */
386  CRYPT_FORMAT_LAST /* Last possible format type */
387 #ifdef _CRYPT_DEFINED
388  , CRYPT_FORMAT_LAST_EXTERNAL = CRYPT_FORMAT_PGP + 1
389 #endif /* _CRYPT_DEFINED */
391 
392 /* Session subtypes */
393 
394 typedef enum {
395  CRYPT_SESSION_NONE, /* No session type */
396  CRYPT_SESSION_SSH, /* SSH */
397  CRYPT_SESSION_SSH_SERVER, /* SSH server */
398  CRYPT_SESSION_SSL, /* SSL/TLS */
399  CRYPT_SESSION_SSL_SERVER, /* SSL/TLS server */
400  CRYPT_SESSION_RTCS, /* RTCS */
401  CRYPT_SESSION_RTCS_SERVER, /* RTCS server */
402  CRYPT_SESSION_OCSP, /* OCSP */
403  CRYPT_SESSION_OCSP_SERVER, /* OCSP server */
404  CRYPT_SESSION_TSP, /* TSP */
405  CRYPT_SESSION_TSP_SERVER, /* TSP server */
406  CRYPT_SESSION_CMP, /* CMP */
407  CRYPT_SESSION_CMP_SERVER, /* CMP server */
408  CRYPT_SESSION_SCEP, /* SCEP */
409  CRYPT_SESSION_SCEP_SERVER, /* SCEP server */
410  CRYPT_SESSION_CERTSTORE_SERVER, /* HTTP cert store interface */
411  CRYPT_SESSION_LAST /* Last possible session type */
413 
414 /* User subtypes */
415 
416 typedef enum {
417  CRYPT_USER_NONE, /* No user type */
418  CRYPT_USER_NORMAL, /* Normal user */
419  CRYPT_USER_SO, /* Security officer */
420  CRYPT_USER_CA, /* CA user */
421  CRYPT_USER_LAST /* Last possible user type */
422  } CRYPT_USER_TYPE;
423 
424 /****************************************************************************
425 * *
426 * Attribute Types *
427 * *
428 ****************************************************************************/
429 
430 /* Attribute types. These are arranged in the following order:
431 
432  PROPERTY - Object property
433  ATTRIBUTE - Generic attributes
434  OPTION - Global or object-specific config.option
435  CTXINFO - Context-specific attribute
436  CERTINFO - Certificate-specific attribute
437  KEYINFO - Keyset-specific attribute
438  DEVINFO - Device-specific attribute
439  ENVINFO - Envelope-specific attribute
440  SESSINFO - Session-specific attribute
441  USERINFO - User-specific attribute */
442 
443 typedef enum {
444  CRYPT_ATTRIBUTE_NONE, /* Non-value */
445 
446  /* Used internally */
448 
449  /*********************/
450  /* Object attributes */
451  /*********************/
452 
453  /* Object properties */
454  CRYPT_PROPERTY_HIGHSECURITY, /* Owned+non-forwardcount+locked */
455  CRYPT_PROPERTY_OWNER, /* Object owner */
456  CRYPT_PROPERTY_FORWARDCOUNT, /* No.of times object can be forwarded */
457  CRYPT_PROPERTY_LOCKED, /* Whether properties can be chged/read */
458  CRYPT_PROPERTY_USAGECOUNT, /* Usage count before object expires */
459  CRYPT_PROPERTY_NONEXPORTABLE, /* Whether key is nonexp.from context */
460 
461  /* Used internally */
463 
464  /* Extended error information */
465  CRYPT_ATTRIBUTE_ERRORTYPE, /* Type of last error */
466  CRYPT_ATTRIBUTE_ERRORLOCUS, /* Locus of last error */
467  CRYPT_ATTRIBUTE_ERRORMESSAGE, /* Detailed error description */
468 
469  /* Generic information */
470  CRYPT_ATTRIBUTE_CURRENT_GROUP, /* Cursor mgt: Group in attribute list */
471  CRYPT_ATTRIBUTE_CURRENT, /* Cursor mgt: Entry in attribute list */
472  CRYPT_ATTRIBUTE_CURRENT_INSTANCE, /* Cursor mgt: Instance in attribute list */
473  CRYPT_ATTRIBUTE_BUFFERSIZE, /* Internal data buffer size */
474 
475  /* User internally */
477 
478  /****************************/
479  /* Configuration attributes */
480  /****************************/
481 
482  /* cryptlib information (read-only) */
483  CRYPT_OPTION_INFO_DESCRIPTION, /* Text description */
484  CRYPT_OPTION_INFO_COPYRIGHT, /* Copyright notice */
485  CRYPT_OPTION_INFO_MAJORVERSION, /* Major release version */
486  CRYPT_OPTION_INFO_MINORVERSION, /* Minor release version */
487  CRYPT_OPTION_INFO_STEPPING, /* Release stepping */
488 
489  /* Encryption options */
490  CRYPT_OPTION_ENCR_ALGO, /* Encryption algorithm */
491  CRYPT_OPTION_ENCR_HASH, /* Hash algorithm */
492  CRYPT_OPTION_ENCR_MAC, /* MAC algorithm */
493 
494  /* PKC options */
495  CRYPT_OPTION_PKC_ALGO, /* Public-key encryption algorithm */
496  CRYPT_OPTION_PKC_KEYSIZE, /* Public-key encryption key size */
497 
498  /* Signature options */
499  CRYPT_OPTION_SIG_ALGO, /* Signature algorithm */
500  CRYPT_OPTION_SIG_KEYSIZE, /* Signature keysize */
501 
502  /* Keying options */
503  CRYPT_OPTION_KEYING_ALGO, /* Key processing algorithm */
504  CRYPT_OPTION_KEYING_ITERATIONS, /* Key processing iterations */
505 
506  /* Certificate options */
507  CRYPT_OPTION_CERT_SIGNUNRECOGNISEDATTRIBUTES, /* Whether to sign unrecog.attrs */
508  CRYPT_OPTION_CERT_VALIDITY, /* Certificate validity period */
509  CRYPT_OPTION_CERT_UPDATEINTERVAL, /* CRL update interval */
510  CRYPT_OPTION_CERT_COMPLIANCELEVEL, /* PKIX compliance level for cert chks.*/
511  CRYPT_OPTION_CERT_REQUIREPOLICY, /* Whether explicit policy req'd for certs */
512 
513  /* CMS/SMIME options */
514  CRYPT_OPTION_CMS_DEFAULTATTRIBUTES, /* Add default CMS attributes */
516 
517  /* LDAP keyset options */
519  CRYPT_OPTION_KEYS_LDAP_OBJECTTYPE, /* Object type to fetch */
520  CRYPT_OPTION_KEYS_LDAP_FILTER, /* Query filter */
521  CRYPT_OPTION_KEYS_LDAP_CACERTNAME, /* CA certificate attribute name */
522  CRYPT_OPTION_KEYS_LDAP_CERTNAME, /* Certificate attribute name */
523  CRYPT_OPTION_KEYS_LDAP_CRLNAME, /* CRL attribute name */
524  CRYPT_OPTION_KEYS_LDAP_EMAILNAME, /* Email attribute name */
525 
526  /* Crypto device options */
527  CRYPT_OPTION_DEVICE_PKCS11_DVR01, /* Name of first PKCS #11 driver */
528  CRYPT_OPTION_DEVICE_PKCS11_DVR02, /* Name of second PKCS #11 driver */
529  CRYPT_OPTION_DEVICE_PKCS11_DVR03, /* Name of third PKCS #11 driver */
530  CRYPT_OPTION_DEVICE_PKCS11_DVR04, /* Name of fourth PKCS #11 driver */
531  CRYPT_OPTION_DEVICE_PKCS11_DVR05, /* Name of fifth PKCS #11 driver */
532  CRYPT_OPTION_DEVICE_PKCS11_HARDWAREONLY,/* Use only hardware mechanisms */
533 
534  /* Network access options */
535  CRYPT_OPTION_NET_SOCKS_SERVER, /* Socks server name */
536  CRYPT_OPTION_NET_SOCKS_USERNAME, /* Socks user name */
537  CRYPT_OPTION_NET_HTTP_PROXY, /* Web proxy server */
538  CRYPT_OPTION_NET_CONNECTTIMEOUT, /* Timeout for network connection setup */
539  CRYPT_OPTION_NET_READTIMEOUT, /* Timeout for network reads */
540  CRYPT_OPTION_NET_WRITETIMEOUT, /* Timeout for network writes */
541 
542  /* Miscellaneous options */
543  CRYPT_OPTION_MISC_ASYNCINIT, /* Whether to init cryptlib async'ly */
544  CRYPT_OPTION_MISC_SIDECHANNELPROTECTION, /* Protect against side-channel attacks */
545 
546  /* cryptlib state information */
547  CRYPT_OPTION_CONFIGCHANGED, /* Whether in-mem.opts match on-disk ones */
548  CRYPT_OPTION_SELFTESTOK, /* Whether self-test was completed and OK */
549 
550  /* Used internally */
552 
553  /**********************/
554  /* Context attributes */
555  /**********************/
556 
557  /* Algorithm and mode information */
558  CRYPT_CTXINFO_ALGO, /* Algorithm */
559  CRYPT_CTXINFO_MODE, /* Mode */
560  CRYPT_CTXINFO_NAME_ALGO, /* Algorithm name */
561  CRYPT_CTXINFO_NAME_MODE, /* Mode name */
562  CRYPT_CTXINFO_KEYSIZE, /* Key size in bytes */
563  CRYPT_CTXINFO_BLOCKSIZE, /* Block size */
564  CRYPT_CTXINFO_IVSIZE, /* IV size */
565  CRYPT_CTXINFO_KEYING_ALGO, /* Key processing algorithm */
566  CRYPT_CTXINFO_KEYING_ITERATIONS,/* Key processing iterations */
567  CRYPT_CTXINFO_KEYING_SALT, /* Key processing salt */
568  CRYPT_CTXINFO_KEYING_VALUE, /* Value used to derive key */
569 
570  /* State information */
571  CRYPT_CTXINFO_KEY, /* Key */
572  CRYPT_CTXINFO_KEY_COMPONENTS, /* Public-key components */
574  CRYPT_CTXINFO_HASHVALUE, /* Hash value */
575 
576  /* Misc.information */
577  CRYPT_CTXINFO_LABEL, /* Label for private/secret key */
578  CRYPT_CTXINFO_PERSISTENT, /* Obj.is backed by device or keyset */
579 
580  /* Used internally */
582 
583  /**************************/
584  /* Certificate attributes */
585  /**************************/
586 
587  /* Because there are so many cert attributes, we break them down into
588  blocks to minimise the number of values that change if a new one is
589  added halfway through */
590 
591  /* Pseudo-information on a cert object or meta-information which is used
592  to control the way that a cert object is processed */
593  CRYPT_CERTINFO_SELFSIGNED, /* Cert is self-signed */
594  CRYPT_CERTINFO_IMMUTABLE, /* Cert is signed and immutable */
595  CRYPT_CERTINFO_XYZZY, /* Cert is a magic just-works cert */
596  CRYPT_CERTINFO_CERTTYPE, /* Certificate object type */
597  CRYPT_CERTINFO_FINGERPRINT, /* Certificate fingerprints */
603  CRYPT_CERTINFO_CURRENT_CERTIFICATE,/* Cursor mgt: Rel.pos in chain/CRL/OCSP */
604  CRYPT_CERTINFO_TRUSTED_USAGE, /* Usage that cert is trusted for */
605  CRYPT_CERTINFO_TRUSTED_IMPLICIT,/* Whether cert is implicitly trusted */
606  CRYPT_CERTINFO_SIGNATURELEVEL, /* Amount of detail to include in sigs.*/
607 
608  /* General certificate object information */
609  CRYPT_CERTINFO_VERSION, /* Cert.format version */
610  CRYPT_CERTINFO_SERIALNUMBER, /* Serial number */
612  CRYPT_CERTINFO_CERTIFICATE, /* User certificate */
614  CRYPT_CERTINFO_CACERTIFICATE, /* CA certificate */
615  CRYPT_CERTINFO_ISSUERNAME, /* Issuer DN */
616  CRYPT_CERTINFO_VALIDFROM, /* Cert valid-from time */
617  CRYPT_CERTINFO_VALIDTO, /* Cert valid-to time */
618  CRYPT_CERTINFO_SUBJECTNAME, /* Subject DN */
619  CRYPT_CERTINFO_ISSUERUNIQUEID, /* Issuer unique ID */
620  CRYPT_CERTINFO_SUBJECTUNIQUEID, /* Subject unique ID */
621  CRYPT_CERTINFO_CERTREQUEST, /* Cert.request (DN + public key) */
622  CRYPT_CERTINFO_THISUPDATE, /* CRL/OCSP current-update time */
623  CRYPT_CERTINFO_NEXTUPDATE, /* CRL/OCSP next-update time */
624  CRYPT_CERTINFO_REVOCATIONDATE, /* CRL/OCSP cert-revocation time */
625  CRYPT_CERTINFO_REVOCATIONSTATUS,/* OCSP revocation status */
626  CRYPT_CERTINFO_CERTSTATUS, /* RTCS certificate status */
627  CRYPT_CERTINFO_DN, /* Currently selected DN in string form */
628  CRYPT_CERTINFO_PKIUSER_ID, /* PKI user ID */
629  CRYPT_CERTINFO_PKIUSER_ISSUEPASSWORD, /* PKI user issue password */
630  CRYPT_CERTINFO_PKIUSER_REVPASSWORD, /* PKI user revocation password */
631 
632  /* X.520 Distinguished Name components. This is a composite field, the
633  DN to be manipulated is selected through the addition of a
634  pseudocomponent, and then one of the following is used to access the
635  DN components directly */
636  CRYPT_CERTINFO_COUNTRYNAME = CRYPT_CERTINFO_FIRST + 100, /* countryName */
637  CRYPT_CERTINFO_STATEORPROVINCENAME, /* stateOrProvinceName */
638  CRYPT_CERTINFO_LOCALITYNAME, /* localityName */
639  CRYPT_CERTINFO_ORGANIZATIONNAME, /* organizationName */
641  CRYPT_CERTINFO_ORGANIZATIONALUNITNAME, /* organizationalUnitName */
643  CRYPT_CERTINFO_COMMONNAME, /* commonName */
644 
645  /* X.509 General Name components. These are handled in the same way as
646  the DN composite field, with the current GeneralName being selected by
647  a pseudo-component after which the individual components can be
648  modified through one of the following */
649  CRYPT_CERTINFO_OTHERNAME_TYPEID, /* otherName.typeID */
650  CRYPT_CERTINFO_OTHERNAME_VALUE, /* otherName.value */
651  CRYPT_CERTINFO_RFC822NAME, /* rfc822Name */
653  CRYPT_CERTINFO_DNSNAME, /* dNSName */
654 #if 0 /* Not supported, these are never used in practice and have an
655  insane internal structure */
656  CRYPT_CERTINFO_X400ADDRESS, /* x400Address */
657 #endif /* 0 */
658  CRYPT_CERTINFO_DIRECTORYNAME, /* directoryName */
659  CRYPT_CERTINFO_EDIPARTYNAME_NAMEASSIGNER, /* ediPartyName.nameAssigner */
660  CRYPT_CERTINFO_EDIPARTYNAME_PARTYNAME, /* ediPartyName.partyName */
661  CRYPT_CERTINFO_UNIFORMRESOURCEIDENTIFIER, /* uniformResourceIdentifier */
662  CRYPT_CERTINFO_IPADDRESS, /* iPAddress */
663  CRYPT_CERTINFO_REGISTEREDID, /* registeredID */
664 
665  /* X.509 certificate extensions. Although it would be nicer to use names
666  that match the extensions more closely (e.g.
667  CRYPT_CERTINFO_BASICCONSTRAINTS_PATHLENCONSTRAINT), these exceed the
668  32-character ANSI minimum length for unique names, and get really
669  hairy once you get into the weird policy constraints extensions whose
670  names wrap around the screen about three times.
671 
672  The following values are defined in OID order, this isn't absolutely
673  necessary but saves an extra layer of processing when encoding them */
674 
675  /* 1 2 840 113549 1 9 7 challengePassword. This is here even though it's
676  a CMS attribute because SCEP stuffs it into PKCS #10 requests */
677  CRYPT_CERTINFO_CHALLENGEPASSWORD = CRYPT_CERTINFO_FIRST + 200,
678 
679  /* 1 3 6 1 4 1 3029 3 1 4 cRLExtReason */
681 
682  /* 1 3 6 1 4 1 3029 3 1 5 keyFeatures */
684 
685  /* 1 3 6 1 5 5 7 1 1 authorityInfoAccess */
687  CRYPT_CERTINFO_AUTHORITYINFO_RTCS, /* accessDescription.accessLocation */
688  CRYPT_CERTINFO_AUTHORITYINFO_OCSP, /* accessDescription.accessLocation */
689  CRYPT_CERTINFO_AUTHORITYINFO_CAISSUERS, /* accessDescription.accessLocation */
690  CRYPT_CERTINFO_AUTHORITYINFO_CERTSTORE, /* accessDescription.accessLocation */
691  CRYPT_CERTINFO_AUTHORITYINFO_CRLS, /* accessDescription.accessLocation */
692 
693  /* 1 3 6 1 5 5 7 1 2 biometricInfo */
695  CRYPT_CERTINFO_BIOMETRICINFO_TYPE, /* biometricData.typeOfData */
696  CRYPT_CERTINFO_BIOMETRICINFO_HASHALGO, /* biometricData.hashAlgorithm */
697  CRYPT_CERTINFO_BIOMETRICINFO_HASH, /* biometricData.dataHash */
698  CRYPT_CERTINFO_BIOMETRICINFO_URL, /* biometricData.sourceDataUri */
699 
700  /* 1 3 6 1 5 5 7 1 3 qcStatements */
703  /* qcStatement.statementInfo.semanticsIdentifier */
705  /* qcStatement.statementInfo.nameRegistrationAuthorities */
706 
707  /* 1 3 6 1 5 5 7 1 7 ipAddrBlocks */
710 /* CRYPT_CERTINFO_IPADDRESSBLOCKS_INHERIT, // ipAddress.inherit */
711  CRYPT_CERTINFO_IPADDRESSBLOCKS_PREFIX, /* ipAddress.addressPrefix */
712  CRYPT_CERTINFO_IPADDRESSBLOCKS_MIN, /* ipAddress.addressRangeMin */
713  CRYPT_CERTINFO_IPADDRESSBLOCKS_MAX, /* ipAddress.addressRangeMax */
714 
715  /* 1 3 6 1 5 5 7 1 8 autonomousSysIds */
717 /* CRYPT_CERTINFO_AUTONOMOUSSYSIDS_ASNUM_INHERIT,// asNum.inherit */
721 
722  /* 1 3 6 1 5 5 7 48 1 2 ocspNonce */
724 
725  /* 1 3 6 1 5 5 7 48 1 4 ocspAcceptableResponses */
727  CRYPT_CERTINFO_OCSP_RESPONSE_OCSP, /* OCSP standard response */
728 
729  /* 1 3 6 1 5 5 7 48 1 5 ocspNoCheck */
731 
732  /* 1 3 6 1 5 5 7 48 1 6 ocspArchiveCutoff */
734 
735  /* 1 3 6 1 5 5 7 48 1 11 subjectInfoAccess */
737  CRYPT_CERTINFO_SUBJECTINFO_TIMESTAMPING,/* accessDescription.accessLocation */
738  CRYPT_CERTINFO_SUBJECTINFO_CAREPOSITORY,/* accessDescription.accessLocation */
739  CRYPT_CERTINFO_SUBJECTINFO_SIGNEDOBJECTREPOSITORY,/* accessDescription.accessLocation */
740  CRYPT_CERTINFO_SUBJECTINFO_RPKIMANIFEST,/* accessDescription.accessLocation */
741  CRYPT_CERTINFO_SUBJECTINFO_SIGNEDOBJECT,/* accessDescription.accessLocation */
742 
743  /* 1 3 36 8 3 1 siggDateOfCertGen */
745 
746  /* 1 3 36 8 3 2 siggProcuration */
750  CRYPT_CERTINFO_SIGG_PROCURE_SIGNINGFOR, /* signingFor.thirdPerson */
751 
752  /* 1 3 36 8 3 3 siggAdmissions */
761 
762  /* 1 3 36 8 3 4 siggMonetaryLimit */
767 
768  /* 1 3 36 8 3 5 siggDeclarationOfMajority */
771 
772  /* 1 3 36 8 3 8 siggRestriction */
774 
775  /* 1 3 36 8 3 13 siggCertHash */
777 
778  /* 1 3 36 8 3 15 siggAdditionalInformation */
780 
781  /* 1 3 101 1 4 1 strongExtranet */
783  CRYPT_CERTINFO_STRONGEXTRANET_ZONE, /* sxNetIDList.sxNetID.zone */
784  CRYPT_CERTINFO_STRONGEXTRANET_ID, /* sxNetIDList.sxNetID.id */
785 
786  /* 2 5 29 9 subjectDirectoryAttributes */
788  CRYPT_CERTINFO_SUBJECTDIR_TYPE, /* attribute.type */
789  CRYPT_CERTINFO_SUBJECTDIR_VALUES, /* attribute.values */
790 
791  /* 2 5 29 14 subjectKeyIdentifier */
793 
794  /* 2 5 29 15 keyUsage */
796 
797  /* 2 5 29 16 privateKeyUsagePeriod */
801 
802  /* 2 5 29 17 subjectAltName */
804 
805  /* 2 5 29 18 issuerAltName */
807 
808  /* 2 5 29 19 basicConstraints */
812  CRYPT_CERTINFO_PATHLENCONSTRAINT, /* pathLenConstraint */
813 
814  /* 2 5 29 20 cRLNumber */
816 
817  /* 2 5 29 21 cRLReason */
819 
820  /* 2 5 29 23 holdInstructionCode */
822 
823  /* 2 5 29 24 invalidityDate */
825 
826  /* 2 5 29 27 deltaCRLIndicator */
828 
829  /* 2 5 29 28 issuingDistributionPoint */
831  CRYPT_CERTINFO_ISSUINGDIST_FULLNAME, /* distributionPointName.fullName */
832  CRYPT_CERTINFO_ISSUINGDIST_USERCERTSONLY, /* onlyContainsUserCerts */
833  CRYPT_CERTINFO_ISSUINGDIST_CACERTSONLY, /* onlyContainsCACerts */
836 
837  /* 2 5 29 29 certificateIssuer */
839 
840  /* 2 5 29 30 nameConstraints */
842  CRYPT_CERTINFO_PERMITTEDSUBTREES, /* permittedSubtrees */
843  CRYPT_CERTINFO_EXCLUDEDSUBTREES, /* excludedSubtrees */
844 
845  /* 2 5 29 31 cRLDistributionPoint */
847  CRYPT_CERTINFO_CRLDIST_FULLNAME, /* distributionPointName.fullName */
850 
851  /* 2 5 29 32 certificatePolicies */
853  CRYPT_CERTINFO_CERTPOLICYID, /* policyInformation.policyIdentifier */
855  /* policyInformation.policyQualifiers.qualifier.cPSuri */
857  /* policyInformation.policyQualifiers.qualifier.userNotice.noticeRef.organization */
859  /* policyInformation.policyQualifiers.qualifier.userNotice.noticeRef.noticeNumbers */
861  /* policyInformation.policyQualifiers.qualifier.userNotice.explicitText */
862 
863  /* 2 5 29 33 policyMappings */
865  CRYPT_CERTINFO_ISSUERDOMAINPOLICY, /* policyMappings.issuerDomainPolicy */
866  CRYPT_CERTINFO_SUBJECTDOMAINPOLICY, /* policyMappings.subjectDomainPolicy */
867 
868  /* 2 5 29 35 authorityKeyIdentifier */
871  CRYPT_CERTINFO_AUTHORITY_CERTISSUER, /* authorityCertIssuer */
872  CRYPT_CERTINFO_AUTHORITY_CERTSERIALNUMBER, /* authorityCertSerialNumber */
873 
874  /* 2 5 29 36 policyConstraints */
876  CRYPT_CERTINFO_REQUIREEXPLICITPOLICY, /* policyConstraints.requireExplicitPolicy */
877  CRYPT_CERTINFO_INHIBITPOLICYMAPPING, /* policyConstraints.inhibitPolicyMapping */
878 
879  /* 2 5 29 37 extKeyUsage */
897  CRYPT_CERTINFO_EXTKEY_ANYKEYUSAGE, /* anyExtendedKeyUsage */
900 
901  /* 2 5 29 40 crlStreamIdentifier */
903 
904  /* 2 5 29 46 freshestCRL */
906  CRYPT_CERTINFO_FRESHESTCRL_FULLNAME, /* distributionPointName.fullName */
909 
910  /* 2 5 29 47 orderedList */
912 
913  /* 2 5 29 51 baseUpdateTime */
915 
916  /* 2 5 29 53 deltaInfo */
920 
921  /* 2 5 29 54 inhibitAnyPolicy */
923 
924  /* 2 5 29 58 toBeRevoked */
926  CRYPT_CERTINFO_TOBEREVOKED_CERTISSUER, /* certificateIssuer */
930 
931  /* 2 5 29 59 revokedGroups */
938 
939  /* 2 5 29 60 expiredCertsOnCRL */
941 
942  /* 2 5 29 63 aaIssuingDistributionPoint */
944  CRYPT_CERTINFO_AAISSUINGDIST_FULLNAME, /* distributionPointName.fullName */
947  CRYPT_CERTINFO_AAISSUINGDIST_USERATTRCERTS, /* containsUserAttributeCerts */
949  CRYPT_CERTINFO_AAISSUINGDIST_SOACERTS, /* containsSOAPublicKeyCerts */
950 
951  /* 2 16 840 1 113730 1 x Netscape extensions */
952  CRYPT_CERTINFO_NS_CERTTYPE, /* netscape-cert-type */
953  CRYPT_CERTINFO_NS_BASEURL, /* netscape-base-url */
954  CRYPT_CERTINFO_NS_REVOCATIONURL, /* netscape-revocation-url */
955  CRYPT_CERTINFO_NS_CAREVOCATIONURL, /* netscape-ca-revocation-url */
956  CRYPT_CERTINFO_NS_CERTRENEWALURL, /* netscape-cert-renewal-url */
957  CRYPT_CERTINFO_NS_CAPOLICYURL, /* netscape-ca-policy-url */
958  CRYPT_CERTINFO_NS_SSLSERVERNAME, /* netscape-ssl-server-name */
959  CRYPT_CERTINFO_NS_COMMENT, /* netscape-comment */
960 
961  /* 2 23 42 7 0 SET hashedRootKey */
963  CRYPT_CERTINFO_SET_ROOTKEYTHUMBPRINT, /* rootKeyThumbPrint */
964 
965  /* 2 23 42 7 1 SET certificateType */
967 
968  /* 2 23 42 7 2 SET merchantData */
971  CRYPT_CERTINFO_SET_MERACQUIRERBIN, /* merAcquirerBIN */
972  CRYPT_CERTINFO_SET_MERCHANTLANGUAGE, /* merNames.language */
973  CRYPT_CERTINFO_SET_MERCHANTNAME, /* merNames.name */
974  CRYPT_CERTINFO_SET_MERCHANTCITY, /* merNames.city */
975  CRYPT_CERTINFO_SET_MERCHANTSTATEPROVINCE,/* merNames.stateProvince */
976  CRYPT_CERTINFO_SET_MERCHANTPOSTALCODE, /* merNames.postalCode */
977  CRYPT_CERTINFO_SET_MERCHANTCOUNTRYNAME, /* merNames.countryName */
980 
981  /* 2 23 42 7 3 SET certCardRequired */
983 
984  /* 2 23 42 7 4 SET tunneling */
989  CRYPT_CERTINFO_SET_TUNNELINGALGID, /* tunnelingAlgID */
991 
992  /* S/MIME attributes */
993 
994  /* 1 2 840 113549 1 9 3 contentType */
995  CRYPT_CERTINFO_CMS_CONTENTTYPE = CRYPT_CERTINFO_FIRST + 500,
996 
997  /* 1 2 840 113549 1 9 4 messageDigest */
999 
1000  /* 1 2 840 113549 1 9 5 signingTime */
1002 
1003  /* 1 2 840 113549 1 9 6 counterSignature */
1004  CRYPT_CERTINFO_CMS_COUNTERSIGNATURE, /* counterSignature */
1005 
1006  /* 1 2 840 113549 1 9 13 signingDescription */
1008 
1009  /* 1 2 840 113549 1 9 15 sMIMECapabilities */
1011  CRYPT_CERTINFO_CMS_SMIMECAP_3DES, /* 3DES encryption */
1012  CRYPT_CERTINFO_CMS_SMIMECAP_AES, /* AES encryption */
1013  CRYPT_CERTINFO_CMS_SMIMECAP_CAST128, /* CAST-128 encryption */
1014  CRYPT_CERTINFO_CMS_SMIMECAP_IDEA, /* IDEA encryption */
1015  CRYPT_CERTINFO_CMS_SMIMECAP_RC2, /* RC2 encryption (w.128 key) */
1016  CRYPT_CERTINFO_CMS_SMIMECAP_RC5, /* RC5 encryption (w.128 key) */
1017  CRYPT_CERTINFO_CMS_SMIMECAP_SKIPJACK, /* Skipjack encryption */
1018  CRYPT_CERTINFO_CMS_SMIMECAP_DES, /* DES encryption */
1023  CRYPT_CERTINFO_CMS_SMIMECAP_HMAC_SHA2, /* HMAC-SHA2-256 MAC */
1025  CRYPT_CERTINFO_CMS_SMIMECAP_AUTHENC256, /* AuthEnc w.256-bit key */
1026  CRYPT_CERTINFO_CMS_SMIMECAP_AUTHENC128, /* AuthEnc w.128-bit key */
1027  CRYPT_CERTINFO_CMS_SMIMECAP_RSA_SHAng, /* RSA with SHA-ng signing */
1028  CRYPT_CERTINFO_CMS_SMIMECAP_RSA_SHA2, /* RSA with SHA2-256 signing */
1029  CRYPT_CERTINFO_CMS_SMIMECAP_RSA_SHA1, /* RSA with SHA1 signing */
1030  CRYPT_CERTINFO_CMS_SMIMECAP_DSA_SHA1, /* DSA with SHA-1 signing */
1031  CRYPT_CERTINFO_CMS_SMIMECAP_ECDSA_SHAng,/* ECDSA with SHA-ng signing */
1032  CRYPT_CERTINFO_CMS_SMIMECAP_ECDSA_SHA2, /* ECDSA with SHA2-256 signing */
1033  CRYPT_CERTINFO_CMS_SMIMECAP_ECDSA_SHA1, /* ECDSA with SHA-1 signing */
1037 
1038  /* 1 2 840 113549 1 9 16 2 1 receiptRequest */
1043 
1044  /* 1 2 840 113549 1 9 16 2 2 essSecurityLabel */
1046  CRYPT_CERTINFO_CMS_SECLABEL_POLICY, /* securityPolicyIdentifier */
1047  CRYPT_CERTINFO_CMS_SECLABEL_CLASSIFICATION, /* securityClassification */
1049  CRYPT_CERTINFO_CMS_SECLABEL_CATTYPE, /* securityCategories.securityCategory.type */
1050  CRYPT_CERTINFO_CMS_SECLABEL_CATVALUE, /* securityCategories.securityCategory.value */
1051 
1052  /* 1 2 840 113549 1 9 16 2 3 mlExpansionHistory */
1054  CRYPT_CERTINFO_CMS_MLEXP_ENTITYIDENTIFIER, /* mlData.mailListIdentifier.issuerAndSerialNumber */
1055  CRYPT_CERTINFO_CMS_MLEXP_TIME, /* mlData.expansionTime */
1056  CRYPT_CERTINFO_CMS_MLEXP_NONE, /* mlData.mlReceiptPolicy.none */
1057  CRYPT_CERTINFO_CMS_MLEXP_INSTEADOF, /* mlData.mlReceiptPolicy.insteadOf.generalNames.generalName */
1058  CRYPT_CERTINFO_CMS_MLEXP_INADDITIONTO, /* mlData.mlReceiptPolicy.inAdditionTo.generalNames.generalName */
1059 
1060  /* 1 2 840 113549 1 9 16 2 4 contentHints */
1064 
1065  /* 1 2 840 113549 1 9 16 2 9 equivalentLabels */
1067  CRYPT_CERTINFO_CMS_EQVLABEL_POLICY, /* securityPolicyIdentifier */
1068  CRYPT_CERTINFO_CMS_EQVLABEL_CLASSIFICATION, /* securityClassification */
1070  CRYPT_CERTINFO_CMS_EQVLABEL_CATTYPE, /* securityCategories.securityCategory.type */
1071  CRYPT_CERTINFO_CMS_EQVLABEL_CATVALUE, /* securityCategories.securityCategory.value */
1072 
1073  /* 1 2 840 113549 1 9 16 2 12 signingCertificate */
1076  CRYPT_CERTINFO_CMS_SIGNINGCERT_POLICIES,/* policies.policyInformation.policyIdentifier */
1077 
1078  /* 1 2 840 113549 1 9 16 2 47 signingCertificateV2 */
1081  CRYPT_CERTINFO_CMS_SIGNINGCERTV2_POLICIES,/* policies.policyInformation.policyIdentifier */
1082 
1083  /* 1 2 840 113549 1 9 16 2 15 signaturePolicyID */
1087  CRYPT_CERTINFO_CMS_SIGPOLICY_CPSURI, /* sigPolicyQualifiers.sigPolicyQualifier.cPSuri */
1089  /* sigPolicyQualifiers.sigPolicyQualifier.userNotice.noticeRef.organization */
1091  /* sigPolicyQualifiers.sigPolicyQualifier.userNotice.noticeRef.noticeNumbers */
1093  /* sigPolicyQualifiers.sigPolicyQualifier.userNotice.explicitText */
1094 
1095  /* 1 2 840 113549 1 9 16 9 signatureTypeIdentifier */
1101 
1102  /* 1 2 840 113549 1 9 25 3 randomNonce */
1103  CRYPT_CERTINFO_CMS_NONCE, /* randomNonce */
1104 
1105  /* SCEP attributes:
1106  2 16 840 1 113733 1 9 2 messageType
1107  2 16 840 1 113733 1 9 3 pkiStatus
1108  2 16 840 1 113733 1 9 4 failInfo
1109  2 16 840 1 113733 1 9 5 senderNonce
1110  2 16 840 1 113733 1 9 6 recipientNonce
1111  2 16 840 1 113733 1 9 7 transID */
1118 
1119  /* 1 3 6 1 4 1 311 2 1 10 spcAgencyInfo */
1121  CRYPT_CERTINFO_CMS_SPCAGENCYURL, /* spcAgencyInfo.url */
1122 
1123  /* 1 3 6 1 4 1 311 2 1 11 spcStatementType */
1127 
1128  /* 1 3 6 1 4 1 311 2 1 12 spcOpusInfo */
1130  CRYPT_CERTINFO_CMS_SPCOPUSINFO_NAME, /* spcOpusInfo.name */
1131  CRYPT_CERTINFO_CMS_SPCOPUSINFO_URL, /* spcOpusInfo.url */
1132 
1133  /* Used internally */
1135 
1136  /*********************/
1137  /* Keyset attributes */
1138  /*********************/
1139 
1140  CRYPT_KEYINFO_QUERY, /* Keyset query */
1141  CRYPT_KEYINFO_QUERY_REQUESTS, /* Query of requests in cert store */
1142 
1143  /* Used internally */
1145 
1146  /*********************/
1147  /* Device attributes */
1148  /*********************/
1149 
1150  CRYPT_DEVINFO_INITIALISE, /* Initialise device for use */
1152  CRYPT_DEVINFO_AUTHENT_USER, /* Authenticate user to device */
1153  CRYPT_DEVINFO_AUTHENT_SUPERVISOR, /* Authenticate supervisor to dev.*/
1154  CRYPT_DEVINFO_SET_AUTHENT_USER, /* Set user authent.value */
1155  CRYPT_DEVINFO_SET_AUTHENT_SUPERVISOR, /* Set supervisor auth.val.*/
1156  CRYPT_DEVINFO_ZEROISE, /* Zeroise device */
1158  CRYPT_DEVINFO_LOGGEDIN, /* Whether user is logged in */
1159  CRYPT_DEVINFO_LABEL, /* Device/token label */
1160 
1161  /* Used internally */
1163 
1164  /***********************/
1165  /* Envelope attributes */
1166  /***********************/
1167 
1168  /* Pseudo-information on an envelope or meta-information which is used to
1169  control the way that data in an envelope is processed */
1170  CRYPT_ENVINFO_DATASIZE, /* Data size information */
1171  CRYPT_ENVINFO_COMPRESSION, /* Compression information */
1172  CRYPT_ENVINFO_CONTENTTYPE, /* Inner CMS content type */
1173  CRYPT_ENVINFO_DETACHEDSIGNATURE,/* Detached signature */
1174  CRYPT_ENVINFO_SIGNATURE_RESULT, /* Signature check result */
1175  CRYPT_ENVINFO_INTEGRITY, /* Integrity-protection level */
1176 
1177  /* Resources required for enveloping/deenveloping */
1178  CRYPT_ENVINFO_PASSWORD, /* User password */
1179  CRYPT_ENVINFO_KEY, /* Conventional encryption key */
1180  CRYPT_ENVINFO_SIGNATURE, /* Signature/signature check key */
1181  CRYPT_ENVINFO_SIGNATURE_EXTRADATA, /* Extra information added to CMS sigs */
1182  CRYPT_ENVINFO_RECIPIENT, /* Recipient email address */
1183  CRYPT_ENVINFO_PUBLICKEY, /* PKC encryption key */
1184  CRYPT_ENVINFO_PRIVATEKEY, /* PKC decryption key */
1185  CRYPT_ENVINFO_PRIVATEKEY_LABEL, /* Label of PKC decryption key */
1186  CRYPT_ENVINFO_ORIGINATOR, /* Originator info/key */
1187  CRYPT_ENVINFO_SESSIONKEY, /* Session key */
1188  CRYPT_ENVINFO_HASH, /* Hash value */
1189  CRYPT_ENVINFO_TIMESTAMP, /* Timestamp information */
1190 
1191  /* Keysets used to retrieve keys needed for enveloping/deenveloping */
1192  CRYPT_ENVINFO_KEYSET_SIGCHECK, /* Signature check keyset */
1193  CRYPT_ENVINFO_KEYSET_ENCRYPT, /* PKC encryption keyset */
1194  CRYPT_ENVINFO_KEYSET_DECRYPT, /* PKC decryption keyset */
1195 
1196  /* Used internally */
1198 
1199  /**********************/
1200  /* Session attributes */
1201  /**********************/
1202 
1203  /* Pseudo-information about the session */
1204  CRYPT_SESSINFO_ACTIVE, /* Whether session is active */
1205  CRYPT_SESSINFO_CONNECTIONACTIVE,/* Whether network connection is active */
1206 
1207  /* Security-related information */
1208  CRYPT_SESSINFO_USERNAME, /* User name */
1209  CRYPT_SESSINFO_PASSWORD, /* Password */
1210  CRYPT_SESSINFO_PRIVATEKEY, /* Server/client private key */
1211  CRYPT_SESSINFO_KEYSET, /* Certificate store */
1212  CRYPT_SESSINFO_AUTHRESPONSE, /* Session authorisation OK */
1213 
1214  /* Client/server information */
1215  CRYPT_SESSINFO_SERVER_NAME, /* Server name */
1216  CRYPT_SESSINFO_SERVER_PORT, /* Server port number */
1217  CRYPT_SESSINFO_SERVER_FINGERPRINT,/* Server key fingerprint */
1218  CRYPT_SESSINFO_CLIENT_NAME, /* Client name */
1219  CRYPT_SESSINFO_CLIENT_PORT, /* Client port number */
1220  CRYPT_SESSINFO_SESSION, /* Transport mechanism */
1221  CRYPT_SESSINFO_NETWORKSOCKET, /* User-supplied network socket */
1222 
1223  /* Generic protocol-related information */
1224  CRYPT_SESSINFO_VERSION, /* Protocol version */
1225  CRYPT_SESSINFO_REQUEST, /* Cert.request object */
1226  CRYPT_SESSINFO_RESPONSE, /* Cert.response object */
1227  CRYPT_SESSINFO_CACERTIFICATE, /* Issuing CA certificate */
1228 
1229  /* Protocol-specific information */
1231  CRYPT_SESSINFO_CMP_PRIVKEYSET, /* Private-key keyset */
1232  CRYPT_SESSINFO_SSH_CHANNEL, /* SSH current channel */
1233  CRYPT_SESSINFO_SSH_CHANNEL_TYPE,/* SSH channel type */
1234  CRYPT_SESSINFO_SSH_CHANNEL_ARG1,/* SSH channel argument 1 */
1235  CRYPT_SESSINFO_SSH_CHANNEL_ARG2,/* SSH channel argument 2 */
1236  CRYPT_SESSINFO_SSH_CHANNEL_ACTIVE,/* SSH channel active */
1237  CRYPT_SESSINFO_SSL_OPTIONS, /* SSL/TLS protocol options */
1238  CRYPT_SESSINFO_TSP_MSGIMPRINT, /* TSP message imprint */
1239 
1240  /* Used internally */
1242 
1243  /**********************/
1244  /* User attributes */
1245  /**********************/
1246 
1247  /* Security-related information */
1248  CRYPT_USERINFO_PASSWORD, /* Password */
1249 
1250  /* User role-related information */
1251  CRYPT_USERINFO_CAKEY_CERTSIGN, /* CA cert signing key */
1252  CRYPT_USERINFO_CAKEY_CRLSIGN, /* CA CRL signing key */
1253  CRYPT_USERINFO_CAKEY_RTCSSIGN, /* CA RTCS signing key */
1254  CRYPT_USERINFO_CAKEY_OCSPSIGN, /* CA OCSP signing key */
1255 
1256  /* Used internally for range checking */
1258 
1259 #ifdef _CRYPT_DEFINED
1260  /***********************/
1261  /* Internal attributes */
1262  /***********************/
1263 
1264  /* The following attributes are only visible internally and are protected
1265  from any external access by the kernel (and for good measure by checks
1266  in other places as well). The two attributes CRYPT_IATTRIBUTE_KEY_SPKI
1267  and CRYPT_IATTRIBUTE_SPKI are actually the same thing, the difference
1268  is that the former is write-only for contexts and the latter is read-
1269  only for certificates (the former is used when loading a context from
1270  a key contained in a device, where the actual key components aren't
1271  directly available in the context but may be needed in the future for
1272  things like cert requests). Because a single object can act as both a
1273  context and a cert, having two explicitly different attribute names
1274  makes things less confusing. In addition, some public-key attributes
1275  have _PARTIAL variants that load the public-key components but don't
1276  initialise the key/move the context into the high state. This is
1277  used for formats in which public and private-key components are loaded
1278  separately */
1279  , CRYPT_IATTRIBUTE_FIRST = 8000,
1280  CRYPT_IATTRIBUTE_TYPE, /* Object type */
1281  CRYPT_IATTRIBUTE_SUBTYPE, /* Object subtype */
1282  CRYPT_IATTRIBUTE_STATUS, /* Object status */
1283  CRYPT_IATTRIBUTE_INTERNAL, /* Object internal flag */
1284  CRYPT_IATTRIBUTE_ACTIONPERMS, /* Object action permissions */
1285  CRYPT_IATTRIBUTE_LOCKED, /* Object locked for exclusive use */
1286  CRYPT_IATTRIBUTE_INITIALISED, /* Object inited (in high state) */
1287 
1288  /* Context internal attributes */
1289  CRYPT_IATTRIBUTE_KEYSIZE, /* Key size (written to non-native ctxs) */
1290  CRYPT_IATTRIBUTE_KEYFEATURES, /* Key feature info */
1291  CRYPT_IATTRIBUTE_KEYID, /* Key ID */
1292  CRYPT_IATTRIBUTE_KEYID_PGP2, /* PGP 2 key ID */
1293  CRYPT_IATTRIBUTE_KEYID_OPENPGP, /* OpenPGP key ID */
1294  CRYPT_IATTRIBUTE_KEY_SPKI, /* SubjectPublicKeyInfo */
1295  CRYPT_IATTRIBUTE_KEY_PGP, /* PGP-format public key */
1296  CRYPT_IATTRIBUTE_KEY_SSH, /* SSH-format public key */
1297  CRYPT_IATTRIBUTE_KEY_SSH1, /* SSHv1-format public key */
1298  CRYPT_IATTRIBUTE_KEY_SSL, /* SSL-format public key */
1299  CRYPT_IATTRIBUTE_KEY_SPKI_PARTIAL,/* SubjectPublicKeyInfo w/o trigger */
1300  CRYPT_IATTRIBUTE_KEY_PGP_PARTIAL,/* PGP public key w/o trigger */
1301  CRYPT_IATTRIBUTE_PGPVALIDITY, /* PGP key validity */
1302  CRYPT_IATTRIBUTE_DEVICEOBJECT, /* Device object handle */
1303  CRYPT_IATTRIBUTE_DEVICESTORAGEID,/* Storage ID for data in device */
1304  CRYPT_IATTRIBUTE_EXISTINGLABEL, /* Existing label for object in device */
1305  CRYPT_IATTRIBUTE_ENCPARAMS, /* Encryption params for generic-secret */
1306  CRYPT_IATTRIBUTE_MACPARAMS, /* MAC params for generic-secret */
1307  CRYPT_IATTRIBUTE_AAD, /* AAD for authenticated-encr.modes */
1308  CRYPT_IATTRIBUTE_ICV, /* ICV for authenticated-encr.modes */
1309 
1310  /* Certificate internal attributes */
1311  CRYPT_IATTRIBUTE_SUBJECT, /* SubjectName */
1312  CRYPT_IATTRIBUTE_ISSUER, /* IssuerName */
1313  CRYPT_IATTRIBUTE_ISSUERANDSERIALNUMBER, /* IssuerAndSerial */
1314  CRYPT_IATTRIBUTE_HOLDERNAME, /* Best approximation to cert.owner name */
1315  CRYPT_IATTRIBUTE_HOLDERURI, /* Best approximation to cert.owner URI */
1316  CRYPT_IATTRIBUTE_SPKI, /* Encoded SubjectPublicKeyInfo */
1317  CRYPT_IATTRIBUTE_CERTKEYALGO, /* PKC algo.used for certificate */
1318  CRYPT_IATTRIBUTE_CERTHASHALGO, /* Hash algo.used for certificate */
1319  CRYPT_IATTRIBUTE_CERTCOLLECTION,/* Certs added to cert chain */
1320  CRYPT_IATTRIBUTE_CRLENTRY, /* Individual entry from CRL */
1321  CRYPT_IATTRIBUTE_RESPONDERURL, /* RTCS/OCSP responder name */
1322  CRYPT_IATTRIBUTE_RTCSREQUEST, /* RTCS req.info added to RTCS resp.*/
1323  CRYPT_IATTRIBUTE_OCSPREQUEST, /* OCSP req.info added to OCSP resp.*/
1324  CRYPT_IATTRIBUTE_REVREQUEST, /* CRMF rev.request added to CRL */
1325  CRYPT_IATTRIBUTE_PKIUSERINFO, /* Additional user info added to cert.req.*/
1326  CRYPT_IATTRIBUTE_BLOCKEDATTRS, /* Template of disallowed attrs.in cert */
1327  CRYPT_IATTRIBUTE_AUTHCERTID, /* Authorising cert ID for a cert/rev.req.*/
1328  CRYPT_IATTRIBUTE_ESSCERTID, /* ESSCertID */
1329  CRYPT_IATTRIBUTE_CERTCOPY, /* Copy of cert object */
1330  CRYPT_IATTRIBUTE_CERTCOPY_DATAONLY, /* Copy of cert object as data-only cert */
1331 
1332  /* Device internal attributes */
1333  CRYPT_IATTRIBUTE_ENTROPY, /* Polled entropy data */
1334  CRYPT_IATTRIBUTE_ENTROPY_QUALITY,/* Quality of entropy data */
1335  CRYPT_IATTRIBUTE_RANDOM_POLL, /* Slow/fast entropy poll */
1336  CRYPT_IATTRIBUTE_RANDOM_LOPICKET,/* Low picket for random data attrs.*/
1337  CRYPT_IATTRIBUTE_RANDOM, /* Random data */
1338  CRYPT_IATTRIBUTE_RANDOM_NZ, /* Nonzero random data */
1339  CRYPT_IATTRIBUTE_RANDOM_HIPICKET,/* High picket for random data attrs.*/
1340  CRYPT_IATTRIBUTE_RANDOM_NONCE, /* Basic nonce */
1341  CRYPT_IATTRIBUTE_TIME, /* Reliable (hardware-based) time value */
1342 
1343  /* Envelope internal attributes */
1344  CRYPT_IATTRIBUTE_INCLUDESIGCERT,/* Whether to include signing cert(s) */
1345  CRYPT_IATTRIBUTE_ATTRONLY, /* Signed data contains only CMS attrs.*/
1346 
1347  /* Keyset internal attributes */
1348  CRYPT_IATTRIBUTE_CONFIGDATA, /* Config information */
1349  CRYPT_IATTRIBUTE_USERINDEX, /* Index of users */
1350  CRYPT_IATTRIBUTE_USERID, /* User ID */
1351  CRYPT_IATTRIBUTE_USERINFO, /* User information */
1352  CRYPT_IATTRIBUTE_TRUSTEDCERT, /* First trusted cert */
1353  CRYPT_IATTRIBUTE_TRUSTEDCERT_NEXT, /* Successive trusted certs */
1354  CRYPT_IATTRIBUTE_HWSTORAGE, /* Associated device for priv.key data */
1355 
1356  /* Session internal attributes */
1357  CRYPT_IATTRIBUTE_ENC_TIMESTAMP, /* Encoded TSA timestamp */
1358 
1359  /* User internal attributes */
1360  CRYPT_IATTRUBUTE_CERTKEYSET, /* Keyset to send trusted certs to */
1361  CRYPT_IATTRIBUTE_CTL, /* Cert.trust list */
1362  CRYPT_IATTRIBUTE_LAST,
1363 
1364  /* Subrange values used internally for range checking */
1365  CRYPT_CERTINFO_FIRST_CERTINFO = CRYPT_CERTINFO_FIRST + 1,
1366  CRYPT_CERTINFO_LAST_CERTINFO = CRYPT_CERTINFO_PKIUSER_REVPASSWORD,
1367  CRYPT_CERTINFO_FIRST_PSEUDOINFO = CRYPT_CERTINFO_SELFSIGNED,
1368  CRYPT_CERTINFO_LAST_PSEUDOINFO = CRYPT_CERTINFO_SIGNATURELEVEL,
1369  CRYPT_CERTINFO_FIRST_NAME = CRYPT_CERTINFO_COUNTRYNAME,
1370  CRYPT_CERTINFO_LAST_NAME = CRYPT_CERTINFO_REGISTEREDID,
1371  CRYPT_CERTINFO_FIRST_DN = CRYPT_CERTINFO_COUNTRYNAME,
1372  CRYPT_CERTINFO_LAST_DN = CRYPT_CERTINFO_COMMONNAME,
1373  CRYPT_CERTINFO_FIRST_GENERALNAME = CRYPT_CERTINFO_OTHERNAME_TYPEID,
1374  CRYPT_CERTINFO_LAST_GENERALNAME = CRYPT_CERTINFO_REGISTEREDID,
1375  CRYPT_CERTINFO_FIRST_EXTENSION = CRYPT_CERTINFO_CHALLENGEPASSWORD,
1376  CRYPT_CERTINFO_LAST_EXTENSION = CRYPT_CERTINFO_SET_TUNNELINGALGID,
1377  CRYPT_CERTINFO_FIRST_CMS = CRYPT_CERTINFO_CMS_CONTENTTYPE,
1378  CRYPT_CERTINFO_LAST_CMS = CRYPT_CERTINFO_LAST - 1,
1379  CRYPT_SESSINFO_FIRST_SPECIFIC = CRYPT_SESSINFO_REQUEST,
1380  CRYPT_SESSINFO_LAST_SPECIFIC = CRYPT_SESSINFO_TSP_MSGIMPRINT
1381 #endif /* _CRYPT_DEFINED */
1383 
1384 /****************************************************************************
1385 * *
1386 * Attribute Subtypes and Related Values *
1387 * *
1388 ****************************************************************************/
1389 
1390 /* Flags for the X.509 keyUsage extension */
1391 
1392 #define CRYPT_KEYUSAGE_NONE 0x000
1393 #define CRYPT_KEYUSAGE_DIGITALSIGNATURE 0x001
1394 #define CRYPT_KEYUSAGE_NONREPUDIATION 0x002
1395 #define CRYPT_KEYUSAGE_KEYENCIPHERMENT 0x004
1396 #define CRYPT_KEYUSAGE_DATAENCIPHERMENT 0x008
1397 #define CRYPT_KEYUSAGE_KEYAGREEMENT 0x010
1398 #define CRYPT_KEYUSAGE_KEYCERTSIGN 0x020
1399 #define CRYPT_KEYUSAGE_CRLSIGN 0x040
1400 #define CRYPT_KEYUSAGE_ENCIPHERONLY 0x080
1401 #define CRYPT_KEYUSAGE_DECIPHERONLY 0x100
1402 #define CRYPT_KEYUSAGE_LAST 0x200 /* Last possible value */
1403 #ifdef _CRYPT_DEFINED
1404 #define CRYPT_KEYUSAGE_FLAG_NONE 0x000 /* Defines for range checking */
1405 #define CRYPT_KEYUSAGE_FLAG_MAX 0x1FF
1406 #endif /* _CRYPT_DEFINED */
1407 
1408 /* X.509 cRLReason and cryptlib cRLExtReason codes */
1409 
1415  CRYPT_CRLREASON_LAST, /* End of standard CRL reasons */
1417 
1418 /* X.509 CRL reason flags. These identify the same thing as the cRLReason
1419  codes but allow for multiple reasons to be specified. Note that these
1420  don't follow the X.509 naming since in that scheme the enumerated types
1421  and bitflags have the same names */
1422 
1423 #define CRYPT_CRLREASONFLAG_UNUSED 0x001
1424 #define CRYPT_CRLREASONFLAG_KEYCOMPROMISE 0x002
1425 #define CRYPT_CRLREASONFLAG_CACOMPROMISE 0x004
1426 #define CRYPT_CRLREASONFLAG_AFFILIATIONCHANGED 0x008
1427 #define CRYPT_CRLREASONFLAG_SUPERSEDED 0x010
1428 #define CRYPT_CRLREASONFLAG_CESSATIONOFOPERATION 0x020
1429 #define CRYPT_CRLREASONFLAG_CERTIFICATEHOLD 0x040
1430 #define CRYPT_CRLREASONFLAG_LAST 0x080 /* Last poss.value */
1431 
1432 /* X.509 CRL holdInstruction codes */
1433 
1437 
1438 /* Certificate checking compliance levels */
1439 
1443 
1444 /* Flags for the Netscape netscape-cert-type extension */
1445 
1446 #define CRYPT_NS_CERTTYPE_SSLCLIENT 0x001
1447 #define CRYPT_NS_CERTTYPE_SSLSERVER 0x002
1448 #define CRYPT_NS_CERTTYPE_SMIME 0x004
1449 #define CRYPT_NS_CERTTYPE_OBJECTSIGNING 0x008
1450 #define CRYPT_NS_CERTTYPE_RESERVED 0x010
1451 #define CRYPT_NS_CERTTYPE_SSLCA 0x020
1452 #define CRYPT_NS_CERTTYPE_SMIMECA 0x040
1453 #define CRYPT_NS_CERTTYPE_OBJECTSIGNINGCA 0x080
1454 #define CRYPT_NS_CERTTYPE_LAST 0x100 /* Last possible value */
1455 
1456 /* Flags for the SET certificate-type extension */
1457 
1458 #define CRYPT_SET_CERTTYPE_CARD 0x001
1459 #define CRYPT_SET_CERTTYPE_MER 0x002
1460 #define CRYPT_SET_CERTTYPE_PGWY 0x004
1461 #define CRYPT_SET_CERTTYPE_CCA 0x008
1462 #define CRYPT_SET_CERTTYPE_MCA 0x010
1463 #define CRYPT_SET_CERTTYPE_PCA 0x020
1464 #define CRYPT_SET_CERTTYPE_GCA 0x040
1465 #define CRYPT_SET_CERTTYPE_BCA 0x080
1466 #define CRYPT_SET_CERTTYPE_RCA 0x100
1467 #define CRYPT_SET_CERTTYPE_ACQ 0x200
1468 #define CRYPT_SET_CERTTYPE_LAST 0x400 /* Last possible value */
1469 
1470 /* CMS contentType values */
1471 
1483 
1484 /* ESS securityClassification codes */
1485 
1490 
1491 /* RTCS certificate status */
1492 
1495 
1496 /* OCSP revocation status */
1497 
1500 
1501 /* The amount of detail to include in signatures when signing certificate
1502  objects */
1503 
1504 typedef enum {
1505  CRYPT_SIGNATURELEVEL_NONE, /* Include only signature */
1506  CRYPT_SIGNATURELEVEL_SIGNERCERT,/* Include signer cert */
1507  CRYPT_SIGNATURELEVEL_ALL, /* Include all relevant info */
1508  CRYPT_SIGNATURELEVEL_LAST /* Last possible sig.level type */
1510 
1511 /* The level of integrity protection to apply to enveloped data. The
1512  default envelope protection for an envelope with keying information
1513  applied is encryption, this can be modified to use MAC-only protection
1514  (with no encryption) or hybrid encryption + authentication */
1515 
1516 typedef enum {
1517  CRYPT_INTEGRITY_NONE, /* No integrity protection */
1518  CRYPT_INTEGRITY_MACONLY, /* MAC only, no encryption */
1519  CRYPT_INTEGRITY_FULL /* Encryption + ingerity protection */
1521 
1522 /* The certificate export format type, which defines the format in which a
1523  certificate object is exported */
1524 
1525 typedef enum {
1526  CRYPT_CERTFORMAT_NONE, /* No certificate format */
1527  CRYPT_CERTFORMAT_CERTIFICATE, /* DER-encoded certificate */
1528  CRYPT_CERTFORMAT_CERTCHAIN, /* PKCS #7 certificate chain */
1529  CRYPT_CERTFORMAT_TEXT_CERTIFICATE, /* base-64 wrapped cert */
1530  CRYPT_CERTFORMAT_TEXT_CERTCHAIN, /* base-64 wrapped cert chain */
1531  CRYPT_CERTFORMAT_XML_CERTIFICATE, /* XML wrapped cert */
1532  CRYPT_CERTFORMAT_XML_CERTCHAIN, /* XML wrapped cert chain */
1533 #ifdef _CRYPT_DEFINED
1534  CRYPT_ICERTFORMAT_CERTSET, /* SET OF Certificate */
1535  CRYPT_ICERTFORMAT_CERTSEQUENCE, /* SEQUENCE OF Certificate */
1536  CRYPT_ICERTFORMAT_SSL_CERTCHAIN,/* SSL certificate chain */
1537  CRYPT_ICERTFORMAT_DATA, /* Non-signed object data */
1538  CRYPT_ICERTFORMAT_SMIME_CERTIFICATE,/* S/MIME cert.request or cert chain */
1539  /* Used as an internal format specifier when the format is
1540  autodetected to tell the base64 decoding code to strip MIME
1541  headers before the base64 data */
1542 #endif /* _CRYPT_DEFINED */
1543  CRYPT_CERTFORMAT_LAST /* Last possible cert.format type */
1544 #ifdef _CRYPT_DEFINED
1545  , CRYPT_CERTFORMAT_LAST_EXTERNAL = CRYPT_CERTFORMAT_XML_CERTCHAIN + 1
1546 #endif /* _CRYPT_DEFINED */
1548 
1549 /* CMP request types */
1550 
1551 typedef enum {
1552  CRYPT_REQUESTTYPE_NONE, /* No request type */
1553  CRYPT_REQUESTTYPE_INITIALISATION, /* Initialisation request */
1555  CRYPT_REQUESTTYPE_CERTIFICATE, /* Certification request */
1556  CRYPT_REQUESTTYPE_KEYUPDATE, /* Key update request */
1557  CRYPT_REQUESTTYPE_REVOCATION, /* Cert revocation request */
1558  CRYPT_REQUESTTYPE_PKIBOOT, /* PKIBoot request */
1559  CRYPT_REQUESTTYPE_LAST /* Last possible request type */
1561 
1562 /* Key ID types */
1563 
1564 typedef enum {
1565  CRYPT_KEYID_NONE, /* No key ID type */
1566  CRYPT_KEYID_NAME, /* Key owner name */
1567  CRYPT_KEYID_URI, /* Key owner URI */
1568  CRYPT_KEYID_EMAIL = CRYPT_KEYID_URI, /* Synonym: owner email addr.*/
1569 #ifdef _CRYPT_DEFINED
1570  /* Internal key ID types */
1571  CRYPT_IKEYID_KEYID, /* SubjectKeyIdentifier/internal ID */
1572  CRYPT_IKEYID_PGPKEYID, /* PGP/OpenPGP key ID */
1573  CRYPT_IKEYID_CERTID, /* Certificate hash */
1574  CRYPT_IKEYID_ISSUERID, /* Hashed issuerAndSerialNumber */
1575  CRYPT_IKEYID_ISSUERANDSERIALNUMBER, /* issuerAndSerialNumber */
1576 #endif /* _CRYPT_DEFINED */
1577  CRYPT_KEYID_LAST /* Last possible key ID type */
1578 #ifdef _CRYPT_DEFINED
1579  , CRYPT_KEYID_LAST_EXTERNAL = CRYPT_KEYID_URI + 1/* Last external key ID */
1580 #endif /* _CRYPT_DEFINED */
1581  } CRYPT_KEYID_TYPE;
1582 
1583 /* The encryption object types */
1584 
1585 typedef enum {
1586  CRYPT_OBJECT_NONE, /* No object type */
1587  CRYPT_OBJECT_ENCRYPTED_KEY, /* Conventionally encrypted key */
1588  CRYPT_OBJECT_PKCENCRYPTED_KEY, /* PKC-encrypted key */
1589  CRYPT_OBJECT_KEYAGREEMENT, /* Key agreement information */
1590  CRYPT_OBJECT_SIGNATURE, /* Signature */
1591  CRYPT_OBJECT_LAST /* Last possible object type */
1593 
1594 /* Object/attribute error type information */
1595 
1596 typedef enum {
1597  CRYPT_ERRTYPE_NONE, /* No error information */
1598  CRYPT_ERRTYPE_ATTR_SIZE, /* Attribute data too small or large */
1599  CRYPT_ERRTYPE_ATTR_VALUE, /* Attribute value is invalid */
1600  CRYPT_ERRTYPE_ATTR_ABSENT, /* Required attribute missing */
1601  CRYPT_ERRTYPE_ATTR_PRESENT, /* Non-allowed attribute present */
1602  CRYPT_ERRTYPE_CONSTRAINT, /* Cert: Constraint violation in object */
1603  CRYPT_ERRTYPE_ISSUERCONSTRAINT, /* Cert: Constraint viol.in issuing cert */
1604  CRYPT_ERRTYPE_LAST /* Last possible error info type */
1606 
1607 /* Cert store management action type */
1608 
1609 typedef enum {
1610  CRYPT_CERTACTION_NONE, /* No cert management action */
1611  CRYPT_CERTACTION_CREATE, /* Create cert store */
1612  CRYPT_CERTACTION_CONNECT, /* Connect to cert store */
1613  CRYPT_CERTACTION_DISCONNECT, /* Disconnect from cert store */
1614  CRYPT_CERTACTION_ERROR, /* Error information */
1615  CRYPT_CERTACTION_ADDUSER, /* Add PKI user */
1616  CRYPT_CERTACTION_DELETEUSER, /* Delete PKI user */
1617  CRYPT_CERTACTION_REQUEST_CERT, /* Cert request */
1618  CRYPT_CERTACTION_REQUEST_RENEWAL,/* Cert renewal request */
1619  CRYPT_CERTACTION_REQUEST_REVOCATION,/* Cert revocation request */
1620  CRYPT_CERTACTION_CERT_CREATION, /* Cert creation */
1621  CRYPT_CERTACTION_CERT_CREATION_COMPLETE,/* Confirmation of cert creation */
1622  CRYPT_CERTACTION_CERT_CREATION_DROP, /* Cancellation of cert creation */
1623  CRYPT_CERTACTION_CERT_CREATION_REVERSE, /* Cancel of creation w.revocation */
1624  CRYPT_CERTACTION_RESTART_CLEANUP, /* Delete reqs after restart */
1625  CRYPT_CERTACTION_RESTART_REVOKE_CERT, /* Complete revocation after restart */
1628  CRYPT_CERTACTION_REVOKE_CERT, /* Cert revocation */
1629  CRYPT_CERTACTION_EXPIRE_CERT, /* Cert expiry */
1630  CRYPT_CERTACTION_CLEANUP, /* Clean up on restart */
1631  CRYPT_CERTACTION_LAST /* Last possible cert store log action */
1632 #ifdef _CRYPT_DEFINED
1633  /* User-settable action types for cert mgmt.actions */
1634  , CRYPT_CERTACTION_FIRST_USER = CRYPT_CERTACTION_ISSUE_CERT,
1635  CRYPT_CERTACTION_LAST_USER = CRYPT_CERTACTION_CLEANUP
1636 #endif /* _CRYPT_DEFINED */
1638 
1639 /* SSL/TLS protocol options. CRYPT_SSLOPTION_MINVER_SSLV3 is the same as
1640  CRYPT_SSLOPTION_NONE since this is the default */
1641 
1642 #define CRYPT_SSLOPTION_NONE 0x00
1643 #define CRYPT_SSLOPTION_MINVER_SSLV3 0x00 /* Min.protocol version */
1644 #define CRYPT_SSLOPTION_MINVER_TLS10 0x01
1645 #define CRYPT_SSLOPTION_MINVER_TLS11 0x02
1646 #define CRYPT_SSLOPTION_MINVER_TLS12 0x03
1647 #define CRYPT_SSLOPTION_SUITEB_128 0x04 /* SuiteB security levels */
1648 #define CRYPT_SSLOPTION_SUITEB_256 0x08
1649 #ifdef _CRYPT_DEFINED
1650 #define CRYPT_SSLOPTION_MAX 0x0F /* Defines for range checking */
1651 #endif /* _CRYPT_DEFINED */
1652 
1653 /****************************************************************************
1654 * *
1655 * General Constants *
1656 * *
1657 ****************************************************************************/
1658 
1659 /* The maximum user key size - 2048 bits */
1660 
1661 #define CRYPT_MAX_KEYSIZE 256
1662 
1663 /* The maximum IV size - 256 bits */
1664 
1665 #define CRYPT_MAX_IVSIZE 32
1666 
1667 /* The maximum public-key component size - 4096 bits, and maximum component
1668  size for ECCs - 576 bits (to handle the P521 curve) */
1669 
1670 #define CRYPT_MAX_PKCSIZE 512
1671 #define CRYPT_MAX_PKCSIZE_ECC 72
1672 
1673 /* The maximum hash size - 512 bits. Before 3.4 this was 256 bits, in the
1674  3.4 release it was increased to 512 bits to accommodate SHA-3 */
1675 
1676 #define CRYPT_MAX_HASHSIZE 64
1677 
1678 /* The maximum size of a text string (e.g.key owner name) */
1679 
1680 #define CRYPT_MAX_TEXTSIZE 64
1681 
1682 /* A magic value indicating that the default setting for this parameter
1683  should be used. The parentheses are to catch potential erroneous use
1684  in an expression */
1685 
1686 #define CRYPT_USE_DEFAULT ( -100 )
1687 
1688 /* A magic value for unused parameters */
1689 
1690 #define CRYPT_UNUSED ( -101 )
1691 
1692 /* Cursor positioning codes for certificate/CRL extensions. The parentheses
1693  are to catch potential erroneous use in an expression */
1694 
1695 #define CRYPT_CURSOR_FIRST ( -200 )
1696 #define CRYPT_CURSOR_PREVIOUS ( -201 )
1697 #define CRYPT_CURSOR_NEXT ( -202 )
1698 #define CRYPT_CURSOR_LAST ( -203 )
1699 
1700 /* The type of information polling to perform to get random seed
1701  information. These values have to be negative because they're used
1702  as magic length values for cryptAddRandom(). The parentheses are to
1703  catch potential erroneous use in an expression */
1704 
1705 #define CRYPT_RANDOM_FASTPOLL ( -300 )
1706 #define CRYPT_RANDOM_SLOWPOLL ( -301 )
1707 
1708 /* Whether the PKC key is a public or private key */
1709 
1710 #define CRYPT_KEYTYPE_PRIVATE 0
1711 #define CRYPT_KEYTYPE_PUBLIC 1
1712 
1713 /* Keyset open options */
1714 
1715 typedef enum {
1716  CRYPT_KEYOPT_NONE, /* No options */
1717  CRYPT_KEYOPT_READONLY, /* Open keyset in read-only mode */
1718  CRYPT_KEYOPT_CREATE, /* Create a new keyset */
1719 #ifdef _CRYPT_DEFINED
1720  /* Internal keyset options */
1721  CRYPT_IKEYOPT_EXCLUSIVEACCESS, /* As _NONE but open for exclusive access */
1722 #endif /* _CRYPT_DEFINED */
1723  CRYPT_KEYOPT_LAST /* Last possible key option type */
1724 #ifdef _CRYPT_DEFINED
1725  , CRYPT_KEYOPT_LAST_EXTERNAL = CRYPT_KEYOPT_CREATE + 1
1726  /* Last external keyset option */
1727 #endif /* _CRYPT_DEFINED */
1729 
1730 /* The various cryptlib objects - these are just integer handles */
1731 
1732 typedef int CRYPT_CERTIFICATE;
1733 typedef int CRYPT_CONTEXT;
1734 typedef int CRYPT_DEVICE;
1735 typedef int CRYPT_ENVELOPE;
1736 typedef int CRYPT_KEYSET;
1737 typedef int CRYPT_SESSION;
1738 typedef int CRYPT_USER;
1739 
1740 /* Sometimes we don't know the exact type of a cryptlib object, so we use a
1741  generic handle type to identify it */
1742 
1743 typedef int CRYPT_HANDLE;
1744 
1745 /****************************************************************************
1746 * *
1747 * Encryption Data Structures *
1748 * *
1749 ****************************************************************************/
1750 
1751 /* Results returned from the capability query */
1752 
1753 typedef struct {
1754  /* Algorithm information */
1755  C_CHR algoName[ CRYPT_MAX_TEXTSIZE ];/* Algorithm name */
1756  int blockSize; /* Block size of the algorithm */
1757  int minKeySize; /* Minimum key size in bytes */
1758  int keySize; /* Recommended key size in bytes */
1759  int maxKeySize; /* Maximum key size in bytes */
1760  } CRYPT_QUERY_INFO;
1761 
1762 /* Results returned from the encoded object query. These provide
1763  information on the objects created by cryptExportKey()/
1764  cryptCreateSignature() */
1765 
1766 typedef struct {
1767  /* The object type */
1769 
1770  /* The encryption algorithm and mode */
1773 
1774  /* The hash algorithm for Signature objects */
1776 
1777  /* The salt for derived keys */
1778  unsigned char salt[ CRYPT_MAX_HASHSIZE ];
1781 
1782 /* Key information for the public-key encryption algorithms. These fields
1783  are not accessed directly, but can be manipulated with the init/set/
1784  destroyComponents() macros */
1785 
1786 typedef struct {
1787  /* Status information */
1788  int isPublicKey; /* Whether this is a public or private key */
1789 
1790  /* Public components */
1791  unsigned char n[ CRYPT_MAX_PKCSIZE ]; /* Modulus */
1792  int nLen; /* Length of modulus in bits */
1793  unsigned char e[ CRYPT_MAX_PKCSIZE ]; /* Public exponent */
1794  int eLen; /* Length of public exponent in bits */
1795 
1796  /* Private components */
1797  unsigned char d[ CRYPT_MAX_PKCSIZE ]; /* Private exponent */
1798  int dLen; /* Length of private exponent in bits */
1799  unsigned char p[ CRYPT_MAX_PKCSIZE ]; /* Prime factor 1 */
1800  int pLen; /* Length of prime factor 1 in bits */
1801  unsigned char q[ CRYPT_MAX_PKCSIZE ]; /* Prime factor 2 */
1802  int qLen; /* Length of prime factor 2 in bits */
1803  unsigned char u[ CRYPT_MAX_PKCSIZE ]; /* Mult.inverse of q, mod p */
1804  int uLen; /* Length of private exponent in bits */
1805  unsigned char e1[ CRYPT_MAX_PKCSIZE ]; /* Private exponent 1 (PKCS) */
1806  int e1Len; /* Length of private exponent in bits */
1807  unsigned char e2[ CRYPT_MAX_PKCSIZE ]; /* Private exponent 2 (PKCS) */
1808  int e2Len; /* Length of private exponent in bits */
1810 
1811 typedef struct {
1812  /* Status information */
1813  int isPublicKey; /* Whether this is a public or private key */
1814 
1815  /* Public components */
1816  unsigned char p[ CRYPT_MAX_PKCSIZE ]; /* Prime modulus */
1817  int pLen; /* Length of prime modulus in bits */
1818  unsigned char q[ CRYPT_MAX_PKCSIZE ]; /* Prime divisor */
1819  int qLen; /* Length of prime divisor in bits */
1820  unsigned char g[ CRYPT_MAX_PKCSIZE ]; /* h^( ( p - 1 ) / q ) mod p */
1821  int gLen; /* Length of g in bits */
1822  unsigned char y[ CRYPT_MAX_PKCSIZE ]; /* Public random integer */
1823  int yLen; /* Length of public integer in bits */
1824 
1825  /* Private components */
1826  unsigned char x[ CRYPT_MAX_PKCSIZE ]; /* Private random integer */
1827  int xLen; /* Length of private integer in bits */
1829 
1830 typedef enum {
1831  /* Named ECC curves. Since these need to be mapped to all manner of
1832  protocol- and mechanism-specific identifiers, when updating this list
1833  grep for occurrences of CRYPT_ECCCURVE_P256 (the most common one) and
1834  check whether any related mapping tables need to be updated */
1835  CRYPT_ECCCURVE_NONE, /* No ECC curve type */
1836  CRYPT_ECCCURVE_P192, /* NIST P192/X9.62 P192r1/SECG p192r1 curve */
1837  CRYPT_ECCCURVE_P224, /* NIST P224/X9.62 P224r1/SECG p224r1 curve */
1838  CRYPT_ECCCURVE_P256, /* NIST P256/X9.62 P256v1/SECG p256r1 curve */
1839  CRYPT_ECCCURVE_P384, /* NIST P384, SECG p384r1 curve */
1840  CRYPT_ECCCURVE_P521, /* NIST P521, SECG p521r1 */
1841  CRYPT_ECCCURVE_LAST /* Last valid ECC curve type */
1843 
1844 typedef struct {
1845  /* Status information */
1846  int isPublicKey; /* Whether this is a public or private key */
1847 
1848  /* Curve domain parameters. Either the curveType or the explicit domain
1849  parameters must be provided */
1850  CRYPT_ECCCURVE_TYPE curveType; /* Named curve */
1851  unsigned char p[ CRYPT_MAX_PKCSIZE_ECC ];/* Prime defining Fq */
1852  int pLen; /* Length of prime in bits */
1853  unsigned char a[ CRYPT_MAX_PKCSIZE_ECC ];/* Element in Fq defining curve */
1854  int aLen; /* Length of element a in bits */
1855  unsigned char b[ CRYPT_MAX_PKCSIZE_ECC ];/* Element in Fq defining curve */
1856  int bLen; /* Length of element b in bits */
1857  unsigned char gx[ CRYPT_MAX_PKCSIZE_ECC ];/* Element in Fq defining point */
1858  int gxLen; /* Length of element gx in bits */
1859  unsigned char gy[ CRYPT_MAX_PKCSIZE_ECC ];/* Element in Fq defining point */
1860  int gyLen; /* Length of element gy in bits */
1861  unsigned char n[ CRYPT_MAX_PKCSIZE_ECC ];/* Order of point */
1862  int nLen; /* Length of order in bits */
1863  unsigned char h[ CRYPT_MAX_PKCSIZE_ECC ];/* Optional cofactor */
1864  int hLen; /* Length of cofactor in bits */
1865 
1866  /* Public components */
1867  unsigned char qx[ CRYPT_MAX_PKCSIZE_ECC ];/* Point Q on the curve */
1868  int qxLen; /* Length of point xq in bits */
1869  unsigned char qy[ CRYPT_MAX_PKCSIZE_ECC ];/* Point Q on the curve */
1870  int qyLen; /* Length of point xy in bits */
1871 
1872  /* Private components */
1873  unsigned char d[ CRYPT_MAX_PKCSIZE_ECC ];/* Private random integer */
1874  int dLen; /* Length of integer in bits */
1876 
1877 /* Macros to initialise and destroy the structure that stores the components
1878  of a public key */
1879 
1880 #define cryptInitComponents( componentInfo, componentKeyType ) \
1881  { memset( ( componentInfo ), 0, sizeof( *componentInfo ) ); \
1882  ( componentInfo )->isPublicKey = ( ( componentKeyType ) ? 1 : 0 ); }
1883 
1884 #define cryptDestroyComponents( componentInfo ) \
1885  memset( ( componentInfo ), 0, sizeof( *componentInfo ) )
1886 
1887 /* Macros to set a component of a public key */
1888 
1889 #define cryptSetComponent( destination, source, length ) \
1890  { memcpy( ( destination ), ( source ), ( ( length ) + 7 ) >> 3 ); \
1891  ( destination##Len ) = length; }
1892 
1893 /****************************************************************************
1894 * *
1895 * Status Codes *
1896 * *
1897 ****************************************************************************/
1898 
1899 /* No error in function call */
1900 
1901 #define CRYPT_OK 0 /* No error */
1902 
1903 /* Error in parameters passed to function. The parentheses are to catch
1904  potential erroneous use in an expression */
1905 
1906 #define CRYPT_ERROR_PARAM1 ( -1 ) /* Bad argument, parameter 1 */
1907 #define CRYPT_ERROR_PARAM2 ( -2 ) /* Bad argument, parameter 2 */
1908 #define CRYPT_ERROR_PARAM3 ( -3 ) /* Bad argument, parameter 3 */
1909 #define CRYPT_ERROR_PARAM4 ( -4 ) /* Bad argument, parameter 4 */
1910 #define CRYPT_ERROR_PARAM5 ( -5 ) /* Bad argument, parameter 5 */
1911 #define CRYPT_ERROR_PARAM6 ( -6 ) /* Bad argument, parameter 6 */
1912 #define CRYPT_ERROR_PARAM7 ( -7 ) /* Bad argument, parameter 7 */
1913 
1914 /* Errors due to insufficient resources */
1915 
1916 #define CRYPT_ERROR_MEMORY ( -10 ) /* Out of memory */
1917 #define CRYPT_ERROR_NOTINITED ( -11 ) /* Data has not been initialised */
1918 #define CRYPT_ERROR_INITED ( -12 ) /* Data has already been init'd */
1919 #define CRYPT_ERROR_NOSECURE ( -13 ) /* Opn.not avail.at requested sec.level */
1920 #define CRYPT_ERROR_RANDOM ( -14 ) /* No reliable random data available */
1921 #define CRYPT_ERROR_FAILED ( -15 ) /* Operation failed */
1922 #define CRYPT_ERROR_INTERNAL ( -16 ) /* Internal consistency check failed */
1923 
1924 /* Security violations */
1925 
1926 #define CRYPT_ERROR_NOTAVAIL ( -20 ) /* This type of opn.not available */
1927 #define CRYPT_ERROR_PERMISSION ( -21 ) /* No permiss.to perform this operation */
1928 #define CRYPT_ERROR_WRONGKEY ( -22 ) /* Incorrect key used to decrypt data */
1929 #define CRYPT_ERROR_INCOMPLETE ( -23 ) /* Operation incomplete/still in progress */
1930 #define CRYPT_ERROR_COMPLETE ( -24 ) /* Operation complete/can't continue */
1931 #define CRYPT_ERROR_TIMEOUT ( -25 ) /* Operation timed out before completion */
1932 #define CRYPT_ERROR_INVALID ( -26 ) /* Invalid/inconsistent information */
1933 #define CRYPT_ERROR_SIGNALLED ( -27 ) /* Resource destroyed by extnl.event */
1934 
1935 /* High-level function errors */
1936 
1937 #define CRYPT_ERROR_OVERFLOW ( -30 ) /* Resources/space exhausted */
1938 #define CRYPT_ERROR_UNDERFLOW ( -31 ) /* Not enough data available */
1939 #define CRYPT_ERROR_BADDATA ( -32 ) /* Bad/unrecognised data format */
1940 #define CRYPT_ERROR_SIGNATURE ( -33 ) /* Signature/integrity check failed */
1941 
1942 /* Data access function errors */
1943 
1944 #define CRYPT_ERROR_OPEN ( -40 ) /* Cannot open object */
1945 #define CRYPT_ERROR_READ ( -41 ) /* Cannot read item from object */
1946 #define CRYPT_ERROR_WRITE ( -42 ) /* Cannot write item to object */
1947 #define CRYPT_ERROR_NOTFOUND ( -43 ) /* Requested item not found in object */
1948 #define CRYPT_ERROR_DUPLICATE ( -44 ) /* Item already present in object */
1949 
1950 /* Data enveloping errors */
1951 
1952 #define CRYPT_ENVELOPE_RESOURCE ( -50 ) /* Need resource to proceed */
1953 
1954 /* Macros to examine return values */
1955 
1956 #define cryptStatusError( status ) ( ( status ) < CRYPT_OK )
1957 #define cryptStatusOK( status ) ( ( status ) == CRYPT_OK )
1958 
1959 /****************************************************************************
1960 * *
1961 * General Functions *
1962 * *
1963 ****************************************************************************/
1964 
1965 /* The following is necessary to stop C++ name mangling */
1966 
1967 #ifdef __cplusplus
1968 extern "C" {
1969 #endif /* __cplusplus */
1970 
1971 /* Initialise and shut down cryptlib */
1972 
1973 C_CHECK_RETVAL \
1974 C_RET cryptInit( void );
1975 C_RET cryptEnd( void );
1976 
1977 /* Query cryptlibs capabilities */
1978 
1979 C_CHECK_RETVAL \
1981  C_OUT_OPT CRYPT_QUERY_INFO C_PTR cryptQueryInfo );
1982 
1983 /* Create and destroy an encryption context */
1984 
1985 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
1988  C_IN CRYPT_ALGO_TYPE cryptAlgo );
1990 
1991 /* Generic "destroy an object" function */
1992 
1993 C_RET cryptDestroyObject( C_IN CRYPT_HANDLE cryptObject );
1994 
1995 /* Generate a key into a context */
1996 
1997 C_CHECK_RETVAL \
1999 C_CHECK_RETVAL \
2001 C_CHECK_RETVAL \
2002 C_RET cryptAsyncQuery( C_IN CRYPT_HANDLE cryptObject );
2003 C_CHECK_RETVAL \
2004 C_RET cryptAsyncCancel( C_IN CRYPT_HANDLE cryptObject );
2005 
2006 /* Encrypt/decrypt/hash a block of memory */
2007 
2008 C_NONNULL_ARG( ( 2 ) ) \
2010  C_IN int length );
2011 C_NONNULL_ARG( ( 2 ) ) \
2013  C_IN int length );
2014 
2015 /* Get/set/delete attribute functions */
2016 
2019  C_IN int value );
2020 C_NONNULL_ARG( ( 3 ) ) \
2023  C_IN void C_PTR value, C_IN int valueLength );
2024 C_NONNULL_ARG( ( 3 ) ) \
2027  C_OUT int C_PTR value );
2030  C_OUT_OPT void C_PTR value,
2031  C_OUT int C_PTR valueLength );
2034 
2035 /* Oddball functions: Add random data to the pool, query an encoded signature
2036  or key data. These are due to be replaced once a suitable alternative can
2037  be found */
2038 
2039 C_RET cryptAddRandom( C_IN void C_PTR randomData, C_IN int randomDataLength );
2040 C_CHECK_RETVAL C_NONNULL_ARG( ( 1, 3 ) ) \
2041 C_RET cryptQueryObject( C_IN void C_PTR objectData,
2044 
2045 /****************************************************************************
2046 * *
2047 * Mid-level Encryption Functions *
2048 * *
2049 ****************************************************************************/
2050 
2051 /* Export and import an encrypted session key */
2052 
2053 C_CHECK_RETVAL C_NONNULL_ARG( ( 3 ) ) \
2059 C_CHECK_RETVAL C_NONNULL_ARG( ( 3 ) ) \
2066 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2071 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2077 
2078 /* Create and check a digital signature */
2079 
2080 C_CHECK_RETVAL C_NONNULL_ARG( ( 3 ) ) \
2086 C_CHECK_RETVAL C_NONNULL_ARG( ( 3 ) ) \
2094 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2099 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2101  C_IN int signatureLength,
2105 
2106 /****************************************************************************
2107 * *
2108 * Keyset Functions *
2109 * *
2110 ****************************************************************************/
2111 
2112 /* Open and close a keyset */
2113 
2114 C_CHECK_RETVAL C_NONNULL_ARG( ( 1, 4 ) ) \
2120 
2121 /* Get a key from a keyset or device */
2122 
2123 C_CHECK_RETVAL C_NONNULL_ARG( ( 2 ) ) \
2127  C_IN_OPT C_STR keyID );
2128 C_CHECK_RETVAL C_NONNULL_ARG( ( 2, 4 ) ) \
2133 C_CHECK_RETVAL C_NONNULL_ARG( ( 2, 4 ) ) \
2138 
2139 /* Add/delete a key to/from a keyset or device */
2140 
2141 C_CHECK_RETVAL \
2144 C_CHECK_RETVAL C_NONNULL_ARG( ( 3 ) ) \
2147  C_IN C_STR password );
2148 C_NONNULL_ARG( ( 3 ) ) \
2151  C_IN C_STR keyID );
2152 
2153 /****************************************************************************
2154 * *
2155 * Certificate Functions *
2156 * *
2157 ****************************************************************************/
2158 
2159 /* Create/destroy a certificate */
2160 
2161 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2166 
2167 /* Get/add/delete certificate extensions. These are direct data insertion
2168  functions whose use is discouraged, so they fix the string at char *
2169  rather than C_STR */
2170 
2171 C_NONNULL_ARG( ( 2, 3, 6 ) ) \
2174  C_OUT int C_PTR criticalFlag,
2175  C_OUT_OPT void C_PTR extension,
2177  C_OUT int C_PTR extensionLength );
2178 C_NONNULL_ARG( ( 2, 4 ) ) \
2180  C_IN char C_PTR oid, C_IN int criticalFlag,
2181  C_IN void C_PTR extension,
2182  C_IN int extensionLength );
2183 C_NONNULL_ARG( ( 2 ) ) \
2185  C_IN char C_PTR oid );
2186 
2187 /* Sign/sig.check a certificate/certification request */
2188 
2189 C_CHECK_RETVAL \
2192 C_CHECK_RETVAL \
2195 
2196 /* Import/export a certificate/certification request */
2197 
2198 C_CHECK_RETVAL C_NONNULL_ARG( ( 1, 4 ) ) \
2199 C_RET cryptImportCert( C_IN void C_PTR certObject,
2203 C_CHECK_RETVAL \
2207  C_IN CRYPT_CERTFORMAT_TYPE certFormatType,
2209 
2210 /* CA management functions */
2211 
2212 C_CHECK_RETVAL \
2215 C_CHECK_RETVAL C_NONNULL_ARG( ( 2 ) ) \
2220  C_IN_OPT C_STR keyID );
2221 C_NONNULL_ARG( ( 4 ) ) \
2225  C_IN C_STR keyID );
2226 C_CHECK_RETVAL \
2228  C_IN CRYPT_CERTACTION_TYPE action,
2231  C_IN CRYPT_CERTIFICATE certRequest );
2232 
2233 /****************************************************************************
2234 * *
2235 * Envelope and Session Functions *
2236 * *
2237 ****************************************************************************/
2238 
2239 /* Create/destroy an envelope */
2240 
2241 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2246 
2247 /* Create/destroy a session */
2248 
2249 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2254 
2255 /* Add/remove data to/from and envelope or session */
2256 
2257 C_CHECK_RETVAL C_NONNULL_ARG( ( 2, 4 ) ) \
2259  C_IN int length, C_OUT int C_PTR bytesCopied );
2260 C_CHECK_RETVAL \
2261 C_RET cryptFlushData( C_IN CRYPT_HANDLE envelope );
2262 C_CHECK_RETVAL C_NONNULL_ARG( ( 2, 4 ) ) \
2263 C_RET cryptPopData( C_IN CRYPT_HANDLE envelope, C_OUT void C_PTR buffer,
2264  C_IN int length, C_OUT int C_PTR bytesCopied );
2265 
2266 /****************************************************************************
2267 * *
2268 * Device Functions *
2269 * *
2270 ****************************************************************************/
2271 
2272 /* Open and close a device */
2273 
2274 C_CHECK_RETVAL C_NONNULL_ARG( ( 1 ) ) \
2275 C_RET cryptDeviceOpen( C_OUT CRYPT_DEVICE C_PTR device,
2278  C_IN_OPT C_STR name );
2280 
2281 /* Query a devices capabilities */
2282 
2283 C_CHECK_RETVAL \
2286  C_OUT_OPT CRYPT_QUERY_INFO C_PTR cryptQueryInfo );
2287 
2288 /* Create an encryption context via the device */
2289 
2290 C_CHECK_RETVAL C_NONNULL_ARG( ( 2 ) ) \
2294 
2295 /****************************************************************************
2296 * *
2297 * User Management Functions *
2298 * *
2299 ****************************************************************************/
2300 
2301 /* Log on and off (create/destroy a user object) */
2302 
2303 C_CHECK_RETVAL C_NONNULL_ARG( ( 1, 2, 3 ) ) \
2304 C_RET cryptLogin( C_OUT CRYPT_USER C_PTR user,
2307 
2308 /****************************************************************************
2309 * *
2310 * User Interface Functions *
2311 * *
2312 ****************************************************************************/
2313 
2314 #if ( defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) ) && \
2315  !( defined( _SCCTK ) || defined( _CVI_ ) )
2316 
2317 /* User interface functions, only available under Win32 */
2318 
2319 C_CHECK_RETVAL C_NONNULL_ARG( ( 2, 4, 5 ) ) \
2320 C_RET cryptUIGenerateKey( C_IN CRYPT_DEVICE cryptDevice,
2322  C_IN CRYPT_CERTIFICATE cryptCert,
2323  C_OUT char C_PTR password, C_IN HWND hWnd );
2324 C_NONNULL_ARG( ( 2 ) ) \
2325 C_RET cryptUIDisplayCert( C_IN CRYPT_CERTIFICATE cryptCert,
2326  C_IN HWND hWnd );
2327 
2328 #endif /* Win32 */
2329 
2330 #ifdef __cplusplus
2331 }
2332 #endif /* __cplusplus */
2333 
2334 #endif /* _CRYPTLIB_DEFINED */