⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iso_7816_4.h

📁 This zip describes an ISO7816 configuration to read the ATR. Includes main.html file for help. For u
💻 H
字号:
//*----------------------------------------------------------------------------
//*      ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : iso7816_4.h
//* Object              : Types and structures relative to 7816-4
//* 1.0 16/12/97 JLV    : Creation
//* 1.1 15/12/00 JPP    : Change on AT91 Lib
//*----------------------------------------------------------------------------

#ifndef iso7816_4_h
#define iso7816_4_h

/*--------------------- Files to be included Definition ---------------------*/


/*---------------------- Types and Constants Definition ---------------------*/


#define LITTEL_INDIAN

// Coding of instruction byte (INS)
#define ERASE_BINARY					0x0E
#define VERIFY							0x20
#define MANAGE_CHANNEL					0x70
#define EXTERNAL_AUTHENTICATE			0x82
#define GET_CHALLENGE					0x84
#define INTERNAL_AUTHENTICATE			0x88
#define SELECT_FILE						0xA4
#define READ_BINARY						0xB0
#define READ_RECORD						0xB2
#define GET_RESPONSE					0xC0
#define ENVELOPE						0xC2
#define GET_DATA						0xCA
#define WRITE_BINARY					0xD0
#define WRITE_RECORD					0xD2
#define UPDATE_BINARY					0xD6
#define PUT_DATA						0xDA
#define UPDATE_RECORD					0xDC
#define APPEND_RECORD					0xE2

// manage chanel
#define OPEN_CHANNEL					0x00
#define CLOSE_CHANNEL					0x80


// Coding of status bytes (SW1-SW2) for normal processing (Process completed)
#ifdef LITTEL_INDIAN
#define NORMAL_PROCESSING				0x0090

// Coding of status bytes (SW1-SW2) for warning processing (Process completed)
#define WARNING_EE_UNCHANGED			0x0062
#define WARNING_EE_CHANGED				0x0063

// Coding of status bytes (SW1-SW2) for execution error (Process aborted)
#define EXEC_ERR_EE_UNCHANGED			0x0064
#define EXEC_ERR_EE_CHANGED				0x0065
#define EXEC_ERR_RESERVED				0x0066

// Coding of status bytes (SW1-SW2) for checking error (Process aborted)
#define CHK_ERR_WRONG_P3				0x0067
#define CHK_ERR_WRONG_CLA_FNCT			0x0068
#define CHK_ERR_CMDE_NOT_ALLOWED		0x0069
#define CHK_ERR_WRONG_PARAMETER			0x006A
#define CHK_ERR_WRONG_P1_P2				0x006B
#define CHK_ERR_WRONG_LENGTH			0x006C
#define CHK_ERR_INS_NOT_SUPPORTED		0x006D
#define CHK_ERR_CLA_NOT_SUPPORTED		0x006E
#define CHK_ERR_NO_DIAGNOSIS			0x006F

#else
#define NORMAL_PROCESSING				0x9000

// Coding of status bytes (SW1-SW2) for warning processing (Process completed)
#define WARNING_EE_UNCHANGED			0x6200
#define WARNING_EE_CHANGED				0x6300

// Coding of status bytes (SW1-SW2) for execution error (Process aborted)
#define EXEC_ERR_EE_UNCHANGED			0x6400
#define EXEC_ERR_EE_CHANGED				0x6500
#define EXEC_ERR_RESERVED				0x6600

// Coding of status bytes (SW1-SW2) for checking error (Process aborted)
#define CHK_ERR_WRONG_P3				0x6700
#define CHK_ERR_WRONG_CLA_FNCT			0x6800
#define CHK_ERR_CMDE_NOT_ALLOWED		0x6900
#define CHK_ERR_WRONG_PARAMETER			0x6A00
#define CHK_ERR_WRONG_P1_P2				0x6B00
#define CHK_ERR_WRONG_LENGTH			0x6C00
#define CHK_ERR_INS_NOT_SUPPORTED		0x6D00
#define CHK_ERR_CLA_NOT_SUPPORTED		0x6E00
#define CHK_ERR_NO_DIAGNOSIS			0x6F00

#endif

// Coding of SW2 when SW1 is 0x65
#define MEMORY_FAILURE					0x81

// Coding of SW2 when SW1 is 0x69
#define AUTHENTICATE_NOT_STATISFIED		0x83
#define CONDITIONS_NOT_STATISFIED		0x85

// Coding of SW2 when SW1 is 0x6A
#define LC_INCONSISTENT_WITH_P1P2		0x87

// Coding of class byte (CLA)
#define CLASS_7816_4					0x00

/*---------------------------*/
/* General ISO 7813-4 Header */
/*---------------------------*/
typedef struct ISO_7813_T0_HEADER {
   u_char  Cla;       // Instruction class
   u_char  Ins;       // Instruction code
   u_char  msbP1P2;   // reference
   u_char  lsbP1P2;   // reference
   u_char  P3;        // number of data bytes
} ISO_7813_T0_HEADER;


/*----------------------------------------------------------------*/
/* Verify structure is paked after the Header at the odd address  */
/*----------------------------------------------------------------*/
typedef struct ISO_7816_VERIFY{
   u_char  msb_add;   		// Big endian address
   u_char  lsb_add;   		//
   u_char  msb_Size;		// Big endian zize
   u_char  lsb_Size;
   u_char  hsb_Checksum; 	// Big endian Checksum
   u_char  MHsb_Checksum;	// Middel high
   u_char  MLsb_Checksum;	// Middel low
   u_char  lsb_Checksum; 	// Low bytes
} ISO_7816_VERIFY;
#endif /* iso7816_4_h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -