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 //! Data Protection API Prototypes and Definitions 7 use shared::minwindef::{BOOL, BYTE, DWORD, LPVOID}; 8 use shared::windef::HWND; 9 use um::wincrypt::DATA_BLOB; 10 use um::winnt::{LPCWSTR, LPWSTR, PSID, PVOID}; 11 pub const szFORCE_KEY_PROTECTION: &'static str = "ForceKeyProtection"; 12 pub const dwFORCE_KEY_PROTECTION_DISABLED: DWORD = 0x0; 13 pub const dwFORCE_KEY_PROTECTION_USER_SELECT: DWORD = 0x1; 14 pub const dwFORCE_KEY_PROTECTION_HIGH: DWORD = 0x2; 15 STRUCT!{struct CRYPTPROTECT_PROMPTSTRUCT { 16 cbSize: DWORD, 17 dwPromptFlags: DWORD, 18 hwndApp: HWND, 19 szPrompt: LPCWSTR, 20 }} 21 pub type PCRYPTPROTECT_PROMPTSTRUCT = *mut CRYPTPROTECT_PROMPTSTRUCT; 22 pub const CRYPTPROTECT_PROMPT_ON_UNPROTECT: DWORD = 0x1; 23 pub const CRYPTPROTECT_PROMPT_ON_PROTECT: DWORD = 0x2; 24 pub const CRYPTPROTECT_PROMPT_RESERVED: DWORD = 0x04; 25 pub const CRYPTPROTECT_PROMPT_STRONG: DWORD = 0x08; 26 pub const CRYPTPROTECT_PROMPT_REQUIRE_STRONG: DWORD = 0x10; 27 pub const CRYPTPROTECT_UI_FORBIDDEN: DWORD = 0x1; 28 pub const CRYPTPROTECT_LOCAL_MACHINE: DWORD = 0x4; 29 pub const CRYPTPROTECT_CRED_SYNC: DWORD = 0x8; 30 pub const CRYPTPROTECT_AUDIT: DWORD = 0x10; 31 pub const CRYPTPROTECT_NO_RECOVERY: DWORD = 0x20; 32 pub const CRYPTPROTECT_VERIFY_PROTECTION: DWORD = 0x40; 33 pub const CRYPTPROTECT_CRED_REGENERATE: DWORD = 0x80; 34 pub const CRYPTPROTECT_FIRST_RESERVED_FLAGVAL: DWORD = 0x0FFFFFFF; 35 pub const CRYPTPROTECT_LAST_RESERVED_FLAGVAL: DWORD = 0xFFFFFFFF; 36 extern "system" { CryptProtectData( pDataIn: *mut DATA_BLOB, szDataDescr: LPCWSTR, pOptionalEntropy: *mut DATA_BLOB, pvReserved: PVOID, pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, dwFlags: DWORD, pDataOut: *mut DATA_BLOB, ) -> BOOL37 pub fn CryptProtectData( 38 pDataIn: *mut DATA_BLOB, 39 szDataDescr: LPCWSTR, 40 pOptionalEntropy: *mut DATA_BLOB, 41 pvReserved: PVOID, 42 pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, 43 dwFlags: DWORD, 44 pDataOut: *mut DATA_BLOB, 45 ) -> BOOL; CryptUnprotectData( pDataIn: *mut DATA_BLOB, ppszDataDescr: *mut LPWSTR, pOptionalEntropy: *mut DATA_BLOB, pvReserved: PVOID, pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, dwFlags: DWORD, pDataOut: *mut DATA_BLOB, ) -> BOOL46 pub fn CryptUnprotectData( 47 pDataIn: *mut DATA_BLOB, 48 ppszDataDescr: *mut LPWSTR, 49 pOptionalEntropy: *mut DATA_BLOB, 50 pvReserved: PVOID, 51 pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, 52 dwFlags: DWORD, 53 pDataOut: *mut DATA_BLOB, 54 ) -> BOOL; CryptProtectDataNoUI( pDataIn: *mut DATA_BLOB, szDataDescr: LPCWSTR, pOptionalEntropy: *mut DATA_BLOB, pvReserved: PVOID, pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, dwFlags: DWORD, pbOptionalPassword: *const BYTE, cbOptionalPassword: DWORD, pDataOut: *mut DATA_BLOB, ) -> BOOL55 pub fn CryptProtectDataNoUI( 56 pDataIn: *mut DATA_BLOB, 57 szDataDescr: LPCWSTR, 58 pOptionalEntropy: *mut DATA_BLOB, 59 pvReserved: PVOID, 60 pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, 61 dwFlags: DWORD, 62 pbOptionalPassword: *const BYTE, 63 cbOptionalPassword: DWORD, 64 pDataOut: *mut DATA_BLOB, 65 ) -> BOOL; CryptUnprotectDataNoUI( pDataIn: *mut DATA_BLOB, ppszDataDescr: *mut LPWSTR, pOptionalEntropy: *mut DATA_BLOB, pvReserved: PVOID, pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, dwFlags: DWORD, pbOptionalPassword: *const BYTE, cbOptionalPassword: DWORD, pDataOut: *mut DATA_BLOB, ) -> BOOL66 pub fn CryptUnprotectDataNoUI( 67 pDataIn: *mut DATA_BLOB, 68 ppszDataDescr: *mut LPWSTR, 69 pOptionalEntropy: *mut DATA_BLOB, 70 pvReserved: PVOID, 71 pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT, 72 dwFlags: DWORD, 73 pbOptionalPassword: *const BYTE, 74 cbOptionalPassword: DWORD, 75 pDataOut: *mut DATA_BLOB, 76 ) -> BOOL; CryptUpdateProtectedState( pOldSid: PSID, pwszOldPassword: LPCWSTR, dwFlags: DWORD, pdwSuccessCount: *mut DWORD, pdwFailureCount: *mut DWORD, ) -> BOOL77 pub fn CryptUpdateProtectedState( 78 pOldSid: PSID, 79 pwszOldPassword: LPCWSTR, 80 dwFlags: DWORD, 81 pdwSuccessCount: *mut DWORD, 82 pdwFailureCount: *mut DWORD, 83 ) -> BOOL; 84 } 85 pub const CRYPTPROTECTMEMORY_BLOCK_SIZE: DWORD = 16; 86 pub const CRYPTPROTECTMEMORY_SAME_PROCESS: DWORD = 0x00; 87 pub const CRYPTPROTECTMEMORY_CROSS_PROCESS: DWORD = 0x01; 88 pub const CRYPTPROTECTMEMORY_SAME_LOGON: DWORD = 0x02; 89 extern "system" { CryptProtectMemory( pDataIn: LPVOID, cbDataIn: DWORD, dwFlags: DWORD, ) -> BOOL90 pub fn CryptProtectMemory( 91 pDataIn: LPVOID, 92 cbDataIn: DWORD, 93 dwFlags: DWORD, 94 ) -> BOOL; CryptUnprotectMemory( pDataIn: LPVOID, cbDataIn: DWORD, dwFlags: DWORD, ) -> BOOL95 pub fn CryptUnprotectMemory( 96 pDataIn: LPVOID, 97 cbDataIn: DWORD, 98 dwFlags: DWORD, 99 ) -> BOOL; 100 } 101