1 /* 2 * Copyright (C) 2007 Francois Gouget 3 * 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. 8 * 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. 13 * 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 17 */ 18 19 #ifndef __WINE_BCRYPT_H 20 #define __WINE_BCRYPT_H 21 22 #ifndef WINAPI 23 #define WINAPI __stdcall 24 #endif 25 26 #ifndef IN 27 #define IN 28 #endif 29 30 #ifndef OUT 31 #define OUT 32 #endif 33 34 #ifndef OPTIONAL 35 #define OPTIONAL 36 #endif 37 38 #ifndef _NTDEF_ 39 typedef _Return_type_success_(return >= 0) LONG NTSTATUS; 40 typedef NTSTATUS *PNTSTATUS; 41 #endif 42 43 #define BCRYPT_ALGORITHM_NAME L"AlgorithmName" 44 #define BCRYPT_AUTH_TAG_LENGTH L"AuthTagLength" 45 #define BCRYPT_BLOCK_LENGTH L"BlockLength" 46 #define BCRYPT_BLOCK_SIZE_LIST L"BlockSizeList" 47 #define BCRYPT_CHAINING_MODE L"ChainingMode" 48 #define BCRYPT_EFFECTIVE_KEY_LENGTH L"EffectiveKeyLength" 49 #define BCRYPT_HASH_BLOCK_LENGTH L"HashBlockLength" 50 #define BCRYPT_HASH_LENGTH L"HashDigestLength" 51 #define BCRYPT_HASH_OID_LIST L"HashOIDList" 52 #define BCRYPT_KEY_LENGTH L"KeyLength" 53 #define BCRYPT_KEY_LENGTHS L"KeyLengths" 54 #define BCRYPT_KEY_OBJECT_LENGTH L"KeyObjectLength" 55 #define BCRYPT_KEY_STRENGTH L"KeyStrength" 56 #define BCRYPT_OBJECT_LENGTH L"ObjectLength" 57 #define BCRYPT_PADDING_SCHEMES L"PaddingSchemes" 58 #define BCRYPT_PROVIDER_HANDLE L"ProviderHandle" 59 #define BCRYPT_SIGNATURE_LENGTH L"SignatureLength" 60 61 #define BCRYPT_OPAQUE_KEY_BLOB L"OpaqueKeyBlob" 62 #define BCRYPT_KEY_DATA_BLOB L"KeyDataBlob" 63 #define BCRYPT_AES_WRAP_KEY_BLOB L"Rfc3565KeyWrapBlob" 64 #define BCRYPT_ECCPUBLIC_BLOB L"ECCPUBLICBLOB" 65 #define BCRYPT_ECCPRIVATE_BLOB L"ECCPRIVATEBLOB" 66 #define BCRYPT_RSAPUBLIC_BLOB L"RSAPUBLICBLOB" 67 #define BCRYPT_RSAPRIVATE_BLOB L"RSAPRIVATEBLOB" 68 69 #define MS_PRIMITIVE_PROVIDER L"Microsoft Primitive Provider" 70 #define MS_PLATFORM_CRYPTO_PROVIDER L"Microsoft Platform Crypto Provider" 71 72 #define BCRYPT_MD5_ALGORITHM L"MD5" 73 #define BCRYPT_RNG_ALGORITHM L"RNG" 74 #define BCRYPT_SHA1_ALGORITHM L"SHA1" 75 #define BCRYPT_SHA256_ALGORITHM L"SHA256" 76 #define BCRYPT_SHA384_ALGORITHM L"SHA384" 77 #define BCRYPT_SHA512_ALGORITHM L"SHA512" 78 #define BCRYPT_ECDSA_P256_ALGORITHM L"ECDSA_P256" 79 #define BCRYPT_ECDSA_P384_ALGORITHM L"ECDSA_P384" 80 #define BCRYPT_ECDSA_P521_ALGORITHM L"ECDSA_P521" 81 82 #define BCRYPT_ECDSA_PUBLIC_P256_MAGIC 0x31534345 83 #define BCRYPT_ECDSA_PRIVATE_P256_MAGIC 0x32534345 84 #define BCRYPT_ECDSA_PUBLIC_P384_MAGIC 0x33534345 85 #define BCRYPT_ECDSA_PRIVATE_P384_MAGIC 0x34534345 86 #define BCRYPT_ECDSA_PUBLIC_P521_MAGIC 0x35534345 87 #define BCRYPT_ECDSA_PRIVATE_P521_MAGIC 0x36534345 88 89 typedef struct _BCRYPT_ALGORITHM_IDENTIFIER 90 { 91 LPWSTR pszName; 92 ULONG dwClass; 93 ULONG dwFlags; 94 } BCRYPT_ALGORITHM_IDENTIFIER; 95 96 typedef struct __BCRYPT_KEY_LENGTHS_STRUCT 97 { 98 ULONG dwMinLength; 99 ULONG dwMaxLength; 100 ULONG dwIncrement; 101 } BCRYPT_KEY_LENGTHS_STRUCT, BCRYPT_AUTH_TAG_LENGTHS_STRUCT; 102 103 typedef struct _BCRYPT_KEY_DATA_BLOB_HEADER 104 { 105 ULONG dwMagic; 106 ULONG dwVersion; 107 ULONG cbKeyData; 108 } BCRYPT_KEY_DATA_BLOB_HEADER, *PBCRYPT_KEY_DATA_BLOB_HEADER; 109 110 typedef struct _BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO 111 { 112 ULONG cbSize; 113 ULONG dwInfoVersion; 114 UCHAR *pbNonce; 115 ULONG cbNonce; 116 UCHAR *pbAuthData; 117 ULONG cbAuthData; 118 UCHAR *pbTag; 119 ULONG cbTag; 120 UCHAR *pbMacContext; 121 ULONG cbMacContext; 122 ULONG cbAAD; 123 ULONGLONG cbData; 124 ULONG dwFlags; 125 } BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO, *PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO; 126 127 typedef struct _BCRYPT_ECCKEY_BLOB 128 { 129 ULONG dwMagic; 130 ULONG cbKey; 131 } BCRYPT_ECCKEY_BLOB, *PBCRYPT_ECCKEY_BLOB; 132 133 #define BCRYPT_RSAPUBLIC_MAGIC 0x31415352 134 #define BCRYPT_RSAPRIVATE_MAGIC 0x32415352 135 #define BCRYPT_RSAFULLPRIVATE_MAGIC 0x33415352 136 137 typedef struct _BCRYPT_RSAKEY_BLOB 138 { 139 ULONG Magic; 140 ULONG BitLength; 141 ULONG cbPublicExp; 142 ULONG cbModulus; 143 ULONG cbPrime1; 144 ULONG cbPrime2; 145 } BCRYPT_RSAKEY_BLOB; 146 147 typedef struct _BCRYPT_PKCS1_PADDING_INFO 148 { 149 LPCWSTR pszAlgId; 150 } BCRYPT_PKCS1_PADDING_INFO; 151 152 #define BCRYPT_PAD_NONE 0x00000001 153 #define BCRYPT_PAD_PKCS1 0x00000002 154 #define BCRYPT_PAD_OAEP 0x00000004 155 #define BCRYPT_PAD_PSS 0x00000008 156 157 #define BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION 1 158 159 #define BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG 0x00000001 160 #define BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG 0x00000002 161 162 #define BCRYPT_KEY_DATA_BLOB_MAGIC 0x4d42444b 163 #define BCRYPT_KEY_DATA_BLOB_VERSION1 1 164 165 typedef PVOID BCRYPT_ALG_HANDLE; 166 typedef PVOID BCRYPT_KEY_HANDLE; 167 typedef PVOID BCRYPT_HANDLE; 168 typedef PVOID BCRYPT_HASH_HANDLE; 169 170 #define BCRYPT_RNG_USE_ENTROPY_IN_BUFFER 0x00000001 171 #define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002 172 #define BCRYPT_ALG_HANDLE_HMAC_FLAG 0x00000008 173 174 NTSTATUS WINAPI BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE, ULONG); 175 NTSTATUS WINAPI BCryptCreateHash(BCRYPT_ALG_HANDLE, BCRYPT_HASH_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG); 176 NTSTATUS WINAPI BCryptDecrypt(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG); 177 NTSTATUS WINAPI BCryptDestroyHash(BCRYPT_HASH_HANDLE); 178 NTSTATUS WINAPI BCryptDestroyKey(BCRYPT_KEY_HANDLE); 179 NTSTATUS WINAPI BCryptEncrypt(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG); 180 NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG, ULONG *, BCRYPT_ALGORITHM_IDENTIFIER **, ULONG); 181 NTSTATUS WINAPI BCryptFinishHash(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG); 182 NTSTATUS WINAPI BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG); 183 NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, ULONG); 184 NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *); 185 NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG *, ULONG); 186 NTSTATUS WINAPI BCryptHash(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, PUCHAR, ULONG, PUCHAR, ULONG); 187 NTSTATUS WINAPI BCryptHashData(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG); 188 NTSTATUS WINAPI BCryptImportKeyPair(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, BCRYPT_KEY_HANDLE *, UCHAR *, ULONG, ULONG); 189 NTSTATUS WINAPI BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE *, LPCWSTR, LPCWSTR, ULONG); 190 NTSTATUS WINAPI BCryptSetProperty(BCRYPT_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG); 191 NTSTATUS WINAPI BCryptDuplicateHash(BCRYPT_HASH_HANDLE, BCRYPT_HASH_HANDLE *, UCHAR *, ULONG, ULONG); 192 NTSTATUS WINAPI BCryptVerifySignature(BCRYPT_KEY_HANDLE, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG); 193 194 #endif /* __WINE_BCRYPT_H */ 195