TianoCore EDK2 master
Loading...
Searching...
No Matches
SmartCardReader.h File Reference

Go to the source code of this file.

Data Structures

struct  _EFI_SMART_CARD_READER_PROTOCOL
 

Macros

#define EFI_SMART_CARD_READER_PROTOCOL_GUID
 
#define SCARD_AM_READER   0x0001
 
#define SCARD_AM_CARD   0x0002
 
#define SCARD_CA_NORESET   0x0000
 
#define SCARD_CA_COLDRESET   0x0001
 
#define SCARD_CA_WARMRESET   0x0002
 
#define SCARD_CA_UNPOWER   0x0003
 
#define SCARD_CA_EJECT   0x0004
 
#define SCARD_PROTOCOL_UNDEFINED   0x0000
 
#define SCARD_PROTOCOL_T0   0x0001
 
#define SCARD_PROTOCOL_T1   0x0002
 
#define SCARD_PROTOCOL_RAW   0x0004
 
#define SCARD_UNKNOWN   0x0000 /* state is unknown */
 
#define SCARD_ABSENT   0x0001 /* Card is absent */
 
#define SCARD_INACTIVE   0x0002 /* Card is present and not powered*/
 
#define SCARD_ACTIVE   0x0003 /* Card is present and powered */
 
#define SCARD_CTL_CODE(code)   (0x42000000 + (code))
 
#define CM_IOCTL_GET_FEATURE_REQUEST   SCARD_CTL_CODE(3400)
 

Typedefs

typedef struct _EFI_SMART_CARD_READER_PROTOCOL EFI_SMART_CARD_READER_PROTOCOL
 
typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_CONNECT) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 AccessMode, IN UINT32 CardAction, IN UINT32 PreferredProtocols, OUT UINT32 *ActiveProtocol)
 
typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_DISCONNECT) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 CardAction)
 
typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_STATUS) (IN EFI_SMART_CARD_READER_PROTOCOL *This, OUT CHAR16 *ReaderName OPTIONAL, IN OUT UINTN *ReaderNameLength OPTIONAL, OUT UINT32 *State OPTIONAL, OUT UINT32 *CardProtocol OPTIONAL, OUT UINT8 *Atr OPTIONAL, IN OUT UINTN *AtrLength OPTIONAL)
 
typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_TRANSMIT) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT8 *CAPDU, IN UINTN CAPDULength, OUT UINT8 *RAPDU, IN OUT UINTN *RAPDULength)
 
typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_CONTROL) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 ControlCode, IN UINT8 *InBuffer OPTIONAL, IN UINTN InBufferLength OPTIONAL, OUT UINT8 *OutBuffer OPTIONAL, IN OUT UINTN *OutBufferLength OPTIONAL)
 
typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_GET_ATTRIB) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 Attrib, OUT UINT8 *OutBuffer, IN OUT UINTN *OutBufferLength)
 

Variables

EFI_GUID gEfiSmartCardReaderProtocolGuid
 

Detailed Description

The UEFI Smart Card Reader Protocol provides an abstraction for device to provide smart card reader support. This protocol is very close to Part 5 of PC/SC workgroup specifications and provides an API to applications willing to communicate with a smart card or a smart card reader.

Copyright (c) 2015, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SmartCardReader.h.

Macro Definition Documentation

◆ CM_IOCTL_GET_FEATURE_REQUEST

#define CM_IOCTL_GET_FEATURE_REQUEST   SCARD_CTL_CODE(3400)

Definition at line 53 of file SmartCardReader.h.

◆ EFI_SMART_CARD_READER_PROTOCOL_GUID

#define EFI_SMART_CARD_READER_PROTOCOL_GUID
Value:
{ \
0x2a4d1adf, 0x21dc, 0x4b81, {0xa4, 0x2f, 0x8b, 0x8e, 0xe2, 0x38, 0x00, 0x60} \
}

Definition at line 15 of file SmartCardReader.h.

◆ SCARD_ABSENT

#define SCARD_ABSENT   0x0001 /* Card is absent */

Definition at line 46 of file SmartCardReader.h.

◆ SCARD_ACTIVE

#define SCARD_ACTIVE   0x0003 /* Card is present and powered */

Definition at line 48 of file SmartCardReader.h.

