| 1 |
// Licensed under the Apache License, Version 2.0 |
| 2 |
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 3 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. |
| 4 |
// All files in the project carrying such notice may not be copied, modified, or distributed |
| 5 |
// except according to those terms. |
| 6 |
use shared::basetsd::{SIZE_T, ULONG_PTR}; |
| 7 |
use shared::bcrypt::{BCRYPT_NO_KEY_VALIDATION, BCryptBufferDesc}; |
| 8 |
use shared::minwindef::{DWORD, LPVOID, PBYTE}; |
| 9 |
use um::winnt::{LONG, LPCWSTR, VOID}; |
| 10 |
pub type SECURITY_STATUS = LONG; |
| 11 |
pub type HCRYPTPROV = ULONG_PTR; |
| 12 |
pub type HCRYPTKEY = ULONG_PTR; |
| 13 |
pub type HCRYPTHASH = ULONG_PTR; |
| 14 |
FN!{stdcall PFN_NCRYPT_ALLOC( |
| 15 |
cbSize: SIZE_T, |
| 16 |
) -> LPVOID} |
| 17 |
FN!{stdcall PFN_NCRYPT_FREE( |
| 18 |
pv: LPVOID, |
| 19 |
) -> VOID} |
| 20 |
STRUCT!{struct NCRYPT_ALLOC_PARA { |
| 21 |
cbSize: DWORD, |
| 22 |
pfnAlloc: PFN_NCRYPT_ALLOC, |
| 23 |
pfnFree: PFN_NCRYPT_FREE, |
| 24 |
}} |
| 25 |
pub type NCryptBufferDesc = BCryptBufferDesc; |
| 26 |
pub type NCRYPT_HANDLE = ULONG_PTR; |
| 27 |
pub type NCRYPT_PROV_HANDLE = ULONG_PTR; |
| 28 |
pub type NCRYPT_KEY_HANDLE = ULONG_PTR; |
| 29 |
pub type NCRYPT_HASH_HANDLE = ULONG_PTR; |
| 30 |
pub type NCRYPT_SECRET_HANDLE = ULONG_PTR; |
| 31 |
pub const NCRYPT_NO_PADDING_FLAG: DWORD = 0x00000001; |
| 32 |
pub const NCRYPT_PAD_PKCS1_FLAG: DWORD = 0x00000002; |
| 33 |
pub const NCRYPT_PAD_OAEP_FLAG: DWORD = 0x00000004; |
| 34 |
pub const NCRYPT_PAD_PSS_FLAG: DWORD = 0x00000008; |
| 35 |
pub const NCRYPT_PAD_CIPHER_FLAG: DWORD = 0x00000010; |
| 36 |
pub const NCRYPT_ATTESTATION_FLAG: DWORD = 0x00000020; |
| 37 |
pub const NCRYPT_SEALING_FLAG: DWORD = 0x00000100; |
| 38 |
pub const NCRYPT_REGISTER_NOTIFY_FLAG: DWORD = 0x00000001; |
| 39 |
pub const NCRYPT_UNREGISTER_NOTIFY_FLAG: DWORD = 0x00000002; |
| 40 |
pub const NCRYPT_NO_KEY_VALIDATION: DWORD = BCRYPT_NO_KEY_VALIDATION; |
| 41 |
pub const NCRYPT_MACHINE_KEY_FLAG: DWORD = 0x00000020; |
| 42 |
pub const NCRYPT_SILENT_FLAG: DWORD = 0x00000040; |
| 43 |
pub const NCRYPT_OVERWRITE_KEY_FLAG: DWORD = 0x00000080; |
| 44 |
pub const NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG: DWORD = 0x00000200; |
| 45 |
pub const NCRYPT_DO_NOT_FINALIZE_FLAG: DWORD = 0x00000400; |
| 46 |
pub const NCRYPT_EXPORT_LEGACY_FLAG: DWORD = 0x00000800; |
| 47 |
pub const NCRYPT_IGNORE_DEVICE_STATE_FLAG: DWORD = 0x00001000; |
| 48 |
pub const NCRYPT_TREAT_NIST_AS_GENERIC_ECC_FLAG: DWORD = 0x00002000; |
| 49 |
pub const NCRYPT_NO_CACHED_PASSWORD: DWORD = 0x00004000; |
| 50 |
pub const NCRYPT_PROTECT_TO_LOCAL_SYSTEM: DWORD = 0x00008000; |
| 51 |
pub const NCRYPT_PERSIST_ONLY_FLAG: DWORD = 0x40000000; |
| 52 |
pub const NCRYPT_PERSIST_FLAG: DWORD = 0x80000000; |
| 53 |
pub const NCRYPT_PREFER_VIRTUAL_ISOLATION_FLAG: DWORD = 0x00010000; |
| 54 |
pub const NCRYPT_USE_VIRTUAL_ISOLATION_FLAG: DWORD = 0x00020000; |
| 55 |
pub const NCRYPT_USE_PER_BOOT_KEY_FLAG: DWORD = 0x00040000; |
| 56 |
extern "system" { |
| 57 |
pub fn NCryptOpenStorageProvider( |
| 58 |
phProvider: *mut NCRYPT_PROV_HANDLE, |
| 59 |
pszProviderName: LPCWSTR, |
| 60 |
dwFlags: DWORD, |
| 61 |
) -> SECURITY_STATUS; |
| 62 |
} |
| 63 |
pub const NCRYPT_ALLOW_EXPORT_FLAG: DWORD = 0x00000001; |
| 64 |
pub const NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG: DWORD = 0x00000002; |
| 65 |
pub const NCRYPT_ALLOW_ARCHIVING_FLAG: DWORD = 0x00000004; |
| 66 |
pub const NCRYPT_ALLOW_PLAINTEXT_ARCHIVING_FLAG: DWORD = 0x00000008; |
| 67 |
extern "system" { |
| 68 |
pub fn NCryptSetProperty( |
| 69 |
hObject: NCRYPT_HANDLE, |
| 70 |
pszProperty: LPCWSTR, |
| 71 |
pbInput: PBYTE, |
| 72 |
cbInput: DWORD, |
| 73 |
dwFlags: DWORD, |
| 74 |
) -> SECURITY_STATUS; |
| 75 |
pub fn NCryptImportKey( |
| 76 |
hProvider: NCRYPT_PROV_HANDLE, |
| 77 |
hImportKey: NCRYPT_KEY_HANDLE, |
| 78 |
pszBlobType: LPCWSTR, |
| 79 |
pParameterList: *const NCryptBufferDesc, |
| 80 |
phKey: *mut NCRYPT_KEY_HANDLE, |
| 81 |
pbData: PBYTE, |
| 82 |
cbData: DWORD, |
| 83 |
dwFlags: DWORD, |
| 84 |
) -> SECURITY_STATUS; |
| 85 |
pub fn NCryptFreeObject( |
| 86 |
hObject: NCRYPT_HANDLE, |
| 87 |
) -> SECURITY_STATUS; |
| 88 |
} |