| 1 |
corcoran |
108 |
#include <stdio.h>
|
| 2 |
|
|
#include <winscard.h>
|
| 3 |
|
|
#include <configfile.h>
|
| 4 |
|
|
#include <stdlib.h>
|
| 5 |
|
|
#include "commands.h"
|
| 6 |
|
|
int temp1;
|
| 7 |
|
|
|
| 8 |
|
|
testBULL(int argc,char** argv ) {
|
| 9 |
|
|
unsigned char test1[] = { 1,25,50,75,100,125,128,150,175,200,225,250,254} ;
|
| 10 |
|
|
unsigned char test2[] = { 0x55,0x55,0xAA,0xAA,0x55,0x55,0xAA,0xAA} ;
|
| 11 |
|
|
unsigned char test3[] = { 0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF} ;
|
| 12 |
|
|
unsigned char atr[] = { 0x3f ,0x67 ,0x25 ,0x0 ,0x21 ,0x20 ,0x0 ,0xf ,0x68 ,0x90 ,0x0,0x90,0} ;
|
| 13 |
|
|
int l,j,i=0;
|
| 14 |
|
|
char dummy[100];
|
| 15 |
|
|
data = alloca(300);
|
| 16 |
|
|
buffer = alloca(300);
|
| 17 |
|
|
//checkATR(atr);
|
| 18 |
|
|
/* Try to set T=0 protocol */
|
| 19 |
|
|
printit("Try to set protocol T1");
|
| 20 |
|
|
data[0]=0x00;
|
| 21 |
|
|
data[1]=0x07;
|
| 22 |
|
|
dwSendLength= 7;
|
| 23 |
|
|
SELECT(02,data,buffer,dwSendLength);
|
| 24 |
|
|
DO_TRANSMIT(SCARD_PCI_T1,1);
|
| 25 |
|
|
myprintf("Set protocol T0 \n");
|
| 26 |
|
|
myprintf("Test No. 1 \n\n");
|
| 27 |
|
|
/* Test1 */
|
| 28 |
|
|
printit("Buffer boundary test");
|
| 29 |
|
|
dwSendLength= 5;
|
| 30 |
|
|
GetCommand(0x00,0x84,0x00,0x00,0x08,data,buffer,dwSendLength);
|
| 31 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,1); /* Changed to 1 - getting 6d,0 */
|
| 32 |
|
|
myprintf("Test No. 2\n");
|
| 33 |
|
|
printit("3 byte APDU");
|
| 34 |
|
|
dwSendLength= 3;
|
| 35 |
|
|
GetCommand(0x00,0x84,0x00,0x00,0x08,data,buffer,dwSendLength);
|
| 36 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,1);
|
| 37 |
|
|
myprintf("Test No. 3\n");
|
| 38 |
|
|
printit("GET CHALLENGE");
|
| 39 |
|
|
dwSendLength=5;
|
| 40 |
|
|
GetCommand(0,0xC4,0,0,8,data,buffer,dwSendLength);
|
| 41 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 42 |
|
|
printit("VERIFY PIN");
|
| 43 |
|
|
dwSendLength=0x0f;
|
| 44 |
|
|
for(i=0;i<0x0a;i++)
|
| 45 |
|
|
data[i]=i+1;
|
| 46 |
|
|
GetCommand(0x00,0x38,0,0,0xA,data,buffer,dwSendLength);
|
| 47 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 48 |
|
|
myprintf("Test No. 4\n");
|
| 49 |
|
|
printit("SEARCH BLANK WORD");
|
| 50 |
|
|
dwSendLength=5;
|
| 51 |
|
|
GetCommand(0x00,0xA0,0,0,0,data,buffer,dwSendLength);
|
| 52 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 53 |
|
|
printit("GET RESPONSE");
|
| 54 |
|
|
dwSendLength=5;
|
| 55 |
|
|
GetCommand(0,0xC0,0,0,8,data,buffer,dwSendLength);
|
| 56 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 57 |
|
|
myprintf("Test No. 5\n");
|
| 58 |
|
|
printit("Lc byte incorrect");
|
| 59 |
|
|
dwSendLength=6;
|
| 60 |
|
|
data[0]=0x2f;
|
| 61 |
|
|
data[1]=0x01;
|
| 62 |
|
|
GetCommand(0,0xA4,0,0,3,data,buffer,dwSendLength);
|
| 63 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,1);
|
| 64 |
|
|
myprintf("Test No. 6\n");
|
| 65 |
|
|
printit("SELECT FILE");
|
| 66 |
|
|
data[0]=0x2f;
|
| 67 |
|
|
data[1]=0x01;
|
| 68 |
|
|
dwSendLength=7;
|
| 69 |
|
|
SELECT(2,data,buffer,dwSendLength);
|
| 70 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 71 |
|
|
printit("ERASE BINARY");
|
| 72 |
|
|
dwSendLength=7;
|
| 73 |
|
|
data[0]=00;
|
| 74 |
|
|
data[1]=0x78;
|
| 75 |
|
|
GetCommand(0x00,0x0E,0,0,2,data,buffer,dwSendLength);
|
| 76 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 77 |
|
|
l=0;
|
| 78 |
|
|
for(i=0x00;i<0x41;i++) {
|
| 79 |
|
|
sprintf(dummy,"WRITE BINARY - 4 bytes (%03d)",i);
|
| 80 |
|
|
printit(dummy);
|
| 81 |
|
|
dwSendLength=9;
|
| 82 |
|
|
data[0]=l;
|
| 83 |
|
|
data[1]=l+1;
|
| 84 |
|
|
data[2]=l+2;
|
| 85 |
|
|
data[3]=l+3;
|
| 86 |
|
|
l+=4;
|
| 87 |
|
|
GetCommand(0x00,0xD0,0,i,4,data,buffer,dwSendLength);
|
| 88 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 89 |
|
|
}
|
| 90 |
|
|
printit("READ BINARY - 256 bytes");
|
| 91 |
|
|
dwSendLength=5;
|
| 92 |
|
|
READBIN(0,0,0,data,buffer,dwSendLength);
|
| 93 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 94 |
|
|
myprintf("Test No. 7\n");
|
| 95 |
|
|
printit("GENERATE TEMP KEY");
|
| 96 |
|
|
dwSendLength=7;
|
| 97 |
|
|
data[0]=0x12;
|
| 98 |
|
|
data[1]=0x00;
|
| 99 |
|
|
GetCommand(0x00,0x80,0,0,2,data,buffer,dwSendLength);
|
| 100 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 101 |
|
|
myprintf("Test No. 8\n");
|
| 102 |
|
|
printit("SELECT FILE");
|
| 103 |
|
|
dwSendLength=7;
|
| 104 |
|
|
data[0]=0x3F;
|
| 105 |
|
|
data[1]=0x00;
|
| 106 |
|
|
SELECT(2,data,buffer,dwSendLength);
|
| 107 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,0);
|
| 108 |
|
|
printit("ERASE BINARY");
|
| 109 |
|
|
dwSendLength=7;
|
| 110 |
|
|
data[0]=0;
|
| 111 |
|
|
data[1]=0x78;
|
| 112 |
|
|
GetCommand(0x00,0x0E,0,0,2,data,buffer,dwSendLength);
|
| 113 |
|
|
DO_TRANSMIT(SCARD_PCI_T0,1); /* changed to 1 - getting 67,9 */
|
| 114 |
|
|
}
|