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
23 #define WINAPI __stdcall
38 #ifndef WINE_NTSTATUS_DECLARED
39 #define WINE_NTSTATUS_DECLARED
40 typedef LONG NTSTATUS
;
43 #define BCRYPT_ALGORITHM_NAME (const WCHAR []){'A','l','g','o','r','i','t','h','m','N','a','m','e',0}
44 #define BCRYPT_AUTH_TAG_LENGTH (const WCHAR []){'A','u','t','h','T','a','g','L','e','n','g','t','h',0}
45 #define BCRYPT_BLOCK_LENGTH (const WCHAR []){'B','l','o','c','k','L','e','n','g','t','h',0}
46 #define BCRYPT_BLOCK_SIZE_LIST (const WCHAR []){'B','l','o','c','k','S','i','z','e','L','i','s','t',0}
47 #define BCRYPT_CHAINING_MODE (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e',0}
48 #define BCRYPT_EFFECTIVE_KEY_LENGTH (const WCHAR []){'E','f','f','e','c','t','i','v','e','K','e','y','L','e','n','g','t','h',0}
49 #define BCRYPT_HASH_BLOCK_LENGTH (const WCHAR []){'H','a','s','h','B','l','o','c','k','L','e','n','g','t','h',0}
50 #define BCRYPT_HASH_LENGTH (const WCHAR []){'H','a','s','h','D','i','g','e','s','t','L','e','n','g','t','h',0}
51 #define BCRYPT_HASH_OID_LIST (const WCHAR []){'H','a','s','h','O','I','D','L','i','s','t',0}
52 #define BCRYPT_KEY_LENGTH (const WCHAR []){'K','e','y','L','e','n','g','t','h',0}
53 #define BCRYPT_KEY_LENGTHS (const WCHAR []){'K','e','y','L','e','n','g','t','h','s',0}
54 #define BCRYPT_KEY_OBJECT_LENGTH (const WCHAR []){'K','e','y','O','b','j','e','c','t','L','e','n','g','t','h',0}
55 #define BCRYPT_KEY_STRENGTH (const WCHAR []){'K','e','y','S','t','r','e','n','g','t','h',0}
56 #define BCRYPT_OBJECT_LENGTH (const WCHAR []){'O','b','j','e','c','t','L','e','n','g','t','h',0}
57 #define BCRYPT_PADDING_SCHEMES (const WCHAR []){'P','a','d','d','i','n','g','S','c','h','e','m','e','s',0}
58 #define BCRYPT_PROVIDER_HANDLE (const WCHAR []){'P','r','o','v','i','d','e','r','H','a','n','d','l','e',0}
59 #define BCRYPT_SIGNATURE_LENGTH (const WCHAR []){'S','i','g','n','a','t','u','r','e','L','e','n','g','t','h',0}
61 #define BCRYPT_OPAQUE_KEY_BLOB (const WCHAR []){'O','p','a','q','u','e','K','e','y','B','l','o','b',0}
62 #define BCRYPT_KEY_DATA_BLOB (const WCHAR []){'K','e','y','D','a','t','a','B','l','o','b',0}
63 #define BCRYPT_AES_WRAP_KEY_BLOB (const WCHAR []){'R','f','c','3','5','6','5','K','e','y','W','r','a','p','B','l','o','b',0}
64 #define BCRYPT_ECCPUBLIC_BLOB (const WCHAR []){'E','C','C','P','U','B','L','I','C','B','L','O','B',0}
65 #define BCRYPT_ECCPRIVATE_BLOB (const WCHAR []){'E','C','C','P','R','I','V','A','T','E','B','L','O','B',0}
66 #define BCRYPT_RSAPUBLIC_BLOB (const WCHAR []){'R','S','A','P','U','B','L','I','C','B','L','O','B',0}
67 #define BCRYPT_RSAPRIVATE_BLOB (const WCHAR []){'R','S','A','P','R','I','V','A','T','E','B','L','O','B',0}
69 #define MS_PRIMITIVE_PROVIDER (const WCHAR [])\
70 {'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}
71 #define MS_PLATFORM_CRYPTO_PROVIDER (const WCHAR [])\
72 {'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}
74 #define BCRYPT_AES_ALGORITHM (const WCHAR []){'A','E','S',0}
75 #define BCRYPT_MD2_ALGORITHM (const WCHAR []){'M','D','2',0}
76 #define BCRYPT_MD4_ALGORITHM (const WCHAR []){'M','D','4',0}
77 #define BCRYPT_MD5_ALGORITHM (const WCHAR []){'M','D','5',0}
78 #define BCRYPT_RNG_ALGORITHM (const WCHAR []){'R','N','G',0}
79 #define BCRYPT_RSA_ALGORITHM (const WCHAR []){'R','S','A',0}
80 #define BCRYPT_SHA1_ALGORITHM (const WCHAR []){'S','H','A','1',0}
81 #define BCRYPT_SHA256_ALGORITHM (const WCHAR []){'S','H','A','2','5','6',0}
82 #define BCRYPT_SHA384_ALGORITHM (const WCHAR []){'S','H','A','3','8','4',0}
83 #define BCRYPT_SHA512_ALGORITHM (const WCHAR []){'S','H','A','5','1','2',0}
84 #define BCRYPT_ECDH_P256_ALGORITHM (const WCHAR []){'E','C','D','H','_','P','2','5','6',0}
85 #define BCRYPT_ECDSA_P256_ALGORITHM (const WCHAR []){'E','C','D','S','A','_','P','2','5','6',0}
86 #define BCRYPT_ECDSA_P384_ALGORITHM (const WCHAR []){'E','C','D','S','A','_','P','3','8','4',0}
87 #define BCRYPT_ECDSA_P521_ALGORITHM (const WCHAR []){'E','C','D','S','A','_','P','5','2','1',0}
89 #define BCRYPT_CHAIN_MODE_NA (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','N','/','A',0}
90 #define BCRYPT_CHAIN_MODE_CBC (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','C','B','C',0}
91 #define BCRYPT_CHAIN_MODE_ECB (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','E','C','B',0}
92 #define BCRYPT_CHAIN_MODE_CFB (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','C','F','B',0}
93 #define BCRYPT_CHAIN_MODE_CCM (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','C','C','M',0}
94 #define BCRYPT_CHAIN_MODE_GCM (const WCHAR []){'C','h','a','i','n','i','n','g','M','o','d','e','G','C','M',0}
96 #define BCRYPT_ECDSA_PUBLIC_P256_MAGIC 0x31534345
97 #define BCRYPT_ECDSA_PRIVATE_P256_MAGIC 0x32534345
98 #define BCRYPT_ECDSA_PUBLIC_P384_MAGIC 0x33534345
99 #define BCRYPT_ECDSA_PRIVATE_P384_MAGIC 0x34534345
100 #define BCRYPT_ECDSA_PUBLIC_P521_MAGIC 0x35534345
101 #define BCRYPT_ECDSA_PRIVATE_P521_MAGIC 0x36534345
103 #define BCRYPT_ECDH_PUBLIC_P256_MAGIC 0x314b4345
104 #define BCRYPT_ECDH_PRIVATE_P256_MAGIC 0x324b4345
105 #define BCRYPT_ECDH_PUBLIC_P384_MAGIC 0x334b4345
106 #define BCRYPT_ECDH_PRIVATE_P384_MAGIC 0x344b4345
107 #define BCRYPT_ECDH_PUBLIC_P521_MAGIC 0x354b4345
108 #define BCRYPT_ECDH_PRIVATE_P521_MAGIC 0x364b4345
110 typedef struct _BCRYPT_ALGORITHM_IDENTIFIER
115 } BCRYPT_ALGORITHM_IDENTIFIER
;
117 typedef struct __BCRYPT_KEY_LENGTHS_STRUCT
122 } BCRYPT_KEY_LENGTHS_STRUCT
, BCRYPT_AUTH_TAG_LENGTHS_STRUCT
;
124 typedef struct _BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
139 } BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
, *PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
;
141 typedef struct _BCRYPT_ECCKEY_BLOB
145 } BCRYPT_ECCKEY_BLOB
, *PBCRYPT_ECCKEY_BLOB
;
147 #define BCRYPT_RSAPUBLIC_MAGIC 0x31415352
148 #define BCRYPT_RSAPRIVATE_MAGIC 0x32415352
149 #define BCRYPT_RSAFULLPRIVATE_MAGIC 0x33415352
151 typedef struct _BCRYPT_RSAKEY_BLOB
159 } BCRYPT_RSAKEY_BLOB
;
161 typedef struct _BCRYPT_PKCS1_PADDING_INFO
164 } BCRYPT_PKCS1_PADDING_INFO
;
166 #define BCRYPT_PAD_NONE 0x00000001
167 #define BCRYPT_PAD_PKCS1 0x00000002
168 #define BCRYPT_PAD_OAEP 0x00000004
169 #define BCRYPT_PAD_PSS 0x00000008
170 #define BCRYPT_PAD_PKCS1_OPTIONAL_HASH_OID 0x00000010
172 #define BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION 1
174 #define BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG 0x00000001
175 #define BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG 0x00000002
177 typedef struct _CRYPT_INTERFACE_REG
182 PWSTR
*rgpszFunctions
;
183 } CRYPT_INTERFACE_REG
, *PCRYPT_INTERFACE_REG
;
185 typedef struct _CRYPT_IMAGE_REG
189 PCRYPT_INTERFACE_REG
*rgpInterfaces
;
190 } CRYPT_IMAGE_REG
, *PCRYPT_IMAGE_REG
;
192 typedef struct _CRYPT_PROVIDER_REG
196 PCRYPT_IMAGE_REG pUM
;
197 PCRYPT_IMAGE_REG pKM
;
198 } CRYPT_PROVIDER_REG
, *PCRYPT_PROVIDER_REG
;
200 typedef struct _BCRYPT_KEY_DATA_BLOB_HEADER
205 } BCRYPT_KEY_DATA_BLOB_HEADER
, *PBCRYPT_KEY_DATA_BLOB_HEADER
;
207 typedef struct _BCryptBuffer
212 } BCryptBuffer
, *PBCryptBuffer
;
214 typedef struct _BCryptBufferDesc
218 PBCryptBuffer pBuffers
;
219 } BCryptBufferDesc
, *PBCryptBufferDesc
;
221 #define BCRYPT_KEY_DATA_BLOB_MAGIC 0x4d42444b
222 #define BCRYPT_KEY_DATA_BLOB_VERSION1 1
224 typedef PVOID BCRYPT_ALG_HANDLE
;
225 typedef PVOID BCRYPT_KEY_HANDLE
;
226 typedef PVOID BCRYPT_HANDLE
;
227 typedef PVOID BCRYPT_HASH_HANDLE
;
228 typedef PVOID BCRYPT_SECRET_HANDLE
;
230 /* Flags for BCryptGenRandom */
231 #define BCRYPT_RNG_USE_ENTROPY_IN_BUFFER 0x00000001
232 #define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002
234 /* Flags for BCryptOpenAlgorithmProvider */
235 #define BCRYPT_ALG_HANDLE_HMAC_FLAG 0x00000008
237 /* Flags for BCryptEncrypt/BCryptDecrypt */
238 #define BCRYPT_BLOCK_PADDING 0x00000001
240 /* Flags for BCryptCreateHash */
241 #define BCRYPT_HASH_REUSABLE_FLAG 0x00000020
243 NTSTATUS WINAPI
BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE
, ULONG
);
244 NTSTATUS WINAPI
BCryptCreateHash(BCRYPT_ALG_HANDLE
, BCRYPT_HASH_HANDLE
*, PUCHAR
, ULONG
, PUCHAR
, ULONG
, ULONG
);
245 NTSTATUS WINAPI
BCryptDecrypt(BCRYPT_KEY_HANDLE
, PUCHAR
, ULONG
, VOID
*, PUCHAR
, ULONG
, PUCHAR
, ULONG
, ULONG
*, ULONG
);
246 NTSTATUS WINAPI
BCryptDeriveKey(BCRYPT_SECRET_HANDLE
, LPCWSTR
, BCryptBufferDesc
*, PUCHAR
, ULONG
, ULONG
*, ULONG
);
247 NTSTATUS WINAPI
BCryptDeriveKeyPBKDF2(BCRYPT_ALG_HANDLE
, PUCHAR
, ULONG
, PUCHAR
, ULONG
, ULONGLONG
, PUCHAR
, ULONG
, ULONG
);
248 NTSTATUS WINAPI
BCryptDestroyHash(BCRYPT_HASH_HANDLE
);
249 NTSTATUS WINAPI
BCryptDestroyKey(BCRYPT_KEY_HANDLE
);
250 NTSTATUS WINAPI
BCryptDestroySecret(BCRYPT_SECRET_HANDLE
);
251 NTSTATUS WINAPI
BCryptDuplicateHash(BCRYPT_HASH_HANDLE
, BCRYPT_HASH_HANDLE
*, UCHAR
*, ULONG
, ULONG
);
252 NTSTATUS WINAPI
BCryptEncrypt(BCRYPT_KEY_HANDLE
, PUCHAR
, ULONG
, VOID
*, PUCHAR
, ULONG
, PUCHAR
, ULONG
, ULONG
*, ULONG
);
253 NTSTATUS WINAPI
BCryptEnumAlgorithms(ULONG
, ULONG
*, BCRYPT_ALGORITHM_IDENTIFIER
**, ULONG
);
254 NTSTATUS WINAPI
BCryptFinalizeKeyPair(BCRYPT_KEY_HANDLE
, ULONG
);
255 NTSTATUS WINAPI
BCryptFinishHash(BCRYPT_HASH_HANDLE
, PUCHAR
, ULONG
, ULONG
);
256 NTSTATUS WINAPI
BCryptGenerateKeyPair(BCRYPT_ALG_HANDLE
, BCRYPT_KEY_HANDLE
*, ULONG
, ULONG
);
257 NTSTATUS WINAPI
BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE
, BCRYPT_KEY_HANDLE
*, PUCHAR
, ULONG
, PUCHAR
, ULONG
, ULONG
);
258 NTSTATUS WINAPI
BCryptGenRandom(BCRYPT_ALG_HANDLE
, PUCHAR
, ULONG
, ULONG
);
259 NTSTATUS WINAPI
BCryptGetFipsAlgorithmMode(BOOLEAN
*);
260 NTSTATUS WINAPI
BCryptGetProperty(BCRYPT_HANDLE
, LPCWSTR
, PUCHAR
, ULONG
, ULONG
*, ULONG
);
261 NTSTATUS WINAPI
BCryptHash(BCRYPT_ALG_HANDLE
, PUCHAR
, ULONG
, PUCHAR
, ULONG
, PUCHAR
, ULONG
);
262 NTSTATUS WINAPI
BCryptHashData(BCRYPT_HASH_HANDLE
, PUCHAR
, ULONG
, ULONG
);
263 NTSTATUS WINAPI
BCryptImportKeyPair(BCRYPT_ALG_HANDLE
, BCRYPT_KEY_HANDLE
, LPCWSTR
, BCRYPT_KEY_HANDLE
*, UCHAR
*, ULONG
, ULONG
);
264 NTSTATUS WINAPI
BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE
*, LPCWSTR
, LPCWSTR
, ULONG
);
265 NTSTATUS WINAPI
BCryptSecretAgreement(BCRYPT_KEY_HANDLE
, BCRYPT_KEY_HANDLE
, BCRYPT_SECRET_HANDLE
*, ULONG
);
266 NTSTATUS WINAPI
BCryptSetProperty(BCRYPT_HANDLE
, LPCWSTR
, PUCHAR
, ULONG
, ULONG
);
267 NTSTATUS WINAPI
BCryptVerifySignature(BCRYPT_KEY_HANDLE
, void *, UCHAR
*, ULONG
, UCHAR
*, ULONG
, ULONG
);
269 #endif /* __WINE_BCRYPT_H */