ws2_32/tests: Wait for AFD_POLL_RESET in test_get_events_reset().
[wine.git] / include / bcrypt.h
blob15dad1308927b3caaed89b0e41fdfe4080ad0571
1 /*
2 * Copyright (C) 2007 Francois Gouget
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_BCRYPT_H
20 #define __WINE_BCRYPT_H
22 #ifndef WINAPI
23 #define WINAPI __stdcall
24 #endif
26 #ifndef IN
27 #define IN
28 #endif
30 #ifndef OUT
31 #define OUT
32 #endif
34 #ifndef OPTIONAL
35 #define OPTIONAL
36 #endif
38 #ifndef WINE_NTSTATUS_DECLARED
39 #define WINE_NTSTATUS_DECLARED
40 typedef LONG NTSTATUS;
41 #endif
43 #if defined(_MSC_VER) || defined(__MINGW32__)
44 #define BCRYPT_ALGORITHM_NAME L"AlgorithmName"
45 #define BCRYPT_AUTH_TAG_LENGTH L"AuthTagLength"
46 #define BCRYPT_BLOCK_LENGTH L"BlockLength"
47 #define BCRYPT_BLOCK_SIZE_LIST L"BlockSizeList"
48 #define BCRYPT_CHAINING_MODE L"ChainingMode"
49 #define BCRYPT_EFFECTIVE_KEY_LENGTH L"EffectiveKeyLength"
50 #define BCRYPT_HASH_BLOCK_LENGTH L"HashBlockLength"
51 #define BCRYPT_HASH_LENGTH L"HashDigestLength"
52 #define BCRYPT_HASH_OID_LIST L"HashOIDList"
53 #define BCRYPT_KEY_LENGTH L"KeyLength"
54 #define BCRYPT_KEY_LENGTHS L"KeyLengths"
55 #define BCRYPT_KEY_OBJECT_LENGTH L"KeyObjectLength"
56 #define BCRYPT_KEY_STRENGTH L"KeyStrength"
57 #define BCRYPT_OBJECT_LENGTH L"ObjectLength"
58 #define BCRYPT_PADDING_SCHEMES L"PaddingSchemes"
59 #define BCRYPT_PROVIDER_HANDLE L"ProviderHandle"
60 #define BCRYPT_SIGNATURE_LENGTH L"SignatureLength"
62 #define BCRYPT_OPAQUE_KEY_BLOB L"OpaqueKeyBlob"
63 #define BCRYPT_KEY_DATA_BLOB L"KeyDataBlob"
64 #define BCRYPT_AES_WRAP_KEY_BLOB L"Rfc3565KeyWrapBlob"
65 #define BCRYPT_ECCPUBLIC_BLOB L"ECCPUBLICBLOB"
66 #define BCRYPT_ECCPRIVATE_BLOB L"ECCPRIVATEBLOB"
67 #define BCRYPT_RSAPUBLIC_BLOB L"RSAPUBLICBLOB"
68 #define BCRYPT_RSAPRIVATE_BLOB L"RSAPRIVATEBLOB"
69 #define BCRYPT_RSAFULLPRIVATE_BLOB L"RSAFULLPRIVATEBLOB"
70 #define BCRYPT_DSA_PUBLIC_BLOB L"DSAPUBLICBLOB"
71 #define BCRYPT_DSA_PRIVATE_BLOB L"DSAPRIVATEBLOB"
72 #define BCRYPT_PUBLIC_KEY_BLOB L"PUBLICBLOB"
73 #define BCRYPT_PRIVATE_KEY_BLOB L"PRIVATEBLOB"
74 #define LEGACY_DSA_PUBLIC_BLOB L"CAPIDSAPUBLICBLOB"
75 #define LEGACY_DSA_PRIVATE_BLOB L"CAPIDSAPRIVATEBLOB"
76 #define LEGACY_DSA_V2_PUBLIC_BLOB L"V2CAPIDSAPUBLICBLOB"
77 #define LEGACY_DSA_V2_PRIVATE_BLOB L"V2CAPIDSAPRIVATEBLOB"
78 #define LEGACY_RSAPUBLIC_BLOB L"CAPIPUBLICBLOB"
79 #define LEGACY_RSAPRIVATE_BLOB L"CAPIPRIVATEBLOB"
81 #define MS_PRIMITIVE_PROVIDER L"Microsoft Primitive Provider"
82 #define MS_PLATFORM_CRYPTO_PROVIDER L"Microsoft Platform Crypto Provider"
84 #define BCRYPT_3DES_ALGORITHM L"3DES"
85 #define BCRYPT_AES_ALGORITHM L"AES"
86 #define BCRYPT_DES_ALGORITHM L"DES"
87 #define BCRYPT_DSA_ALGORITHM L"DSA"
88 #define BCRYPT_ECDH_P256_ALGORITHM L"ECDH_P256"
89 #define BCRYPT_ECDH_P384_ALGORITHM L"ECDH_P384"
90 #define BCRYPT_ECDSA_P256_ALGORITHM L"ECDSA_P256"
91 #define BCRYPT_ECDSA_P384_ALGORITHM L"ECDSA_P384"
92 #define BCRYPT_ECDSA_P521_ALGORITHM L"ECDSA_P521"
93 #define BCRYPT_MD2_ALGORITHM L"MD2"
94 #define BCRYPT_MD4_ALGORITHM L"MD4"
95 #define BCRYPT_MD5_ALGORITHM L"MD5"
96 #define BCRYPT_RC2_ALGORITHM L"RC2"
97 #define BCRYPT_RC4_ALGORITHM L"RC4"
98 #define BCRYPT_RNG_ALGORITHM L"RNG"
99 #define BCRYPT_RSA_ALGORITHM L"RSA"
100 #define BCRYPT_RSA_SIGN_ALGORITHM L"RSA_SIGN"
101 #define BCRYPT_SHA1_ALGORITHM L"SHA1"
102 #define BCRYPT_SHA256_ALGORITHM L"SHA256"
103 #define BCRYPT_SHA384_ALGORITHM L"SHA384"
104 #define BCRYPT_SHA512_ALGORITHM L"SHA512"
106 #define BCRYPT_CHAIN_MODE_NA L"ChainingModeN/A"
107 #define BCRYPT_CHAIN_MODE_CBC L"ChainingModeCBC"
108 #define BCRYPT_CHAIN_MODE_ECB L"ChainingModeECB"
109 #define BCRYPT_CHAIN_MODE_CFB L"ChainingModeCFB"
110 #define BCRYPT_CHAIN_MODE_CCM L"ChainingModeCCM"
111 #define BCRYPT_CHAIN_MODE_GCM L"ChainingModeGCM"
113 #define BCRYPT_KDF_HASH L"HASH"
114 #define BCRYPT_KDF_HMAC L"HMAC"
115 #define BCRYPT_KDF_TLS_PRF L"TLS_PRF"
116 #define BCRYPT_KDF_SP80056A_CONCAT L"SP800_56A_CONCAT"
117 #define BCRYPT_KDF_RAW_SECRET L"TRUNCATE"
118 #else
119 static const WCHAR BCRYPT_ALGORITHM_NAME[] = {'A','l','g','o','r','i','t','h','m','N','a','m','e',0};
120 static const WCHAR BCRYPT_AUTH_TAG_LENGTH[] = {'A','u','t','h','T','a','g','L','e','n','g','t','h',0};
121 static const WCHAR BCRYPT_BLOCK_LENGTH[] = {'B','l','o','c','k','L','e','n','g','t','h',0};
122 static const WCHAR BCRYPT_BLOCK_SIZE_LIST[] = {'B','l','o','c','k','S','i','z','e','L','i','s','t',0};
123 static const WCHAR BCRYPT_CHAINING_MODE[] = {'C','h','a','i','n','i','n','g','M','o','d','e',0};
124 static const WCHAR BCRYPT_EFFECTIVE_KEY_LENGTH[] = {'E','f','f','e','c','t','i','v','e','K','e','y','L','e','n','g','t','h',0};
125 static const WCHAR BCRYPT_HASH_BLOCK_LENGTH[] = {'H','a','s','h','B','l','o','c','k','L','e','n','g','t','h',0};
126 static const WCHAR BCRYPT_HASH_LENGTH[] = {'H','a','s','h','D','i','g','e','s','t','L','e','n','g','t','h',0};
127 static const WCHAR BCRYPT_HASH_OID_LIST[] = {'H','a','s','h','O','I','D','L','i','s','t',0};
128 static const WCHAR BCRYPT_KEY_LENGTH[] = {'K','e','y','L','e','n','g','t','h',0};
129 static const WCHAR BCRYPT_KEY_LENGTHS[] = {'K','e','y','L','e','n','g','t','h','s',0};
130 static const WCHAR BCRYPT_KEY_OBJECT_LENGTH[] = {'K','e','y','O','b','j','e','c','t','L','e','n','g','t','h',0};
131 static const WCHAR BCRYPT_KEY_STRENGTH[] = {'K','e','y','S','t','r','e','n','g','t','h',0};
132 static const WCHAR BCRYPT_OBJECT_LENGTH[] = {'O','b','j','e','c','t','L','e','n','g','t','h',0};
133 static const WCHAR BCRYPT_PADDING_SCHEMES[] = {'P','a','d','d','i','n','g','S','c','h','e','m','e','s',0};
134 static const WCHAR BCRYPT_PROVIDER_HANDLE[] = {'P','r','o','v','i','d','e','r','H','a','n','d','l','e',0};
135 static const WCHAR BCRYPT_SIGNATURE_LENGTH[] = {'S','i','g','n','a','t','u','r','e','L','e','n','g','t','h',0};
137 static const WCHAR BCRYPT_OPAQUE_KEY_BLOB[] = {'O','p','a','q','u','e','K','e','y','B','l','o','b',0};
138 static const WCHAR BCRYPT_KEY_DATA_BLOB[] = {'K','e','y','D','a','t','a','B','l','o','b',0};
139 static const WCHAR BCRYPT_AES_WRAP_KEY_BLOB[] = {'R','f','c','3','5','6','5','K','e','y','W','r','a','p','B','l','o','b',0};
140 static const WCHAR BCRYPT_ECCPUBLIC_BLOB[] = {'E','C','C','P','U','B','L','I','C','B','L','O','B',0};
141 static const WCHAR BCRYPT_ECCPRIVATE_BLOB[] = {'E','C','C','P','R','I','V','A','T','E','B','L','O','B',0};
142 static const WCHAR BCRYPT_RSAPUBLIC_BLOB[] = {'R','S','A','P','U','B','L','I','C','B','L','O','B',0};
143 static const WCHAR BCRYPT_RSAPRIVATE_BLOB[] = {'R','S','A','P','R','I','V','A','T','E','B','L','O','B',0};
144 static const WCHAR BCRYPT_RSAFULLPRIVATE_BLOB[] = {'R','S','A','F','U','L','L','P','R','I','V','A','T','E','B','L','O','B',0};
145 static const WCHAR BCRYPT_DSA_PUBLIC_BLOB[] = {'D','S','A','P','U','B','L','I','C','B','L','O','B',0};
146 static const WCHAR BCRYPT_DSA_PRIVATE_BLOB[] = {'D','S','A','P','R','I','V','A','T','E','B','L','O','B',0};
147 static const WCHAR BCRYPT_PUBLIC_KEY_BLOB[] = {'P','U','B','L','I','C','B','L','O','B',0};
148 static const WCHAR BCRYPT_PRIVATE_KEY_BLOB[] = {'P','R','I','V','A','T','E','B','L','O','B',0};
149 static const WCHAR LEGACY_DSA_PUBLIC_BLOB[] = {'C','A','P','I','D','S','A','P','U','B','L','I','C','B','L','O','B',0};
150 static const WCHAR LEGACY_DSA_PRIVATE_BLOB[] = {'C','A','P','I','D','S','A','P','R','I','V','A','T','E','B','L','O','B',0};
151 static const WCHAR LEGACY_DSA_V2_PUBLIC_BLOB[] = {'V','2','C','A','P','I','D','S','A','P','U','B','L','I','C','B','L','O','B',0};
152 static const WCHAR LEGACY_DSA_V2_PRIVATE_BLOB[] = {'V','2','C','A','P','I','D','S','A','P','R','I','V','A','T','E','B','L','O','B',0};
153 static const WCHAR LEGACY_RSAPUBLIC_BLOB[] = {'C','A','P','I','P','U','B','L','I','C','B','L','O','B',0};
154 static const WCHAR LEGACY_RSAPRIVATE_BLOB[] = {'C','A','P','I','P','R','I','V','A','T','E','B','L','O','B',0};
156 static const WCHAR MS_PRIMITIVE_PROVIDER[] = \
157 {'M','i','c','r','o','s','o','f','t',' ','P','r','i','m','i','t','i','v','e',' ','P','r','o','v','i','d','e','r',0};
158 static const WCHAR MS_PLATFORM_CRYPTO_PROVIDER[] = \
159 {'M','i','c','r','o','s','o','f','t',' ','P','l','a','t','f','o','r','m',' ','C','r','y','p','t','o',' ','P','r','o','v','i','d','e','r',0};
161 static const WCHAR BCRYPT_3DES_ALGORITHM[] = {'3','D','E','S',0};
162 static const WCHAR BCRYPT_AES_ALGORITHM[] = {'A','E','S',0};
163 static const WCHAR BCRYPT_DES_ALGORITHM[] = {'D','E','S',0};
164 static const WCHAR BCRYPT_DSA_ALGORITHM[] = {'D','S','A',0};
165 static const WCHAR BCRYPT_ECDH_P256_ALGORITHM[] = {'E','C','D','H','_','P','2','5','6',0};
166 static const WCHAR BCRYPT_ECDH_P384_ALGORITHM[] = {'E','C','D','H','_','P','3','8','4',0};
167 static const WCHAR BCRYPT_ECDSA_P256_ALGORITHM[] = {'E','C','D','S','A','_','P','2','5','6',0};
168 static const WCHAR BCRYPT_ECDSA_P384_ALGORITHM[] = {'E','C','D','S','A','_','P','3','8','4',0};
169 static const WCHAR BCRYPT_ECDSA_P521_ALGORITHM[] = {'E','C','D','S','A','_','P','5','2','1',0};
170 static const WCHAR BCRYPT_MD2_ALGORITHM[] = {'M','D','2',0};
171 static const WCHAR BCRYPT_MD4_ALGORITHM[] = {'M','D','4',0};
172 static const WCHAR BCRYPT_MD5_ALGORITHM[] = {'M','D','5',0};
173 static const WCHAR BCRYPT_RC2_ALGORITHM[] = {'R','C','2',0};
174 static const WCHAR BCRYPT_RC4_ALGORITHM[] = {'R','C','4',0};
175 static const WCHAR BCRYPT_RNG_ALGORITHM[] = {'R','N','G',0};
176 static const WCHAR BCRYPT_RSA_ALGORITHM[] = {'R','S','A',0};
177 static const WCHAR BCRYPT_RSA_SIGN_ALGORITHM[] = {'R','S','A','_','S','I','G','N',0};
178 static const WCHAR BCRYPT_SHA1_ALGORITHM[] = {'S','H','A','1',0};
179 static const WCHAR BCRYPT_SHA256_ALGORITHM[] = {'S','H','A','2','5','6',0};
180 static const WCHAR BCRYPT_SHA384_ALGORITHM[] = {'S','H','A','3','8','4',0};
181 static const WCHAR BCRYPT_SHA512_ALGORITHM[] = {'S','H','A','5','1','2',0};
183 static const WCHAR BCRYPT_CHAIN_MODE_NA[] = {'C','h','a','i','n','i','n','g','M','o','d','e','N','/','A',0};
184 static const WCHAR BCRYPT_CHAIN_MODE_CBC[] = {'C','h','a','i','n','i','n','g','M','o','d','e','C','B','C',0};
185 static const WCHAR BCRYPT_CHAIN_MODE_ECB[] = {'C','h','a','i','n','i','n','g','M','o','d','e','E','C','B',0};
186 static const WCHAR BCRYPT_CHAIN_MODE_CFB[] = {'C','h','a','i','n','i','n','g','M','o','d','e','C','F','B',0};
187 static const WCHAR BCRYPT_CHAIN_MODE_CCM[] = {'C','h','a','i','n','i','n','g','M','o','d','e','C','C','M',0};
188 static const WCHAR BCRYPT_CHAIN_MODE_GCM[] = {'C','h','a','i','n','i','n','g','M','o','d','e','G','C','M',0};
190 static const WCHAR BCRYPT_KDF_HASH[] = {'H','A','S','H',0};
191 static const WCHAR BCRYPT_KDF_HMAC[] = {'H','M','A','C',0};
192 static const WCHAR BCRYPT_KDF_TLS_PRF[] = {'T','L','S','_','P','R','F',0};
193 static const WCHAR BCRYPT_KDF_SP80056A_CONCAT[] = {'S','P','8','0','0','_','5','6','A','_','C','O','N','C','A','T',0};
194 static const WCHAR BCRYPT_KDF_RAW_SECRET[] = {'T','R','U','N','C','A','T','E',0};
195 #endif
197 #define BCRYPT_ECDSA_PUBLIC_P256_MAGIC 0x31534345
198 #define BCRYPT_ECDSA_PRIVATE_P256_MAGIC 0x32534345
199 #define BCRYPT_ECDSA_PUBLIC_P384_MAGIC 0x33534345
200 #define BCRYPT_ECDSA_PRIVATE_P384_MAGIC 0x34534345
201 #define BCRYPT_ECDSA_PUBLIC_P521_MAGIC 0x35534345
202 #define BCRYPT_ECDSA_PRIVATE_P521_MAGIC 0x36534345
204 #define BCRYPT_ECDH_PUBLIC_P256_MAGIC 0x314b4345
205 #define BCRYPT_ECDH_PRIVATE_P256_MAGIC 0x324b4345
206 #define BCRYPT_ECDH_PUBLIC_P384_MAGIC 0x334b4345
207 #define BCRYPT_ECDH_PRIVATE_P384_MAGIC 0x344b4345
208 #define BCRYPT_ECDH_PUBLIC_P521_MAGIC 0x354b4345
209 #define BCRYPT_ECDH_PRIVATE_P521_MAGIC 0x364b4345
211 #define BCRYPT_CIPHER_OPERATION 0x00000001
212 #define BCRYPT_HASH_OPERATION 0x00000002
213 #define BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION 0x00000004
214 #define BCRYPT_SECRET_AGREEMENT_OPERATION 0x00000008
215 #define BCRYPT_SIGNATURE_OPERATION 0x00000010
216 #define BCRYPT_RNG_OPERATION 0x00000020
218 #define BCRYPT_CIPHER_INTERFACE 0x00000001
219 #define BCRYPT_HASH_INTERFACE 0x00000002
220 #define BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE 0x00000003
221 #define BCRYPT_SECRET_AGREEMENT_INTERFACE 0x00000004
222 #define BCRYPT_SIGNATURE_INTERFACE 0x00000005
223 #define BCRYPT_RNG_INTERFACE 0x00000006
224 #define BCRYPT_KEY_DERIVATION_INTERFACE 0x00000007
226 #define BCRYPT_SUPPORTED_PAD_ROUTER 0x00000001
227 #define BCRYPT_SUPPORTED_PAD_PKCS1_ENC 0x00000002
228 #define BCRYPT_SUPPORTED_PAD_PKCS1_SIG 0x00000004
229 #define BCRYPT_SUPPORTED_PAD_OAEP 0x00000008
230 #define BCRYPT_SUPPORTED_PAD_PSS 0x00000010
232 typedef struct _BCRYPT_ALGORITHM_IDENTIFIER
234 LPWSTR pszName;
235 ULONG dwClass;
236 ULONG dwFlags;
237 } BCRYPT_ALGORITHM_IDENTIFIER;
239 typedef struct __BCRYPT_KEY_LENGTHS_STRUCT
241 ULONG dwMinLength;
242 ULONG dwMaxLength;
243 ULONG dwIncrement;
244 } BCRYPT_KEY_LENGTHS_STRUCT, BCRYPT_AUTH_TAG_LENGTHS_STRUCT;
246 typedef struct _BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
248 ULONG cbSize;
249 ULONG dwInfoVersion;
250 UCHAR *pbNonce;
251 ULONG cbNonce;
252 UCHAR *pbAuthData;
253 ULONG cbAuthData;
254 UCHAR *pbTag;
255 ULONG cbTag;
256 UCHAR *pbMacContext;
257 ULONG cbMacContext;
258 ULONG cbAAD;
259 ULONGLONG cbData;
260 ULONG dwFlags;
261 } BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO, *PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO;
263 typedef struct _BCRYPT_KEY_BLOB
265 ULONG Magic;
266 } BCRYPT_KEY_BLOB;
268 typedef struct _BCRYPT_ECCKEY_BLOB
270 ULONG dwMagic;
271 ULONG cbKey;
272 } BCRYPT_ECCKEY_BLOB, *PBCRYPT_ECCKEY_BLOB;
274 #define BCRYPT_RSAPUBLIC_MAGIC 0x31415352
275 #define BCRYPT_RSAPRIVATE_MAGIC 0x32415352
276 #define BCRYPT_RSAFULLPRIVATE_MAGIC 0x33415352
278 typedef struct _BCRYPT_RSAKEY_BLOB
280 ULONG Magic;
281 ULONG BitLength;
282 ULONG cbPublicExp;
283 ULONG cbModulus;
284 ULONG cbPrime1;
285 ULONG cbPrime2;
286 } BCRYPT_RSAKEY_BLOB;
288 typedef struct _BCRYPT_PKCS1_PADDING_INFO
290 LPCWSTR pszAlgId;
291 } BCRYPT_PKCS1_PADDING_INFO;
293 typedef struct _BCRYPT_PSS_PADDING_INFO
295 LPCWSTR pszAlgId;
296 ULONG cbSalt;
297 } BCRYPT_PSS_PADDING_INFO;
299 typedef struct _BCRYPT_OAEP_PADDING_INFO
301 LPCWSTR pszAlgId;
302 PUCHAR pbLabel;
303 ULONG cbLabel;
304 } BCRYPT_OAEP_PADDING_INFO;
306 #define BCRYPT_PAD_NONE 0x00000001
307 #define BCRYPT_PAD_PKCS1 0x00000002
308 #define BCRYPT_PAD_OAEP 0x00000004
309 #define BCRYPT_PAD_PSS 0x00000008
310 #define BCRYPT_PAD_PKCS1_OPTIONAL_HASH_OID 0x00000010
312 #define BCRYPT_DSA_PUBLIC_MAGIC 0x42505344
313 #define BCRYPT_DSA_PRIVATE_MAGIC 0x56505344
315 typedef struct _BCRYPT_DSA_KEY_BLOB
317 ULONG dwMagic;
318 ULONG cbKey;
319 UCHAR Count[4];
320 UCHAR Seed[20];
321 UCHAR q[20];
322 } BCRYPT_DSA_KEY_BLOB, *PBCRYPT_DSA_KEY_BLOB;
324 #define BCRYPT_DSA_PUBLIC_MAGIC_V2 0x32425044
325 #define BCRYPT_DSA_PRIVATE_MAGIC_V2 0x32565044
327 typedef enum
329 DSA_HASH_ALGORITHM_SHA1,
330 DSA_HASH_ALGORITHM_SHA256,
331 DSA_HASH_ALGORITHM_SHA512
332 } HASHALGORITHM_ENUM;
334 typedef enum
336 DSA_FIPS186_2,
337 DSA_FIPS186_3
338 } DSAFIPSVERSION_ENUM;
340 typedef struct _BCRYPT_DSA_KEY_BLOB_V2
342 ULONG dwMagic;
343 ULONG cbKey;
344 HASHALGORITHM_ENUM hashAlgorithm;
345 DSAFIPSVERSION_ENUM standardVersion;
346 ULONG cbSeedLength;
347 ULONG cbGroupSize;
348 UCHAR Count[4];
349 } BCRYPT_DSA_KEY_BLOB_V2, *PBCRYPT_DSA_KEY_BLOB_V2;
351 #define BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION 1
353 #define BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG 0x00000001
354 #define BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG 0x00000002
356 typedef struct _CRYPT_INTERFACE_REG
358 ULONG dwInterface;
359 ULONG dwFlags;
360 ULONG cFunctions;
361 PWSTR *rgpszFunctions;
362 } CRYPT_INTERFACE_REG, *PCRYPT_INTERFACE_REG;
364 typedef struct _CRYPT_IMAGE_REG
366 PWSTR pszImage;
367 ULONG cInterfaces;
368 PCRYPT_INTERFACE_REG *rgpInterfaces;
369 } CRYPT_IMAGE_REG, *PCRYPT_IMAGE_REG;
371 typedef struct _CRYPT_PROVIDER_REG
373 ULONG cAliases;
374 PWSTR *rgpszAliases;
375 PCRYPT_IMAGE_REG pUM;
376 PCRYPT_IMAGE_REG pKM;
377 } CRYPT_PROVIDER_REG, *PCRYPT_PROVIDER_REG;
379 typedef struct _BCRYPT_KEY_DATA_BLOB_HEADER
381 ULONG dwMagic;
382 ULONG dwVersion;
383 ULONG cbKeyData;
384 } BCRYPT_KEY_DATA_BLOB_HEADER, *PBCRYPT_KEY_DATA_BLOB_HEADER;
386 #define KDF_HASH_ALGORITHM 0x00000000
387 #define KDF_SECRET_PREPEND 0x00000001
388 #define KDF_SECRET_APPEND 0x00000002
390 typedef struct _BCryptBuffer
392 ULONG cbBuffer;
393 ULONG BufferType;
394 void *pvBuffer;
395 } BCryptBuffer, *PBCryptBuffer;
397 #define BCRYPTBUFFER_VERSION 0
399 typedef struct _BCryptBufferDesc
401 ULONG ulVersion;
402 ULONG cBuffers;
403 PBCryptBuffer pBuffers;
404 } BCryptBufferDesc, *PBCryptBufferDesc;
406 #define BCRYPT_KEY_DATA_BLOB_MAGIC 0x4d42444b
407 #define BCRYPT_KEY_DATA_BLOB_VERSION1 1
409 typedef PVOID BCRYPT_ALG_HANDLE;
410 typedef PVOID BCRYPT_KEY_HANDLE;
411 typedef PVOID BCRYPT_HANDLE;
412 typedef PVOID BCRYPT_HASH_HANDLE;
413 typedef PVOID BCRYPT_SECRET_HANDLE;
415 /* Pseudo handles */
416 #define BCRYPT_MD2_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000001)
417 #define BCRYPT_MD4_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000011)
418 #define BCRYPT_MD5_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000021)
419 #define BCRYPT_SHA1_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000031)
420 #define BCRYPT_SHA256_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000041)
421 #define BCRYPT_SHA384_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000051)
422 #define BCRYPT_SHA512_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000061)
423 #define BCRYPT_RC4_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000071)
424 #define BCRYPT_RNG_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000081)
425 #define BCRYPT_HMAC_MD5_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000091)
426 #define BCRYPT_HMAC_SHA1_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000a1)
427 #define BCRYPT_HMAC_SHA256_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000b1)
428 #define BCRYPT_HMAC_SHA384_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000c1)
429 #define BCRYPT_HMAC_SHA512_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000d1)
430 #define BCRYPT_RSA_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000e1)
431 #define BCRYPT_ECDSA_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000f1)
432 #define BCRYPT_AES_CMAC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000101)
433 #define BCRYPT_AES_GMAC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000111)
434 #define BCRYPT_HMAC_MD2_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000121)
435 #define BCRYPT_HMAC_MD4_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000131)
436 #define BCRYPT_3DES_CBC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000141)
437 #define BCRYPT_3DES_ECB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000151)
438 #define BCRYPT_3DES_CFB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000161)
439 #define BCRYPT_3DES_112_CBC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000171)
440 #define BCRYPT_3DES_112_ECB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000181)
441 #define BCRYPT_3DES_112_CFB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000191)
442 #define BCRYPT_AES_CBC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000001a1)
443 #define BCRYPT_AES_ECB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000001b1)
444 #define BCRYPT_AES_CFB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000001c1)
445 #define BCRYPT_AES_CCM_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000001d1)
446 #define BCRYPT_AES_GCM_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000001e1)
447 #define BCRYPT_DES_CBC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000001f1)
448 #define BCRYPT_DES_ECB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000201)
449 #define BCRYPT_DES_CFB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000211)
450 #define BCRYPT_DESX_CBC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000221)
451 #define BCRYPT_DESX_ECB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000231)
452 #define BCRYPT_DESX_CFB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000241)
453 #define BCRYPT_RC2_CBC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000251)
454 #define BCRYPT_RC2_ECB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000261)
455 #define BCRYPT_RC2_CFB_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000271)
456 #define BCRYPT_DH_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000281)
457 #define BCRYPT_ECDH_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000291)
458 #define BCRYPT_ECDH_P256_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000002a1)
459 #define BCRYPT_ECDH_P384_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000002b1)
460 #define BCRYPT_ECDH_P521_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000002c1)
461 #define BCRYPT_DSA_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000002d1)
462 #define BCRYPT_ECDSA_P256_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000002e1)
463 #define BCRYPT_ECDSA_P384_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000002f1)
464 #define BCRYPT_ECDSA_P521_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000301)
465 #define BCRYPT_RSA_SIGN_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000311)
466 #define BCRYPT_CAPI_KDF_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000321)
467 #define BCRYPT_PBKDF2_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000331)
468 #define BCRYPT_SP800108_CTR_HMAC_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000341)
469 #define BCRYPT_SP80056A_CONCAT_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000351)
470 #define BCRYPT_TLS1_1_KDF_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000361)
471 #define BCRYPT_TLS1_2_KDF_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000371)
472 #define BCRYPT_XTS_AES_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000381)
473 #define BCRYPT_HKDF_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000391)
475 /* Flags for BCryptGenRandom */
476 #define BCRYPT_RNG_USE_ENTROPY_IN_BUFFER 0x00000001
477 #define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002
479 /* Flags for BCryptOpenAlgorithmProvider */
480 #define BCRYPT_ALG_HANDLE_HMAC_FLAG 0x00000008
482 /* Flags for BCryptEncrypt/BCryptDecrypt */
483 #define BCRYPT_BLOCK_PADDING 0x00000001
485 /* Flags for BCryptCreateHash */
486 #define BCRYPT_HASH_REUSABLE_FLAG 0x00000020
488 #define CRYPT_LOCAL 0x00000001
489 #define CRYPT_DOMAIN 0x00000002
491 typedef struct _CRYPT_CONTEXT_FUNCTIONS
493 ULONG cFunctions;
494 WCHAR **rgpszFunctions;
495 } CRYPT_CONTEXT_FUNCTIONS, *PCRYPT_CONTEXT_FUNCTIONS;
497 NTSTATUS WINAPI BCryptAddContextFunction(ULONG, LPCWSTR, ULONG, LPCWSTR, ULONG);
498 NTSTATUS WINAPI BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE, ULONG);
499 NTSTATUS WINAPI BCryptCreateHash(BCRYPT_ALG_HANDLE, BCRYPT_HASH_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG);
500 NTSTATUS WINAPI BCryptDecrypt(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG);
501 NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE, LPCWSTR, BCryptBufferDesc*, PUCHAR, ULONG, ULONG *, ULONG);
502 NTSTATUS WINAPI BCryptDeriveKeyCapi(BCRYPT_HASH_HANDLE, BCRYPT_ALG_HANDLE, PUCHAR, ULONG, ULONG);
503 NTSTATUS WINAPI BCryptDeriveKeyPBKDF2(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, PUCHAR, ULONG, ULONGLONG, PUCHAR, ULONG, ULONG);
504 NTSTATUS WINAPI BCryptDestroyHash(BCRYPT_HASH_HANDLE);
505 NTSTATUS WINAPI BCryptDestroyKey(BCRYPT_KEY_HANDLE);
506 NTSTATUS WINAPI BCryptDestroySecret(BCRYPT_SECRET_HANDLE);
507 NTSTATUS WINAPI BCryptDuplicateHash(BCRYPT_HASH_HANDLE, BCRYPT_HASH_HANDLE *, UCHAR *, ULONG, ULONG);
508 NTSTATUS WINAPI BCryptDuplicateKey(BCRYPT_KEY_HANDLE, BCRYPT_KEY_HANDLE *, PUCHAR, ULONG, ULONG);
509 NTSTATUS WINAPI BCryptEncrypt(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG);
510 NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG, ULONG *, BCRYPT_ALGORITHM_IDENTIFIER **, ULONG);
511 NTSTATUS WINAPI BCryptEnumContextFunctions(ULONG, const WCHAR *, ULONG, ULONG *, CRYPT_CONTEXT_FUNCTIONS **);
512 NTSTATUS WINAPI BCryptExportKey(BCRYPT_KEY_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG *, ULONG);
513 NTSTATUS WINAPI BCryptFinalizeKeyPair(BCRYPT_KEY_HANDLE, ULONG);
514 NTSTATUS WINAPI BCryptFinishHash(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG);
515 void WINAPI BCryptFreeBuffer(void *);
516 NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, ULONG);
517 NTSTATUS WINAPI BCryptGenerateKeyPair(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE *, ULONG, ULONG);
518 NTSTATUS WINAPI BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG);
519 NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *);
520 NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG *, ULONG);
521 NTSTATUS WINAPI BCryptHash(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, PUCHAR, ULONG, PUCHAR, ULONG);
522 NTSTATUS WINAPI BCryptHashData(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG);
523 NTSTATUS WINAPI BCryptImportKey(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, BCRYPT_KEY_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG);
524 NTSTATUS WINAPI BCryptImportKeyPair(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, BCRYPT_KEY_HANDLE *, UCHAR *, ULONG, ULONG);
525 NTSTATUS WINAPI BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE *, LPCWSTR, LPCWSTR, ULONG);
526 NTSTATUS WINAPI BCryptRemoveContextFunction(ULONG, LPCWSTR, ULONG, LPCWSTR);
527 NTSTATUS WINAPI BCryptSecretAgreement(BCRYPT_KEY_HANDLE, BCRYPT_KEY_HANDLE, BCRYPT_SECRET_HANDLE *, ULONG);
528 NTSTATUS WINAPI BCryptSetProperty(BCRYPT_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG);
529 NTSTATUS WINAPI BCryptSignHash(BCRYPT_KEY_HANDLE, void *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG);
530 NTSTATUS WINAPI BCryptVerifySignature(BCRYPT_KEY_HANDLE, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG);
532 #endif /* __WINE_BCRYPT_H */