1 |
vletoux |
1 |
/* OpenPGP Smart Card Mini Driver |
2 |
|
|
Copyright (C) 2009 Vincent Le Toux |
3 |
|
|
|
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 version 2.1 as published by the Free Software Foundation. |
7 |
|
|
|
8 |
|
|
This library is distributed in the hope that it will be useful, |
9 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 |
|
|
Lesser General Public License for more details. |
12 |
|
|
|
13 |
|
|
You should have received a copy of the GNU Lesser General Public |
14 |
|
|
License along with this library; if not, write to the Free Software |
15 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
16 |
|
|
*/ |
17 |
|
|
|
18 |
|
|
#include <windows.h> |
19 |
|
|
#include <cardmod.h> |
20 |
|
|
#include "Tracing.h" |
21 |
|
|
|
22 |
|
|
// 4.8 Secure key injection |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
/** The CardImportSessionKey function imports a temporary session key to the card. |
26 |
|
|
The session key is encrypted with a key exchange key, and the function returns a |
27 |
|
|
handle of the imported session key to the caller.*/ |
28 |
|
|
|
29 |
|
|
DWORD WINAPI CardImportSessionKey( |
30 |
|
|
__in PCARD_DATA pCardData, |
31 |
|
|
__in BYTE bContainerIndex, |
32 |
|
|
__in VOID *pPaddingInfo, |
33 |
|
|
__in LPCWSTR pwszBlobType, |
34 |
|
|
__in LPCWSTR pwszAlgId, |
35 |
|
|
__out CARD_KEY_HANDLE *phKey, |
36 |
|
|
__in_bcount(cbInput) PBYTE pbInput, |
37 |
|
|
__in DWORD cbInput, |
38 |
|
|
__in DWORD dwFlags |
39 |
|
|
) |
40 |
|
|
{ |
41 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
42 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
/** The MDImportSessionKey function imports a temporary session key to the card minidriver |
46 |
|
|
and returns a key handle to the caller.*/ |
47 |
|
|
|
48 |
|
|
DWORD WINAPI MDImportSessionKey( |
49 |
|
|
__in PCARD_DATA pCardData, |
50 |
|
|
__in LPCWSTR pwszBlobType, |
51 |
|
|
__in LPCWSTR pwszAlgId, |
52 |
|
|
__out PCARD_KEY_HANDLE phKey, |
53 |
|
|
__in_bcount(cbInput) PBYTE pbInput, |
54 |
|
|
__in DWORD cbInput |
55 |
|
|
) |
56 |
|
|
{ |
57 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
58 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
/** The MDEncryptData function uses a key handle to encrypt data with a symmetric key. |
62 |
|
|
The data is encrypted in a format that the smart card supports.*/ |
63 |
|
|
|
64 |
|
|
DWORD WINAPI MDEncryptData( |
65 |
|
|
__in PCARD_DATA pCardData, |
66 |
|
|
__in CARD_KEY_HANDLE hKey, |
67 |
|
|
__in LPCWSTR pwszSecureFunction, |
68 |
|
|
__in_bcount(cbInput) PBYTE pbInput, |
69 |
|
|
__in DWORD cbInput, |
70 |
|
|
__in DWORD dwFlags, |
71 |
|
|
__deref_out_ecount(*pcEncryptedData) |
72 |
|
|
PCARD_ENCRYPTED_DATA *ppEncryptedData, |
73 |
|
|
__out PDWORD pcEncryptedData |
74 |
|
|
) |
75 |
|
|
{ |
76 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
77 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
|
81 |
|
|
/** The CardGetSharedKeyHandle function returns a session key handle to the caller. |
82 |
|
|
Note: The manner in which this session key has been established is outside the |
83 |
|
|
scope of this specification. For example, the session key could be established |
84 |
|
|
by either a permanent shared key or a key derivation algorithm that has occurred |
85 |
|
|
before the call to CardGetSharedKeyHandle.*/ |
86 |
|
|
|
87 |
|
|
DWORD WINAPI CardGetSharedKeyHandle( |
88 |
|
|
__in PCARD_DATA pCardData, |
89 |
|
|
__in_bcount(cbInput) PBYTE pbInput, |
90 |
|
|
__in DWORD cbInput, |
91 |
|
|
__deref_opt_out_bcount(*pcbOutput) |
92 |
|
|
PBYTE *ppbOutput, |
93 |
|
|
__out_opt PDWORD pcbOutput, |
94 |
|
|
__out PCARD_KEY_HANDLE phKey |
95 |
|
|
) |
96 |
|
|
{ |
97 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
98 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
/** The CardDestroyKey function releases a temporary key on the card. The card |
102 |
|
|
should delete all of the key material that is associated with that key handle.*/ |
103 |
|
|
|
104 |
|
|
DWORD WINAPI CardDestroyKey( |
105 |
|
|
__in PCARD_DATA pCardData, |
106 |
|
|
__in CARD_KEY_HANDLE hKey |
107 |
|
|
) |
108 |
|
|
{ |
109 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
110 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
/** This function can be used to get properties for a cryptographic algorithm.*/ |
114 |
|
|
DWORD WINAPI CardGetAlgorithmProperty ( |
115 |
|
|
__in PCARD_DATA pCardData, |
116 |
|
|
__in LPCWSTR pwszAlgId, |
117 |
|
|
__in LPCWSTR pwszProperty, |
118 |
|
|
__out_bcount_part_opt(cbData, *pdwDataLen) |
119 |
|
|
PBYTE pbData, |
120 |
|
|
__in DWORD cbData, |
121 |
|
|
__out PDWORD pdwDataLen, |
122 |
|
|
__in DWORD dwFlags |
123 |
|
|
) |
124 |
|
|
{ |
125 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
126 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
127 |
|
|
} |
128 |
|
|
|
129 |
vletoux |
12 |
/** This function is used to get the properties of a key.*/ |
130 |
|
|
DWORD WINAPI CardGetKeyProperty( |
131 |
|
|
__in PCARD_DATA pCardData, |
132 |
|
|
__in CARD_KEY_HANDLE hKey, |
133 |
|
|
__in LPCWSTR pwszProperty, |
134 |
|
|
__out_bcount_part_opt(cbData, *pdwDataLen) PBYTE pbData, |
135 |
|
|
__in DWORD cbData, |
136 |
|
|
__out PDWORD pdwDataLen, |
137 |
|
|
__in DWORD dwFlags |
138 |
|
|
) |
139 |
|
|
{ |
140 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
141 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
142 |
|
|
} |
143 |
|
|
|
144 |
vletoux |
1 |
/** This function is used to set the properties of a key.*/ |
145 |
|
|
DWORD WINAPI CardSetKeyProperty( |
146 |
|
|
__in PCARD_DATA pCardData, |
147 |
|
|
__in CARD_KEY_HANDLE hKey, |
148 |
|
|
__in LPCWSTR pwszProperty, |
149 |
|
|
__in_bcount(cbInput) PBYTE pbInput, |
150 |
|
|
__in DWORD cbInput, |
151 |
|
|
__in DWORD dwFlags |
152 |
|
|
) |
153 |
|
|
{ |
154 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
155 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
/** CardProcessEncryptedData processes a set of encrypted data BLOBs by |
159 |
|
|
sending them to the card where the data BLOBs are decrypted.*/ |
160 |
|
|
|
161 |
|
|
DWORD WINAPI CardProcessEncryptedData( |
162 |
|
|
__in PCARD_DATA pCardData, |
163 |
|
|
__in CARD_KEY_HANDLE hKey, |
164 |
|
|
__in LPCWSTR pwszSecureFunction, |
165 |
|
|
__in_ecount(cEncryptedData) |
166 |
|
|
PCARD_ENCRYPTED_DATA pEncryptedData, |
167 |
|
|
__in DWORD cEncryptedData, |
168 |
|
|
__out_bcount_part_opt(cbOutput, *pdwOutputLen) |
169 |
|
|
PBYTE pbOutput, |
170 |
|
|
__in DWORD cbOutput, |
171 |
|
|
__out_opt PDWORD pdwOutputLen, |
172 |
|
|
__in DWORD dwFlags |
173 |
|
|
) |
174 |
|
|
{ |
175 |
|
|
Trace(WINEVENT_LEVEL_VERBOSE, L"Enter"); |
176 |
|
|
return SCARD_E_UNSUPPORTED_FEATURE; |
177 |
|
|
} |
178 |
|
|
|