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

📄 iccapp.lst

📁 mifarea卡程序mifarea卡程序mifarea卡程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 573   1          if(!SamSendCommand(&command, &response))
 574   1              return -1;
 575   1          else
 576   1          {   
 577   2                      memcpy(buf, response.DAT, response.len);
 578   2              return response.ISW;
 579   2          }
 580   1      }
 581          
 582          /*****************************************
 583           * Read Record file                      *
 584           * CLA: 00, INS: B2                      *
 585           * Secret and protect mode: YES          *
 586           * Suport: ISO/PBOC                      *
 587           * recid:   记录号(或记录标识)         *
 588           * flag:    读方式详见说明               *
 589           * buf:     读到的内容                   *
 590           *****************************************/
 591          int ICC_read_record(unsigned char recid, unsigned char flag, char *buf)
 592          {   
 593   1              command.CLA = 00;
 594   1          command.INS = 0xb2;
 595   1          command.P1 = recid;
 596   1          command.P2 = flag;
 597   1          command.Lc = 00;
 598   1          command.Le = 00;
 599   1      
 600   1          if(!SamSendCommand(&command, &response))
 601   1              return -1;
 602   1          else
 603   1          {    
 604   2                      memcpy(buf, response.DAT, response.len);
 605   2              return response.ISW;
 606   2          }   
 607   1      }
 608          
 609          /*****************************************
 610           * Get response from card                *
 611           * CLA: 00, INS: C0                      *
 612           * Secret and protect mode: NO           *
C51 COMPILER V7.07   ICCAPP                                                                12/06/2003 18:49:10 PAGE 11  

 613           * Suport: ISO/PBOC                      *
 614           * len:     期望得到的长度               *
 615           * buf:     输出,读到的内容             *
 616           *****************************************/
 617          int ICC_get_response(unsigned char len, char *buf)
 618          {  
 619   1              command.CLA = 00;
 620   1          command.INS = 0xc0;
 621   1          command.P1 = 0;
 622   1          command.P2 = 0;
 623   1          command.Lc = 0;
 624   1          command.DAT =0;
 625   1          command.Le = len;
 626   1      
 627   1          if(!SamSendCommand(&command, &response))
 628   1              return -1;
 629   1          else
 630   1          {    
 631   2                      memcpy(buf, response.DAT, response.len);
 632   2              return response.ISW;
 633   2          }
 634   1      }
 635          
 636          /*****************************************
 637           * Update binary file (更新二进制文件)  *
 638           * CLA: 00, INS: D6                      *
 639           * Secret and protect mode: YES          *
 640           * Suport: ISO/PBOC                      ***
 641           * para1: 短文标识或偏移量高字节(100xxxxx) *
 642           *      如果是偏移量高字节则写当前文件     *
 643           * para2: 偏移量                           *
 644           * len:     写入的长度                     *
 645           * buf:     待写的内容                     *
 646           *******************************************/
 647          int ICC_update_binary(unsigned char para1, unsigned char para2, char *buf, unsigned char len)
 648          {   
 649   1              command.CLA = 00;
 650   1          command.INS = 0xd6;
 651   1          command.P1 = para1;
 652   1          command.P2 = para2;
 653   1          command.Lc = len;
 654   1          command.DAT = buf;
 655   1          command.Le = 0;
 656   1      
 657   1          if(!SamSendCommand(&command, &response))
 658   1              return -1;
 659   1          else
 660   1          {
 661   2              return response.ISW;
 662   2          }   
 663   1      }
 664          
 665          /*****************************************
 666           * Update record file (更新记录文件)    *
 667           * CLA: 00, INS: DC                      *
 668           * Secret and protect mode: YES          *
 669           * Suport: ISO/PBOC                      *
 670           * recid:   记录号或标识,00表示当前纪录 *
 671           * flag:    写入方式,详见说明           *
 672           * len:     写入数据的长度               *
 673           * buf:     待写入的数据                 *
 674           *****************************************/
C51 COMPILER V7.07   ICCAPP                                                                12/06/2003 18:49:10 PAGE 12  

 675          int ICC_update_record(unsigned char recid, unsigned char flag, char *buf, unsigned char len)
 676          {   
 677   1              command.CLA = 00;
 678   1          command.INS = 0xdc;
 679   1          command.P1 = recid;
 680   1          command.P2 = flag;
 681   1          command.Lc = len;
 682   1          command.DAT = buf;
 683   1          command.Le = 0;
 684   1      
 685   1          if(!SamSendCommand(&command, &response))
 686   1              return -1;
 687   1          else
 688   1              return response.ISW;
 689   1      }
 690          
 691          /*****************************************
 692           * Card block        (卡锁定)          *
 693           * CLA: 84, INS: 16                      *
 694           * Secret and protect mode: NO           *
 695           * Suport: PBOC                          *
 696           * 参数1:MAC                           *
 697           *****************************************/
 698          int ICC_block(unsigned char *MAC)
 699          {
 700   1          command.CLA = 84;
 701   1          command.INS = 16;
 702   1          command.P1 = 0;
 703   1          command.P2 = 0;
 704   1          command.Lc = 4;
 705   1          command.DAT =MAC;
 706   1          command.Le = 0;
 707   1      
 708   1          if(!SamSendCommand(&command, &response))
 709   1              return -1;
 710   1          else
 711   1              return response.ISW;
 712   1      }
 713          
 714          /*****************************************
 715           * Application unblock  (应用解锁)       *
 716           * CLA: 84, INS: 18                      *
 717           * Secret and protect mode: NO           *
 718           * Suport: PBOC                          *
 719            * 参数1:MAC                           *
 720           *****************************************/
 721          int ICC_app_unblock(unsigned char *MAC)
 722          {
 723   1              command.CLA = 84;
 724   1          command.INS = 18;
 725   1          command.P1 = 0;
 726   1          command.P2 = 0;
 727   1          command.Lc = 4;
 728   1          command.DAT =MAC;
 729   1          command.Le = 0;
 730   1      
 731   1          if(!SamSendCommand(&command, &response))
 732   1              return -1;
 733   1          else
 734   1              return response.ISW;
 735   1           
 736   1      }
