MdePkg[all]  1.08
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SmartCardReader.h File Reference

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 IN UINT32 AccessMode
 
typedef IN UINT32 IN UINT32 CardAction
 
typedef IN UINT32 IN UINT32 IN
UINT32 
PreferredProtocols
 
typedef IN UINT32 IN UINT32 IN
UINT32 OUT UINT32
ActiveProtocol
 
typedef OUT CHAR16ReaderName
 
typedef OUT CHAR16 IN OUT UINTNReaderNameLength
 
typedef OUT CHAR16 IN OUT
UINTN OUT UINT32
State
 
typedef OUT CHAR16 IN OUT
UINTN OUT UINT32 OUT UINT32
CardProtocol
 
typedef OUT CHAR16 IN OUT
UINTN OUT UINT32 OUT UINT32
OUT UINT8
Atr
 
typedef OUT CHAR16 IN OUT
UINTN OUT UINT32 OUT UINT32
OUT UINT8 IN OUT UINTN
AtrLength
 
typedef IN UINT8CAPDU
 
typedef IN UINT8 IN UINTN CAPDULength
 
typedef IN UINT8 IN UINTN OUT
UINT8
RAPDU
 
typedef IN UINT8 IN UINTN OUT
UINT8 IN OUT UINTN
RAPDULength
 
typedef IN UINT32 ControlCode
 
typedef IN UINT32 IN UINT8InBuffer
 
typedef IN UINT32 IN UINT8 IN UINTN InBufferLength
 
typedef IN UINT32 IN UINT8 IN
UINTN OUT UINT8
OutBuffer
 
typedef IN UINT32 IN UINT8 IN
UINTN OUT UINT8 IN OUT UINTN
OutBufferLength
 
typedef IN UINT32 Attrib
 

Functions

typedef EFI_STATUS (EFIAPI *EFI_SMART_CARD_READER_CONNECT)(IN EFI_SMART_CARD_READER_PROTOCOL *This
 

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

Macro Definition Documentation

#define CM_IOCTL_GET_FEATURE_REQUEST   SCARD_CTL_CODE(3400)
#define EFI_SMART_CARD_READER_PROTOCOL_GUID
Value:
{ \
0x2a4d1adf, 0x21dc, 0x4b81, {0xa4, 0x2f, 0x8b, 0x8e, 0xe2, 0x38, 0x00, 0x60} \
}
#define SCARD_ABSENT   0x0001 /* Card is absent */
#define SCARD_ACTIVE   0x0003 /* Card is present and powered */
#define SCARD_AM_CARD   0x0002
#define SCARD_AM_READER   0x0001
#define SCARD_CA_COLDRESET   0x0001
#define SCARD_CA_EJECT   0x0004
#define SCARD_CA_NORESET   0x0000
#define SCARD_CA_UNPOWER   0x0003
#define SCARD_CA_WARMRESET   0x0002
#define SCARD_CTL_CODE (   code)    (0x42000000 + (code))
#define SCARD_INACTIVE   0x0002 /* Card is present and not powered*/
#define SCARD_PROTOCOL_RAW   0x0004
#define SCARD_PROTOCOL_T0   0x0001
#define SCARD_PROTOCOL_T1   0x0002
#define SCARD_PROTOCOL_UNDEFINED   0x0000
#define SCARD_UNKNOWN   0x0000 /* state is unknown */

Typedef Documentation

typedef IN UINT32 AccessMode
typedef IN UINT32 Attrib
typedef IN UINT8* CAPDU
typedef IN UINT32 CardAction
typedef OUT CHAR16* ReaderName

Function Documentation

typedef EFI_STATUS ( EFIAPI EFI_SMART_CARD_READER_GET_ATTRIB)

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.

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.

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.

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.

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.

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.

Variable Documentation

EFI_GUID gEfiSmartCardReaderProtocolGuid