2 * Copyright (c) 2016 Austin English
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define WINAPI __stdcall
30 #ifndef __SECSTATUS_DEFINED__
31 typedef LONG SECURITY_STATUS
;
32 #define __SECSTATUS_DEFINED__
35 typedef struct _NCryptAlgorithmName
{
38 DWORD dwAlgOperations
;
40 } NCryptAlgorithmName
;
42 typedef struct _NCryptBuffer
{
46 } NCryptBuffer
, *PNCryptBuffer
;
48 typedef struct _NCryptBufferDesc
{
51 PNCryptBuffer pBuffers
;
52 } NCryptBufferDesc
, *PNCryptBufferDesc
;
54 typedef struct NCryptKeyName
{
57 DWORD dwLegacyKeySpec
;
61 typedef ULONG_PTR NCRYPT_HANDLE
;
62 typedef ULONG_PTR NCRYPT_PROV_HANDLE
;
63 typedef ULONG_PTR NCRYPT_KEY_HANDLE
;
64 typedef ULONG_PTR NCRYPT_HASH_HANDLE
;
65 typedef ULONG_PTR NCRYPT_SECRET_HANDLE
;
67 #define NCRYPT_KEY_STORAGE_INTERFACE 0x00010001
68 #define NCRYPT_SCHANNEL_INTERFACE 0x00010002
69 #define NCRYPT_SCHANNEL_SIGNATURE_INTERFACE 0x00010003
70 #define NCRYPT_KEY_PROTECTION_INTERFACE 0x00010004
72 #define NCRYPT_SILENT_FLAG 0x00000040
74 #define NCRYPT_NO_PADDING_FLAG 0x00000001
75 #define NCRYPT_PAD_PKCS1_FLAG 0x00000002
76 #define NCRYPT_PAD_OAEP_FLAG 0x00000004
77 #define NCRYPT_PAD_PSS_FLAG 0x00000008
79 #define NCRYPT_NAME_PROPERTY L"Name"
80 #define NCRYPT_UNIQUE_NAME_PROPERTY L"Unique Name"
81 #define NCRYPT_ALGORITHM_PROPERTY L"Algorithm Name"
82 #define NCRYPT_LENGTH_PROPERTY L"Length"
83 #define NCRYPT_LENGTHS_PROPERTY L"Lengths"
84 #define NCRYPT_BLOCK_LENGTH_PROPERTY L"Block Length"
85 #define NCRYPT_UI_POLICY_PROPERTY L"UI Policy"
86 #define NCRYPT_EXPORT_POLICY_PROPERTY L"Export Policy"
87 #define NCRYPT_WINDOW_HANDLE_PROPERTY L"HWND Handle"
88 #define NCRYPT_USE_CONTEXT_PROPERTY L"Use Context"
89 #define NCRYPT_IMPL_TYPE_PROPERTY L"Impl Type"
90 #define NCRYPT_KEY_USAGE_PROPERTY L"Key Usage"
91 #define NCRYPT_KEY_TYPE_PROPERTY L"Key Type"
92 #define NCRYPT_VERSION_PROPERTY L"Version"
93 #define NCRYPT_SECURITY_DESCR_SUPPORT_PROPERTY L"Security Descr Support"
94 #define NCRYPT_SECURITY_DESCR_PROPERTY L"Security Descr"
95 #define NCRYPT_USE_COUNT_ENABLED_PROPERTY L"Enabled Use Count"
96 #define NCRYPT_USE_COUNT_PROPERTY L"Use Count"
97 #define NCRYPT_LAST_MODIFIED_PROPERTY L"Modified"
98 #define NCRYPT_MAX_NAME_LENGTH_PROPERTY L"Max Name Length"
99 #define NCRYPT_ALGORITHM_GROUP_PROPERTY L"Algorithm Group"
100 #define NCRYPT_PROVIDER_HANDLE_PROPERTY L"Provider Handle"
101 #define NCRYPT_PIN_PROPERTY L"SmartCardPin"
102 #define NCRYPT_READER_PROPERTY L"SmartCardReader"
103 #define NCRYPT_SMARTCARD_GUID_PROPERTY L"SmartCardGuid"
104 #define NCRYPT_CERTIFICATE_PROPERTY L"SmartCardKeyCertificate"
105 #define NCRYPT_PIN_PROMPT_PROPERTY L"SmartCardPinPrompt"
106 #define NCRYPT_USER_CERTSTORE_PROPERTY L"SmartCardUserCertStore"
107 #define NCRYPT_ROOT_CERTSTORE_PROPERTY L"SmartcardRootCertStore"
108 #define NCRYPT_SECURE_PIN_PROPERTY L"SmartCardSecurePin"
109 #define NCRYPT_ASSOCIATED_ECDH_KEY L"SmartCardAssociatedECDHKey"
110 #define NCRYPT_SCARD_PIN_ID L"SmartCardPinId"
111 #define NCRYPT_SCARD_PIN_INFO L"SmartCardPinInfo"
113 SECURITY_STATUS WINAPI
NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE
, NCRYPT_KEY_HANDLE
*, const WCHAR
*, const WCHAR
*, DWORD
, DWORD
);
114 SECURITY_STATUS WINAPI
NCryptDecrypt(NCRYPT_KEY_HANDLE
, BYTE
*, DWORD
, void *, BYTE
*, DWORD
, DWORD
*, DWORD
);
115 SECURITY_STATUS WINAPI
NCryptEncrypt(NCRYPT_KEY_HANDLE
, BYTE
*, DWORD
, void *, BYTE
*, DWORD
, DWORD
*, DWORD
);
116 SECURITY_STATUS WINAPI
NCryptFinalizeKey(NCRYPT_KEY_HANDLE
, DWORD
);
117 SECURITY_STATUS WINAPI
NCryptFreeObject(NCRYPT_HANDLE
);
118 SECURITY_STATUS WINAPI
NCryptGetProperty(NCRYPT_HANDLE
, const WCHAR
*, BYTE
*, DWORD
, DWORD
*, DWORD
);
119 SECURITY_STATUS WINAPI
NCryptImportKey(NCRYPT_PROV_HANDLE
, NCRYPT_KEY_HANDLE
, const WCHAR
*, NCryptBufferDesc
*,
120 NCRYPT_KEY_HANDLE
*, BYTE
*, DWORD
, DWORD
);
121 SECURITY_STATUS WINAPI
NCryptIsAlgSupported(NCRYPT_PROV_HANDLE
, const WCHAR
*, DWORD
);
122 SECURITY_STATUS WINAPI
NCryptOpenKey(NCRYPT_PROV_HANDLE
, NCRYPT_KEY_HANDLE
*, const WCHAR
*, DWORD
, DWORD
);
123 SECURITY_STATUS WINAPI
NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE
*, const WCHAR
*, DWORD
);
124 SECURITY_STATUS WINAPI
NCryptSetProperty(NCRYPT_HANDLE
, const WCHAR
*, BYTE
*, DWORD
, DWORD
);
125 SECURITY_STATUS WINAPI
NCryptVerifySignature(NCRYPT_KEY_HANDLE
, void *, BYTE
*, DWORD
, BYTE
*, DWORD
, DWORD
);
131 #endif /* __NCRYPT_H__ */