C51 COMPILER V7.07   ICCAPP                                                                12/06/2003 18:49:10 PAGE 13  

 737          
 738          /*****************************************
 739           * Application block     (应用锁定)    *
 740           * CLA: 84, INS: 1E                      *
 741           * Secret and protect mode: NO           *
 742           * Suport: PBOC                          *
 743           * 参数1:锁定类型(0/1);参数2:MAC    *
 744           *****************************************/
 745          int ICC_app_block(char Block_style,unsigned char *MAC)
 746          {       
 747   1              command.CLA = 84;
 748   1          command.INS = 0x1e;
 749   1          command.P1 = 0;
 750   1          command.P2 = Block_style;
 751   1          command.Lc = 4;
 752   1          command.DAT =MAC;
 753   1          command.Le = 0;
 754   1      
 755   1          if(!SamSendCommand(&command, &response))
 756   1              return -1;
 757   1          else
 758   1          {
 759   2              return response.ISW;
 760   2          }
 761   1           
 762   1          
 763   1      }
 764          
 765          /*****************************************
 766           * Pin unblock                           *
 767           * CLA: 80, INS: 24                      *
 768           * Secret and protect mode: YES          *
 769           * Suport: PBOC                          *
 770           *****************************************/
 771          int ICC_pin_unblock(char Block_style,unsigned char *MAC)
 772          {
 773   1          command.CLA = 84;
 774   1          command.INS = 24;
 775   1          command.P1 = 0;
 776   1          command.P2 = Block_style;
 777   1          command.Lc = 4;
 778   1          command.DAT =MAC;
 779   1          command.Le = 0;
 780   1      
 781   1          if(!SamSendCommand(&command, &response))
 782   1              return -1;
 783   1          else
 784   1          {
 785   2              return response.ISW;
 786   2          }
 787   1           
 788   1      }
 789          
 790          /*****************************************
 791           * Initialize for load(初始化圈存交易)   *
 792           * CLA: 80, INS: 50                      *
 793           * Secret and protect mode: NO           *
 794           * Suport: PBOC                          *
 795           * ED_or_EP: 电子钱包或存折,01-ED, 02-EP ********
 796           * transinfo: 交易信息                          *
 797           *(密钥索引1字节+交易金额4字节+终端机编号6字节)*
 798           * outbuf:  输出如下:                           *
C51 COMPILER V7.07   ICCAPP                                                                12/06/2003 18:49:10 PAGE 14  

 799           * 余额*4 + 交易序号*2 + 密钥版本*1 + 算法标识*1 *
 800           * + 伪随机数*4 + MAC1*4                         *
 801           *************************************************/
 802          int ICC_init_for_load(unsigned char ED_or_EP, char *transinfo, unsigned char *outbuf)
 803          {
 804   1          command.CLA = 0x80;
 805   1          command.INS = 0x50;
 806   1          command.P1 = 0;
 807   1          command.P2 = ED_or_EP;
 808   1          command.Lc = 0x0b;
 809   1          command.DAT = transinfo;
 810   1          command.Le = 0x10;
 811   1          
 812   1          if(!SamSendCommand(&command, &response))
 813   1              return -1;
 814   1          else
 815   1          {
 816   2              memcpy(outbuf, response.DAT, response.len);
 817   2              return response.ISW;
 818   2          }  
 819   1      }
 820          /*****************************************
 821           * Initialize for unload(初始化圈提交易) *
 822           * CLA: 80, INS: 50                      *
 823           * Secret and protect mode: NO           *
 824           * Suport: PBOC                          *
 825           * 参数1:交易信息(密钥索引1字节+交易金额4字节+终端机编号6字节)*
 826            *参数2:输出指针                         * 
 827           *****************************************/
 828          int ICC_init_for_unload(unsigned char *transinfo,unsigned char *outbuf)
 829          {
 830   1          command.CLA = 0x80;
 831   1          command.INS = 0x50;
 832   1          command.P1 = 05;
 833   1          command.P2 = 01;
 834   1          command.Lc = 0x0b;
 835   1          command.DAT = transinfo;
 836   1          command.Le = 0x10;
 837   1          
 838   1          if(!SamSendCommand(&command, &response))
 839   1              return -1;
 840   1          else
 841   1          {
 842   2              memcpy(outbuf, response.DAT, response.len);
 843   2              return response.ISW;
 844   2          }  
 845   1          
 846   1      }
 847          /*****************************************
 848           * Initialize for cash withdraw          *
 849           * CLA: 80, INS: 50                      *
 850           * Secret and protect mode: NO           *
 851           * Suport: PBOC                          *
 852           * 参数1:交易信息(密钥索引1字节+交易金额4字节+终端机编号6字节)*
 853           * 参数2:输出指针                        *
 854           *****************************************/
 855          int ICC_init_for_cash(unsigned char *transinfo,unsigned char *outbuf)
 856          {
 857   1          command.CLA = 0x80;
 858   1          command.INS = 0x50;
 859   1          command.P1 = 02;
 860   1          command.P2 = 01;
C51 COMPILER V7.07   ICCAPP                                                                12/06/2003 18:49:10 PAGE 15  

 861   1          command.Lc = 0x0b;
 862   1          command.DAT = transinfo;

⌨️ 快捷键说明

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