source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/bcrypt.h

Last change on this file was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 26.3 KB
RevLine 
[1166]1/**
2 * This file is part of the mingw-w64 runtime package.
3 * No warranty is given; refer to the file DISCLAIMER within this package.
4 */
5
6#include <winapifamily.h>
7
8#ifndef __BCRYPT_H__
9#define __BCRYPT_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || _WIN32_WINNT >= 0x0A00
16
17#ifndef WINAPI
18#if defined(_ARM_)
19#define WINAPI
20#else
21#define WINAPI __stdcall
22#endif
23#endif
24
25#if !defined (_NTDEF_) && !defined (_NTSTATUS_PSDK)
26#define _NTSTATUS_PSDK
27 typedef LONG NTSTATUS,*PNTSTATUS;
28#endif
29
30#ifndef BCRYPT_SUCCESS
31#define BCRYPT_SUCCESS(Status) (((NTSTATUS) (Status)) >= 0)
32#endif
33
34#ifndef CONST
35#define CONST const
36#endif
37#ifndef _NO_W32_PSEUDO_MODIFIERS
38#ifndef IN
39#define IN
40#endif
41#ifndef OUT
42#define OUT
43#endif
44#ifndef OPTIONAL
45#define OPTIONAL
46#endif
47#endif
48
49#define BCRYPT_OBJECT_ALIGNMENT 16
50
51#define BCRYPT_STRUCT_ALIGNMENT
52
53#define BCRYPT_KDF_HASH L"HASH"
54#define BCRYPT_KDF_HMAC L"HMAC"
55#define BCRYPT_KDF_TLS_PRF L"TLS_PRF"
56#define BCRYPT_KDF_SP80056A_CONCAT L"SP800_56A_CONCAT"
57
58#if NTDDI_VERSION >= NTDDI_WINBLUE
59#define BCRYPT_KDF_RAW_SECRET L"TRUNCATE"
60#endif
61
62#if NTDDI_VERSION >= NTDDI_WIN10_RS4
63#define BCRYPT_KDF_HKDF L"HKDF"
64#endif
65
66#define KDF_HASH_ALGORITHM 0x0
67#define KDF_SECRET_PREPEND 0x1
68#define KDF_SECRET_APPEND 0x2
69#define KDF_HMAC_KEY 0x3
70#define KDF_TLS_PRF_LABEL 0x4
71#define KDF_TLS_PRF_SEED 0x5
72#define KDF_SECRET_HANDLE 0x6
73#if NTDDI_VERSION >= NTDDI_WIN7
74#define KDF_TLS_PRF_PROTOCOL 0x7
75#define KDF_ALGORITHMID 0x8
76#define KDF_PARTYUINFO 0x9
77#define KDF_PARTYVINFO 0xa
78#define KDF_SUPPPUBINFO 0xb
79#define KDF_SUPPPRIVINFO 0xc
80#endif
81#if NTDDI_VERSION >= NTDDI_WIN8
82#define KDF_LABEL 0xd
83#define KDF_CONTEXT 0xe
84#define KDF_SALT 0xf
85#define KDF_ITERATION_COUNT 0x10
86#define KDF_GENERIC_PARAMETER 0x11
87#define KDF_KEYBITLENGTH 0x12
88#endif
89#if NTDDI_VERSION >= NTDDI_WIN10_RS4
90#define KDF_HKDF_SALT 0x13
91#define KDF_HKDF_INFO 0x14
92#endif
93
94#define KDF_USE_SECRET_AS_HMAC_KEY_FLAG 1
95
96#define BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION 1
97
98#define BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG 0x00000001
99#define BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG 0x00000002
100
101#define BCRYPT_INIT_AUTH_MODE_INFO(_AUTH_INFO_STRUCT_) \
102 RtlZeroMemory ((&_AUTH_INFO_STRUCT_), sizeof (BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO)); \
103 (_AUTH_INFO_STRUCT_).cbSize = sizeof (BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO); \
104 (_AUTH_INFO_STRUCT_).dwInfoVersion = BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION;
105
106#define BCRYPT_OPAQUE_KEY_BLOB L"OpaqueKeyBlob"
107#define BCRYPT_KEY_DATA_BLOB L"KeyDataBlob"
108#if NTDDI_VERSION >= NTDDI_WIN7
109#define BCRYPT_AES_WRAP_KEY_BLOB L"Rfc3565KeyWrapBlob"
110#endif
111
112#define BCRYPT_ALGORITHM_NAME L"AlgorithmName"
113#define BCRYPT_AUTH_TAG_LENGTH L"AuthTagLength"
114#define BCRYPT_BLOCK_LENGTH L"BlockLength"
115#define BCRYPT_BLOCK_SIZE_LIST L"BlockSizeList"
116#define BCRYPT_CHAINING_MODE L"ChainingMode"
117#define BCRYPT_CHAIN_MODE_CBC L"ChainingModeCBC"
118#define BCRYPT_CHAIN_MODE_CCM L"ChainingModeCCM"
119#define BCRYPT_CHAIN_MODE_CFB L"ChainingModeCFB"
120#define BCRYPT_CHAIN_MODE_ECB L"ChainingModeECB"
121#define BCRYPT_CHAIN_MODE_GCM L"ChainingModeGCM"
122#define BCRYPT_CHAIN_MODE_NA L"ChainingModeN/A"
123#define BCRYPT_EFFECTIVE_KEY_LENGTH L"EffectiveKeyLength"
124#define BCRYPT_HASH_BLOCK_LENGTH L"HashBlockLength"
125#define BCRYPT_HASH_LENGTH L"HashDigestLength"
126#define BCRYPT_HASH_OID_LIST L"HashOIDList"
127#define BCRYPT_INITIALIZATION_VECTOR L"IV"
128#define BCRYPT_IS_KEYED_HASH L"IsKeyedHash"
129#define BCRYPT_IS_REUSABLE_HASH L"IsReusableHash"
130#define BCRYPT_KEY_LENGTH L"KeyLength"
131#define BCRYPT_KEY_LENGTHS L"KeyLengths"
132#define BCRYPT_KEY_OBJECT_LENGTH L"KeyObjectLength"
133#define BCRYPT_KEY_STRENGTH L"KeyStrength"
134#define BCRYPT_MESSAGE_BLOCK_LENGTH L"MessageBlockLength"
135#define BCRYPT_OBJECT_LENGTH L"ObjectLength"
136#define BCRYPT_PADDING_SCHEMES L"PaddingSchemes"
137#define BCRYPT_PCP_PLATFORM_TYPE_PROPERTY L"PCP_PLATFORM_TYPE"
138#define BCRYPT_PCP_PROVIDER_VERSION_PROPERTY L"PCP_PROVIDER_VERSION"
139#define BCRYPT_PRIMITIVE_TYPE L"PrimitiveType"
140#define BCRYPT_PROVIDER_HANDLE L"ProviderHandle"
141#define BCRYPT_PUBLIC_KEY_LENGTH L"PublicKeyLength"
142#define BCRYPT_SIGNATURE_LENGTH L"SignatureLength"
143#if (NTDDI_VERSION > NTDDI_WINBLUE || (NTDDI_VERSION == NTDDI_WINBLUE && defined(WINBLUE_KBSPRING14)))
144#define BCRYPT_MULTI_OBJECT_LENGTH L"MultiObjectLength"
145#endif
146#if NTDDI_VERSION >= NTDDI_WIN10_RS4
147#define BCRYPT_IS_IFX_TPM_WEAK_KEY L"IsIfxTpmWeakKey"
148#define BCRYPT_HKDF_HASH_ALGORITHM L"HkdfHashAlgorithm"
149#define BCRYPT_HKDF_SALT_AND_FINALIZE L"HkdfSaltAndFinalize"
150#define BCRYPT_HKDF_PRK_AND_FINALIZE L"HkdfPrkAndFinalize"
151#endif
152
153#define BCRYPT_SUPPORTED_PAD_ROUTER 0x00000001
154#define BCRYPT_SUPPORTED_PAD_PKCS1_ENC 0x00000002
155#define BCRYPT_SUPPORTED_PAD_PKCS1_SIG 0x00000004
156#define BCRYPT_SUPPORTED_PAD_OAEP 0x00000008
157#define BCRYPT_SUPPORTED_PAD_PSS 0x00000010
158
159#define BCRYPT_PROV_DISPATCH 0x00000001
160
161#define BCRYPT_BLOCK_PADDING 0x00000001
162
163#define BCRYPT_PAD_NONE 0x00000001
164#define BCRYPT_PAD_PKCS1 0x00000002
165#define BCRYPT_PAD_OAEP 0x00000004
166#define BCRYPT_PAD_PSS 0x00000008
167#if NTDDI_VERSION >= NTDDI_WINBLUE
168#define BCRYPT_PAD_PKCS1_OPTIONAL_HASH_OID 0x00000010
169#endif
170
171#define BCRYPTBUFFER_VERSION 0
172
173 typedef struct __BCRYPT_KEY_LENGTHS_STRUCT {
174 ULONG dwMinLength;
175 ULONG dwMaxLength;
176 ULONG dwIncrement;
177 } BCRYPT_KEY_LENGTHS_STRUCT;
178
179 typedef BCRYPT_KEY_LENGTHS_STRUCT BCRYPT_AUTH_TAG_LENGTHS_STRUCT;
180
181 typedef struct _BCRYPT_OID {
182 ULONG cbOID;
183 PUCHAR pbOID;
184 } BCRYPT_OID;
185
186 typedef struct _BCRYPT_OID_LIST {
187 ULONG dwOIDCount;
188 BCRYPT_OID *pOIDs;
189 } BCRYPT_OID_LIST;
190
191 typedef struct _BCRYPT_PKCS1_PADDING_INFO {
192 LPCWSTR pszAlgId;
193 } BCRYPT_PKCS1_PADDING_INFO;
194
195 typedef struct _BCRYPT_PSS_PADDING_INFO {
196 LPCWSTR pszAlgId;
197 ULONG cbSalt;
198 } BCRYPT_PSS_PADDING_INFO;
199
200 typedef struct _BCRYPT_OAEP_PADDING_INFO {
201 LPCWSTR pszAlgId;
202 PUCHAR pbLabel;
203 ULONG cbLabel;
204 } BCRYPT_OAEP_PADDING_INFO;
205
206 typedef struct _BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO {
207 ULONG cbSize;
208 ULONG dwInfoVersion;
209 PUCHAR pbNonce;
210 ULONG cbNonce;
211 PUCHAR pbAuthData;
212 ULONG cbAuthData;
213 PUCHAR pbTag;
214 ULONG cbTag;
215 PUCHAR pbMacContext;
216 ULONG cbMacContext;
217 ULONG cbAAD;
218 ULONGLONG cbData;
219 ULONG dwFlags;
220 } BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO,*PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO;
221#endif
222
223#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) || _WIN32_WINNT >= 0x0A00
224 typedef struct _BCryptBuffer {
225 ULONG cbBuffer;
226 ULONG BufferType;
227 PVOID pvBuffer;
228 } BCryptBuffer,*PBCryptBuffer;
229
230 typedef struct _BCryptBufferDesc {
231 ULONG ulVersion;
232 ULONG cBuffers;
233 PBCryptBuffer pBuffers;
234 } BCryptBufferDesc,*PBCryptBufferDesc;
235#endif
236
237#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || _WIN32_WINNT >= 0x0A00
238
239#define BCRYPT_PUBLIC_KEY_BLOB L"PUBLICBLOB"
240#define BCRYPT_PRIVATE_KEY_BLOB L"PRIVATEBLOB"
241
242#define BCRYPT_RSAPUBLIC_BLOB L"RSAPUBLICBLOB"
243#define BCRYPT_RSAPRIVATE_BLOB L"RSAPRIVATEBLOB"
244#define LEGACY_RSAPUBLIC_BLOB L"CAPIPUBLICBLOB"
245#define LEGACY_RSAPRIVATE_BLOB L"CAPIPRIVATEBLOB"
246
247#define BCRYPT_RSAPUBLIC_MAGIC 0x31415352
248#define BCRYPT_RSAPRIVATE_MAGIC 0x32415352
249
250#define BCRYPT_RSAFULLPRIVATE_BLOB L"RSAFULLPRIVATEBLOB"
251
252#define BCRYPT_RSAFULLPRIVATE_MAGIC 0x33415352
253
254#if NTDDI_VERSION >= NTDDI_WIN8
255#define BCRYPT_GLOBAL_PARAMETERS L"SecretAgreementParam"
256#define BCRYPT_PRIVATE_KEY L"PrivKeyVal"
257#endif
258
259#define BCRYPT_ECCPUBLIC_BLOB L"ECCPUBLICBLOB"
260#define BCRYPT_ECCPRIVATE_BLOB L"ECCPRIVATEBLOB"
261
262#if NTDDI_VERSION >= NTDDI_WINTHRESHOLD
263#define BCRYPT_ECCFULLPUBLIC_BLOB L"ECCFULLPUBLICBLOB"
264#define BCRYPT_ECCFULLPRIVATE_BLOB L"ECCFULLPRIVATEBLOB"
265#define SSL_ECCPUBLIC_BLOB L"SSLECCPUBLICBLOB"
266#endif
267
268#define BCRYPT_ECDH_PUBLIC_P256_MAGIC 0x314b4345
269#define BCRYPT_ECDH_PRIVATE_P256_MAGIC 0x324b4345
270#define BCRYPT_ECDH_PUBLIC_P384_MAGIC 0x334b4345
271#define BCRYPT_ECDH_PRIVATE_P384_MAGIC 0x344b4345
272#define BCRYPT_ECDH_PUBLIC_P521_MAGIC 0x354b4345
273#define BCRYPT_ECDH_PRIVATE_P521_MAGIC 0x364b4345
274#if NTDDI_VERSION >= NTDDI_WINTHRESHOLD
275#define BCRYPT_ECDH_PUBLIC_GENERIC_MAGIC 0x504B4345
276#define BCRYPT_ECDH_PRIVATE_GENERIC_MAGIC 0x564B4345
277#endif
278
279#define BCRYPT_ECDSA_PUBLIC_P256_MAGIC 0x31534345
280#define BCRYPT_ECDSA_PRIVATE_P256_MAGIC 0x32534345
281#define BCRYPT_ECDSA_PUBLIC_P384_MAGIC 0x33534345
282#define BCRYPT_ECDSA_PRIVATE_P384_MAGIC 0x34534345
283#define BCRYPT_ECDSA_PUBLIC_P521_MAGIC 0x35534345
284#define BCRYPT_ECDSA_PRIVATE_P521_MAGIC 0x36534345
285#if NTDDI_VERSION >= NTDDI_WINTHRESHOLD
286#define BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC 0x50444345
287#define BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC 0x56444345
288#endif
289
290#define BCRYPT_DH_PUBLIC_BLOB L"DHPUBLICBLOB"
291#define BCRYPT_DH_PRIVATE_BLOB L"DHPRIVATEBLOB"
292#define LEGACY_DH_PUBLIC_BLOB L"CAPIDHPUBLICBLOB"
293#define LEGACY_DH_PRIVATE_BLOB L"CAPIDHPRIVATEBLOB"
294
295#define BCRYPT_DH_PUBLIC_MAGIC 0x42504844
296#define BCRYPT_DH_PRIVATE_MAGIC 0x56504844
297
298#define BCRYPT_DH_PARAMETERS L"DHParameters"
299#define BCRYPT_DH_PARAMETERS_MAGIC 0x4d504844
300
301#define BCRYPT_DSA_PUBLIC_BLOB L"DSAPUBLICBLOB"
302#define BCRYPT_DSA_PRIVATE_BLOB L"DSAPRIVATEBLOB"
303#define LEGACY_DSA_PUBLIC_BLOB L"CAPIDSAPUBLICBLOB"
304#define LEGACY_DSA_PRIVATE_BLOB L"CAPIDSAPRIVATEBLOB"
305#define LEGACY_DSA_V2_PUBLIC_BLOB L"V2CAPIDSAPUBLICBLOB"
306#define LEGACY_DSA_V2_PRIVATE_BLOB L"V2CAPIDSAPRIVATEBLOB"
307
308#define BCRYPT_DSA_PUBLIC_MAGIC 0x42505344
309#define BCRYPT_DSA_PRIVATE_MAGIC 0x56505344
310#define BCRYPT_DSA_PUBLIC_MAGIC_V2 0x32425044
311#define BCRYPT_DSA_PRIVATE_MAGIC_V2 0x32565044
312
313#define BCRYPT_KEY_DATA_BLOB_MAGIC 0x4d42444b
314#define BCRYPT_KEY_DATA_BLOB_VERSION1 0x1
315
316#define BCRYPT_DSA_PARAMETERS L"DSAParameters"
317#define BCRYPT_DSA_PARAMETERS_MAGIC 0x4d505344
318#define BCRYPT_DSA_PARAMETERS_MAGIC_V2 0x324d5044
319
320#define MS_PRIMITIVE_PROVIDER L"Microsoft Primitive Provider"
321#define MS_PLATFORM_CRYPTO_PROVIDER L"Microsoft Platform Crypto Provider"
322
323#define BCRYPT_RSA_ALGORITHM L"RSA"
324#define BCRYPT_RSA_SIGN_ALGORITHM L"RSA_SIGN"
325#define BCRYPT_DH_ALGORITHM L"DH"
326#define BCRYPT_DSA_ALGORITHM L"DSA"
327#define BCRYPT_RC2_ALGORITHM L"RC2"
328#define BCRYPT_RC4_ALGORITHM L"RC4"
329#define BCRYPT_AES_ALGORITHM L"AES"
330#define BCRYPT_DES_ALGORITHM L"DES"
331#define BCRYPT_DESX_ALGORITHM L"DESX"
332#define BCRYPT_3DES_ALGORITHM L"3DES"
333#define BCRYPT_3DES_112_ALGORITHM L"3DES_112"
334#define BCRYPT_MD2_ALGORITHM L"MD2"
335#define BCRYPT_MD4_ALGORITHM L"MD4"
336#define BCRYPT_MD5_ALGORITHM L"MD5"
337#define BCRYPT_SHA1_ALGORITHM L"SHA1"
338#define BCRYPT_SHA256_ALGORITHM L"SHA256"
339#define BCRYPT_SHA384_ALGORITHM L"SHA384"
340#define BCRYPT_SHA512_ALGORITHM L"SHA512"
341#define BCRYPT_AES_GMAC_ALGORITHM L"AES-GMAC"
342#define BCRYPT_AES_CMAC_ALGORITHM L"AES-CMAC"
343#define BCRYPT_ECDSA_P256_ALGORITHM L"ECDSA_P256"
344#define BCRYPT_ECDSA_P384_ALGORITHM L"ECDSA_P384"
345#define BCRYPT_ECDSA_P521_ALGORITHM L"ECDSA_P521"
346#define BCRYPT_ECDH_P256_ALGORITHM L"ECDH_P256"
347#define BCRYPT_ECDH_P384_ALGORITHM L"ECDH_P384"
348#define BCRYPT_ECDH_P521_ALGORITHM L"ECDH_P521"
349#define BCRYPT_RNG_ALGORITHM L"RNG"
350#define BCRYPT_RNG_FIPS186_DSA_ALGORITHM L"FIPS186DSARNG"
351#define BCRYPT_RNG_DUAL_EC_ALGORITHM L"DUALECRNG"
352#define BCRYPT_SP800108_CTR_HMAC_ALGORITHM L"SP800_108_CTR_HMAC"
353#define BCRYPT_SP80056A_CONCAT_ALGORITHM L"SP800_56A_CONCAT"
354#define BCRYPT_PBKDF2_ALGORITHM L"PBKDF2"
355#define BCRYPT_CAPI_KDF_ALGORITHM L"CAPI_KDF"
356
357#define BCRYPT_CIPHER_INTERFACE 0x00000001
358#define BCRYPT_HASH_INTERFACE 0x00000002
359#define BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE 0x00000003
360#define BCRYPT_SECRET_AGREEMENT_INTERFACE 0x00000004
361#define BCRYPT_SIGNATURE_INTERFACE 0x00000005
362#define BCRYPT_RNG_INTERFACE 0x00000006
363#define BCRYPT_KEY_DERIVATION_INTERFACE 0x00000007
364
365#define BCRYPT_ALG_HANDLE_HMAC_FLAG 0x00000008
366#define BCRYPT_CAPI_AES_FLAG 0x00000010
367#define BCRYPT_HASH_REUSABLE_FLAG 0x00000020
368
369#define BCRYPT_BUFFERS_LOCKED_FLAG 0x00000040
370
371#define BCRYPT_CIPHER_OPERATION 0x00000001
372#define BCRYPT_HASH_OPERATION 0x00000002
373#define BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION 0x00000004
374#define BCRYPT_SECRET_AGREEMENT_OPERATION 0x00000008
375#define BCRYPT_SIGNATURE_OPERATION 0x00000010
376#define BCRYPT_RNG_OPERATION 0x00000020
377#define BCRYPT_KEY_DERIVATION_OPERATION 0x00000040
378
379#define BCRYPT_PUBLIC_KEY_FLAG 0x00000001
380#define BCRYPT_PRIVATE_KEY_FLAG 0x00000002
381
382#define BCRYPT_NO_KEY_VALIDATION 0x00000008
383
384#define BCRYPT_RNG_USE_ENTROPY_IN_BUFFER 0x00000001
385#define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002
386
387#define BCRYPT_MAKE_INTERFACE_VERSION(major, minor) { (USHORT)major,(USHORT)minor}
388#define BCRYPT_IS_INTERFACE_VERSION_COMPATIBLE(loader, provider) ((loader).MajorVersion <= (provider).MajorVersion)
389
390#define BCRYPT_CIPHER_INTERFACE_VERSION_1 BCRYPT_MAKE_INTERFACE_VERSION (1, 0)
391#define BCRYPT_HASH_INTERFACE_VERSION_1 BCRYPT_MAKE_INTERFACE_VERSION (1, 0)
392#define BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE_VERSION_1 BCRYPT_MAKE_INTERFACE_VERSION (1, 0)
393#define BCRYPT_SECRET_AGREEMENT_INTERFACE_VERSION_1 BCRYPT_MAKE_INTERFACE_VERSION (1, 0)
394#define BCRYPT_SIGNATURE_INTERFACE_VERSION_1 BCRYPT_MAKE_INTERFACE_VERSION (1, 0)
395#define BCRYPT_RNG_INTERFACE_VERSION_1 BCRYPT_MAKE_INTERFACE_VERSION (1, 0)
396
397#define CRYPT_MIN_DEPENDENCIES (0x00000001)
398#define CRYPT_PROCESS_ISOLATE (0x00010000)
399
400#define CRYPT_UM (0x00000001)
401#define CRYPT_KM (0x00000002)
402#define CRYPT_MM (0x00000003)
403#define CRYPT_ANY (0x00000004)
404
405#define CRYPT_OVERWRITE (0x00000001)
406
407#define CRYPT_LOCAL (0x00000001)
408#define CRYPT_DOMAIN (0x00000002)
409
410#define CRYPT_EXCLUSIVE (0x00000001)
411#define CRYPT_OVERRIDE (0x00010000)
412
413#define CRYPT_ALL_FUNCTIONS (0x00000001)
414#define CRYPT_ALL_PROVIDERS (0x00000002)
415
416#define CRYPT_PRIORITY_TOP (0x00000000)
417#define CRYPT_PRIORITY_BOTTOM (0xffffffff)
418
419#define CRYPT_DEFAULT_CONTEXT L"Default"
420
421typedef PVOID BCRYPT_HANDLE;
422 typedef PVOID BCRYPT_ALG_HANDLE;
423 typedef PVOID BCRYPT_KEY_HANDLE;
424 typedef PVOID BCRYPT_HASH_HANDLE;
425 typedef PVOID BCRYPT_SECRET_HANDLE;
426
427 typedef struct _BCRYPT_KEY_BLOB {
428 ULONG Magic;
429 } BCRYPT_KEY_BLOB;
430
431 typedef struct _BCRYPT_RSAKEY_BLOB {
432 ULONG Magic;
433 ULONG BitLength;
434 ULONG cbPublicExp;
435 ULONG cbModulus;
436 ULONG cbPrime1;
437 ULONG cbPrime2;
438 } BCRYPT_RSAKEY_BLOB;
439
440 typedef struct _BCRYPT_ECCKEY_BLOB {
441 ULONG dwMagic;
442 ULONG cbKey;
443 } BCRYPT_ECCKEY_BLOB,*PBCRYPT_ECCKEY_BLOB;
444
445 typedef struct _BCRYPT_DH_KEY_BLOB {
446 ULONG dwMagic;
447 ULONG cbKey;
448 } BCRYPT_DH_KEY_BLOB,*PBCRYPT_DH_KEY_BLOB;
449
450 typedef struct _BCRYPT_DH_PARAMETER_HEADER {
451 ULONG cbLength;
452 ULONG dwMagic;
453 ULONG cbKeyLength;
454 } BCRYPT_DH_PARAMETER_HEADER;
455
456 typedef struct _BCRYPT_DSA_KEY_BLOB {
457 ULONG dwMagic;
458 ULONG cbKey;
459 UCHAR Count[4];
460 UCHAR Seed[20];
461 UCHAR q[20];
462 } BCRYPT_DSA_KEY_BLOB,*PBCRYPT_DSA_KEY_BLOB;
463
464 typedef enum {
465 DSA_HASH_ALGORITHM_SHA1,
466 DSA_HASH_ALGORITHM_SHA256,
467 DSA_HASH_ALGORITHM_SHA512
468 } HASHALGORITHM_ENUM;
469
470 typedef enum {
471 DSA_FIPS186_2,
472 DSA_FIPS186_3
473 } DSAFIPSVERSION_ENUM;
474 typedef struct _BCRYPT_DSA_KEY_BLOB_V2 {
475 ULONG dwMagic;
476 ULONG cbKey;
477 HASHALGORITHM_ENUM hashAlgorithm;
478 DSAFIPSVERSION_ENUM standardVersion;
479 ULONG cbSeedLength;
480 ULONG cbGroupSize;
481 UCHAR Count[4];
482 } BCRYPT_DSA_KEY_BLOB_V2,*PBCRYPT_DSA_KEY_BLOB_V2;
483
484 typedef struct _BCRYPT_KEY_DATA_BLOB_HEADER {
485 ULONG dwMagic;
486 ULONG dwVersion;
487 ULONG cbKeyData;
488 } BCRYPT_KEY_DATA_BLOB_HEADER,*PBCRYPT_KEY_DATA_BLOB_HEADER;
489
490 typedef struct _BCRYPT_DSA_PARAMETER_HEADER {
491 ULONG cbLength;
492 ULONG dwMagic;
493 ULONG cbKeyLength;
494 UCHAR Count[4];
495 UCHAR Seed[20];
496 UCHAR q[20];
497 } BCRYPT_DSA_PARAMETER_HEADER;
498
499 typedef struct _BCRYPT_DSA_PARAMETER_HEADER_V2 {
500 ULONG cbLength;
501 ULONG dwMagic;
502 ULONG cbKeyLength;
503 HASHALGORITHM_ENUM hashAlgorithm;
504 DSAFIPSVERSION_ENUM standardVersion;
505 ULONG cbSeedLength;
506 ULONG cbGroupSize;
507 UCHAR Count[4];
508 } BCRYPT_DSA_PARAMETER_HEADER_V2;
509
510 typedef struct _BCRYPT_ECC_CURVE_NAMES {
511 ULONG dwEccCurveNames;
512 LPWSTR *pEccCurveNames;
513 } BCRYPT_ECC_CURVE_NAMES;
514
515 typedef enum {
516 BCRYPT_HASH_OPERATION_HASH_DATA = 1,
517 BCRYPT_HASH_OPERATION_FINISH_HASH = 2
518 } BCRYPT_HASH_OPERATION_TYPE;
519
520 typedef struct _BCRYPT_MULTI_HASH_OPERATION {
521 ULONG iHash;
522 BCRYPT_HASH_OPERATION_TYPE hashOperation;
523 PUCHAR pbBuffer;
524 ULONG cbBuffer;
525 } BCRYPT_MULTI_HASH_OPERATION;
526
527 typedef enum {
528 BCRYPT_OPERATION_TYPE_HASH = 1
529 } BCRYPT_MULTI_OPERATION_TYPE;
530
531 typedef struct _BCRYPT_MULTI_OBJECT_LENGTH_STRUCT {
532 ULONG cbPerObject;
533 ULONG cbPerElement;
534 } BCRYPT_MULTI_OBJECT_LENGTH_STRUCT;
535
536 typedef struct _BCRYPT_ALGORITHM_IDENTIFIER {
537 LPWSTR pszName;
538 ULONG dwClass;
539 ULONG dwFlags;
540 } BCRYPT_ALGORITHM_IDENTIFIER;
541
542 typedef struct _BCRYPT_PROVIDER_NAME {
543 LPWSTR pszProviderName;
544 } BCRYPT_PROVIDER_NAME;
545
546 typedef struct _BCRYPT_INTERFACE_VERSION {
547 USHORT MajorVersion;
548 USHORT MinorVersion;
549 } BCRYPT_INTERFACE_VERSION,*PBCRYPT_INTERFACE_VERSION;
550
551 typedef struct _CRYPT_INTERFACE_REG {
552 ULONG dwInterface;
553 ULONG dwFlags;
554 ULONG cFunctions;
555 PWSTR *rgpszFunctions;
556 } CRYPT_INTERFACE_REG,*PCRYPT_INTERFACE_REG;
557
558 typedef struct _CRYPT_IMAGE_REG {
559 PWSTR pszImage;
560 ULONG cInterfaces;
561 PCRYPT_INTERFACE_REG *rgpInterfaces;
562 } CRYPT_IMAGE_REG,*PCRYPT_IMAGE_REG;
563
564 typedef struct _CRYPT_PROVIDER_REG {
565 ULONG cAliases;
566 PWSTR *rgpszAliases;
567 PCRYPT_IMAGE_REG pUM;
568 PCRYPT_IMAGE_REG pKM;
569 } CRYPT_PROVIDER_REG,*PCRYPT_PROVIDER_REG;
570
571 typedef struct _CRYPT_PROVIDERS {
572 ULONG cProviders;
573 PWSTR *rgpszProviders;
574 } CRYPT_PROVIDERS,*PCRYPT_PROVIDERS;
575
576 typedef struct _CRYPT_CONTEXT_CONFIG {
577 ULONG dwFlags;
578 ULONG dwReserved;
579 } CRYPT_CONTEXT_CONFIG,*PCRYPT_CONTEXT_CONFIG;
580
581 typedef struct _CRYPT_CONTEXT_FUNCTION_CONFIG {
582 ULONG dwFlags;
583 ULONG dwReserved;
584 } CRYPT_CONTEXT_FUNCTION_CONFIG,*PCRYPT_CONTEXT_FUNCTION_CONFIG;
585
586 typedef struct _CRYPT_CONTEXTS {
587 ULONG cContexts;
588 PWSTR *rgpszContexts;
589 } CRYPT_CONTEXTS,*PCRYPT_CONTEXTS;
590
591 typedef struct _CRYPT_CONTEXT_FUNCTIONS {
592 ULONG cFunctions;
593 PWSTR *rgpszFunctions;
594 } CRYPT_CONTEXT_FUNCTIONS,*PCRYPT_CONTEXT_FUNCTIONS;
595
596 typedef struct _CRYPT_CONTEXT_FUNCTION_PROVIDERS {
597 ULONG cProviders;
598 PWSTR *rgpszProviders;
599 } CRYPT_CONTEXT_FUNCTION_PROVIDERS,*PCRYPT_CONTEXT_FUNCTION_PROVIDERS;
600
601 typedef struct _CRYPT_PROPERTY_REF {
602 PWSTR pszProperty;
603 ULONG cbValue;
604 PUCHAR pbValue;
605 } CRYPT_PROPERTY_REF,*PCRYPT_PROPERTY_REF;
606
607 typedef struct _CRYPT_IMAGE_REF {
608 PWSTR pszImage;
609 ULONG dwFlags;
610 } CRYPT_IMAGE_REF,*PCRYPT_IMAGE_REF;
611
612 typedef struct _CRYPT_PROVIDER_REF {
613 ULONG dwInterface;
614 PWSTR pszFunction;
615 PWSTR pszProvider;
616 ULONG cProperties;
617 PCRYPT_PROPERTY_REF *rgpProperties;
618 PCRYPT_IMAGE_REF pUM;
619 PCRYPT_IMAGE_REF pKM;
620 } CRYPT_PROVIDER_REF,*PCRYPT_PROVIDER_REF;
621
622 typedef struct _CRYPT_PROVIDER_REFS {
623 ULONG cProviders;
624 PCRYPT_PROVIDER_REF *rgpProviders;
625 } CRYPT_PROVIDER_REFS,*PCRYPT_PROVIDER_REFS;
626
627 NTSTATUS WINAPI BCryptOpenAlgorithmProvider (BCRYPT_ALG_HANDLE *phAlgorithm, LPCWSTR pszAlgId, LPCWSTR pszImplementation, ULONG dwFlags);
628 NTSTATUS WINAPI BCryptEnumAlgorithms (ULONG dwAlgOperations, ULONG *pAlgCount, BCRYPT_ALGORITHM_IDENTIFIER **ppAlgList, ULONG dwFlags);
629 NTSTATUS WINAPI BCryptEnumProviders (LPCWSTR pszAlgId, ULONG *pImplCount, BCRYPT_PROVIDER_NAME **ppImplList, ULONG dwFlags);
630 NTSTATUS WINAPI BCryptGetProperty (BCRYPT_HANDLE hObject, LPCWSTR pszProperty, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags);
631 NTSTATUS WINAPI BCryptSetProperty (BCRYPT_HANDLE hObject, LPCWSTR pszProperty, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags);
632 NTSTATUS WINAPI BCryptCloseAlgorithmProvider (BCRYPT_ALG_HANDLE hAlgorithm, ULONG dwFlags);
633 VOID WINAPI BCryptFreeBuffer (PVOID pvBuffer);
634 NTSTATUS WINAPI BCryptGenerateSymmetricKey (BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbKeyObject, ULONG cbKeyObject, PUCHAR pbSecret, ULONG cbSecret, ULONG dwFlags);
635 NTSTATUS WINAPI BCryptGenerateKeyPair (BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE *phKey, ULONG dwLength, ULONG dwFlags);
636 NTSTATUS WINAPI BCryptEncrypt (BCRYPT_KEY_HANDLE hKey, PUCHAR pbInput, ULONG cbInput, VOID *pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags);
637 NTSTATUS WINAPI BCryptDecrypt (BCRYPT_KEY_HANDLE hKey, PUCHAR pbInput, ULONG cbInput, VOID *pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags);
638 NTSTATUS WINAPI BCryptExportKey (BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE hExportKey, LPCWSTR pszBlobType, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags);
639 NTSTATUS WINAPI BCryptImportKey (BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbKeyObject, ULONG cbKeyObject, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags);
640 NTSTATUS WINAPI BCryptImportKeyPair (BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags);
641 NTSTATUS WINAPI BCryptDuplicateKey (BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE *phNewKey, PUCHAR pbKeyObject, ULONG cbKeyObject, ULONG dwFlags);
642 NTSTATUS WINAPI BCryptFinalizeKeyPair (BCRYPT_KEY_HANDLE hKey, ULONG dwFlags);
643 NTSTATUS WINAPI BCryptDestroyKey (BCRYPT_KEY_HANDLE hKey);
644 NTSTATUS WINAPI BCryptDestroySecret (BCRYPT_SECRET_HANDLE hSecret);
645 NTSTATUS WINAPI BCryptSignHash (BCRYPT_KEY_HANDLE hKey, VOID *pPaddingInfo, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags);
646 NTSTATUS WINAPI BCryptVerifySignature (BCRYPT_KEY_HANDLE hKey, VOID *pPaddingInfo, PUCHAR pbHash, ULONG cbHash, PUCHAR pbSignature, ULONG cbSignature, ULONG dwFlags);
647 NTSTATUS WINAPI BCryptSecretAgreement (BCRYPT_KEY_HANDLE hPrivKey, BCRYPT_KEY_HANDLE hPubKey, BCRYPT_SECRET_HANDLE *phAgreedSecret, ULONG dwFlags);
648 NTSTATUS WINAPI BCryptDeriveKey (BCRYPT_SECRET_HANDLE hSharedSecret, LPCWSTR pwszKDF, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG *pcbResult, ULONG dwFlags);
649 NTSTATUS WINAPI BCryptKeyDerivation (BCRYPT_KEY_HANDLE hKey, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG *pcbResult, ULONG dwFlags);
650 NTSTATUS WINAPI BCryptCreateHash (BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE *phHash, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, ULONG cbSecret, ULONG dwFlags);
651 NTSTATUS WINAPI BCryptHashData (BCRYPT_HASH_HANDLE hHash, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags);
652 NTSTATUS WINAPI BCryptFinishHash (BCRYPT_HASH_HANDLE hHash, PUCHAR pbOutput, ULONG cbOutput, ULONG dwFlags);
653#if (NTDDI_VERSION > NTDDI_WINBLUE || (NTDDI_VERSION == NTDDI_WINBLUE && defined(WINBLUE_KBSPRING14)))
654 NTSTATUS WINAPI BCryptCreateMultiHash (BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE *phHash, ULONG nHashes, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, ULONG cbSecret, ULONG dwFlags);
655 NTSTATUS WINAPI BCryptProcessMultiOperations (BCRYPT_HANDLE hObject, BCRYPT_MULTI_OPERATION_TYPE operationType, PVOID pOperations, ULONG cbOperations, ULONG dwFlags);
656#endif
657 NTSTATUS WINAPI BCryptDuplicateHash (BCRYPT_HASH_HANDLE hHash, BCRYPT_HASH_HANDLE *phNewHash, PUCHAR pbHashObject, ULONG cbHashObject, ULONG dwFlags);
658 NTSTATUS WINAPI BCryptDestroyHash (BCRYPT_HASH_HANDLE hHash);
659#if NTDDI_VERSION >= NTDDI_WINTHRESHOLD
660 NTSTATUS WINAPI BCryptHash (BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbSecret, ULONG cbSecret, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput);
661#endif
662 NTSTATUS WINAPI BCryptGenRandom (BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer, ULONG cbBuffer, ULONG dwFlags);
663 NTSTATUS WINAPI BCryptDeriveKeyCapi (BCRYPT_HASH_HANDLE hHash, BCRYPT_ALG_HANDLE hTargetAlg, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG dwFlags);
664 NTSTATUS WINAPI BCryptDeriveKeyPBKDF2 (BCRYPT_ALG_HANDLE hPrf, PUCHAR pbPassword, ULONG cbPassword, PUCHAR pbSalt, ULONG cbSalt, ULONGLONG cIterations, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG dwFlags);
665 NTSTATUS WINAPI BCryptResolveProviders (LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, LPCWSTR pszProvider, ULONG dwMode, ULONG dwFlags, ULONG *pcbBuffer, PCRYPT_PROVIDER_REFS *ppBuffer);
666 NTSTATUS WINAPI BCryptGetFipsAlgorithmMode (BOOLEAN *pfEnabled);
667#endif
668#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
669#ifndef KERNEL_MODE_CNG
670 NTSTATUS WINAPI BCryptQueryProviderRegistration (LPCWSTR pszProvider, ULONG dwMode, ULONG dwInterface, ULONG *pcbBuffer, PCRYPT_PROVIDER_REG *ppBuffer);
671 NTSTATUS WINAPI BCryptEnumRegisteredProviders (ULONG *pcbBuffer, PCRYPT_PROVIDERS *ppBuffer);
672 NTSTATUS WINAPI BCryptCreateContext (ULONG dwTable, LPCWSTR pszContext, PCRYPT_CONTEXT_CONFIG pConfig);
673 NTSTATUS WINAPI BCryptDeleteContext (ULONG dwTable, LPCWSTR pszContext);
674 NTSTATUS WINAPI BCryptEnumContexts (ULONG dwTable, ULONG *pcbBuffer, PCRYPT_CONTEXTS *ppBuffer);
675 NTSTATUS WINAPI BCryptConfigureContext (ULONG dwTable, LPCWSTR pszContext, PCRYPT_CONTEXT_CONFIG pConfig);
676 NTSTATUS WINAPI BCryptQueryContextConfiguration (ULONG dwTable, LPCWSTR pszContext, ULONG *pcbBuffer, PCRYPT_CONTEXT_CONFIG *ppBuffer);
677 NTSTATUS WINAPI BCryptAddContextFunction (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, ULONG dwPosition);
678 NTSTATUS WINAPI BCryptRemoveContextFunction (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction);
679 NTSTATUS WINAPI BCryptEnumContextFunctions (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, ULONG *pcbBuffer, PCRYPT_CONTEXT_FUNCTIONS *ppBuffer);
680 NTSTATUS WINAPI BCryptConfigureContextFunction (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, PCRYPT_CONTEXT_FUNCTION_CONFIG pConfig);
681 NTSTATUS WINAPI BCryptQueryContextFunctionConfiguration (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, ULONG *pcbBuffer, PCRYPT_CONTEXT_FUNCTION_CONFIG *ppBuffer);
682 NTSTATUS WINAPI BCryptEnumContextFunctionProviders (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, ULONG *pcbBuffer, PCRYPT_CONTEXT_FUNCTION_PROVIDERS *ppBuffer);
683 NTSTATUS WINAPI BCryptSetContextFunctionProperty (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, LPCWSTR pszProperty, ULONG cbValue, PUCHAR pbValue);
684 NTSTATUS WINAPI BCryptQueryContextFunctionProperty (ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, LPCWSTR pszProperty, ULONG *pcbValue, PUCHAR *ppbValue);
685 NTSTATUS WINAPI BCryptRegisterConfigChangeNotify (HANDLE *phEvent);
686 NTSTATUS WINAPI BCryptUnregisterConfigChangeNotify (HANDLE hEvent);
687#else
688 NTSTATUS WINAPI BCryptRegisterConfigChangeNotify (PRKEVENT pEvent);
689 NTSTATUS WINAPI BCryptUnregisterConfigChangeNotify (PRKEVENT pEvent);
690#endif
691#endif
692
693#ifdef __cplusplus
694}
695#endif
696#endif
Note: See TracBrowser for help on using the repository browser.