FreeRDP
include/winpr/ncrypt.h
1 
20 #ifndef WINPR_INCLUDE_WINPR_NCRYPT_H_
21 #define WINPR_INCLUDE_WINPR_NCRYPT_H_
22 
23 #ifdef _WIN32
24 #include <wincrypt.h>
25 #include <ncrypt.h>
26 #else
27 
28 #include <winpr/wtypes.h>
29 #include <winpr/winpr.h>
30 
31 WINPR_PRAGMA_DIAG_PUSH
32 WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
33 
34 #ifndef __SECSTATUS_DEFINED__
35 typedef LONG SECURITY_STATUS;
36 #define __SECSTATUS_DEFINED__
37 #endif
38 
39 WINPR_PRAGMA_DIAG_POP
40 
41 typedef ULONG_PTR NCRYPT_HANDLE;
42 typedef ULONG_PTR NCRYPT_PROV_HANDLE;
43 typedef ULONG_PTR NCRYPT_KEY_HANDLE;
44 
45 #define MS_KEY_STORAGE_PROVIDER \
46  (const WCHAR*)"M\x00i\x00" \
47  "c\x00r\x00o\x00s\x00o\x00" \
48  "f\x00t\x00 " \
49  "\x00S\x00o\x00" \
50  "f\x00t\x00w\x00" \
51  "a\x00r\x00" \
52  "e\x00 \x00K\x00" \
53  "e\x00y\x00 " \
54  "\x00S\x00t\x00o\x00r\x00" \
55  "a\x00g\x00" \
56  "e\x00 " \
57  "\x00P\x00r\x00o\x00v\x00i\x00" \
58  "d\x00" \
59  "e\x00r\x00\x00"
60 #define MS_SMART_CARD_KEY_STORAGE_PROVIDER \
61  (const WCHAR*)"M\x00i\x00" \
62  "c\x00r\x00o\x00s\x00o\x00" \
63  "f\x00t\x00 \x00S\x00m\x00" \
64  "a\x00r\x00t\x00 " \
65  "\x00" \
66  "C\x00" \
67  "a\x00r\x00" \
68  "d\x00 \x00K\x00" \
69  "e\x00y\x00 " \
70  "\x00S\x00t\x00o\x00r\x00" \
71  "a\x00g\x00" \
72  "e\x00 " \
73  "\x00P\x00r\x00o\x00v\x00i\x00" \
74  "d\x00" \
75  "e\x00r\x00\x00"
76 
77 #define MS_SCARD_PROV_A "Microsoft Base Smart Card Crypto Provider"
78 #define MS_SCARD_PROV \
79  (const WCHAR*)("M\x00i\x00" \
80  "c\x00r\x00o\x00s\x00o\x00" \
81  "f\x00t\x00 \x00" \
82  "B\x00" \
83  "a\x00s\x00" \
84  "e\x00 " \
85  "\x00S\x00m\x00" \
86  "a\x00r\x00t\x00 \x00" \
87  "C\x00" \
88  "a\x00r\x00" \
89  "d\x00 " \
90  "\x00" \
91  "C\x00r\x00y\x00p\x00t\x00o\x00 " \
92  "\x00P\x00r\x00o\x00v\x00i\x00" \
93  "d\x00" \
94  "e\x00r\x00\x00")
95 
96 #define MS_PLATFORM_KEY_STORAGE_PROVIDER \
97  (const WCHAR*)"M\x00i\x00" \
98  "c\x00r\x00o\x00s\x00o\x00" \
99  "f\x00t\x00 " \
100  "\x00P\x00l\x00" \
101  "a\x00t\x00" \
102  "f\x00o\x00r\x00m\x00 " \
103  "\x00" \
104  "C\x00r\x00y\x00p\x00t\x00o\x00 " \
105  "\x00P\x00r\x00o\x00v\x00i\x00" \
106  "d\x00" \
107  "e\x00r\x00\x00"
108 
109 #define NCRYPT_CERTIFICATE_PROPERTY \
110  (const WCHAR*)"S\x00m\x00" \
111  "a\x00r\x00t\x00" \
112  "C\x00" \
113  "a\x00r\x00" \
114  "d\x00K\x00" \
115  "e\x00y\x00" \
116  "C\x00" \
117  "e\x00r\x00t" \
118  "\x00i\x00" \
119  "f\x00i\x00" \
120  "c\x00" \
121  "a\x00t\x00" \
122  "e\x00\x00"
123 #define NCRYPT_NAME_PROPERTY (const WCHAR*)"N\x00a\x00m\x00e\x00\x00"
124 #define NCRYPT_UNIQUE_NAME_PROPERTY \
125  (const WCHAR*)"U\x00n\x00i\x00q\x00u\x00" \
126  "e\x00 \x00N\x00" \
127  "a\x00m\x00" \
128  "e\x00\x00"
129 #define NCRYPT_READER_PROPERTY \
130  (const WCHAR*)"S\x00m\x00" \
131  "a\x00r\x00t\x00" \
132  "C\x00" \
133  "a\x00r\x00" \
134  "d\x00R\x00" \
135  "e\x00" \
136  "a\x00" \
137  "d\x00" \
138  "e\x00r\x00\x00"
139 
140 /* winpr specific properties */
141 #define NCRYPT_WINPR_SLOTID (const WCHAR*)"S\x00l\x00o\x00t\x00\x00"
142 
143 #define NCRYPT_MACHINE_KEY_FLAG 0x20
144 #define NCRYPT_SILENT_FLAG 0x40
145 
147 typedef struct NCryptKeyName
148 {
149  LPWSTR pszName;
150  LPWSTR pszAlgid;
151  DWORD dwLegacyKeySpec;
152  DWORD dwFlags;
153 } NCryptKeyName;
154 
156 typedef struct NCryptProviderName
157 {
158  LPWSTR pszName;
159  LPWSTR pszComment;
161 
162 #ifdef __cplusplus
163 extern "C"
164 {
165 #endif
166 
167  WINPR_API SECURITY_STATUS NCryptEnumStorageProviders(DWORD* wProviderCount,
168  NCryptProviderName** ppProviderList,
169  DWORD dwFlags);
170 
171  WINPR_API SECURITY_STATUS NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE* phProvider,
172  LPCWSTR pszProviderName, DWORD dwFlags);
173 
174  WINPR_API SECURITY_STATUS NCryptEnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR pszScope,
175  NCryptKeyName** ppKeyName, PVOID* ppEnumState,
176  DWORD dwFlags);
177 
178  WINPR_API SECURITY_STATUS NCryptOpenKey(NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE* phKey,
179  LPCWSTR pszKeyName, DWORD dwLegacyKeySpec,
180  DWORD dwFlags);
181 
182  WINPR_API SECURITY_STATUS NCryptGetProperty(NCRYPT_HANDLE hObject, LPCWSTR pszProperty,
183  PBYTE pbOutput, DWORD cbOutput, DWORD* pcbResult,
184  DWORD dwFlags);
185 
186  WINPR_API SECURITY_STATUS NCryptFreeObject(NCRYPT_HANDLE hObject);
187  WINPR_API SECURITY_STATUS NCryptFreeBuffer(PVOID pvInput);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* _WIN32 */
194 
195 #ifdef __cplusplus
196 extern "C"
197 {
198 #endif
199 
208  WINPR_API SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
209  LPCWSTR pszProviderName,
210  DWORD dwFlags, LPCSTR* modulePaths);
211 
218  WINPR_API const char* winpr_NCryptSecurityStatusError(SECURITY_STATUS status);
219 
227  WINPR_API const char* winpr_NCryptGetModulePath(NCRYPT_PROV_HANDLE phProvider);
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif /* WINPR_INCLUDE_WINPR_NCRYPT_H_ */
a key name descriptor
a provider name descriptor