1 | /** @file
|
---|
2 | The Smart Card Edge Protocol provides an abstraction for device to provide Smart
|
---|
3 | Card support.
|
---|
4 |
|
---|
5 | This protocol allows UEFI applications to interface with a Smart Card during
|
---|
6 | boot process for authentication or data signing/decryption, especially if the
|
---|
7 | application has to make use of PKI.
|
---|
8 |
|
---|
9 | Copyright (c) 2015-2018, Intel Corporation. All rights reserved.<BR>
|
---|
10 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
11 |
|
---|
12 | @par Revision Reference:
|
---|
13 | This Protocol was introduced in UEFI Specification 2.5.
|
---|
14 |
|
---|
15 | **/
|
---|
16 |
|
---|
17 | #ifndef __SMART_CARD_EDGE_H__
|
---|
18 | #define __SMART_CARD_EDGE_H__
|
---|
19 |
|
---|
20 | #define EFI_SMART_CARD_EDGE_PROTOCOL_GUID \
|
---|
21 | { \
|
---|
22 | 0xd317f29b, 0xa325, 0x4712, {0x9b, 0xf1, 0xc6, 0x19, 0x54, 0xdc, 0x19, 0x8c} \
|
---|
23 | }
|
---|
24 |
|
---|
25 | typedef struct _EFI_SMART_CARD_EDGE_PROTOCOL EFI_SMART_CARD_EDGE_PROTOCOL;
|
---|
26 |
|
---|
27 | //
|
---|
28 | // Maximum size for a Smart Card AID (Application IDentifier)
|
---|
29 | //
|
---|
30 | #define SCARD_AID_MAXSIZE 0x0010
|
---|
31 | //
|
---|
32 | // Size of CSN (Card Serial Number)
|
---|
33 | //
|
---|
34 | #define SCARD_CSN_SIZE 0x0010
|
---|
35 | //
|
---|
36 | // Current specification version 1.00
|
---|
37 | //
|
---|
38 | #define SMART_CARD_EDGE_PROTOCOL_VERSION_1 0x00000100
|
---|
39 | //
|
---|
40 | // Parameters type definition
|
---|
41 | //
|
---|
42 | typedef UINT8 SMART_CARD_AID[SCARD_AID_MAXSIZE];
|
---|
43 | typedef UINT8 SMART_CARD_CSN[SCARD_CSN_SIZE];
|
---|
44 |
|
---|
45 | //
|
---|
46 | // Type of data elements in credentials list
|
---|
47 | //
|
---|
48 | // value of tag field for header, the number of containers
|
---|
49 | //
|
---|
50 | #define SC_EDGE_TAG_HEADER 0x0000
|
---|
51 | //
|
---|
52 | // value of tag field for certificate
|
---|
53 | //
|
---|
54 | #define SC_EDGE_TAG_CERT 0x0001
|
---|
55 | //
|
---|
56 | // value of tag field for key index associated with certificate
|
---|
57 | //
|
---|
58 | #define SC_EDGE_TAG_KEY_ID 0x0002
|
---|
59 | //
|
---|
60 | // value of tag field for key type
|
---|
61 | //
|
---|
62 | #define SC_EDGE_TAG_KEY_TYPE 0x0003
|
---|
63 | //
|
---|
64 | // value of tag field for key size
|
---|
65 | //
|
---|
66 | #define SC_EDGE_TAG_KEY_SIZE 0x0004
|
---|
67 |
|
---|
68 | //
|
---|
69 | // Length of L fields of TLV items
|
---|
70 | //
|
---|
71 | //
|
---|
72 | // size of L field for header
|
---|
73 | //
|
---|
74 | #define SC_EDGE_L_SIZE_HEADER 1
|
---|
75 | //
|
---|
76 | // size of L field for certificate (big endian)
|
---|
77 | //
|
---|
78 | #define SC_EDGE_L_SIZE_CERT 2
|
---|
79 | //
|
---|
80 | // size of L field for key index
|
---|
81 | //
|
---|
82 | #define SC_EDGE_L_SIZE_KEY_ID 1
|
---|
83 | //
|
---|
84 | // size of L field for key type
|
---|
85 | //
|
---|
86 | #define SC_EDGE_L_SIZE_KEY_TYPE 1
|
---|
87 | //
|
---|
88 | // size of L field for key size (big endian)
|
---|
89 | //
|
---|
90 | #define SC_EDGE_L_SIZE_KEY_SIZE 2
|
---|
91 |
|
---|
92 | //
|
---|
93 | // Some TLV items have a fixed value for L field
|
---|
94 | //
|
---|
95 | // value of L field for header
|
---|
96 | //
|
---|
97 | #define SC_EDGE_L_VALUE_HEADER 1
|
---|
98 | //
|
---|
99 | // value of L field for key index
|
---|
100 | //
|
---|
101 | #define SC_EDGE_L_VALUE_KEY_ID 1
|
---|
102 | //
|
---|
103 | // value of L field for key type
|
---|
104 | //
|
---|
105 | #define SC_EDGE_L_VALUE_KEY_TYPE 1
|
---|
106 | //
|
---|
107 | // value of L field for key size
|
---|
108 | //
|
---|
109 | #define SC_EDGE_L_VALUE_KEY_SIZE 2
|
---|
110 |
|
---|
111 | //
|
---|
112 | // Possible values for key type
|
---|
113 | //
|
---|
114 | //
|
---|
115 | // RSA decryption
|
---|
116 | //
|
---|
117 | #define SC_EDGE_RSA_EXCHANGE 0x01
|
---|
118 | //
|
---|
119 | // RSA signature
|
---|
120 | //
|
---|
121 | #define SC_EDGE_RSA_SIGNATURE 0x02
|
---|
122 | //
|
---|
123 | // ECDSA signature
|
---|
124 | //
|
---|
125 | #define SC_EDGE_ECDSA_256 0x03
|
---|
126 | //
|
---|
127 | // ECDSA signature
|
---|
128 | //
|
---|
129 | #define SC_EDGE_ECDSA_384 0x04
|
---|
130 | //
|
---|
131 | // ECDSA signature
|
---|
132 | //
|
---|
133 | #define SC_EDGE_ECDSA_521 0x05
|
---|
134 | //
|
---|
135 | // ECDH agreement
|
---|
136 | //
|
---|
137 | #define SC_EDGE_ECDH_256 0x06
|
---|
138 | //
|
---|
139 | // ECDH agreement
|
---|
140 | //
|
---|
141 | #define SC_EDGE_ECDH_384 0x07
|
---|
142 | //
|
---|
143 | // ECDH agreement
|
---|
144 | //
|
---|
145 | #define SC_EDGE_ECDH_521 0x08
|
---|
146 |
|
---|
147 | //
|
---|
148 | // Padding methods GUIDs for signature
|
---|
149 | //
|
---|
150 | //
|
---|
151 | // RSASSA- PKCS#1-V1.5 padding method, for signature
|
---|
152 | //
|
---|
153 | #define EFI_PADDING_RSASSA_PKCS1V1P5_GUID \
|
---|
154 | { \
|
---|
155 | 0x9317ec24, 0x7cb0, 0x4d0e, {0x8b, 0x32, 0x2e, 0xd9, 0x20, 0x9c, 0xd8, 0xaf} \
|
---|
156 | }
|
---|
157 |
|
---|
158 | extern EFI_GUID gEfiPaddingRsassaPkcs1V1P5Guid;
|
---|
159 |
|
---|
160 | //
|
---|
161 | // RSASSA-PSS padding method, for signature
|
---|
162 | //
|
---|
163 | #define EFI_PADDING_RSASSA_PSS_GUID \
|
---|
164 | { \
|
---|
165 | 0x7b2349e0, 0x522d, 0x4f8e, {0xb9, 0x27, 0x69, 0xd9, 0x7c, 0x9e, 0x79, 0x5f} \
|
---|
166 | }
|
---|
167 |
|
---|
168 | extern EFI_GUID gEfiPaddingRsassaPssGuid;
|
---|
169 |
|
---|
170 | //
|
---|
171 | // Padding methods GUIDs for decryption
|
---|
172 | //
|
---|
173 | //
|
---|
174 | // No padding, for decryption
|
---|
175 | //
|
---|
176 | #define EFI_PADDING_NONE_GUID \
|
---|
177 | { \
|
---|
178 | 0x3629ddb1, 0x228c, 0x452e, {0xb6, 0x16, 0x09, 0xed, 0x31, 0x6a, 0x97, 0x00} \
|
---|
179 | }
|
---|
180 |
|
---|
181 | extern EFI_GUID gEfiPaddingNoneGuid;
|
---|
182 |
|
---|
183 | //
|
---|
184 | // RSAES-PKCS#1-V1.5 padding, for decryption
|
---|
185 | //
|
---|
186 | #define EFI_PADDING_RSAES_PKCS1V1P5_GUID \
|
---|
187 | { \
|
---|
188 | 0xe1c1d0a9, 0x40b1, 0x4632, {0xbd, 0xcc, 0xd9, 0xd6, 0xe5, 0x29, 0x56, 0x31} \
|
---|
189 | }
|
---|
190 |
|
---|
191 | extern EFI_GUID gEfiPaddingRsaesPkcs1V1P5Guid;
|
---|
192 |
|
---|
193 | //
|
---|
194 | // RSAES-OAEP padding, for decryption
|
---|
195 | //
|
---|
196 | #define EFI_PADDING_RSAES_OAEP_GUID \
|
---|
197 | { \
|
---|
198 | 0xc1e63ac4, 0xd0cf, 0x4ce6, {0x83, 0x5b, 0xee, 0xd0, 0xe6, 0xa8, 0xa4, 0x5b} \
|
---|
199 | }
|
---|
200 |
|
---|
201 | extern EFI_GUID gEfiPaddingRsaesOaepGuid;
|
---|
202 |
|
---|
203 | /**
|
---|
204 | This function retrieves the context driver.
|
---|
205 |
|
---|
206 | The GetContextfunction returns the context of the protocol, the application
|
---|
207 | identifiers supported by the protocol and the number and the CSN unique identifier
|
---|
208 | of Smart Cards that are present and supported by protocol.
|
---|
209 |
|
---|
210 | If AidTableSize, AidTable, CsnTableSize, CsnTable or VersionProtocol is NULL,
|
---|
211 | the function does not fail but does not fill in such variables.
|
---|
212 |
|
---|
213 | In case AidTableSize indicates a buffer too small to hold all the protocol AID table,
|
---|
214 | only the first AidTableSize items of the table are returned in AidTable.
|
---|
215 |
|
---|
216 | In case CsnTableSize indicates a buffer too small to hold the entire table of
|
---|
217 | Smart Card CSN present, only the first CsnTableSize items of the table are returned
|
---|
218 | in CsnTable.
|
---|
219 |
|
---|
220 | VersionScEdgeProtocol returns the version of the EFI_SMART_CARD_EDGE_PROTOCOL this
|
---|
221 | driver uses. For this protocol specification value is SMART_CARD_EDGE_PROTOCOL_VERSION_1.
|
---|
222 |
|
---|
223 | In case of Smart Card removal the internal CSN list is immediately updated, even if
|
---|
224 | a connection is opened with that Smart Card.
|
---|
225 |
|
---|
226 | @param[in] This Indicates a pointer to the calling context.
|
---|
227 | @param[out] NumberAidSupported Number of AIDs this protocol supports.
|
---|
228 | @param[in, out] AidTableSize On input, number of items allocated for the
|
---|
229 | AID table. On output, number of items returned
|
---|
230 | by protocol.
|
---|
231 | @param[out] AidTable Table of the AIDs supported by the protocol.
|
---|
232 | @param[out] NumberSCPresent Number of currently present Smart Cards that
|
---|
233 | are supported by protocol.
|
---|
234 | @param[in, out] CsnTableSize On input, the number of items the buffer CSN
|
---|
235 | table can contain. On output, the number of
|
---|
236 | items returned by the protocol.
|
---|
237 | @param[out] CsnTable Table of the CSN of the Smart Card present and
|
---|
238 | supported by protocol.
|
---|
239 | @param[out] VersionScEdgeProtocol EFI_SMART_CARD_EDGE_PROTOCOL version.
|
---|
240 |
|
---|
241 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
242 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
243 | @retval EFI_INVALID_PARAMETER NumberSCPresent is NULL.
|
---|
244 |
|
---|
245 | **/
|
---|
246 | typedef
|
---|
247 | EFI_STATUS
|
---|
248 | (EFIAPI *EFI_SMART_CARD_EDGE_GET_CONTEXT)(
|
---|
249 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
250 | OUT UINTN *NumberAidSupported,
|
---|
251 | IN OUT UINTN *AidTableSize OPTIONAL,
|
---|
252 | OUT SMART_CARD_AID *AidTable OPTIONAL,
|
---|
253 | OUT UINTN *NumberSCPresent,
|
---|
254 | IN OUT UINTN *CsnTableSize OPTIONAL,
|
---|
255 | OUT SMART_CARD_CSN *CsnTable OPTIONAL,
|
---|
256 | OUT UINT32 *VersionScEdgeProtocol OPTIONAL
|
---|
257 | );
|
---|
258 |
|
---|
259 | /**
|
---|
260 | This function establish a connection with a Smart Card the protocol support.
|
---|
261 |
|
---|
262 | In case of success the SCardHandle can be used.
|
---|
263 |
|
---|
264 | If the ScardCsn is NULL the connection is established with the first Smart Card
|
---|
265 | the protocol finds in its table of Smart Card present and supported. Else it
|
---|
266 | establish context with the Smart Card whose CSN given by ScardCsn.
|
---|
267 |
|
---|
268 | If ScardAid is not NULL the function returns the Smart Card AID the protocol supports.
|
---|
269 | After a successful connect the SCardHandle will remain existing even in case Smart Card
|
---|
270 | removed from Smart Card reader, but all function invoking this SCardHandle will fail.
|
---|
271 | SCardHandle is released only on Disconnect.
|
---|
272 |
|
---|
273 | @param[in] This Indicates a pointer to the calling context.
|
---|
274 | @param[out] SCardHandle Handle on Smart Card connection.
|
---|
275 | @param[in] ScardCsn CSN of the Smart Card the connection has to be
|
---|
276 | established.
|
---|
277 | @param[out] ScardAid AID of the Smart Card the connection has been
|
---|
278 | established.
|
---|
279 |
|
---|
280 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
281 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
282 | @retval EFI_INVALID_PARAMETER SCardHandle is NULL.
|
---|
283 | @retval EFI_NO_MEDIA No Smart Card supported by protocol is present,
|
---|
284 | Smart Card with CSN ScardCsn or Reader has been
|
---|
285 | removed. A Disconnect should be performed.
|
---|
286 |
|
---|
287 | **/
|
---|
288 | typedef
|
---|
289 | EFI_STATUS
|
---|
290 | (EFIAPI *EFI_SMART_CARD_EDGE_CONNECT)(
|
---|
291 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
292 | OUT EFI_HANDLE *SCardHandle,
|
---|
293 | IN UINT8 *ScardCsn OPTIONAL,
|
---|
294 | OUT UINT8 *ScardAid OPTIONAL
|
---|
295 | );
|
---|
296 |
|
---|
297 | /**
|
---|
298 | This function releases a connection previously established by Connect.
|
---|
299 |
|
---|
300 | The Disconnect function releases the connection previously established by
|
---|
301 | a Connect. In case the Smart Card or the Smart Card reader has been removed
|
---|
302 | before this call, this function returns EFI_SUCCESS.
|
---|
303 |
|
---|
304 | @param[in] This Indicates a pointer to the calling context.
|
---|
305 | @param[in] SCardHandle Handle on Smart Card connection to release.
|
---|
306 |
|
---|
307 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
308 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
309 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
310 |
|
---|
311 | **/
|
---|
312 | typedef
|
---|
313 | EFI_STATUS
|
---|
314 | (EFIAPI *EFI_SMART_CARD_EDGE_DISCONNECT)(
|
---|
315 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
316 | IN EFI_HANDLE SCardHandle
|
---|
317 | );
|
---|
318 |
|
---|
319 | /**
|
---|
320 | This function returns the Smart Card serial number.
|
---|
321 |
|
---|
322 | @param[in] This Indicates a pointer to the calling context.
|
---|
323 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
324 | @param[out] Csn The Card Serial number, 16 bytes array.
|
---|
325 |
|
---|
326 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
327 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
328 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
329 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
330 | has been removed. A Disconnect should be performed.
|
---|
331 |
|
---|
332 | **/
|
---|
333 | typedef
|
---|
334 | EFI_STATUS
|
---|
335 | (EFIAPI *EFI_SMART_CARD_EDGE_GET_CSN)(
|
---|
336 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
337 | IN EFI_HANDLE SCardHandle,
|
---|
338 | OUT UINT8 Csn[SCARD_CSN_SIZE]
|
---|
339 | );
|
---|
340 |
|
---|
341 | /**
|
---|
342 | This function returns the name of the Smart Card reader used for this connection.
|
---|
343 |
|
---|
344 | @param[in] This Indicates a pointer to the calling context.
|
---|
345 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
346 | @param[in, out] ReaderNameLength On input, a pointer to the variable that holds
|
---|
347 | the maximal size, in bytes, of ReaderName.
|
---|
348 | On output, the required size, in bytes, for ReaderName.
|
---|
349 | @param[out] ReaderName A pointer to a NULL terminated string that will
|
---|
350 | contain the reader name.
|
---|
351 |
|
---|
352 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
353 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
354 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
355 | @retval EFI_INVALID_PARAMETER ReaderNameLength is NULL.
|
---|
356 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
357 | has been removed. A Disconnect should be performed.
|
---|
358 |
|
---|
359 | **/
|
---|
360 | typedef
|
---|
361 | EFI_STATUS
|
---|
362 | (EFIAPI *EFI_SMART_CARD_EDGE_GET_READER_NAME)(
|
---|
363 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
364 | IN EFI_HANDLE SCardHandle,
|
---|
365 | IN OUT UINTN *ReaderNameLength,
|
---|
366 | OUT CHAR16 *ReaderName OPTIONAL
|
---|
367 | );
|
---|
368 |
|
---|
369 | /**
|
---|
370 | This function authenticates a Smart Card user by presenting a PIN code.
|
---|
371 |
|
---|
372 | The VerifyPinfunction presents a PIN code to the Smart Card.
|
---|
373 |
|
---|
374 | If Smart Card found the PIN code correct the user is considered authenticated
|
---|
375 | to current application, and the function returns TRUE.
|
---|
376 |
|
---|
377 | Negative or null PinSize value rejected if PinCodeis not NULL.
|
---|
378 |
|
---|
379 | A NULL PinCodebuffer means the application didn't know the PIN, in that case:
|
---|
380 | - If PinSize value is negative the caller only wants to know if the current
|
---|
381 | chain of the elements Smart Card Edge protocol, Smart Card Reader protocol
|
---|
382 | and Smart Card Reader supports the Secure Pin Entry PCSC V2 functionality.
|
---|
383 | - If PinSize value is positive or null the caller ask to perform the verify
|
---|
384 | PIN using the Secure PIN Entry functionality.
|
---|
385 |
|
---|
386 | In PinCode buffer, the PIN value is always given in plaintext, in case of secure
|
---|
387 | messaging the SMART_CARD_EDGE_PROTOCOL will be in charge of all intermediate
|
---|
388 | treatments to build the correct Smart Card APDU.
|
---|
389 |
|
---|
390 | @param[in] This Indicates a pointer to the calling context.
|
---|
391 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
392 | @param[in] PinSize PIN code buffer size.
|
---|
393 | @param[in] PinCode PIN code to present to the Smart Card.
|
---|
394 | @param[out] PinResult Result of PIN code presentation to the Smart Card.
|
---|
395 | TRUE when Smard Card founds the PIN code correct.
|
---|
396 | @param[out] RemainingAttempts Number of attempts still possible.
|
---|
397 |
|
---|
398 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
399 | @retval EFI_UNSUPPORTED Pinsize < 0 and Secure PIN Entry functionality not
|
---|
400 | supported.
|
---|
401 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
402 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
403 | @retval EFI_INVALID_PARAMETER Bad value for PinSize: value not supported by Smart
|
---|
404 | Card or, negative with PinCode not null.
|
---|
405 | @retval EFI_INVALID_PARAMETER PinResult is NULL.
|
---|
406 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
407 | has been removed. A Disconnect should be performed.
|
---|
408 |
|
---|
409 | **/
|
---|
410 | typedef
|
---|
411 | EFI_STATUS
|
---|
412 | (EFIAPI *EFI_SMART_CARD_EDGE_VERIFY_PIN)(
|
---|
413 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
414 | IN EFI_HANDLE SCardHandle,
|
---|
415 | IN INT32 PinSize,
|
---|
416 | IN UINT8 *PinCode,
|
---|
417 | OUT BOOLEAN *PinResult,
|
---|
418 | OUT UINT32 *RemainingAttempts OPTIONAL
|
---|
419 | );
|
---|
420 |
|
---|
421 | /**
|
---|
422 | This function gives the remaining number of attempts for PIN code presentation.
|
---|
423 |
|
---|
424 | The number of attempts to present a correct PIN is limited and depends on Smart
|
---|
425 | Card and on PIN.
|
---|
426 |
|
---|
427 | This function will retrieve the number of remaining possible attempts.
|
---|
428 |
|
---|
429 | @param[in] This Indicates a pointer to the calling context.
|
---|
430 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
431 | @param[out] RemainingAttempts Number of attempts still possible.
|
---|
432 |
|
---|
433 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
434 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
435 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
436 | @retval EFI_INVALID_PARAMETER RemainingAttempts is NULL.
|
---|
437 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
438 | has been removed. A Disconnect should be performed.
|
---|
439 |
|
---|
440 | **/
|
---|
441 | typedef
|
---|
442 | EFI_STATUS
|
---|
443 | (EFIAPI *EFI_SMART_CARD_EDGE_GET_PIN_REMAINING)(
|
---|
444 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
445 | IN EFI_HANDLE SCardHandle,
|
---|
446 | OUT UINT32 *RemainingAttempts
|
---|
447 | );
|
---|
448 |
|
---|
449 | /**
|
---|
450 | This function returns a specific data from Smart Card.
|
---|
451 |
|
---|
452 | The function is generic for any kind of data, but driver and application must
|
---|
453 | share an EFI_GUID that identify the data.
|
---|
454 |
|
---|
455 | @param[in] This Indicates a pointer to the calling context.
|
---|
456 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
457 | @param[in] DataId The type identifier of the data to get.
|
---|
458 | @param[in, out] DataSize On input, in bytes, the size of Data. On output,
|
---|
459 | in bytes, the size of buffer required to store
|
---|
460 | the specified data.
|
---|
461 | @param[out] Data The data buffer in which the data is returned.
|
---|
462 | The type of the data buffer is associated with
|
---|
463 | the DataId. Ignored if *DataSize is 0.
|
---|
464 |
|
---|
465 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
466 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
467 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
468 | @retval EFI_INVALID_PARAMETER DataId is NULL.
|
---|
469 | @retval EFI_INVALID_PARAMETER DataSize is NULL.
|
---|
470 | @retval EFI_INVALID_PARAMETER Data is NULL, and *DataSize is not zero.
|
---|
471 | @retval EFI_NOT_FOUND DataId unknown for this driver.
|
---|
472 | @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified
|
---|
473 | data and the required size is returned in DataSize.
|
---|
474 | @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
|
---|
475 | PIN not verified.
|
---|
476 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
477 | has been removed. A Disconnect should be performed.
|
---|
478 |
|
---|
479 | **/
|
---|
480 | typedef
|
---|
481 | EFI_STATUS
|
---|
482 | (EFIAPI *EFI_SMART_CARD_EDGE_GET_DATA)(
|
---|
483 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
484 | IN EFI_HANDLE SCardHandle,
|
---|
485 | IN EFI_GUID *DataId,
|
---|
486 | IN OUT UINTN *DataSize,
|
---|
487 | OUT VOID *Data OPTIONAL
|
---|
488 | );
|
---|
489 |
|
---|
490 | /**
|
---|
491 | This function retrieve credentials store into the Smart Card.
|
---|
492 |
|
---|
493 | The function returns a series of items in TLV (Tag Length Value) format.
|
---|
494 |
|
---|
495 | First TLV item is the header item that gives the number of following
|
---|
496 | containers (0x00, 0x01, Nb containers).
|
---|
497 |
|
---|
498 | All these containers are a series of 4 TLV items:
|
---|
499 | - The certificate item (0x01, certificate size, certificate)
|
---|
500 | - The Key identifier item (0x02, 0x01, key index)
|
---|
501 | - The key type item (0x03, 0x01, key type)
|
---|
502 | - The key size item (0x04, 0x02, key size), key size in number of bits.
|
---|
503 | Numeric multi-bytes values are on big endian format, most significant byte first:
|
---|
504 | - The L field value for certificate (2 bytes)
|
---|
505 | - The L field value for key size (2 bytes)
|
---|
506 | - The value field for key size (2 bytes)
|
---|
507 |
|
---|
508 | @param[in] This Indicates a pointer to the calling context.
|
---|
509 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
510 | @param[in, out] CredentialSize On input, in bytes, the size of buffer to store
|
---|
511 | the list of credential.
|
---|
512 | On output, in bytes, the size of buffer required
|
---|
513 | to store the entire list of credentials.
|
---|
514 |
|
---|
515 | @param[out] CredentialList List of credentials stored into the Smart Card.
|
---|
516 | A list of TLV (Tag Length Value) elements organized
|
---|
517 | in containers array.
|
---|
518 |
|
---|
519 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
520 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
521 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
522 | @retval EFI_INVALID_PARAMETER CredentialSize is NULL.
|
---|
523 | @retval EFI_INVALID_PARAMETER CredentialList is NULL, if CredentialSize is not zero.
|
---|
524 | @retval EFI_BUFFER_TOO_SMALL The size of CredentialList is too small for the
|
---|
525 | specified data and the required size is returned in
|
---|
526 | CredentialSize.
|
---|
527 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
528 | has been removed. A Disconnect should be performed.
|
---|
529 |
|
---|
530 | **/
|
---|
531 | typedef
|
---|
532 | EFI_STATUS
|
---|
533 | (EFIAPI *EFI_SMART_CARD_EDGE_GET_CREDENTIAL)(
|
---|
534 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
535 | IN EFI_HANDLE SCardHandle,
|
---|
536 | IN OUT UINTN *CredentialSize,
|
---|
537 | OUT UINT8 *CredentialList OPTIONAL
|
---|
538 | );
|
---|
539 |
|
---|
540 | /**
|
---|
541 | This function signs an already hashed data with a Smart Card private key.
|
---|
542 |
|
---|
543 | This function signs data, actually it is the hash of these data that is given
|
---|
544 | to the function.
|
---|
545 |
|
---|
546 | SignatureData buffer shall be big enough for signature. Signature size is
|
---|
547 | function key size and key type.
|
---|
548 |
|
---|
549 | @param[in] This Indicates a pointer to the calling context.
|
---|
550 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
551 | @param[in] KeyId Identifier of the key container, retrieved
|
---|
552 | in a key index item of credentials.
|
---|
553 | @param[in] KeyType The key type, retrieved in a key type item of
|
---|
554 | credentials.
|
---|
555 |
|
---|
556 | @param[in] HashAlgorithm Hash algorithm used to hash the, one of:
|
---|
557 | - EFI_HASH_ALGORITHM_SHA1_GUID
|
---|
558 | - EFI_HASH_ALGORITHM_SHA256_GUID
|
---|
559 | - EFI_HASH_ALGORITHM_SHA384_GUID
|
---|
560 | - EFI_HASH_ALGORITHM_SHA512_GUID
|
---|
561 | @param[in] PaddingMethod Padding method used jointly with hash algorithm,
|
---|
562 | one of:
|
---|
563 | - EFI_PADDING_RSASSA_PKCS1V1P5_GUID
|
---|
564 | - EFI_PADDING_RSASSA_PSS_GUID
|
---|
565 | @param[in] HashedData Hash of the data to sign. Size is function of the
|
---|
566 | HashAlgorithm.
|
---|
567 |
|
---|
568 | @param[out] SignatureData Resulting signature with private key KeyId. Size
|
---|
569 | is function of the KeyType and key size retrieved
|
---|
570 | in the associated key size item of credentials.
|
---|
571 |
|
---|
572 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
573 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
574 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
575 | @retval EFI_INVALID_PARAMETER KeyId is not valid.
|
---|
576 | @retval EFI_INVALID_PARAMETER KeyType is not valid or not corresponding to KeyId.
|
---|
577 | @retval EFI_INVALID_PARAMETER HashAlgorithm is NULL.
|
---|
578 | @retval EFI_INVALID_PARAMETER HashAlgorithm is not valid.
|
---|
579 | @retval EFI_INVALID_PARAMETER PaddingMethod is NULL.
|
---|
580 | @retval EFI_INVALID_PARAMETER PaddingMethod is not valid.
|
---|
581 | @retval EFI_INVALID_PARAMETER HashedData is NULL.
|
---|
582 | @retval EFI_INVALID_PARAMETER SignatureData is NULL.
|
---|
583 | @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
|
---|
584 | PIN not verified.
|
---|
585 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
586 | has been removed. A Disconnect should be performed.
|
---|
587 |
|
---|
588 | **/
|
---|
589 | typedef
|
---|
590 | EFI_STATUS
|
---|
591 | (EFIAPI *EFI_SMART_CARD_EDGE_SIGN_DATA)(
|
---|
592 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
593 | IN EFI_HANDLE SCardHandle,
|
---|
594 | IN UINTN KeyId,
|
---|
595 | IN UINTN KeyType,
|
---|
596 | IN EFI_GUID *HashAlgorithm,
|
---|
597 | IN EFI_GUID *PaddingMethod,
|
---|
598 | IN UINT8 *HashedData,
|
---|
599 | OUT UINT8 *SignatureData
|
---|
600 | );
|
---|
601 |
|
---|
602 | /**
|
---|
603 | This function decrypts data with a PKI/RSA Smart Card private key.
|
---|
604 |
|
---|
605 | The function decrypts some PKI/RSA encrypted data with private key securely
|
---|
606 | stored into the Smart Card.
|
---|
607 |
|
---|
608 | The KeyId must reference a key of type SC_EDGE_RSA_EXCHANGE.
|
---|
609 |
|
---|
610 | @param[in] This Indicates a pointer to the calling context.
|
---|
611 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
612 | @param[in] KeyId Identifier of the key container, retrieved
|
---|
613 | in a key index item of credentials.
|
---|
614 | @param[in] HashAlgorithm Hash algorithm used to hash the, one of:
|
---|
615 | - EFI_HASH_ALGORITHM_SHA1_GUID
|
---|
616 | - EFI_HASH_ALGORITHM_SHA256_GUID
|
---|
617 | - EFI_HASH_ALGORITHM_SHA384_GUID
|
---|
618 | - EFI_HASH_ALGORITHM_SHA512_GUID
|
---|
619 | @param[in] PaddingMethod Padding method used jointly with hash algorithm,
|
---|
620 | one of:
|
---|
621 | - EFI_PADDING_NONE_GUID
|
---|
622 | - EFI_PADDING_RSAES_PKCS1V1P5_GUID
|
---|
623 | - EFI_PADDING_RSAES_OAEP_GUID
|
---|
624 | @param[in] EncryptedSize Size of data to decrypt.
|
---|
625 | @param[in] EncryptedData Data to decrypt
|
---|
626 | @param[in, out] PlaintextSize On input, in bytes, the size of buffer to store
|
---|
627 | the decrypted data.
|
---|
628 | On output, in bytes, the size of buffer required
|
---|
629 | to store the decrypted data.
|
---|
630 | @param[out] PlaintextData Buffer for decrypted data, padding removed.
|
---|
631 |
|
---|
632 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
633 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
634 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
635 | @retval EFI_INVALID_PARAMETER KeyId is not valid or associated key not of type
|
---|
636 | SC_EDGE_RSA_EXCHANGE.
|
---|
637 | @retval EFI_INVALID_PARAMETER HashAlgorithm is NULL.
|
---|
638 | @retval EFI_INVALID_PARAMETER HashAlgorithm is not valid.
|
---|
639 | @retval EFI_INVALID_PARAMETER PaddingMethod is NULL.
|
---|
640 | @retval EFI_INVALID_PARAMETER PaddingMethod is not valid.
|
---|
641 | @retval EFI_INVALID_PARAMETER EncryptedSize is 0.
|
---|
642 | @retval EFI_INVALID_PARAMETER EncryptedData is NULL.
|
---|
643 | @retval EFI_INVALID_PARAMETER PlaintextSize is NULL.
|
---|
644 | @retval EFI_INVALID_PARAMETER PlaintextData is NULL.
|
---|
645 | @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
|
---|
646 | PIN not verified.
|
---|
647 | @retval EFI_BUFFER_TOO_SMALL PlaintextSize is too small for the plaintext data
|
---|
648 | and the required size is returned in PlaintextSize.
|
---|
649 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
650 | has been removed. A Disconnect should be performed.
|
---|
651 |
|
---|
652 | **/
|
---|
653 | typedef
|
---|
654 | EFI_STATUS
|
---|
655 | (EFIAPI *EFI_SMART_CARD_EDGE_DECRYPT_DATA)(
|
---|
656 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
657 | IN EFI_HANDLE SCardHandle,
|
---|
658 | IN UINTN KeyId,
|
---|
659 | IN EFI_GUID *HashAlgorithm,
|
---|
660 | IN EFI_GUID *PaddingMethod,
|
---|
661 | IN UINTN EncryptedSize,
|
---|
662 | IN UINT8 *EncryptedData,
|
---|
663 | IN OUT UINTN *PlaintextSize,
|
---|
664 | OUT UINT8 *PlaintextData
|
---|
665 | );
|
---|
666 |
|
---|
667 | /**
|
---|
668 | This function performs a secret Diffie Hellman agreement calculation that would
|
---|
669 | be used to derive a symmetric encryption / decryption key.
|
---|
670 |
|
---|
671 | The function compute a DH agreement that should be diversified togenerate a symmetric
|
---|
672 | key to proceed encryption or decryption.
|
---|
673 |
|
---|
674 | The application and the Smart Card shall agree on the diversification process.
|
---|
675 |
|
---|
676 | The KeyId must reference a key of one of the types: SC_EDGE_ECDH_256, SC_EDGE_ECDH_384
|
---|
677 | or SC_EDGE_ECDH_521.
|
---|
678 |
|
---|
679 | @param[in] This Indicates a pointer to the calling context.
|
---|
680 | @param[in] SCardHandle Handle on Smart Card connection.
|
---|
681 | @param[in] KeyId Identifier of the key container, retrieved
|
---|
682 | in a key index item of credentials.
|
---|
683 | @param[in] dataQx Public key x coordinate. Size is the same as
|
---|
684 | key size for KeyId. Stored in big endian format.
|
---|
685 | @param[in] dataQy Public key y coordinate. Size is the same as
|
---|
686 | key size for KeyId. Stored in big endian format.
|
---|
687 | @param[out] DHAgreement Buffer for DH agreement computed. Size must be
|
---|
688 | bigger or equal to key size for KeyId.
|
---|
689 |
|
---|
690 | @retval EFI_SUCCESS The requested command completed successfully.
|
---|
691 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
692 | @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
|
---|
693 | @retval EFI_INVALID_PARAMETER KeyId is not valid.
|
---|
694 | @retval EFI_INVALID_PARAMETER dataQx is NULL.
|
---|
695 | @retval EFI_INVALID_PARAMETER dataQy is NULL.
|
---|
696 | @retval EFI_INVALID_PARAMETER DHAgreement is NULL.
|
---|
697 | @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
|
---|
698 | PIN not verified.
|
---|
699 | @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
|
---|
700 | has been removed. A Disconnect should be performed.
|
---|
701 |
|
---|
702 | **/
|
---|
703 | typedef
|
---|
704 | EFI_STATUS
|
---|
705 | (EFIAPI *EFI_SMART_CARD_EDGE_BUILD_DH_AGREEMENT)(
|
---|
706 | IN EFI_SMART_CARD_EDGE_PROTOCOL *This,
|
---|
707 | IN EFI_HANDLE SCardHandle,
|
---|
708 | IN UINTN KeyId,
|
---|
709 | IN UINT8 *dataQx,
|
---|
710 | IN UINT8 *dataQy,
|
---|
711 | OUT UINT8 *DHAgreement
|
---|
712 | );
|
---|
713 |
|
---|
714 | ///
|
---|
715 | /// Smart card aware application invokes this protocol to get access to an inserted
|
---|
716 | /// smart card in the reader or to the reader itself.
|
---|
717 | ///
|
---|
718 | struct _EFI_SMART_CARD_EDGE_PROTOCOL {
|
---|
719 | EFI_SMART_CARD_EDGE_GET_CONTEXT GetContext;
|
---|
720 | EFI_SMART_CARD_EDGE_CONNECT Connect;
|
---|
721 | EFI_SMART_CARD_EDGE_DISCONNECT Disconnect;
|
---|
722 | EFI_SMART_CARD_EDGE_GET_CSN GetCsn;
|
---|
723 | EFI_SMART_CARD_EDGE_GET_READER_NAME GetReaderName;
|
---|
724 | EFI_SMART_CARD_EDGE_VERIFY_PIN VerifyPin;
|
---|
725 | EFI_SMART_CARD_EDGE_GET_PIN_REMAINING GetPinRemaining;
|
---|
726 | EFI_SMART_CARD_EDGE_GET_DATA GetData;
|
---|
727 | EFI_SMART_CARD_EDGE_GET_CREDENTIAL GetCredential;
|
---|
728 | EFI_SMART_CARD_EDGE_SIGN_DATA SignData;
|
---|
729 | EFI_SMART_CARD_EDGE_DECRYPT_DATA DecryptData;
|
---|
730 | EFI_SMART_CARD_EDGE_BUILD_DH_AGREEMENT BuildDHAgreement;
|
---|
731 | };
|
---|
732 |
|
---|
733 | extern EFI_GUID gEfiSmartCardEdgeProtocolGuid;
|
---|
734 |
|
---|
735 | #endif
|
---|