📄 cciddriver.h
字号:
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \unit
///
/// !Purpose
///
/// Definition of methods for using a CCID device driver.
///
/// !Usage
///
/// -# CCIDDriver_Initialize
/// -# CCID_Read
/// -# CCID_Write
/// -# CCID_SmartCardRequest
/// -# CCID_Insertion
/// -# CCID_Removal
/// -# RDRtoPCHardwareError
//------------------------------------------------------------------------------
#ifndef CCID_DRIVER_H
#define CCID_DRIVER_H
/// For reference, the absolute maximum block size
/// for a TPDU T=0 block is 260 bytes (5 bytes command; 255 bytes data), 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.
#define ABDATA_SIZE 260
/// define protocol T=0
#define PROTOCOL_TO 0
/// define protocol T=1
#define PROTOCOL_T1 1
/// define for dwFeatures see Table 5.1-1 Smart Card Device Class Descriptors
/// No special characteristics
#define CCID_FEATURES_NADA 0x00000000
/// Automatic parameter configuration based on ATR data
#define CCID_FEATURES_AUTO_PCONF 0x00000002
/// Automatic activation of ICC on inserting
#define CCID_FEATURES_AUTO_ACTIV 0x00000004
/// Automatic ICC voltage selection
#define CCID_FEATURES_AUTO_VOLT 0x00000008
/// Automatic ICC clock frequency change according to active parameters provided
/// by the Host or self determined
#define CCID_FEATURES_AUTO_CLOCK 0x00000010
/// Automatic baud rate change according to active parameters provided by the
/// Host or self determined
#define CCID_FEATURES_AUTO_BAUD 0x00000020
/// Automatic parameters negotiation made by the CCID (use of warm or cold
/// resets or PPS according to a manufacturer proprietary algorithm to select
/// the communication parameters with the ICC)
#define CCID_FEATURES_AUTO_PNEGO 0x00000040
/// Automatic PPS made by the CCID according to the active parameters
#define CCID_FEATURES_AUTO_PPS 0x00000080
/// CCID can set ICC in clock stop mode
#define CCID_FEATURES_ICCSTOP 0x00000100
/// NAD value other than 00 accepted (T=1 protocol in use)
#define CCID_FEATURES_NAD 0x00000200
/// Automatic IFSD exchange as first exchange (T=1 protocol in use)
#define CCID_FEATURES_AUTO_IFSD 0x00000400
/// TPDU level exchanges with CCID
#define CCID_FEATURES_EXC_TPDU 0x00010000
/// Short APDU level exchange with CCID
#define CCID_FEATURES_EXC_SAPDU 0x00020000
/// Short and Extended APDU level exchange with CCID
#define CCID_FEATURES_EXC_APDU 0x00040000
/// USB Wake up signaling supported on card insertion and removal
#define CCID_FEATURES_WAKEUP 0x00100000
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
/// Bulk CCID Message header structure
typedef struct
{
unsigned char bMessageType;
/// Message-specific data length
unsigned long wLength;
/// Identifies the slot number for this command
unsigned char bSlot;
/// Sequence number for command.
unsigned char bSeq;
/// Slot status register
unsigned char bStatus;
/// Slot error
unsigned char bError;
/// specific register
unsigned char bSpecific;
/// Data block sent to the CCID.
unsigned char abData[ABDATA_SIZE];
unsigned char bSizeToSend;
} __attribute__ ((packed)) S_ccid_bulk_in_header;
/// 6.1 Bulk Transfers
typedef struct
{
unsigned char bMessageType;
/// Message-specific data length
unsigned long wLength;
/// Identifies the slot number for this command
unsigned char bSlot;
/// Sequence number for command.
unsigned char bSeq;
/// specific register
unsigned char bSpecific_0;
unsigned char bSpecific_1;
unsigned char bSpecific_2;
/// Application Protocol Data Unit
unsigned char APDU[ABDATA_SIZE];
} __attribute__ ((packed)) S_ccid_bulk_out_header;
/// 6.1.11.2 PIN Verification Data Structure
typedef struct
{
/// Number of seconds.
unsigned char bTimerOut;
/// Several parameters for the PIN format options
unsigned char bmFormatString;
/// Define the length of the PIN to present in the APDU command
unsigned char bmPINBlockString;
/// Allows the length PIN insertion in the APDU command
unsigned char bmPINLengthFormat;
/// Minimum PIN size in digit and Maximum PIN size in digit
unsigned char wPINMaxExtraDigit;
/// The value is a bit wise OR operation.
unsigned char bEntryValidationCondition;
/// Number of messages to display for the PIN modify command
unsigned char bNumberMessage;
/// Language used to display the messages.
unsigned char wLangId;
/// Message index in the Reader message table
unsigned char bMsgIndex;
/// T=1 I-block prologue field to use
unsigned char bTeoPrologue[3];
/// APDU to send to the ICC
unsigned char abPINApdu[255];
}__attribute__ ((packed)) S_ccid_PIN_Verification;
/// 6.1.11.7 PIN Modification Data Structure
typedef struct
{
/// Number of seconds. If 00h then CCID default value is used.
unsigned char bTimeOut;
/// Several parameters for the PIN format options (defined in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -