Release v2.10.0

This commit is contained in:
slimih
2021-09-16 17:30:01 +01:00
parent 06808a92fe
commit 69fa8a86ad
60 changed files with 6008 additions and 2759 deletions

View File

@@ -101,28 +101,28 @@ extern "C" {
#ifndef CCID_VOLTAGE_SUPP
#define CCID_VOLTAGE_SUPP 0x07U
#endif
#endif /* CCID_VOLTAGE_SUPP */
#ifndef USBD_CCID_PROTOCOL
#define USBD_CCID_PROTOCOL 0x03U
#endif
#endif /* USBD_CCID_PROTOCOL */
#ifndef USBD_CCID_DEFAULT_CLOCK_FREQ
#define USBD_CCID_DEFAULT_CLOCK_FREQ 3600U
#endif
#endif /* USBD_CCID_DEFAULT_CLOCK_FREQ */
#ifndef USBD_CCID_MAX_CLOCK_FREQ
#define USBD_CCID_MAX_CLOCK_FREQ USBD_CCID_DEFAULT_CLOCK_FREQ
#endif
#endif /* USBD_CCID_MAX_CLOCK_FREQ */
#ifndef USBD_CCID_DEFAULT_DATA_RATE
#define USBD_CCID_DEFAULT_DATA_RATE 9677U
#endif
#endif /* USBD_CCID_DEFAULT_DATA_RATE */
#ifndef USBD_CCID_MAX_DATA_RATE
#define USBD_CCID_MAX_DATA_RATE USBD_CCID_DEFAULT_DATA_RATE
#endif
#endif /* USBD_CCID_MAX_DATA_RATE */
#ifndef USBD_CCID_MAX_INF_FIELD_SIZE
#define USBD_CCID_MAX_INF_FIELD_SIZE 254U
#endif
#endif /* USBD_CCID_MAX_INF_FIELD_SIZE */
#ifndef CCID_MAX_BLOCK_SIZE_HEADER
#define CCID_MAX_BLOCK_SIZE_HEADER 271U
#endif
#endif /* CCID_MAX_BLOCK_SIZE_HEADER */
#define TPDU_EXCHANGE 0x01U
#define SHORT_APDU_EXCHANGE 0x02U
@@ -131,20 +131,24 @@ extern "C" {
#ifndef EXCHANGE_LEVEL_FEATURE
#define EXCHANGE_LEVEL_FEATURE TPDU_EXCHANGE
#endif
#endif /* EXCHANGE_LEVEL_FEATURE */
#define CCID_ENDPOINT_DESC_SIZE 0x07U
#ifndef CCID_EP0_BUFF_SIZ
#define CCID_EP0_BUFF_SIZ 64U
#endif
#endif /* CCID_EP0_BUFF_SIZ */
#ifndef CCID_BULK_EPIN_SIZE
#define CCID_BULK_EPIN_SIZE 64U
#endif
#endif /* CCID_BULK_EPIN_SIZE */
#define CCID_INT_BUFF_SIZ 2U
/*---------------------------------------------------------------------*/
/*
* CCID Class specification revision 1.1
* Command Pipe. Bulk Messages
*/
/* CCID Bulk Out Command definitions */
#define PC_TO_RDR_ICCPOWERON 0x62U
@@ -213,7 +217,6 @@ typedef struct
uint8_t datatype;
} USBD_CCID_LineCodingTypeDef;
#pragma pack(1)
typedef struct
{
uint8_t bMessageType; /* Offset = 0*/
@@ -230,10 +233,8 @@ typedef struct
or for a TPDU T=1 block is 259 bytes,
or for a short APDU T=1 block is 261 bytes,
or for an extended APDU T=1 block is 65544 bytes.*/
} USBD_CCID_BulkOut_DataTypeDef;
#pragma pack()
} __PACKED USBD_CCID_BulkOut_DataTypeDef;
#pragma pack(1)
typedef struct
{
uint8_t bMessageType; /* Offset = 0 */
@@ -245,8 +246,7 @@ typedef struct
uint8_t bSpecific; /* Offset = 9 */
uint8_t abData[ABDATA_SIZE]; /* Offset = 10 */
uint16_t u16SizeToSend;
} USBD_CCID_BulkIn_DataTypeDef;
#pragma pack()
} __PACKED USBD_CCID_BulkIn_DataTypeDef;
typedef struct
{
@@ -262,6 +262,36 @@ typedef struct
__IO uint8_t bSlot;
} USBD_CCID_ParamTypeDef;
/*
* CCID Class specification revsion 1.1
* Smart Card Device Class Descriptor Table
*/
typedef struct
{
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdCCID;
uint8_t bMaxSlotIndex;
uint8_t bVoltageSupport;
uint32_t dwProtocols;
uint32_t dwDefaultClock;
uint32_t dwMaximumClock;
uint8_t bNumClockSupported;
uint32_t dwDataRate;
uint32_t dwMaxDataRate;
uint8_t bNumDataRatesSupported;
uint32_t dwMaxIFSD;
uint32_t dwSynchProtocols;
uint32_t dwMechanical;
uint32_t dwFeatures;
uint32_t dwMaxCCIDMessageLength;
uint8_t bClassGetResponse;
uint8_t bClassEnvelope;
uint16_t wLcdLayout;
uint8_t bPINSupport;
uint8_t bMaxCCIDBusySlots;
} __PACKED USBD_CCID_DescTypeDef;
typedef struct
{

View File

@@ -27,11 +27,11 @@ extern "C" {
/* Includes ------------------------------------------------------------------*/
#ifndef __USBD_CCID_IF_H
#include "usbd_ccid_if_template.h"
#endif
#endif /* __USBD_CCID_IF_H */
#ifndef __USBD_CCID_SC_IF_H
#include "usbd_ccid_sc_if_template.h"
#endif
#endif /* __USBD_CCID_SC_IF_H */
/* Exported types ------------------------------------------------------------*/
@@ -54,6 +54,10 @@ extern "C" {
positive number (1-127). For instance, if the CCID receives an ICC command to
an unimplemented slot, then the Slot Error register shall be set to 5 (index of bSlot field) */
/*
* CCID Class specification revsion 1.1
*/
/* Following Parameters used in PC_to_RDR_XfrBlock */
#define SLOTERROR_BAD_LENTGH 0x01U
#define SLOTERROR_BAD_SLOT 0x05U
@@ -97,25 +101,25 @@ extern "C" {
/* DEFAULT_FIDI_VALUE */
#ifndef DEFAULT_FIDI
#define DEFAULT_FIDI 0x11U
#endif
#endif /* DEFAULT_FIDI */
#ifndef DEFAULT_T01CONVCHECKSUM
#define DEFAULT_T01CONVCHECKSUM 0x00U
#endif
#endif /* DEFAULT_T01CONVCHECKSUM */
#ifndef DEFAULT_EXTRA_GUARDTIME
#define DEFAULT_EXTRA_GUARDTIME 0x00U
#endif
#endif /* DEFAULT_EXTRA_GUARDTIME */
#ifndef DEFAULT_WAITINGINTEGER
#define DEFAULT_WAITINGINTEGER 0x0AU
#endif
#endif /* DEFAULT_WAITINGINTEGER */
#ifndef DEFAULT_CLOCKSTOP
#define DEFAULT_CLOCKSTOP 0x00U
#endif
#endif /* DEFAULT_CLOCKSTOP */
#ifndef DEFAULT_IFSC
#define DEFAULT_IFSC 0x20U
#endif
#endif /* DEFAULT_IFSC */
#ifndef DEFAULT_NAD
#define DEFAULT_NAD 0x00U
#endif
#endif /* DEFAULT_NAD */
/* Following Parameters used in PC_to_RDR_IccPowerOn */
#define VOLTAGE_SELECTION_AUTOMATIC 0xFFU
@@ -151,10 +155,9 @@ Offset=6 bmCommandStatus 2 bits 0, 1, 2
#define SIZE_OF_ATR 19U
#else
#define SIZE_OF_ATR 15U
#endif
#endif /* (ATR_T01 == 0) */
/* defines for the CCID_CMD Layers */
#define LEN_RDR_TO_PC_SLOTSTATUS 10U
#define LEN_PROTOCOL_STRUCT_T0 5U
#define LEN_PROTOCOL_STRUCT_T1 7U
@@ -174,8 +177,8 @@ Offset=6 bmCommandStatus 2 bits 0, 1, 2
#define CHK_PARAM_SLOT 0x01U
#define CHK_PARAM_DWLENGTH 0x02U
#define CHK_PARAM_abRFU2 0x04U
#define CHK_PARAM_abRFU3 0x08U
#define CHK_PARAM_ABRFU2 0x04U
#define CHK_PARAM_ABRFU3 0x08U
#define CHK_PARAM_CARD_PRESENT 0x10U
#define CHK_PARAM_ABORT 0x20U
#define CHK_ACTIVE_STATE 0x40U
@@ -207,7 +210,7 @@ void RDR_to_PC_DataRateAndClockFrequency(uint8_t errorCode, USBD_HandleTypeDef *
void CCID_UpdSlotStatus(USBD_HandleTypeDef *pdev, uint8_t slotStatus);
void CCID_UpdSlotChange(USBD_HandleTypeDef *pdev, uint8_t changeStatus);
uint8_t CCID_IsSlotStatusChange(USBD_HandleTypeDef *pdev);
uint8_t CCID_CmdAbort(uint8_t slot, uint8_t seq);
uint8_t CCID_CmdAbort(USBD_HandleTypeDef *pdev, uint8_t slot, uint8_t seq);
uint8_t USBD_CCID_Transfer_Data_Request(USBD_HandleTypeDef *pdev,
uint8_t *dataPointer, uint16_t dataLen);

View File

@@ -30,7 +30,7 @@ extern "C" {
#ifndef __USBD_CCID_SMARTCARD_H
#include "usbd_ccid_smartcard_template.h"
#endif
#endif /* __USBD_CCID_SMARTCARD_H */
/* Exported defines ----------------------------------------------------------*/
@@ -49,11 +49,11 @@ extern "C" {
#define BOTH_DIR 2U
/************ Value of the Interrupt transfer status to set ******************/
#define IntrStatus_Complete 1U
#define IntrStatus_Reset 0U
#define INTRSTATUS_COMPLETE 1U
#define INTRSTATUS_RESET 0U
/************** slot change status *******************************************/
#define SlotStatus_Changed 1U
#define SlotStatus_Reset 0U
#define SLOTSTATUS_CHANGED 1U
#define SLOTSTATUS_RESET 0U
/* Exported types ------------------------------------------------------------*/
extern USBD_HandleTypeDef USBD_Device;

View File

@@ -30,7 +30,7 @@ extern "C" {
#ifndef __USBD_CCID_SMARTCARD_H
#include "usbd_ccid_smartcard_template.h"
#endif
#endif /* __USBD_CCID_SMARTCARD_H */
/* Exported constants --------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/

View File

@@ -28,7 +28,7 @@ extern "C" {
/* Includes ------------------------------------------------------------------*/
#ifndef __USBD_CCID_IF_H
#include "usbd_ccid_if_template.h"
#endif
#endif /* __USBD_CCID_IF_H */
/* Exported constants --------------------------------------------------------*/
#define T0_PROTOCOL 0x00U /* T0 protocol */
@@ -162,29 +162,29 @@ typedef enum
/* Interface Byte structure - TA(i), TB(i), TC(i) and TD(i) ------------------*/
typedef struct
{
uint8_t Status; /* The Presence of the Interface byte */
uint8_t Value; /* The Value of the Interface byte */
} SC_InterfaceByte;
uint8_t Status; /* The Presence of the Interface byte */
uint8_t Value; /* The Value of the Interface byte */
} SC_InterfaceByteTypeDef;
/* Protocol Level structure - ------------------------------------------------*/
typedef struct
{
SC_InterfaceByte InterfaceByte[MAX_INTERFACEBYTE]; /* The Values of the Interface byte TA(i), TB(i), TC(i)and TD(i) */
} SC_ProtocolLevel;
SC_InterfaceByteTypeDef InterfaceByte[MAX_INTERFACEBYTE]; /* The Values of the Interface byte
TA(i), TB(i), TC(i)and TD(i) */
} SC_ProtocolLevelTypeDef;
/* ATR structure - Answer To Reset -------------------------------------------*/
typedef struct
{
uint8_t TS; /* Bit Convention Direct/Indirect */
uint8_t T0; /* Each bit in the high nibble = Presence of the further interface byte;
Low nibble = Number of historical byte */
SC_ProtocolLevel T[MAX_PROTOCOLLEVEL]; /* Setup array */
uint8_t H[HIST_LENGTH]; /* Historical array */
uint8_t Tlength; /* Setup array dimension */
uint8_t Hlength; /* Historical array dimension */
uint8_t TS; /* Bit Convention Direct/Indirect */
uint8_t T0; /* Each bit in the high nibble = Presence of the further interface byte;
Low nibble = Number of historical byte */
SC_ProtocolLevelTypeDef T[MAX_PROTOCOLLEVEL]; /* Setup array */
uint8_t Historical[HIST_LENGTH]; /* Historical array */
uint8_t Tlength; /* Setup array dimension */
uint8_t Hlength; /* Historical array dimension */
uint8_t TCK;
} SC_ATR;
} SC_ATRTypeDef;
/* ADPU-Header command structure ---------------------------------------------*/
typedef struct
@@ -193,7 +193,7 @@ typedef struct
uint8_t INS; /* Operation code */
uint8_t P1; /* Selection Mode */
uint8_t P2; /* Selection Option */
} SC_Header;
} SC_HeaderTypeDef;
/* ADPU-Body command structure -----------------------------------------------*/
typedef struct
@@ -201,22 +201,22 @@ typedef struct
uint8_t LC; /* Data field length */
uint8_t Data[LC_MAX]; /* Command parameters */
uint8_t LE; /* Expected length of data to be returned */
} SC_Body;
} SC_BodyTypeDef;
/* ADPU Command structure ----------------------------------------------------*/
typedef struct
{
SC_Header Header;
SC_Body Body;
} SC_ADPU_Commands;
SC_HeaderTypeDef Header;
SC_BodyTypeDef Body;
} SC_ADPU_CommandsTypeDef;
/* SC response structure -----------------------------------------------------*/
typedef struct
{
uint8_t Data[LC_MAX]; /* Data returned from the card */
uint8_t SW1; /* Command Processing status */
uint8_t SW2; /* Command Processing qualification */
} SC_ADPU_Response;
uint8_t SW1; /* Command Processing status */
uint8_t SW2; /* Command Processing qualification */
} SC_ADPU_ResponseTypeDef;
/* SC Command Status -----------------------------------------------------*/
typedef enum
@@ -255,7 +255,7 @@ typedef enum
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* APPLICATION LAYER ---------------------------------------------------------*/
void SC_Handler(SC_State *SCState, SC_ADPU_Commands *SC_ADPU, SC_ADPU_Response *SC_Response);
void SC_Handler(SC_State *SCState, SC_ADPU_CommandsTypeDef *SC_ADPU, SC_ADPU_ResponseTypeDef *SC_Response);
void SC_PowerCmd(SCPowerState NewState);
void SC_ParityErrorHandler(void);
void SC_PTSConfig(void);
@@ -266,11 +266,11 @@ void SC_SetState(SC_State scState);
void SC_IOConfig(void);
extern uint8_t SC_ATR_Table[40];
extern SC_ATR SC_A2R;
extern SC_ADPU_Response SC_Response;
extern SC_ATRTypeDef SC_A2R;
extern SC_ADPU_ResponseTypeDef SC_Response;
extern uint8_t ProtocolNUM_OUT;
extern SC_ADPU_Commands SC_ADPU;
extern SC_ADPU_CommandsTypeDef SC_ADPU;
#ifdef __cplusplus
}