◆ SCARD_AM_CARD

#define SCARD_AM_CARD   0x0002

Definition at line 26 of file SmartCardReader.h.

◆ SCARD_AM_READER

#define SCARD_AM_READER   0x0001

Definition at line 25 of file SmartCardReader.h.

◆ SCARD_CA_COLDRESET

#define SCARD_CA_COLDRESET   0x0001

Definition at line 31 of file SmartCardReader.h.

◆ SCARD_CA_EJECT

#define SCARD_CA_EJECT   0x0004

Definition at line 34 of file SmartCardReader.h.

◆ SCARD_CA_NORESET

#define SCARD_CA_NORESET   0x0000

Definition at line 30 of file SmartCardReader.h.

◆ SCARD_CA_UNPOWER

#define SCARD_CA_UNPOWER   0x0003

Definition at line 33 of file SmartCardReader.h.

◆ SCARD_CA_WARMRESET

#define SCARD_CA_WARMRESET   0x0002

Definition at line 32 of file SmartCardReader.h.

◆ SCARD_CTL_CODE

#define SCARD_CTL_CODE (   code)    (0x42000000 + (code))

Definition at line 52 of file SmartCardReader.h.

◆ SCARD_INACTIVE

#define SCARD_INACTIVE   0x0002 /* Card is present and not powered*/

Definition at line 47 of file SmartCardReader.h.

◆ SCARD_PROTOCOL_RAW

#define SCARD_PROTOCOL_RAW   0x0004

Definition at line 41 of file SmartCardReader.h.

◆ SCARD_PROTOCOL_T0

#define SCARD_PROTOCOL_T0   0x0001

Definition at line 39 of file SmartCardReader.h.

◆ SCARD_PROTOCOL_T1

#define SCARD_PROTOCOL_T1   0x0002

Definition at line 40 of file SmartCardReader.h.

◆ SCARD_PROTOCOL_UNDEFINED

#define SCARD_PROTOCOL_UNDEFINED   0x0000

Definition at line 38 of file SmartCardReader.h.

◆ SCARD_UNKNOWN

#define SCARD_UNKNOWN   0x0000 /* state is unknown */

Definition at line 45 of file SmartCardReader.h.

Typedef Documentation

◆ EFI_SMART_CARD_READER_CONNECT

typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_CONNECT) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 AccessMode, IN UINT32 CardAction, IN UINT32 PreferredProtocols, OUT UINT32 *ActiveProtocol)

This function requests connection to the smart card or the reader, using the appropriate reset type and protocol.

The SCardConnectfunction requests access to the smart card or the reader. Upon success, it is then possible to call SCardTransmit.

If AccessMode is set to SCARD_AM_READER, PreferredProtocols must be set to SCARD_PROTOCOL_UNDEFINED and CardAction to SCARD_CA_NORESET else function fails with EFI_INVALID_PARAMETER.

Parameters
[in]ThisIndicates a pointer to the calling context.
[in]AccessModeCodes of access mode.
[in]CardActionSCARD_CA_NORESET, SCARD_CA_COLDRESET or SCARD_CA_WARMRESET.
[in]PreferredProtocolsBitmask of acceptable protocols.
[out]ActiveProtocolA flag that indicates the active protocol.
Return values
EFI_SUCCESSThe requested command completed successfully.
EFI_INVALID_PARAMETERThis is NULL
EFI_INVALID_PARAMETERAccessMode is not valid.
EFI_INVALID_PARAMETERCardAction is not valid.
EFI_INVALID_PARAMETERInvalid combination of AccessMode/CardAction/ PreferredProtocols.
EFI_NOT_READYA smart card is inserted but failed to return an ATR.
EFI_UNSUPPORTEDPreferredProtocols does not contain an available protocol to use.
EFI_NO_MEDIAAccessMode is set to SCARD_AM_CARD but there is no smart card inserted.
EFI_ACCESS_DENIEDAccess is already locked by a previous SCardConnectcall.
EFI_DEVICE_ERRORAny other error condition, typically a reader removal.

Definition at line 89 of file SmartCardReader.h.

◆ EFI_SMART_CARD_READER_CONTROL

typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_CONTROL) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 ControlCode, IN UINT8 *InBuffer OPTIONAL, IN UINTN InBufferLength OPTIONAL, OUT UINT8 *OutBuffer OPTIONAL, IN OUT UINTN *OutBufferLength OPTIONAL)

This function provides direct access to the reader.

This function gives direct control to send commands to the driver or the reader. The ControlCode to use is vendor dependant; the only standard code defined is the one to get PC/SC part 10 features.

InBuffer and Outbuffer may be NULL when ControlCode operation does not require them.

Parameters
[in]ThisIndicates a pointer to the calling context.
[in]ControlCodeThe control code for the operation to perform.
[in]InBufferA pointer to the input parameters.
[in]InBufferLengthSize, in bytes, of input parameters.
[out]OutBufferA pointer to the output parameters.
[in,out]OutBufferLengthOn input, maximal size, in bytes, to store output parameters. On output, the size, in bytes, of output parameters.
Return values
EFI_SUCCESSThe requested command completed successfully.
EFI_INVALID_PARAMETERThis is NULL.
EFI_INVALID_PARAMETERControlCode requires input parameters but: InBuffer is NULL or InBufferLenth is NULL or InBuffer is not NULL but InBufferLenth is less than expected.
EFI_INVALID_PARAMETEROutBuffer is not NULL but OutBufferLength is NULL.
EFI_UNSUPPORTEDControlCode is not supported.
EFI_BUFFER_TOO_SMALLOutBufferLength is not big enough to hold the output parameters. OutBufferLength has been updated to the required value.
EFI_NO_MEDIAThere is no card in the reader and the control code specified requires one.
EFI_NOT_READYControlCode requires a powered card to operate.
EFI_PROTOCOL_ERRORA protocol error has occurred.
EFI_TIMEOUTThe reader did not respond.
EFI_ACCESS_DENIEDA communication with the reader/card is already pending.
EFI_DEVICE_ERRORAny other error condition, typically a reader removal.

Definition at line 254 of file SmartCardReader.h.

◆ EFI_SMART_CARD_READER_DISCONNECT

typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_DISCONNECT) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 CardAction)

This function releases a connection previously taken by SCardConnect.

The SCardDisconnect function releases the lock previously taken by SCardConnect. In case the smart card has been removed before this call, thisfunction returns EFI_SUCCESS. If there is no previous call to SCardConnect, this function returns EFI_SUCCESS.

Parameters
[in]ThisIndicates a pointer to the calling context.
[in]CardActionCodes for card action.
Return values
EFI_SUCCESSThe requested command completed successfully.
EFI_INVALID_PARAMETERThis is NULL
EFI_INVALID_PARAMETERCardAction value is unknown.
EFI_UNSUPPORTEDReader does not support Eject card feature (disconnect was not performed).
EFI_DEVICE_ERRORAny other error condition, typically a reader removal.

Definition at line 118 of file SmartCardReader.h.

◆ EFI_SMART_CARD_READER_GET_ATTRIB

typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_GET_ATTRIB) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT32 Attrib, OUT UINT8 *OutBuffer, IN OUT UINTN *OutBufferLength)

This function retrieves a reader or smart card attribute.

Possibly supported attrib values are listed in "PC/SC specification, Part 3: Requirements for PC-Connected Interface Devices".

Parameters
[in]ThisIndicates a pointer to the calling context.
[in]AttribIdentifier for the attribute to retrieve.
[out]OutBufferA pointer to a buffer that will contain attribute data.
[in,out]OutBufferLengthOn input, maximal size, in bytes, to store attribute data. On output, the size, in bytes, of attribute data.
Return values
EFI_SUCCESSThe requested command completed successfully.
EFI_INVALID_PARAMETERThis is NULL.
EFI_INVALID_PARAMETEROutBuffer is NULL or OutBufferLength is 0.
EFI_BUFFER_TOO_SMALLOutBufferLength is not big enough to hold the output parameters. OutBufferLength has been updated to the required value.
EFI_UNSUPPORTEDAttribis not supported
EFI_NO_MEDIAThere is no card in the reader and Attrib value requires one.
EFI_NOT_READYAttrib requires a powered card to operate.
EFI_PROTOCOL_ERRORA protocol error has occurred.
EFI_TIMEOUTThe reader did not respond.
EFI_DEVICE_ERRORAny other error condition, typically a reader removal.

