📄 sim.lst
字号:
792 2 }
793 1 statecode=GetResponse(8,card);
794 1 if(statecode != 0x9000)
795 1 {
796 2 ErrorHint("内部认证出错2!",statecode);
797 2 }
798 1 for(i=0;i<8;i++)
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 14
799 1 dat[i]=RxdBuf[i];
800 1 }
801 /*
802 //MAC 如何取得????
803 void ApplictionBlock(uchar xp2,uchar *mac,uchar card)
804 {
805 uint statecode;
806 uchar i;
807
808 TxdBuf[0]=0x84;
809 TxdBuf[1]=0x18;
810 TxdBuf[2]=0x00;
811 TxdBuf[3]=xp2;
812 TxdBuf[4]=0x04;
813 for(i=0;i<4;i++)
814 TxdBuf[5+i]=mac[i];
815 statecode=SimCmd(9,card);
816 if(statecode != 0x9000)
817 {
818 ErrorHint("应用锁定出错!",statecode);
819 return;
820 }
821
822 }
823
824 //MAC 如何取得????
825 void ApplictionUnblock(uchar *mac,uchar card)
826 {
827 uint statecode;
828 uchar i;
829
830 TxdBuf[0]=0x84;
831 TxdBuf[1]=0x18;
832 TxdBuf[2]=0x00;
833 TxdBuf[3]=0x00;
834 TxdBuf[4]=0x04;
835 for(i=0;i<4;i++)
836 TxdBuf[5+i]=mac[i];
837 statecode=SimCmd(9,card);
838 if(statecode != 0x9000)
839 {
840 ErrorHint("解除应用锁定出错!",statecode);
841 }
842 }
843
844 //MAC 如何取得????
845 void CardBlock(uchar *mac,uchar card)
846 {
847 uint statecode;
848 uchar i;
849
850 TxdBuf[0]=0x84;
851 TxdBuf[1]=0x16;
852 TxdBuf[2]=0x00;
853 TxdBuf[3]=0x00;
854 TxdBuf[4]=0x04;
855 for(i=0;i<4;i++)
856 TxdBuf[5+i]=mac[i];
857 statecode=SimCmd(9,card);
858 if(statecode != 0x9000)
859 {
860 ErrorHint("SIM卡锁定出错!",statecode);
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 15
861 }
862 }
863
864 void PinUnblock(uchar xp1,uchar *dat)
865 {//由发卡方解锁PIN
866 uchar i;
867 uint statecode;
868
869 TxdBuf[0]=0x84;
870 TxdBuf[1]=0x24;
871 TxdBuf[2]=xp1;
872 TxdBuf[3]=0x01;
873 TxdBuf[4]=0x0C;
874 for(i=0;i<0x0C;i++)
875 TxdBuf[5+i]=dat[i];
876 statecode=SimCmd(17,0);
877 if(statecode != 0x6181)
878 {
879 ErrorHint("PIN解锁出错!",statecode);
880 return;
881 }
882 }
883 */
884 void DailyCollectSign(uchar xp2,uchar *dat,uchar *str)
885 {
886 1 uchar i,lc,k=0;
887 1 uint statecode;
888 1
889 1 if(xp2==0)
890 1 lc=0x41;
891 1 else
892 1 lc=0x81;
893 1
894 1 RxdBuf[0]=0xEF;
895 1 RxdBuf[1]=0x03;
896 1 SelectFile(0x00,0x00,0x02,RxdBuf,0);
897 1 VerifyFiscalPin();
898 1
899 1 TxdBuf[0]=0xC0;
900 1 TxdBuf[1]=0xFB;
901 1 TxdBuf[2]=0x00;
902 1 TxdBuf[3]=xp2;
903 1 TxdBuf[4]=lc;
904 1 lc--;
905 1 for(i=0;i<lc;i++)
906 1 {
907 2 TxdBuf[5+i]=dat[i];
908 2 k ^= dat[i];
909 2 }
910 1 lc++;
911 1 TxdBuf[lc+4]=k;
912 1 TxdBuf[lc+5]=0x81;
913 1 // UartTxd(72,TxdBuf);
914 1 statecode=SimCmd(lc+6,0);
915 1 if(statecode != 0x6181)
916 1 {
917 2 if(statecode==0x9303)AppBlockHint(0,1);
918 2 ErrorHint("日交易累计记录签名出错!",statecode);
919 2 }
920 1 statecode=GetResponse(0x81,0);
921 1 if(statecode != 0x9000)
922 1 {
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 16
923 2 ErrorHint("获取签名出错!",statecode);
924 2 }
925 1 for(i=0;i<128;i++)str[i]=RxdBuf[i];
926 1 }
927
928 //00 20 00 02 08 31 32 33 34 35 36 37 38
929 void VerifyPin(uchar xp2,uchar lc,uchar *dat,uchar card)
930 {//效验命令数据域(用户卡?)的PIN的正确性
931 1 uchar i;
932 1 uint statecode;
933 1
934 1 TxdBuf[0]=0x00;
935 1 TxdBuf[1]=0x20; //Verify
936 1 TxdBuf[2]=0x00;
937 1 TxdBuf[3]=xp2; //PIN标识,00:银行标准PIN(只能为数字),01:用户卡使用口令,其它保留
938 1 TxdBuf[4]=lc;
939 1 for(i=0;i<lc;i++)
940 1 TxdBuf[5+i]=dat[i];
941 1 statecode=SimCmd(5+lc,card);
942 1 if(statecode != 0x9000)
943 1 {
944 2 if(statecode==0x6983)AppBlockHint(card,0);
945 2 ErrorHint("PIN效验出错!",statecode);
946 2 }
947 1 }
948
949 uchar ManagementIdentify()
950 {
951 1 uchar dat[16],k,i,m;
952 1 gyt4 *xp,*tp;
953 1 // ulong pin;
954 1
955 1 SimRstCold(2);
956 1 RxdBuf[0]=0x2F;
957 1 RxdBuf[1]=0x02;
958 1 SelectFile(0x00,0x00,0x02,RxdBuf,2);
959 1 ReadBinary(0x82,0,17,2);
960 1 if(RxdBuf[0]!=2)
961 1 {
962 2 LcdDisplay(16,0,"没有检测到管理卡!",1);
963 2 Hint(32,0,"请检查卡的类型是否正确!",1);
964 2 return 0xFF;
965 2 }
966 1 ReadDate();
967 1 xp=InvoDate;
*** WARNING C182 IN LINE 967 OF SIM.C: pointer to different objects
968 1 tp=&RxdBuf[13];
*** WARNING C182 IN LINE 968 OF SIM.C: pointer to different objects
969 1 if(xp->dat>tp->dat)
970 1 {
971 2 LcdDisplay(16,0,"应用有效日期已过!",1);
972 2 return 0xFF;
973 2 }
974 1 ReadBinary(0x81,0,10,2);
975 1 k=RxdBuf[8];
976 1 m=RxdBuf[9];
977 1 if(m!=0xFF)
978 1 {//非最高级别核查,需要做外部认证
979 2 I2cRead(TaxpayerNo,8,dat);
980 2 for(i=0;i<8;i++)
981 2 if(RxdBuf[i]!=dat[i])
982 2 {//纳税人编号不一致
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 17
983 3 LcdDisplay(16,0,"非本机管理卡!",1);
984 3 return 0xFF;
985 3 }
986 2 if(!FiscalIdentify(1))
987 2 {
988 3 LcdDisplay(16,0,"非本机税控卡!",1);
989 3 return 0xFF;
990 3 }
991 2 memset(dat,0,sizeof(dat));
992 2 GetChallenge(8,dat,2);
993 2 InternalAtuhntication(1,dat,0);
994 2 ExternalAuthentication(1,dat,2);
995 2 }
996 1 if(m==0xFF && k==3)//修改时钟时需要做PIN效验
997 1 {//输入PIN码效验
998 2 // LcdDisplay(0,0,"请输入认证密码",3);
999 2 // LcdDisplay(16,0,"PIN:",0);
1000 2 // while(1)
1001 2 // {
1002 2 // temp[0]=0;
1003 2 // memset(dat,0,sizeof(dat));
1004 2 // if(SimType==SimTianYu)
1005 2 // i=GetBcd(16,32,dat,8,temp); //天喻
1006 2 // else
1007 2 //// if(SimType==SimWoQi)
1008 2 // i=GetBcd(16,32,dat,16,temp); //渥奇
1009 2 // if(i==K_TC)return 0xFF;
1010 2 // if(i==K_HJ)break;
1011 2 // }
1012 2 // if(SimType==SimTianYu)
1013 2 // VerifyPin(0,4,dat,1); //天喻
1014 2 // else
1015 2 //// if(SimType==SimWoQi)
1016 2 // VerifyPin(1,8,dat,1); //渥奇,PIN标识符可以在后台设置
1017 2 }
1018 1 RxdBuf[0]=0xEF;
1019 1 RxdBuf[1]=0x03;
1020 1 SelectFile(0x00,0x00,0x02,RxdBuf,2);
1021 1 return k;
1022 1 }
1023
1024 uchar UserIdentify(uchar x)
1025 {//用户卡识别,补发的用户卡如何处理?
1026 1 uchar i,dat[10],k,j;
1027 1 uint statecode;
1028 1
1029 1 SimRstCold(1);
1030 1 RxdBuf[0]=0x2F;
1031 1 RxdBuf[1]=0x02;
1032 1 SelectFile(0x00,0x00,0x02,RxdBuf,1);
1033 1 ReadBinary(0x82,0,10,1); //读取纳税人编码
1034 1 for(i=0;i<8;i++)dat[i]=RxdBuf[i+2];
1035 1 if(RxdBuf[0]!=1)
1036 1 {
1037 2 LcdDisplay(16,0,"没有检测到用户卡!",1);
1038 2 Hint(32,0,"请检查卡的类型是否正确!",1);
1039 2 return 0;
1040 2 }
1041 1
1042 1 if(x==0)
1043 1 {
1044 2 SimRstCold(0);
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 18
1045 2 RxdBuf[0]=0x2F;
1046 2 RxdBuf[1]=0x02;
1047 2 SelectFile(0x00,0x00,0x02,RxdBuf,0);
1048 2 ReadBinary(0x82,0,10,0); //读取税控卡编号
1049 2 for(i=0;i<8;i++)dat[i]=RxdBuf[i+2];
1050 2
1051 2 j=1;k=0;
1052 2 while(1)
1053 2 {
1054 3 statecode=ReadRecord(0,j,0x0C,37,1); //读取用户卡的税控卡编号
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -