FreeRDP
libwinpr/ncrypt/ncrypt.h
1 
20 #ifndef WINPR_LIBWINPR_NCRYPT_NCRYPT_H_
21 #define WINPR_LIBWINPR_NCRYPT_NCRYPT_H_
22 
23 #include <winpr/config.h>
24 
25 #include <winpr/bcrypt.h>
26 #include <winpr/crypto.h>
27 #include <winpr/ncrypt.h>
28 #include <winpr/error.h>
29 #include <winpr/string.h>
30 
32 typedef enum
33 {
34  WINPR_NCRYPT_INVALID,
35  WINPR_NCRYPT_PROVIDER,
36  WINPR_NCRYPT_KEY
37 } NCryptHandleType;
38 
40 typedef SECURITY_STATUS (*NCryptReleaseFn)(NCRYPT_HANDLE handle);
41 
43 typedef enum
44 {
45  NCRYPT_PROPERTY_CERTIFICATE,
46  NCRYPT_PROPERTY_READER,
47  NCRYPT_PROPERTY_SLOTID,
48  NCRYPT_PROPERTY_NAME,
49  NCRYPT_PROPERTY_UNKNOWN
50 } NCryptKeyGetPropertyEnum;
51 
52 typedef SECURITY_STATUS (*NCryptGetPropertyFn)(NCRYPT_HANDLE hObject,
53  NCryptKeyGetPropertyEnum property, PBYTE pbOutput,
54  DWORD cbOutput, DWORD* pcbResult, DWORD dwFlags);
55 
57 typedef struct
58 {
59  char magic[6];
60  NCryptHandleType type;
61  NCryptGetPropertyFn getPropertyFn;
62  NCryptReleaseFn releaseFn;
64 
65 typedef SECURITY_STATUS (*NCryptEnumKeysFn)(NCRYPT_PROV_HANDLE hProvider, LPCWSTR pszScope,
66  NCryptKeyName** ppKeyName, PVOID* ppEnumState,
67  DWORD dwFlags);
68 typedef SECURITY_STATUS (*NCryptOpenKeyFn)(NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE* phKey,
69  LPCWSTR pszKeyName, DWORD dwLegacyKeySpec,
70  DWORD dwFlags);
71 
73 typedef struct
74 {
75  NCryptBaseHandle baseHandle;
76 
77  NCryptEnumKeysFn enumKeysFn;
78  NCryptOpenKeyFn openKeyFn;
80 
81 SECURITY_STATUS checkNCryptHandle(NCRYPT_HANDLE handle, NCryptHandleType matchType);
82 
83 SECURITY_STATUS winpr_NCryptDefault_dtor(NCRYPT_HANDLE handle);
84 
85 void* ncrypt_new_handle(NCryptHandleType kind, size_t len, NCryptGetPropertyFn getProp,
86  NCryptReleaseFn dtor);
87 
88 #if defined(WITH_PKCS11)
89 SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
90  LPCWSTR pszProviderName, DWORD dwFlags,
91  LPCSTR* modulePaths);
92 
93 const char* NCryptGetModulePath(NCRYPT_PROV_HANDLE phProvider);
94 #endif
95 
96 #endif /* WINPR_LIBWINPR_NCRYPT_NCRYPT_H_ */
common ncrypt handle items
common ncrypt provider items
a key name descriptor