Definition at line 295 of file SmartCardReader.h.

◆ EFI_SMART_CARD_READER_PROTOCOL

◆ EFI_SMART_CARD_READER_STATUS

typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_STATUS) (IN EFI_SMART_CARD_READER_PROTOCOL *This, OUT CHAR16 *ReaderName OPTIONAL, IN OUT UINTN *ReaderNameLength OPTIONAL, OUT UINT32 *State OPTIONAL, OUT UINT32 *CardProtocol OPTIONAL, OUT UINT8 *Atr OPTIONAL, IN OUT UINTN *AtrLength OPTIONAL)

This function retrieves some basic information about the smart card and reader.

The SCardStatusfunction retrieves basic reader and card information.

If ReaderName, State, CardProtocolor Atris NULL, the function does not fail but does not fill in such variables.

If EFI_SUCCESS is not returned, ReaderName and Atr contents shall not be considered as valid.

Parameters
[in]ThisIndicates a pointer to the calling context.
[out]ReaderNameA pointer to a NULL terminated string that will contain the reader name.
[in,out]ReaderNameLengthOn input, a pointer to the variablethat holds the maximal size, in bytes,of ReaderName. On output, the required size, in bytes, for ReaderName.
[out]StateCurrent state of the smart card reader.
[out]CardProtocolCurrent protocol used to communicate with the smart card.
[out]AtrA pointer to retrieve the ATR of the smart card.
[in,out]AtrLengthOn input, a pointer to hold the maximum size, in bytes, of Atr(usually 33). On output, the required size, inbytes, for the smart card ATR.
Return values
EFI_SUCCESSThe requested command completed successfully.
EFI_INVALID_PARAMETERThis is NULL
EFI_INVALID_PARAMETERReaderName is not NULL but ReaderNameLength is NULL
EFI_INVALID_PARAMETERAtr is not NULL but AtrLength is NULL
EFI_BUFFER_TOO_SMALLReaderNameLength is not big enough to hold the reader name. ReaderNameLength has been updated to the required value.
EFI_BUFFER_TOO_SMALLAtrLength is not big enough to hold the ATR. AtrLength has been updated to the required value.
EFI_DEVICE_ERRORAny other error condition, typically a reader removal.

Definition at line 161 of file SmartCardReader.h.

◆ EFI_SMART_CARD_READER_TRANSMIT

typedef EFI_STATUS(EFIAPI * EFI_SMART_CARD_READER_TRANSMIT) (IN EFI_SMART_CARD_READER_PROTOCOL *This, IN UINT8 *CAPDU, IN UINTN CAPDULength, OUT UINT8 *RAPDU, IN OUT UINTN *RAPDULength)

This function sends a command to the card or reader and returns its response.

The protocol to use to communicate with the smart card has been selected through SCardConnectcall.

In case RAPDULength indicates a buffer too small to holdthe response APDU, the function fails with EFI_BUFFER_TOO_SMALL.

Parameters
[in]ThisA pointer to the EFI_USBFN_IO_PROTOCOLinstance.
[in]CAPDUA pointer to a byte array thatcontains the Command APDU to send to the smart card or reader.
[in]CAPDULengthCommand APDU size, in bytes.
[out]RAPDUA pointer to a byte array that will contain the Response APDU.
[in,out]RAPDULengthOn input, the maximum size, inbytes, of the Response APDU. On output, the size, in bytes, of the Response APDU.
Return values
EFI_SUCCESSThe requested command completed successfully.
EFI_INVALID_PARAMETERThis is NULL.
EFI_INVALID_PARAMETERCAPDU is NULL or CAPDULength is 0.
EFI_BUFFER_TOO_SMALLRAPDULength is not big enough to hold the response APDU. RAPDULength has been updated to the required value.
EFI_NO_MEDIAThere is no card in the reader.
EFI_NOT_READYCard is not powered.
EFI_PROTOCOL_ERRORA protocol error has occurred.
EFI_TIMEOUTThe reader did not respond.
EFI_ACCESS_DENIEDA communication with the reader/card is already pending.
EFI_DEVICE_ERRORAny other error condition, typically a reader removal.

Definition at line 205 of file SmartCardReader.h.