如何在Scosta智能卡中读取EF中的二进制数据?

时间:2015-07-14 11:59:36

标签: smartcard apdu scosta

我正在使用SCOSTA智能卡,我已经成功创建了MF,DF,EF文件结构,我已经在智能卡中成功创建了EF文件格式,以下是代码。

SendBuff[0] = 0x00;     //CLA
SendBuff[1] = 0xE0;     //INS
SendBuff[2] = 0x00;     //p1
SendBuff[3] = 0x00;     //p2
SendBuff[4] = 0x1A;     //len
SendBuff[5] = 0x62;     //T
SendBuff[6] = 0x18;     //L

SendBuff[7] = 0x80;     //T
SendBuff[8] = 0x02;     //Len
SendBuff[9] = 0x02;     //Value,File size
SendBuff[10] = 0x08;    //value,File size

SendBuff[11] = 0x82;    //T
SendBuff[12] = 0x01;    //Len
SendBuff[13] = 0x01;    //FDB (Transparent Working EF)

SendBuff[14] = 0x83;     //T
SendBuff[15] = 0x02;     //Len
SendBuff[16] = 0xE0;     //EF INDENTIFIER
SendBuff[17] = 0x07;

SendBuff[18] = 0x88;      //T
SendBuff[19] = 0x01;      //Len
SendBuff[20] = 0x09;      //Value

SendBuff[21] = 0x8A;      //T
SendBuff[22] = 0x01;
SendBuff[23] = 0x01;      //LCSI. When file is created first, it will be in 01

SendBuff[24] = 0x8C;      //T
SendBuff[25] = 0x05;      //Len
SendBuff[26] = 0x6A;      //Security Attributes
SendBuff[27] = 0xFF;        //Delete File: Never
SendBuff[28] = 0xFF;        //Terminate EF: Never
SendBuff[29] = 0xFF;        //Deactivate EF: Never
SendBuff[30] = 0x23;        //Update Binary: SE#3`

我已经使用APDU 00 D0 00 04 10 + Data.so在智能卡中写了二进制命令,借助于此,我已成功在智能卡中写入数据, 在读取二进制命令之前,我已经在智能卡上选择了写入的文件,之后我使用了READ二进制APDU命令00 B0 00 00 00.响应状态为:

  

6986不允许命令(没有当前的EF)。

阅读二进制代码:

ModWinsCard.SCARD_IO_REQUEST SendRequest;
SendRequest.dwProtocol = 1;
SendRequest.cbPciLength = 8;

ModWinsCard.SCARD_IO_REQUEST RecvRequest;
RecvRequest.dwProtocol = 1;
RecvRequest.cbPciLength = 8;


byte[] SendBuff = new byte[255];
byte[] RecvBuff = new byte[255];

int SendBuffLen = 0x5;
int RecvBuffLen = 0x12;

//Byte currentBlock = (byte)(int.Parse(strBlock));
//Byte currentBlock = Convert.ToByte(strBlock, 16);
//Byte len = Convert.ToByte(Len);

SendBuff[0] = 0x00;
SendBuff[1] = 0xB0;       
SendBuff[2] = 0x00;
SendBuff[3] = 0x00;
SendBuff[4] = 0x00;

status = ModWinsCard.SCardTransmit(hCard, ref SendRequest, ref SendBuff[0], SendBuffLen, ref RecvRequest, ref RecvBuff[0], ref RecvBuffLen);

我有2个以下的外部工具供参考:

  1. Smart Card ToolSet PRO v3.4
  2. Cryptware智能卡控制台
  3. 通过使用这些工具,我可以编写二进制文件,更新二进制文件,读取二进制文件,获取数据,所以我已经在上述工具的帮助下成功执行了这些操作,响应为“9000”,但在我自己的编码智能卡中应用程序无法正常工作,即写入二进制,更新二进制,读取二进制命令。从开始到结束步骤在智能卡上执行操作的顺序是什么?

1 个答案:

答案 0 :(得分:0)

8c标签是关于紧凑型安全性的。由于在创建文件期间启用了安全性,因此希望出现此错误。

你能以可读的形式分享APDU命令吗?它将有助于确定问题。