8 #ifndef _CRYPTLIB_DEFINED
10 #define _CRYPTLIB_DEFINED
14 #define CRYPTLIB_VERSION 3410
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
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." )
51 #pragma message( " To allow compilation to proceed the wincrypt.h encryption modes have been undefined." )
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"
69 #if ( defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || \
70 defined( _WIN32_WCE ) ) && !( defined( STATIC_LIB ) || defined( _SCCTK ) )
72 #if defined( _WIN32_WCE )
82 #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x500 )
84 #define C_RET int _export _stdcall
86 #define C_RET int _import _stdcall
90 #define C_RET __declspec( dllexport ) int __stdcall
92 #define C_RET __declspec( dllimport ) int __stdcall
95 #elif defined( _WINDOWS ) && !defined( STATIC_LIB )
98 #define C_STR C_CHR FAR *
99 #define C_RET int FAR PASCAL _export
100 #elif defined( __BEOS__ )
104 #define C_STR C_CHR *
105 #ifdef _STATIC_LINKING
108 #ifdef _CRYPT_DEFINED
109 #define C_RET __declspec( dllexport ) int
111 #define C_RET __declspec( dllimport ) int
114 #elif defined( __SYMBIAN32__ )
115 #ifdef _CRYPT_DEFINED
116 #define C_RET EXPORT_C
118 #define C_RET IMPORT_C
123 #define C_STR C_CHR *
130 #define C_IN_OPT const
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 )
143 #define C_NONNULL_ARG( argIndex ) __attribute__(( nonnull argIndex ))
145 #elif defined( _MSC_VER ) && defined( _PREFAST_ )
147 #define C_CHECK_RETVAL _Check_return_ \
148 _Success_( result == CRYPT_OK )
149 #define C_NONNULL_ARG( argIndex )
151 #define C_IN_OPT _In_opt_ const
153 #define C_OUT_OPT _Out_opt_
155 #define C_INOUT _Inout_
157 #define C_CHECK_RETVAL __checkReturn \
158 __success( result == CRYPT_OK ) \
159 __range( MAX_ERROR, CRYPT_OK )
160 #define C_NONNULL_ARG( argIndex )
162 #define C_IN_OPT __in_opt const
164 #define C_OUT_OPT __out_opt
166 #define C_INOUT __inout
169 #define C_CHECK_RETVAL
170 #define C_NONNULL_ARG( argIndex )
173 #ifdef _CRYPTLIB_DEFINED
239 #ifdef _CRYPT_DEFINED
245 CRYPT_IALGO_GENERIC_SECRET = 1000,
253 #ifdef USE_VENDOR_ALGOS
254 CRYPT_ALGO_VENDOR1 = 10000, CRYPT_ALGO_VENDOR2, CRYPT_ALGO_VENDOR3,
258 #ifdef _CRYPT_DEFINED
285 #if ( defined( _WINDOWS ) || defined( WIN32 ) || defined( _WIN32 ) || \
286 defined( __WIN32__ ) ) && !defined( _SCCTK )
289 #define CRYPT_MODE_ECB 1
305 #ifdef _CRYPT_DEFINED
340 #ifdef _CRYPT_DEFINED
346 CRYPT_ICERTTYPE_CMS_CERTSET,
347 CRYPT_ICERTTYPE_SSL_CERTCHAIN,
349 CRYPT_ICERTTYPE_REVINFO,
360 CRYPT_ICERTTYPE_DATAONLY,
363 #ifdef _CRYPT_DEFINED
378 #ifdef _CRYPT_DEFINED
387 #ifdef _CRYPT_DEFINED
656 CRYPT_CERTINFO_X400ADDRESS,
1259 #ifdef _CRYPT_DEFINED
1279 , CRYPT_IATTRIBUTE_FIRST = 8000,
1280 CRYPT_IATTRIBUTE_TYPE,
1281 CRYPT_IATTRIBUTE_SUBTYPE,
1282 CRYPT_IATTRIBUTE_STATUS,
1283 CRYPT_IATTRIBUTE_INTERNAL,
1284 CRYPT_IATTRIBUTE_ACTIONPERMS,
1285 CRYPT_IATTRIBUTE_LOCKED,
1286 CRYPT_IATTRIBUTE_INITIALISED,
1289 CRYPT_IATTRIBUTE_KEYSIZE,
1290 CRYPT_IATTRIBUTE_KEYFEATURES,
1291 CRYPT_IATTRIBUTE_KEYID,
1292 CRYPT_IATTRIBUTE_KEYID_PGP2,
1293 CRYPT_IATTRIBUTE_KEYID_OPENPGP,
1294 CRYPT_IATTRIBUTE_KEY_SPKI,
1295 CRYPT_IATTRIBUTE_KEY_PGP,
1296 CRYPT_IATTRIBUTE_KEY_SSH,
1297 CRYPT_IATTRIBUTE_KEY_SSH1,
1298 CRYPT_IATTRIBUTE_KEY_SSL,
1299 CRYPT_IATTRIBUTE_KEY_SPKI_PARTIAL,
1300 CRYPT_IATTRIBUTE_KEY_PGP_PARTIAL,
1301 CRYPT_IATTRIBUTE_PGPVALIDITY,
1302 CRYPT_IATTRIBUTE_DEVICEOBJECT,
1303 CRYPT_IATTRIBUTE_DEVICESTORAGEID,
1304 CRYPT_IATTRIBUTE_EXISTINGLABEL,
1305 CRYPT_IATTRIBUTE_ENCPARAMS,
1306 CRYPT_IATTRIBUTE_MACPARAMS,
1307 CRYPT_IATTRIBUTE_AAD,
1308 CRYPT_IATTRIBUTE_ICV,
1311 CRYPT_IATTRIBUTE_SUBJECT,
1312 CRYPT_IATTRIBUTE_ISSUER,
1313 CRYPT_IATTRIBUTE_ISSUERANDSERIALNUMBER,
1314 CRYPT_IATTRIBUTE_HOLDERNAME,
1315 CRYPT_IATTRIBUTE_HOLDERURI,
1316 CRYPT_IATTRIBUTE_SPKI,
1317 CRYPT_IATTRIBUTE_CERTKEYALGO,
1318 CRYPT_IATTRIBUTE_CERTHASHALGO,
1319 CRYPT_IATTRIBUTE_CERTCOLLECTION,
1320 CRYPT_IATTRIBUTE_CRLENTRY,
1321 CRYPT_IATTRIBUTE_RESPONDERURL,
1322 CRYPT_IATTRIBUTE_RTCSREQUEST,
1323 CRYPT_IATTRIBUTE_OCSPREQUEST,
1324 CRYPT_IATTRIBUTE_REVREQUEST,
1325 CRYPT_IATTRIBUTE_PKIUSERINFO,
1326 CRYPT_IATTRIBUTE_BLOCKEDATTRS,
1327 CRYPT_IATTRIBUTE_AUTHCERTID,
1328 CRYPT_IATTRIBUTE_ESSCERTID,
1329 CRYPT_IATTRIBUTE_CERTCOPY,
1330 CRYPT_IATTRIBUTE_CERTCOPY_DATAONLY,
1333 CRYPT_IATTRIBUTE_ENTROPY,
1334 CRYPT_IATTRIBUTE_ENTROPY_QUALITY,
1335 CRYPT_IATTRIBUTE_RANDOM_POLL,
1336 CRYPT_IATTRIBUTE_RANDOM_LOPICKET,
1337 CRYPT_IATTRIBUTE_RANDOM,
1338 CRYPT_IATTRIBUTE_RANDOM_NZ,
1339 CRYPT_IATTRIBUTE_RANDOM_HIPICKET,
1340 CRYPT_IATTRIBUTE_RANDOM_NONCE,
1341 CRYPT_IATTRIBUTE_TIME,
1344 CRYPT_IATTRIBUTE_INCLUDESIGCERT,
1345 CRYPT_IATTRIBUTE_ATTRONLY,
1348 CRYPT_IATTRIBUTE_CONFIGDATA,
1349 CRYPT_IATTRIBUTE_USERINDEX,
1350 CRYPT_IATTRIBUTE_USERID,
1351 CRYPT_IATTRIBUTE_USERINFO,
1352 CRYPT_IATTRIBUTE_TRUSTEDCERT,
1353 CRYPT_IATTRIBUTE_TRUSTEDCERT_NEXT,
1354 CRYPT_IATTRIBUTE_HWSTORAGE,
1357 CRYPT_IATTRIBUTE_ENC_TIMESTAMP,
1360 CRYPT_IATTRUBUTE_CERTKEYSET,
1361 CRYPT_IATTRIBUTE_CTL,
1362 CRYPT_IATTRIBUTE_LAST,
1365 CRYPT_CERTINFO_FIRST_CERTINFO = CRYPT_CERTINFO_FIRST + 1,
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
1403 #ifdef _CRYPT_DEFINED
1404 #define CRYPT_KEYUSAGE_FLAG_NONE 0x000
1405 #define CRYPT_KEYUSAGE_FLAG_MAX 0x1FF
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
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
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
1533 #ifdef _CRYPT_DEFINED
1534 CRYPT_ICERTFORMAT_CERTSET,
1535 CRYPT_ICERTFORMAT_CERTSEQUENCE,
1536 CRYPT_ICERTFORMAT_SSL_CERTCHAIN,
1537 CRYPT_ICERTFORMAT_DATA,
1538 CRYPT_ICERTFORMAT_SMIME_CERTIFICATE,
1544 #ifdef _CRYPT_DEFINED
1569 #ifdef _CRYPT_DEFINED
1572 CRYPT_IKEYID_PGPKEYID,
1573 CRYPT_IKEYID_CERTID,
1574 CRYPT_IKEYID_ISSUERID,
1575 CRYPT_IKEYID_ISSUERANDSERIALNUMBER,
1578 #ifdef _CRYPT_DEFINED
1632 #ifdef _CRYPT_DEFINED
1642 #define CRYPT_SSLOPTION_NONE 0x00
1643 #define CRYPT_SSLOPTION_MINVER_SSLV3 0x00
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
1648 #define CRYPT_SSLOPTION_SUITEB_256 0x08
1649 #ifdef _CRYPT_DEFINED
1650 #define CRYPT_SSLOPTION_MAX 0x0F
1661 #define CRYPT_MAX_KEYSIZE 256
1665 #define CRYPT_MAX_IVSIZE 32
1670 #define CRYPT_MAX_PKCSIZE 512
1671 #define CRYPT_MAX_PKCSIZE_ECC 72
1676 #define CRYPT_MAX_HASHSIZE 64
1680 #define CRYPT_MAX_TEXTSIZE 64
1686 #define CRYPT_USE_DEFAULT ( -100 )
1690 #define CRYPT_UNUSED ( -101 )
1695 #define CRYPT_CURSOR_FIRST ( -200 )
1696 #define CRYPT_CURSOR_PREVIOUS ( -201 )
1697 #define CRYPT_CURSOR_NEXT ( -202 )
1698 #define CRYPT_CURSOR_LAST ( -203 )
1705 #define CRYPT_RANDOM_FASTPOLL ( -300 )
1706 #define CRYPT_RANDOM_SLOWPOLL ( -301 )
1710 #define CRYPT_KEYTYPE_PRIVATE 0
1711 #define CRYPT_KEYTYPE_PUBLIC 1
1719 #ifdef _CRYPT_DEFINED
1721 CRYPT_IKEYOPT_EXCLUSIVEACCESS,
1724 #ifdef _CRYPT_DEFINED
1880 #define cryptInitComponents( componentInfo, componentKeyType ) \
1881 { memset( ( componentInfo ), 0, sizeof( *componentInfo ) ); \
1882 ( componentInfo )->isPublicKey = ( ( componentKeyType ) ? 1 : 0 ); }
1884 #define cryptDestroyComponents( componentInfo ) \
1885 memset( ( componentInfo ), 0, sizeof( *componentInfo ) )
1889 #define cryptSetComponent( destination, source, length ) \
1890 { memcpy( ( destination ), ( source ), ( ( length ) + 7 ) >> 3 ); \
1891 ( destination##Len ) = length; }
1906 #define CRYPT_ERROR_PARAM1 ( -1 )
1907 #define CRYPT_ERROR_PARAM2 ( -2 )
1908 #define CRYPT_ERROR_PARAM3 ( -3 )
1909 #define CRYPT_ERROR_PARAM4 ( -4 )
1910 #define CRYPT_ERROR_PARAM5 ( -5 )
1911 #define CRYPT_ERROR_PARAM6 ( -6 )
1912 #define CRYPT_ERROR_PARAM7 ( -7 )
1916 #define CRYPT_ERROR_MEMORY ( -10 )
1917 #define CRYPT_ERROR_NOTINITED ( -11 )
1918 #define CRYPT_ERROR_INITED ( -12 )
1919 #define CRYPT_ERROR_NOSECURE ( -13 )
1920 #define CRYPT_ERROR_RANDOM ( -14 )
1921 #define CRYPT_ERROR_FAILED ( -15 )
1922 #define CRYPT_ERROR_INTERNAL ( -16 )
1926 #define CRYPT_ERROR_NOTAVAIL ( -20 )
1927 #define CRYPT_ERROR_PERMISSION ( -21 )
1928 #define CRYPT_ERROR_WRONGKEY ( -22 )
1929 #define CRYPT_ERROR_INCOMPLETE ( -23 )
1930 #define CRYPT_ERROR_COMPLETE ( -24 )
1931 #define CRYPT_ERROR_TIMEOUT ( -25 )
1932 #define CRYPT_ERROR_INVALID ( -26 )
1933 #define CRYPT_ERROR_SIGNALLED ( -27 )
1937 #define CRYPT_ERROR_OVERFLOW ( -30 )
1938 #define CRYPT_ERROR_UNDERFLOW ( -31 )
1939 #define CRYPT_ERROR_BADDATA ( -32 )
1940 #define CRYPT_ERROR_SIGNATURE ( -33 )
1944 #define CRYPT_ERROR_OPEN ( -40 )
1945 #define CRYPT_ERROR_READ ( -41 )
1946 #define CRYPT_ERROR_WRITE ( -42 )
1947 #define CRYPT_ERROR_NOTFOUND ( -43 )
1948 #define CRYPT_ERROR_DUPLICATE ( -44 )
1952 #define CRYPT_ENVELOPE_RESOURCE ( -50 )
1956 #define cryptStatusError( status ) ( ( status ) < CRYPT_OK )
1957 #define cryptStatusOK( status ) ( ( status ) == CRYPT_OK )
2314 #if ( defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) ) && \
2315 !( defined( _SCCTK ) || defined( _CVI_ ) )