1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #ifndef _INC_NCRYPT 7 #define _INC_NCRYPT 8 #if (_WIN32_WINNT >= 0x0600) 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #define NCRYPTBUFFER_SSL_CLIENT_RANDOM 20 15 #define NCRYPTBUFFER_SSL_SERVER_RANDOM 21 16 #define NCRYPTBUFFER_SSL_HIGHEST_VERSION 22 17 #define NCRYPTBUFFER_SSL_CLEAR_KEY 23 18 #define NCRYPTBUFFER_SSL_KEY_ARG_DATA 24 19 #define NCRYPTBUFFER_PKCS_OID 40 20 #define NCRYPTBUFFER_PKCS_ALG_OID 41 21 #define NCRYPTBUFFER_PKCS_ALG_PARAM 42 22 #define NCRYPTBUFFER_PKCS_ALG_ID 43 23 #define NCRYPTBUFFER_PKCS_ATTRS 44 24 #define NCRYPTBUFFER_PKCS_KEY_NAME 45 25 #define NCRYPTBUFFER_PKCS_SECRET 46 26 #define NCRYPTBUFFER_CERT_BLOB 47 27 28 #ifndef __SECSTATUS_DEFINED__ 29 typedef LONG SECURITY_STATUS; 30 #define __SECSTATUS_DEFINED__ 31 #endif 32 33 #ifndef __NCRYPT_KEY_HANDLE__ 34 #define __NCRYPT_KEY_HANDLE__ 35 /*in wincrypt.h too*/ 36 typedef ULONG_PTR NCRYPT_KEY_HANDLE; 37 #endif 38 39 typedef ULONG_PTR NCRYPT_PROV_HANDLE; 40 typedef ULONG_PTR NCRYPT_SECRET_HANDLE; 41 typedef ULONG_PTR NCRYPT_HANDLE; 42 43 #ifndef __HCRYPTKEY__ 44 #define __HCRYPTKEY__ 45 /* In wincrypt.h too */ 46 typedef ULONG_PTR HCRYPTPROV; 47 typedef ULONG_PTR HCRYPTKEY; 48 #endif 49 50 typedef struct _NCryptBuffer { 51 ULONG cbBuffer; 52 ULONG BufferType; 53 PVOID pvBuffer; 54 } NCryptBuffer, *PNCryptBuffer; 55 56 typedef struct _NCryptBufferDesc { 57 ULONG ulVersion; 58 ULONG cBuffers; 59 PNCryptBuffer pBuffers; 60 } NCryptBufferDesc, *PNCryptBufferDesc; 61 62 typedef struct __NCRYPT_SUPPORTED_LENGTHS { 63 DWORD dwMinLength; 64 DWORD dwMaxLength; 65 DWORD dwIncrement; 66 DWORD dwDefaultLength; 67 } NCRYPT_SUPPORTED_LENGTHS; 68 69 #define NCRYPT_UI_PROTECT_KEY_FLAG 0x00000001 70 #define NCRYPT_UI_FORCE_HIGH_PROTECTION_FLAG 0x00000002 71 72 typedef struct __NCRYPT_UI_POLICY { 73 DWORD dwVersion; 74 DWORD dwFlags; 75 LPCWSTR pszCreationTitle; 76 LPCWSTR pszFriendlyName; 77 LPCWSTR pszDescription; 78 } NCRYPT_UI_POLICY; 79 80 typedef struct __NCRYPT_UI_POLICY_BLOB { 81 DWORD dwVersion; 82 DWORD dwFlags; 83 DWORD cbCreationTitle; 84 DWORD cbFriendlyName; 85 DWORD cbDescription; 86 } NCRYPT_UI_POLICY_BLOB; 87 88 typedef struct NCryptKeyName { 89 LPWSTR pszName; 90 LPWSTR pszAlgid; 91 DWORD dwLegacyKeySpec; 92 DWORD dwFlags; 93 } NCryptKeyName; 94 95 #define NCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE 0x00000003 96 #define NCRYPT_SECRET_AGREEMENT_INTERFACE 0x00000004 97 #define NCRYPT_SIGNATURE_INTERFACE 0x00000005 98 99 #define NCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION 0x00000004 100 #define NCRYPT_SECRET_AGREEMENT_OPERATION 0x00000008 101 #define NCRYPT_SIGNATURE_OPERATION 0x00000010 102 103 typedef struct _NCryptAlgorithmName { 104 LPWSTR pszName; 105 DWORD dwClass; 106 DWORD dwAlgOperations; 107 DWORD dwFlags; 108 } NCryptAlgorithmName; 109 110 typedef struct NCryptProviderName { 111 LPWSTR pszName; 112 LPWSTR pszComment; 113 } NCryptProviderName; 114 115 SECURITY_STATUS WINAPI NCryptExportKey( 116 NCRYPT_KEY_HANDLE hKey, 117 NCRYPT_KEY_HANDLE hExportKey, 118 LPCWSTR pszBlobType, 119 NCryptBufferDesc *pParameterList, 120 PBYTE pbOutput, 121 DWORD cbOutput, 122 DWORD *pcbResult, 123 DWORD dwFlags 124 ); 125 126 SECURITY_STATUS WINAPI NCryptCreatePersistedKey( 127 NCRYPT_PROV_HANDLE hProvider, 128 NCRYPT_KEY_HANDLE *phKey, 129 LPCWSTR pszAlgId, 130 LPCWSTR pszKeyName, 131 DWORD dwLegacyKeySpec, 132 DWORD dwFlags 133 ); 134 135 SECURITY_STATUS WINAPI NCryptDecrypt( 136 NCRYPT_KEY_HANDLE hKey, 137 PBYTE pbInput, 138 DWORD cbInput, 139 VOID *pPaddingInfo, 140 PBYTE pbOutput, 141 DWORD cbOutput, 142 DWORD *pcbResult, 143 DWORD dwFlags 144 ); 145 146 SECURITY_STATUS WINAPI NCryptDeleteKey( 147 NCRYPT_KEY_HANDLE hKey, 148 DWORD dwFlags 149 ); 150 151 SECURITY_STATUS WINAPI NCryptDeriveKey( 152 NCRYPT_SECRET_HANDLE hSharedSecret, 153 LPCWSTR pwszKDF, 154 NCryptBufferDesc *pParameterList, 155 PBYTE pbDerivedKey, 156 DWORD cbDerivedKey, 157 DWORD *pcbResult, 158 ULONG dwFlags 159 ); 160 161 SECURITY_STATUS WINAPI NCryptEncrypt( 162 NCRYPT_KEY_HANDLE hKey, 163 PBYTE pbInput, 164 DWORD cbInput, 165 VOID *pPaddingInfo, 166 PBYTE pbOutput, 167 DWORD cbOutput, 168 DWORD *pcbResult, 169 DWORD dwFlags 170 ); 171 172 #define NCRYPT_CIPHER_OPERATION 0x00000001 173 #define NCRYPT_HASH_OPERATION 0x00000002 174 #define NCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION 0x00000004 175 #define NCRYPT_SECRET_AGREEMENT_OPERATION 0x00000008 176 #define NCRYPT_SIGNATURE_OPERATION 0x00000010 177 #define NCRYPT_RNG_OPERATION 0x00000020 178 179 SECURITY_STATUS WINAPI NCryptEnumAlgorithms( 180 NCRYPT_PROV_HANDLE hProvider, 181 DWORD dwAlgOperations, 182 DWORD *pdwAlgCount, 183 NCryptAlgorithmName **ppAlgList, 184 DWORD dwFlags 185 ); 186 187 SECURITY_STATUS WINAPI NCryptEnumKeys( 188 NCRYPT_PROV_HANDLE hProvider, 189 LPCWSTR pszScope, 190 NCryptKeyName **ppKeyName, 191 PVOID *ppEnumState, 192 DWORD dwFlags 193 ); 194 195 SECURITY_STATUS WINAPI NCryptEnumStorageProviders( 196 DWORD *pdwProviderCount, 197 NCryptProviderName **ppProviderList, 198 DWORD dwFlags 199 ); 200 201 SECURITY_STATUS NCryptFinalizeKey( 202 NCRYPT_KEY_HANDLE hKey, 203 DWORD dwFlags 204 ); 205 206 SECURITY_STATUS WINAPI NCryptFreeBuffer( 207 PVOID pvInput 208 ); 209 210 SECURITY_STATUS WINAPI NCryptFreeObject( 211 NCRYPT_HANDLE hObject 212 ); 213 214 SECURITY_STATUS WINAPI NCryptGetProperty( 215 NCRYPT_HANDLE hObject, 216 LPCWSTR pszProperty, 217 PBYTE pbOutput, 218 DWORD cbOutput, 219 DWORD *pcbResult, 220 DWORD dwFlags 221 ); 222 223 SECURITY_STATUS WINAPI NCryptImportKey( 224 NCRYPT_PROV_HANDLE hProvider, 225 NCRYPT_KEY_HANDLE hImportKey, 226 LPCWSTR pszBlobType, 227 NCryptBufferDesc *pParameterList, 228 NCRYPT_KEY_HANDLE *phKey, 229 PBYTE pbData, 230 DWORD cbData, 231 DWORD dwFlags 232 ); 233 234 SECURITY_STATUS WINAPI NCryptIsAlgSupported( 235 NCRYPT_PROV_HANDLE hProvider, 236 LPCWSTR pszAlgId, 237 DWORD dwFlags 238 ); 239 240 WINBOOL WINAPI NCryptIsKeyHandle( 241 NCRYPT_KEY_HANDLE hKey 242 ); 243 244 SECURITY_STATUS WINAPI NCryptNotifyChangeKey( 245 NCRYPT_PROV_HANDLE hProvider, 246 HANDLE *phEvent, 247 DWORD dwFlags 248 ); 249 250 SECURITY_STATUS WINAPI NCryptOpenKey( 251 NCRYPT_PROV_HANDLE hProvider, 252 NCRYPT_KEY_HANDLE *phKey, 253 LPCWSTR pszKeyName, 254 DWORD dwLegacyKeySpec, 255 DWORD dwFlags 256 ); 257 258 SECURITY_STATUS WINAPI NCryptOpenStorageProvider( 259 NCRYPT_PROV_HANDLE *phProvider, 260 LPCWSTR pszProviderName, 261 DWORD dwFlags 262 ); 263 264 SECURITY_STATUS WINAPI NCryptSecretAgreement( 265 NCRYPT_KEY_HANDLE hPrivKey, 266 NCRYPT_KEY_HANDLE hPubKey, 267 NCRYPT_SECRET_HANDLE *phSecret, 268 DWORD dwFlags 269 ); 270 271 SECURITY_STATUS WINAPI NCryptSetProperty( 272 NCRYPT_HANDLE hObject, 273 LPCWSTR pszProperty, 274 PBYTE pbInput, 275 DWORD cbInput, 276 DWORD dwFlags 277 ); 278 279 SECURITY_STATUS WINAPI NCryptSignHash( 280 NCRYPT_KEY_HANDLE hKey, 281 VOID *pPaddingInfo, 282 PBYTE pbHashValue, 283 DWORD cbHashValue, 284 PBYTE pbSignature, 285 DWORD cbSignature, 286 DWORD *pcbResult, 287 DWORD dwFlags 288 ); 289 290 SECURITY_STATUS WINAPI NCryptTranslateHandle( 291 NCRYPT_PROV_HANDLE *phProvider, 292 NCRYPT_KEY_HANDLE *phKey, 293 HCRYPTPROV hLegacyProv, 294 HCRYPTKEY hLegacyKey, 295 DWORD dwLegacyKeySpec, 296 DWORD dwFlags 297 ); 298 299 SECURITY_STATUS WINAPI NCryptVerifySignature( 300 NCRYPT_KEY_HANDLE hKey, 301 VOID *pPaddingInfo, 302 PBYTE pbHashValue, 303 DWORD cbHashValue, 304 PBYTE pbSignature, 305 DWORD cbSignature, 306 DWORD dwFlags 307 ); 308 309 #ifdef __cplusplus 310 } 311 #endif 312 #endif /*(_WIN32_WINNT >= 0x0600)*/ 313 #endif /*_INC_NCRYPT*/ 314