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

📄 magcard.h

📁 一个读取ic卡的读卡程序。一个读取ic卡的读卡程序一个读取ic卡的读卡程序
💻 H
📖 第 1 页 / 共 5 页
字号:

#define SUCCESS 0                 //success
#define ERR_COUPLER_ERROR 1       //wrong number of bytes read or write
#define ERR_DUMB_CARD 2           //dumb card
#define ERR_COMPARE_ERROR 3       //password error

#ifdef __cplusplus
extern "C" {
#endif

int MCAPI ICread_4428B(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwrite_4428B(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICprotect_4428B(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICPassword_4428B(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICChangePassword_4428B(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);


#ifdef __cplusplus
    }
#endif

int MCAPI ICreadEC_4428B(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwriteEC_4428B(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICPSC_4428B(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

#endif

#endif // USE_SLE4428_B

#ifdef USE_SLE4432

#ifndef _4432_H_
#define _4432_H_

#ifdef __cplusplus
extern "C" {
#endif

int MCAPI ICread_4432(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwrite_4432(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwriteP_4432(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

#ifdef __cplusplus
}
#endif

#endif

#endif // USE_SLE4432

#ifdef USE_SLE4442

#ifndef _4442_H_
#define _4442_H_

#define SUCCESS 0                 //success
#define ERR_COUPLER_ERROR 1       //wrong number of bytes read or write
#define ERR_DUMB_CARD 2           //dumb card
#define ERR_COMPARE_ERROR 3       //password error

#ifdef __cplusplus
extern "C" {
#endif

int MCAPI ICread_4442(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);


int MCAPI ICwrite_4442(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwriteP_4442(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICreadEC_4442(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICPassword_4442(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI  ICChangePassword_4442(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

#ifdef __cplusplus
}
#endif

int MCAPI ICreadS_4442(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwriteS_4442(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICPSC_4442(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);


#endif

#endif // USE_SLE4442

#ifdef USE_GPM103

#ifndef _GPM103_H_
#define _GPM103_H_

#ifdef __cplusplus
extern "C" {
#endif

int MCAPI ICread_GPM103(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwrite_GPM103(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICerase_GPM103(int port, int address,unsigned char * me1,
	unsigned char * me2,int * status, int *line);

int MCAPI ICreadA_GPM103(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwriteA_GPM103(int port, int address, int datalen,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICPassword_GPM103(int port,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

#ifdef __cplusplus
}
#endif

#endif

#endif // USE_GPM103

#ifdef USE_GPM416

#ifndef _GPM416_H_
#define _GPM416_H_

#define  GPM416_SIZE             52          //  GPM416 Card Total Byte Size

#define  MANUF416_OFFSET          0          //  Manufacturing Area Offset
#define  MANUF416_SIZE            2          //  Manufacturing Area Size

#define  ISSUER416_OFFSET         2          //  Issuer Area Offset
#define  ISSUER416_SIZE           6          //  Issuer Area Size

#define  CSC416_OFFSET            8          //  Card Secret Code Offset
#define  CSC416_SIZE              2          //  Card Secret Code Size

#define  ERROR_CNT416_OFFSET     10          //  Error Counter Offset
#define  ERROR_CNT416_SIZE        2          //  Error Counter Size

#define  PROTECTED416_OFFSET     12          //  Area Protected by CSC Offset
#define  PROTECTED416_SIZE        2          //  Area Protected by CSC Size

#define  APP416_OFFSET           14          //  Application Area Offset
#define  APP416_SIZE             26          //  Application Area Size

#define  ESC416_OFFSET           40          //  Erase Secret Code Offset
#define  ESC416_SIZE              4          //  Erase Secret Code Size

#define  ERASE_CNT416_OFFSET     44          //  Erase Counter Offset
#define  ERASE_CNT416_SIZE        8          //  Erase Counter Size

enum GPM416_AREA
   {
   GPM416_ManufArea,           //  Manufacturing Area
   GPM416_IssuerArea,         //  Issuer Area
   GPM416_CardSecretCode,        //  Card Secret Code
   GPM416_ErrorCounter,    //  Error Counter
   GPM416_ProtectedArea,   //  Area Protected by CSC
   GPM416_ApplicationArea,     //  Application Area 2
   GPM416_EraseSecretCode,     //  Erase Secret Code 2
   GPM416_EraseCounter,    //  Erase Counter Size
   GPM416_AreaNumber
   };


#ifdef __cplusplus
extern "C" {
#endif

int MCAPI ICread_GPM416(int port, enum GPM416_AREA area,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwrite_GPM416(int port, enum GPM416_AREA area,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICPassword_GPM416(int port, enum GPM416_AREA area,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICerase_GPM416(int port, enum GPM416_AREA area,
	unsigned char * me1,unsigned char * me2,int * status, int *line);

int MCAPI ICFuse_GPM416(int port,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

#ifdef __cplusplus
}
#endif

#endif

#endif // USE_GPM416

#ifdef USE_GPM896

#ifndef _GPM896_H_
#define _GPM896_H_

#define  GPM896_SIZE            112          //  GPM896 Card Total Byte Size

#define  MANUF896_OFFSET          0          //  Manufacturing Area Offset
#define  MANUF896_SIZE            2          //  Manufacturing Area Size

#define  ISSUER896_OFFSET         2          //  Issuer Area Offset
#define  ISSUER896_SIZE           8          //  Issuer Area Size

#define  CSC896_OFFSET           10          //  Card Secret Code Offset
#define  CSC896_SIZE              2          //  Card Secret Code Size

#define  ERROR_CNT896_OFFSET     12          //  Error Counter Offset
#define  ERROR_CNT896_SIZE        2          //  Error Counter Size

#define  PROTECTED896_OFFSET     14          //  Area Protected by CSC Offset
#define  PROTECTED896_SIZE        8          //  Area Protected by CSC Size

#define  APP1896_OFFSET          22          //  Application Area 1 Offset
#define  APP1896_SIZE            32          //  Application Area 1 Size

#define  ESC1896_OFFSET          54          //  Erase Secret Code 1 Offset
#define  ESC1896_SIZE             6          //  Erase Secret Code 1 Size

#define  APP2896_OFFSET          60          //  Application Area 2 Offset
#define  APP2896_SIZE            32          //  Application Area 2 Size

#define  ESC2896_OFFSET          92          //  Erase Secret Code 2 Offset
#define  ESC2896_SIZE             4          //  Erase Secret Code 2 Size

#define  ERASE_CNT896_OFFSET     96          //  Erase Counter Offset
#define  ERASE_CNT896_SIZE       16          //  Erase Counter Size

enum GPM896_AREA
   {
   GPM896_ManufArea,           //  Manufacturing Area
   GPM896_IssuerArea,         //  Issuer Area
   GPM896_CardSecretCode,        //  Card Secret Code
   GPM896_ErrorCounter,    //  Error Counter
   GPM896_ProtectedArea,   //  Area Protected by CSC
   GPM896_ApplicationArea1,     //  Application Area 1
   GPM896_EraseSecretCode1,     //  Erase Secret Code 1
   GPM896_ApplicationArea2,     //  Application Area 2
   GPM896_EraseSecretCode2,     //  Erase Secret Code 2
   GPM896_EraseCounter,    //  Erase Counter Size
   GPM896_AreaNumber
   };

#ifdef __cplusplus
extern "C" {
#endif

int MCAPI ICread_GPM896(int port, enum GPM896_AREA area,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICwrite_GPM896(int port, enum GPM896_AREA area,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICPassword_GPM896(int port, enum GPM896_AREA area,
	 unsigned char *data,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICfuse_GPM896(int port,unsigned char * me1,unsigned char * me2,
	int * status, int *line);

int MCAPI ICerase_GPM896(int port, enum GPM896_AREA area,
	unsigned char * me1,unsigned char * me2,int * status, int *line);

#ifdef __cplusplus
}
#endif

#endif

#endif // USE_GPM896

#ifndef _CARDOS_H_
#define _CARDOS_H_

#define NONE 0x00FF

struct  ICCCommand
{
    unsigned int function;       /*  Function (see function table )    */
    unsigned int efIdent;        /*  short EF-Identifier               */
    unsigned int dataPointer;    /*  file- offset    / record number   */
    unsigned int lc;             /*  length send data                  */
    byte * data;    /*  send datablock                    */
    unsigned int le;             /*  max length  response              */
};

/***************************************************************************/
/*                        response block                                   */
/***************************************************************************/

struct ICCResponse
{
    byte sw1;         /* Status bytes                         */
    byte sw2;         /*                                      */
    unsigned int ldata;        /* length response                      */
    byte * data;  /* respons datablock                    */
};

/***************************************************************************/
/*                        security block                                   */
/***************************************************************************/

struct ICCSecurity
{
    byte macDown;        /* signature algorithm              */
    byte macUp;          /*                                  */
    byte * macKey;   /* signature key                    */

    byte encDown;        /* encryption algorithm             */
    byte encUp;          /*                                  */
    byte * encKey;   /* encryption key                   */
};


/***************************************************************************/
/*                 cypher block                                            */
/***************************************************************************/

struct ICCCodeBlock
{

    byte function;        /* cypher mode           */
    byte * secKey;    /* cypher key            */
    unsigned int  ls;              /* length of data        */
    byte * data;      /* pointer to data       */
};

/***************************************************************************/
/*                     data telegram block                                 */
/***************************************************************************/

struct ICCApdu
{
#ifdef __cplusplus
    ICCApdu () : cla(0), ins(0), p1(0), p2(0), lc(0), le(0) {}
#endif
    byte  cla;
    byte  ins;
    byte  p1,p2;
    byte  lc;
    byte  data[256];
    byte  le;
};

/***************************************************************************/
/*                        function calls                                   */
/***************************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

int       PASCAL ICCInit     (int ch);
int       PASCAL ICCDefineCard (int ch, int CardType);
int       PASCAL ICCClose    (int ch);
int       PASCAL ICCCardReset (int ch );
int       PASCAL ICCSetBufferSize (int,
                                        int ch
                                        );
int       PASCAL ICCSetVersion (int,
                                        int ch
                                        );
int       PASCAL ICCGetVersion (int ch
                                        );

⌨️ 快捷键说明

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