1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
//! Data Protection API Prototypes and Definitions
use shared::minwindef::{BOOL, BYTE, DWORD, LPVOID};
use shared::windef::HWND;
use um::wincrypt::DATA_BLOB;
use um::winnt::{LPCWSTR, LPWSTR, PSID, PVOID};
pub const szFORCE_KEY_PROTECTION: &'static str = "ForceKeyProtection";
pub const dwFORCE_KEY_PROTECTION_DISABLED: DWORD = 0x0;
pub const dwFORCE_KEY_PROTECTION_USER_SELECT: DWORD = 0x1;
pub const dwFORCE_KEY_PROTECTION_HIGH: DWORD = 0x2;
STRUCT!{struct CRYPTPROTECT_PROMPTSTRUCT {
cbSize: DWORD,
dwPromptFlags: DWORD,
hwndApp: HWND,
szPrompt: LPCWSTR,
}}
pub type PCRYPTPROTECT_PROMPTSTRUCT = *mut CRYPTPROTECT_PROMPTSTRUCT;
pub const CRYPTPROTECT_PROMPT_ON_UNPROTECT: DWORD = 0x1;
pub const CRYPTPROTECT_PROMPT_ON_PROTECT: DWORD = 0x2;
pub const CRYPTPROTECT_PROMPT_RESERVED: DWORD = 0x04;
pub const CRYPTPROTECT_PROMPT_STRONG: DWORD = 0x08;
pub const CRYPTPROTECT_PROMPT_REQUIRE_STRONG: DWORD = 0x10;
pub const CRYPTPROTECT_UI_FORBIDDEN: DWORD = 0x1;
pub const CRYPTPROTECT_LOCAL_MACHINE: DWORD = 0x4;
pub const CRYPTPROTECT_CRED_SYNC: DWORD = 0x8;
pub const CRYPTPROTECT_AUDIT: DWORD = 0x10;
pub const CRYPTPROTECT_NO_RECOVERY: DWORD = 0x20;
pub const CRYPTPROTECT_VERIFY_PROTECTION: DWORD = 0x40;
pub const CRYPTPROTECT_CRED_REGENERATE: DWORD = 0x80;
pub const CRYPTPROTECT_FIRST_RESERVED_FLAGVAL: DWORD = 0x0FFFFFFF;
pub const CRYPTPROTECT_LAST_RESERVED_FLAGVAL: DWORD = 0xFFFFFFFF;
extern "system" {
pub fn CryptProtectData(
pDataIn: *mut DATA_BLOB,
szDataDescr: LPCWSTR,
pOptionalEntropy: *mut DATA_BLOB,
pvReserved: PVOID,
pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT,
dwFlags: DWORD,
pDataOut: *mut DATA_BLOB,
) -> BOOL;
pub fn CryptUnprotectData(
pDataIn: *mut DATA_BLOB,
ppszDataDescr: *mut LPWSTR,
pOptionalEntropy: *mut DATA_BLOB,
pvReserved: PVOID,
pPromptStruct: *mut CRYPTPROTECT_PROMPTSTRUCT,
dwFlags: DWORD,
pDataOut: *mut DATA_BLOB,
) -> BOOL;
pub fn 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,
) -> BOOL;
pub fn 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,
) -> BOOL;
pub fn CryptUpdateProtectedState(
pOldSid: PSID,
pwszOldPassword: LPCWSTR,
dwFlags: DWORD,
pdwSuccessCount: *mut DWORD,
pdwFailureCount: *mut DWORD,
) -> BOOL;
}
pub const CRYPTPROTECTMEMORY_BLOCK_SIZE: DWORD = 16;
pub const CRYPTPROTECTMEMORY_SAME_PROCESS: DWORD = 0x00;
pub const CRYPTPROTECTMEMORY_CROSS_PROCESS: DWORD = 0x01;
pub const CRYPTPROTECTMEMORY_SAME_LOGON: DWORD = 0x02;
extern "system" {
pub fn CryptProtectMemory(
pDataIn: LPVOID,
cbDataIn: DWORD,
dwFlags: DWORD,
) -> BOOL;
pub fn CryptUnprotectMemory(
pDataIn: LPVOID,
cbDataIn: DWORD,
dwFlags: DWORD,
) -> BOOL;
}
|