2 The Smart Card Edge Protocol provides an abstraction for device to provide Smart
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.
9 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #ifndef __SMART_CARD_EDGE_H__
21 #define __SMART_CARD_EDGE_H__
23 #define EFI_SMART_CARD_EDGE_PROTOCOL_GUID \
25 0xd317f29b, 0xa325, 0x4712, {0x9b, 0xf1, 0xc6, 0x19, 0x54, 0xdc, 0x19, 0x8c} \
28 typedef struct _EFI_SMART_CARD_EDGE_PROTOCOL EFI_SMART_CARD_EDGE_PROTOCOL
;
31 // Maximum size for a Smart Card AID (Application IDentifier)
33 #define SCARD_AID_MAXSIZE 0x0010
35 // Size of CSN (Card Serial Number)
37 #define SCARD_CSN_SIZE 0x0010
39 // Current specification version 1.00
41 #define SMART_CARD_EDGE_PROTOCOL_VERSION_1 0x00000100
43 // Parameters type definition
45 typedef UINT8 SMART_CARD_AID
[SCARD_AID_MAXSIZE
];
46 typedef UINT8 SMART_CARD_CSN
[SCARD_CSN_SIZE
];
49 // Type of data elements in credentials list
51 // value of tag field for header, the number of containers
53 #define SC_EDGE_TAG_HEADER 0x0000
55 // value of tag field for certificate
57 #define SC_EDGE_TAG_CERT 0x0001
59 // value of tag field for key index associated with certificate
61 #define SC_EDGE_TAG_KEY_ID 0x0002
63 // value of tag field for key type
65 #define SC_EDGE_TAG_KEY_TYPE 0x0003
67 // value of tag field for key size
69 #define SC_EDGE_TAG_KEY_SIZE 0x0004
72 // Length of L fields of TLV items
75 // size of L field for header
77 #define SC_EDGE_L_SIZE_HEADER 1
79 // size of L field for certificate (big endian)
81 #define SC_EDGE_L_SIZE_CERT 2
83 // size of L field for key index
85 #define SC_EDGE_L_SIZE_KEY_ID 1
87 // size of L field for key type
89 #define SC_EDGE_L_SIZE_KEY_TYPE 1
91 // size of L field for key size (big endian)
93 #define SC_EDGE_L_SIZE_KEY_SIZE 2
96 // Some TLV items have a fixed value for L field
98 // value of L field for header
100 #define SC_EDGE_L_VALUE_HEADER 1
102 // value of L field for key index
104 #define SC_EDGE_L_VALUE_KEY_ID 1
106 // value of L field for key type
108 #define SC_EDGE_L_VALUE_KEY_TYPE 1
110 // value of L field for key size
112 #define SC_EDGE_L_VALUE_KEY_SIZE 2
115 // Possible values for key type
120 #define SC_EDGE_RSA_EXCHANGE 0x01
124 #define SC_EDGE_RSA_SIGNATURE 0x02
128 #define SC_EDGE_ECDSA_256 0x03
132 #define SC_EDGE_ECDSA_384 0x04
136 #define SC_EDGE_ECDSA_521 0x05
140 #define SC_EDGE_ECDH_256 0x06
144 #define SC_EDGE_ECDH_384 0x07
148 #define SC_EDGE_ECDH_521 0x08
151 // Padding methods GUIDs for signature
154 // RSASSA- PKCS#1-V1.5 padding method, for signature
156 #define EFI_PADDING_RSASSA_PKCS1V1P5_GUID \
158 0x9317ec24, 0x7cb0, 0x4d0e, {0x8b, 0x32, 0x2e, 0xd9, 0x20, 0x9c, 0xd8, 0xaf} \
161 extern EFI_GUID gEfiPaddingRsassaPkcs1V1P5Guid
;
164 // RSASSA-PSS padding method, for signature
166 #define EFI_PADDING_RSASSA_PSS_GUID \
168 0x7b2349e0, 0x522d, 0x4f8e, {0xb9, 0x27, 0x69, 0xd9, 0x7c, 0x9e, 0x79, 0x5f} \
171 extern EFI_GUID gEfiPaddingRsassaPssGuid
;
174 // Padding methods GUIDs for decryption
177 // No padding, for decryption
179 #define EFI_PADDING_NONE_GUID \
181 0x3629ddb1, 0x228c, 0x452e, {0xb6, 0x16, 0x09, 0xed, 0x31, 0x6a, 0x97, 0x00} \
184 extern EFI_GUID gEfiPaddingNoneGuid
;
187 // RSAES-PKCS#1-V1.5 padding, for decryption
189 #define EFI_PADDING_RSAES_PKCS1V1P5_GUID \
191 0xe1c1d0a9, 0x40b1, 0x4632, {0xbd, 0xcc, 0xd9, 0xd6, 0xe5, 0x29, 0x56, 0x31} \
194 extern EFI_GUID gEfiPaddingRsaesPkcs1V1P5Guid
;
197 // RSAES-OAEP padding, for decryption
199 #define EFI_PADDING_RSAES_OAEP_GUID \
201 0xc1e63ac4, 0xd0cf, 0x4ce6, {0x83, 0x5b, 0xee, 0xd0, 0xe6, 0xa8, 0xa4, 0x5b} \
204 extern EFI_GUID gEfiPaddingRsaesOaepGuid
;
207 This function retrieves the context driver.
209 The GetContextfunction returns the context of the protocol, the application
210 identifiers supported by the protocol and the number and the CSN unique identifier
211 of Smart Cards that are present and supported by protocol.
213 If AidTableSize, AidTable, CsnTableSize, CsnTable or VersionProtocol is NULL,
214 the function does not fail but does not fill in such variables.
216 In case AidTableSize indicates a buffer too small to hold all the protocol AID table,
217 only the first AidTableSize items of the table are returned in AidTable.
219 In case CsnTableSize indicates a buffer too small to hold the entire table of
220 Smart Card CSN present, only the first CsnTableSize items of the table are returned
223 VersionScEdgeProtocol returns the version of the EFI_SMART_CARD_EDGE_PROTOCOL this
224 driver uses. For this protocol specification value is SMART_CARD_EDGE_PROTOCOL_VERSION_1.
226 In case of Smart Card removal the internal CSN list is immediately updated, even if
227 a connection is opened with that Smart Card.
229 @param[in] This Indicates a pointer to the calling context.
230 @param[out] NumberAidSupported Number of AIDs this protocol supports.
231 @param[in, out] AidTableSize On input, number of items allocated for the
232 AID table. On output, number of items returned
234 @param[out] AidTable Table of the AIDs supported by the protocol.
235 @param[out] NumberSCPresent Number of currently present Smart Cards that
236 are supported by protocol.
237 @param[in, out] CsnTableSize On input, the number of items the buffer CSN
238 table can contain. On output, the number of
239 items returned by the protocol.
240 @param[out] CsnTable Table of the CSN of the Smart Card present and
241 supported by protocol.
242 @param[out] VersionScEdgeProtocol EFI_SMART_CARD_EDGE_PROTOCOL version.
244 @retval EFI_SUCCESS The requested command completed successfully.
245 @retval EFI_INVALID_PARAMETER This is NULL.
246 @retval EFI_INVALID_PARAMETER NumberSCPresent is NULL.
251 (EFIAPI
*EFI_SMART_CARD_EDGE_GET_CONTEXT
) (
252 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
253 OUT UINTN
*NumberAidSupported
,
254 IN OUT UINTN
*AidTableSize OPTIONAL
,
255 OUT SMART_CARD_AID
*AidTable OPTIONAL
,
256 OUT UINTN
*NumberSCPresent
,
257 IN OUT UINTN
*CsnTableSize OPTIONAL
,
258 OUT SMART_CARD_CSN
*CsnTable OPTIONAL
,
259 OUT UINT32
*VersionScEdgeProtocol OPTIONAL
263 This function establish a connection with a Smart Card the protocol support.
265 In case of success the SCardHandle can be used.
267 If the ScardCsn is NULL the connection is established with the first Smart Card
268 the protocol finds in its table of Smart Card present and supported. Else it
269 establish context with the Smart Card whose CSN given by ScardCsn.
271 If ScardAid is not NULL the function returns the Smart Card AID the protocol supports.
272 After a successful connect the SCardHandle will remain existing even in case Smart Card
273 removed from Smart Card reader, but all function invoking this SCardHandle will fail.
274 SCardHandle is released only on Disconnect.
276 @param[in] This Indicates a pointer to the calling context.
277 @param[out] SCardHandle Handle on Smart Card connection.
278 @param[in] ScardCsn CSN of the Smart Card the connection has to be
280 @param[out] ScardAid AID of the Smart Card the connection has been
283 @retval EFI_SUCCESS The requested command completed successfully.
284 @retval EFI_INVALID_PARAMETER This is NULL.
285 @retval EFI_INVALID_PARAMETER SCardHandle is NULL.
286 @retval EFI_NO_MEDIA No Smart Card supported by protocol is present,
287 Smart Card with CSN ScardCsn or Reader has been
288 removed. A Disconnect should be performed.
293 (EFIAPI
*EFI_SMART_CARD_EDGE_CONNECT
) (
294 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
295 OUT EFI_HANDLE
*SCardHandle
,
296 IN UINT8
*ScardCsn OPTIONAL
,
297 OUT UINT8
*ScardAid OPTIONAL
301 This function releases a connection previously established by Connect.
303 The Disconnect function releases the connection previously established by
304 a Connect. In case the Smart Card or the Smart Card reader has been removed
305 before this call, this function returns EFI_SUCCESS.
307 @param[in] This Indicates a pointer to the calling context.
308 @param[in] SCardHandle Handle on Smart Card connection to release.
310 @retval EFI_SUCCESS The requested command completed successfully.
311 @retval EFI_INVALID_PARAMETER This is NULL.
312 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
317 (EFIAPI
*EFI_SMART_CARD_EDGE_DISCONNECT
) (
318 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
319 IN EFI_HANDLE SCardHandle
323 This function returns the Smart Card serial number.
325 @param[in] This Indicates a pointer to the calling context.
326 @param[in] SCardHandle Handle on Smart Card connection.
327 @param[out] Csn The Card Serial number, 16 bytes array.
329 @retval EFI_SUCCESS The requested command completed successfully.
330 @retval EFI_INVALID_PARAMETER This is NULL.
331 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
332 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
333 has been removed. A Disconnect should be performed.
338 (EFIAPI
*EFI_SMART_CARD_EDGE_GET_CSN
) (
339 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
340 IN EFI_HANDLE SCardHandle
,
341 OUT UINT8 Csn
[SCARD_CSN_SIZE
]
345 This function returns the name of the Smart Card reader used for this connection.
347 @param[in] This Indicates a pointer to the calling context.
348 @param[in] SCardHandle Handle on Smart Card connection.
349 @param[in, out] ReaderNameLength On input, a pointer to the variable that holds
350 the maximal size, in bytes, of ReaderName.
351 On output, the required size, in bytes, for ReaderName.
352 @param[out] ReaderName A pointer to a NULL terminated string that will
353 contain the reader name.
355 @retval EFI_SUCCESS The requested command completed successfully.
356 @retval EFI_INVALID_PARAMETER This is NULL.
357 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
358 @retval EFI_INVALID_PARAMETER ReaderNameLength is NULL.
359 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
360 has been removed. A Disconnect should be performed.
365 (EFIAPI
*EFI_SMART_CARD_EDGE_GET_READER_NAME
) (
366 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
367 IN EFI_HANDLE SCardHandle
,
368 IN OUT UINTN
*ReaderNameLength
,
369 OUT CHAR16
*ReaderName OPTIONAL
373 This function authenticates a Smart Card user by presenting a PIN code.
375 The VerifyPinfunction presents a PIN code to the Smart Card.
377 If Smart Card found the PIN code correct the user is considered authenticated
378 to current application, and the function returns TRUE.
380 Negative or null PinSize value rejected if PinCodeis not NULL.
382 A NULL PinCodebuffer means the application didn't know the PIN, in that case:
383 - If PinSize value is negative the caller only wants to know if the current
384 chain of the elements Smart Card Edge protocol, Smart Card Reader protocol
385 and Smart Card Reader supports the Secure Pin Entry PCSC V2 functionality.
386 - If PinSize value is positive or null the caller ask to perform the verify
387 PIN using the Secure PIN Entry functionality.
389 In PinCode buffer, the PIN value is always given in plaintext, in case of secure
390 messaging the SMART_CARD_EDGE_PROTOCOL will be in charge of all intermediate
391 treatments to build the correct Smart Card APDU.
393 @param[in] This Indicates a pointer to the calling context.
394 @param[in] SCardHandle Handle on Smart Card connection.
395 @param[in] PinSize PIN code buffer size.
396 @param[in] PinCode PIN code to present to the Smart Card.
397 @param[out] PinResult Result of PIN code presentation to the Smart Card.
398 TRUE when Smard Card founds the PIN code correct.
399 @param[out] RemainingAttempts Number of attempts still possible.
401 @retval EFI_SUCCESS The requested command completed successfully.
402 @retval EFI_UNSUPPORTED Pinsize < 0 and Secure PIN Entry functionality not
404 @retval EFI_INVALID_PARAMETER This is NULL.
405 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
406 @retval EFI_INVALID_PARAMETER Bad value for PinSize: value not supported by Smart
407 Card or, negative with PinCode not null.
408 @retval EFI_INVALID_PARAMETER PinResult is NULL.
409 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
410 has been removed. A Disconnect should be performed.
415 (EFIAPI
*EFI_SMART_CARD_EDGE_VERIFY_PIN
) (
416 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
417 IN EFI_HANDLE SCardHandle
,
420 OUT BOOLEAN
*PinResult
,
421 OUT UINT32
*RemainingAttempts OPTIONAL
425 This function gives the remaining number of attempts for PIN code presentation.
427 The number of attempts to present a correct PIN is limited and depends on Smart
430 This function will retrieve the number of remaining possible attempts.
432 @param[in] This Indicates a pointer to the calling context.
433 @param[in] SCardHandle Handle on Smart Card connection.
434 @param[out] RemainingAttempts Number of attempts still possible.
436 @retval EFI_SUCCESS The requested command completed successfully.
437 @retval EFI_INVALID_PARAMETER This is NULL.
438 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
439 @retval EFI_INVALID_PARAMETER RemainingAttempts is NULL.
440 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
441 has been removed. A Disconnect should be performed.
446 (EFIAPI
*EFI_SMART_CARD_EDGE_GET_PIN_REMAINING
) (
447 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
448 IN EFI_HANDLE SCardHandle
,
449 OUT UINT32
*RemainingAttempts
453 This function returns a specific data from Smart Card.
455 The function is generic for any kind of data, but driver and application must
456 share an EFI_GUID that identify the data.
458 @param[in] This Indicates a pointer to the calling context.
459 @param[in] SCardHandle Handle on Smart Card connection.
460 @param[in] DataId The type identifier of the data to get.
461 @param[in, out] DataSize On input, in bytes, the size of Data. On output,
462 in bytes, the size of buffer required to store
464 @param[out] Data The data buffer in which the data is returned.
465 The type of the data buffer is associated with
466 the DataId. Ignored if *DataSize is 0.
468 @retval EFI_SUCCESS The requested command completed successfully.
469 @retval EFI_INVALID_PARAMETER This is NULL.
470 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
471 @retval EFI_INVALID_PARAMETER DataId is NULL.
472 @retval EFI_INVALID_PARAMETER DataSize is NULL.
473 @retval EFI_INVALID_PARAMETER Data is NULL, and *DataSize is not zero.
474 @retval EFI_NOT_FOUND DataId unknown for this driver.
475 @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified
476 data and the required size is returned in DataSize.
477 @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
479 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
480 has been removed. A Disconnect should be performed.
485 (EFIAPI
*EFI_SMART_CARD_EDGE_GET_DATA
) (
486 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
487 IN EFI_HANDLE SCardHandle
,
489 IN OUT UINTN
*DataSize
,
490 OUT VOID
*Data OPTIONAL
494 This function retrieve credentials store into the Smart Card.
496 The function returns a series of items in TLV (Tag Length Value) format.
498 First TLV item is the header item that gives the number of following
499 containers (0x00, 0x01, Nb containers).
501 All these containers are a series of 4 TLV items:
502 - The certificate item (0x01, certificate size, certificate)
503 - The Key identifier item (0x02, 0x01, key index)
504 - The key type item (0x03, 0x01, key type)
505 - The key size item (0x04, 0x02, key size), key size in number of bits.
506 Numeric multi-bytes values are on big endian format, most significant byte first:
507 - The L field value for certificate (2 bytes)
508 - The L field value for key size (2 bytes)
509 - The value field for key size (2 bytes)
511 @param[in] This Indicates a pointer to the calling context.
512 @param[in] SCardHandle Handle on Smart Card connection.
513 @param[in, out] CredentialSize On input, in bytes, the size of buffer to store
514 the list of credential.
515 On output, in bytes, the size of buffer required
516 to store the entire list of credentials.
518 @param[out] CredentialList List of credentials stored into the Smart Card.
519 A list of TLV (Tag Length Value) elements organized
522 @retval EFI_SUCCESS The requested command completed successfully.
523 @retval EFI_INVALID_PARAMETER This is NULL.
524 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
525 @retval EFI_INVALID_PARAMETER CredentialSize is NULL.
526 @retval EFI_INVALID_PARAMETER CredentialList is NULL, if CredentialSize is not zero.
527 @retval EFI_BUFFER_TOO_SMALL The size of CredentialList is too small for the
528 specified data and the required size is returned in
530 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
531 has been removed. A Disconnect should be performed.
536 (EFIAPI
*EFI_SMART_CARD_EDGE_GET_CREDENTIAL
) (
537 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
538 IN EFI_HANDLE SCardHandle
,
539 IN OUT UINTN
*CredentialSize
,
540 OUT UINT8
*CredentialList OPTIONAL
544 This function signs an already hashed data with a Smart Card private key.
546 This function signs data, actually it is the hash of these data that is given
549 SignatureData buffer shall be big enough for signature. Signature size is
550 function key size and key type.
552 @param[in] This Indicates a pointer to the calling context.
553 @param[in] SCardHandle Handle on Smart Card connection.
554 @param[in] KeyId Identifier of the key container, retrieved
555 in a key index item of credentials.
556 @param[in] KeyType The key type, retrieved in a key type item of
559 @param[in] HashAlgorithm Hash algorithm used to hash the, one of:
560 - EFI_HASH_ALGORITHM_SHA1_GUID
561 - EFI_HASH_ALGORITHM_SHA256_GUID
562 - EFI_HASH_ALGORITHM_SHA384_GUID
563 - EFI_HASH_ALGORITHM_SHA512_GUID
564 @param[in] PaddingMethod Padding method used jointly with hash algorithm,
566 - EFI_PADDING_RSASSA_PKCS1V1P5_GUID
567 - EFI_PADDING_RSASSA_PSS_GUID
568 @param[in] HashedData Hash of the data to sign. Size is function of the
571 @param[out] SignatureData Resulting signature with private key KeyId. Size
572 is function of the KeyType and key size retrieved
573 in the associated key size item of credentials.
575 @retval EFI_SUCCESS The requested command completed successfully.
576 @retval EFI_INVALID_PARAMETER This is NULL.
577 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
578 @retval EFI_INVALID_PARAMETER KeyId is not valid.
579 @retval EFI_INVALID_PARAMETER KeyType is not valid or not corresponding to KeyId.
580 @retval EFI_INVALID_PARAMETER HashAlgorithm is NULL.
581 @retval EFI_INVALID_PARAMETER HashAlgorithm is not valid.
582 @retval EFI_INVALID_PARAMETER PaddingMethod is NULL.
583 @retval EFI_INVALID_PARAMETER PaddingMethod is not valid.
584 @retval EFI_INVALID_PARAMETER HashedData is NULL.
585 @retval EFI_INVALID_PARAMETER SignatureData is NULL.
586 @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
588 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
589 has been removed. A Disconnect should be performed.
594 (EFIAPI
*EFI_SMART_CARD_EDGE_SIGN_DATA
) (
595 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
596 IN EFI_HANDLE SCardHandle
,
599 IN EFI_GUID
*HashAlgorithm
,
600 IN EFI_GUID
*PaddingMethod
,
601 IN UINT8
*HashedData
,
602 OUT UINT8
*SignatureData
606 This function decrypts data with a PKI/RSA Smart Card private key.
608 The function decrypts some PKI/RSA encrypted data with private key securely
609 stored into the Smart Card.
611 The KeyId must reference a key of type SC_EDGE_RSA_EXCHANGE.
613 @param[in] This Indicates a pointer to the calling context.
614 @param[in] SCardHandle Handle on Smart Card connection.
615 @param[in] KeyId Identifier of the key container, retrieved
616 in a key index item of credentials.
617 @param[in] HashAlgorithm Hash algorithm used to hash the, one of:
618 - EFI_HASH_ALGORITHM_SHA1_GUID
619 - EFI_HASH_ALGORITHM_SHA256_GUID
620 - EFI_HASH_ALGORITHM_SHA384_GUID
621 - EFI_HASH_ALGORITHM_SHA512_GUID
622 @param[in] PaddingMethod Padding method used jointly with hash algorithm,
624 - EFI_PADDING_NONE_GUID
625 - EFI_PADDING_RSAES_PKCS1V1P5_GUID
626 - EFI_PADDING_RSAES_OAEP_GUID
627 @param[in] EncryptedSize Size of data to decrypt.
628 @param[in] EncryptedData Data to decrypt
629 @param[in, out] PlaintextSize On input, in bytes, the size of buffer to store
631 On output, in bytes, the size of buffer required
632 to store the decrypted data.
633 @param[out] PlaintextData Buffer for decrypted data, padding removed.
635 @retval EFI_SUCCESS The requested command completed successfully.
636 @retval EFI_INVALID_PARAMETER This is NULL.
637 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
638 @retval EFI_INVALID_PARAMETER KeyId is not valid or associated key not of type
639 SC_EDGE_RSA_EXCHANGE.
640 @retval EFI_INVALID_PARAMETER HashAlgorithm is NULL.
641 @retval EFI_INVALID_PARAMETER HashAlgorithm is not valid.
642 @retval EFI_INVALID_PARAMETER PaddingMethod is NULL.
643 @retval EFI_INVALID_PARAMETER PaddingMethod is not valid.
644 @retval EFI_INVALID_PARAMETER EncryptedSize is 0.
645 @retval EFI_INVALID_PARAMETER EncryptedData is NULL.
646 @retval EFI_INVALID_PARAMETER PlaintextSize is NULL.
647 @retval EFI_INVALID_PARAMETER PlaintextData is NULL.
648 @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
650 @retval EFI_BUFFER_TOO_SMALL PlaintextSize is too small for the plaintext data
651 and the required size is returned in PlaintextSize.
652 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
653 has been removed. A Disconnect should be performed.
658 (EFIAPI
*EFI_SMART_CARD_EDGE_DECRYPT_DATA
) (
659 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
660 IN EFI_HANDLE SCardHandle
,
662 IN EFI_GUID
*HashAlgorithm
,
663 IN EFI_GUID
*PaddingMethod
,
664 IN UINTN EncryptedSize
,
665 IN UINT8
*EncryptedData
,
666 IN OUT UINTN
*PlaintextSize
,
667 OUT UINT8
*PlaintextData
671 This function performs a secret Diffie Hellman agreement calculation that would
672 be used to derive a symmetric encryption / decryption key.
674 The function compute a DH agreement that should be diversified togenerate a symmetric
675 key to proceed encryption or decryption.
677 The application and the Smart Card shall agree on the diversification process.
679 The KeyId must reference a key of one of the types: SC_EDGE_ECDH_256, SC_EDGE_ECDH_384
682 @param[in] This Indicates a pointer to the calling context.
683 @param[in] SCardHandle Handle on Smart Card connection.
684 @param[in] KeyId Identifier of the key container, retrieved
685 in a key index item of credentials.
686 @param[in] dataQx Public key x coordinate. Size is the same as
687 key size for KeyId. Stored in big endian format.
688 @param[in] dataQy Public key y coordinate. Size is the same as
689 key size for KeyId. Stored in big endian format.
690 @param[out] DHAgreement Buffer for DH agreement computed. Size must be
691 bigger or equal to key size for KeyId.
693 @retval EFI_SUCCESS The requested command completed successfully.
694 @retval EFI_INVALID_PARAMETER This is NULL.
695 @retval EFI_INVALID_PARAMETER No connection for SCardHandle value.
696 @retval EFI_INVALID_PARAMETER KeyId is not valid.
697 @retval EFI_INVALID_PARAMETER dataQx is NULL.
698 @retval EFI_INVALID_PARAMETER dataQy is NULL.
699 @retval EFI_INVALID_PARAMETER DHAgreement is NULL.
700 @retval EFI_ACCESS_DENIED Operation not performed, conditions not fulfilled.
702 @retval EFI_NO_MEDIA Smart Card or Reader of SCardHandle connection
703 has been removed. A Disconnect should be performed.
708 (EFIAPI
*EFI_SMART_CARD_EDGE_BUILD_DH_AGREEMENT
) (
709 IN EFI_SMART_CARD_EDGE_PROTOCOL
*This
,
710 IN EFI_HANDLE SCardHandle
,
714 OUT UINT8
*DHAgreement
718 /// Smart card aware application invokes this protocol to get access to an inserted
719 /// smart card in the reader or to the reader itself.
721 struct _EFI_SMART_CARD_EDGE_PROTOCOL
{
722 EFI_SMART_CARD_EDGE_GET_CONTEXT GetContext
;
723 EFI_SMART_CARD_EDGE_CONNECT Connect
;
724 EFI_SMART_CARD_EDGE_DISCONNECT Disconnect
;
725 EFI_SMART_CARD_EDGE_GET_CSN GetCsn
;
726 EFI_SMART_CARD_EDGE_GET_READER_NAME GetReaderName
;
727 EFI_SMART_CARD_EDGE_VERIFY_PIN VerifyPin
;
728 EFI_SMART_CARD_EDGE_GET_PIN_REMAINING GetPinRemaining
;
729 EFI_SMART_CARD_EDGE_GET_DATA GetData
;
730 EFI_SMART_CARD_EDGE_GET_CREDENTIAL GetCredential
;
731 EFI_SMART_CARD_EDGE_SIGN_DATA SignData
;
732 EFI_SMART_CARD_EDGE_DECRYPT_DATA DecryptData
;
733 EFI_SMART_CARD_EDGE_BUILD_DH_AGREEMENT BuildDHAgreement
;
736 extern EFI_GUID gEfiSmartCardEdgeProtocolGuid
;