diff options
author | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2005-06-13 09:19:51 +0000 |
---|---|---|
committer | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2005-06-13 09:19:51 +0000 |
commit | e710ef620b6666597b5f85a1ca4ae8f221f385a6 (patch) | |
tree | e8451b93f6eef088050a135d20daa412f90fc336 | |
parent | ce0639ab6e20bed99d0702a0658bd178c4ef9bf2 (diff) |
select_mf() and get_challenge() to test whether T=CL layer is working
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1210 e0336214-984f-0b4b-a45f-81c69e1f0ede
-rw-r--r-- | openct-escape.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/openct-escape.c b/openct-escape.c index 7533d0f..32bc123 100644 --- a/openct-escape.c +++ b/openct-escape.c @@ -90,8 +90,8 @@ static int init() } printf("opening layer2 handle\n"); - //l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443A); - l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443B); + l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443A); + //l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443B); if (!l2h) { fprintf(stderr, "error during iso14443a_init\n"); return -1; @@ -122,16 +122,58 @@ static int init() return 0; } +static int select_mf(void) +{ + unsigned char cmd[] = { 0x00, 0xa4, 0x00, 0x00, 0x02, 0x3f, 0x00, 0x00 }; + unsigned char ret[256]; + unsigned int rlen = sizeof(ret); + + int rv; + + rv = rfid_protocol_transcieve(ph, cmd, sizeof(cmd), ret, &rlen, 0, 0); + if (rv < 0) + return rv; + + //printf("%s\n", rfid_hexdump(ret, rlen)); + + return 0; +} + + +static int get_challenge(unsigned char len) +{ + unsigned char cmd[] = { 0x00, 0x84, 0x00, 0x00, 0x08 }; + unsigned char ret[256]; + unsigned int rlen = sizeof(ret); + + cmd[4] = len; + + int rv; + + rv = rfid_protocol_transcieve(ph, cmd, sizeof(cmd), ret, &rlen, 0, 0); + if (rv < 0) + return rv; + + //printf("%s\n", rfid_hexdump(ret, rlen)); + + return 0; +} int main(int argc, char **argv) { int rc; char buf[0x40]; + int i; if (init() < 0) exit(1); /* we've established T=CL at this point */ + + select_mf(); + + for (i = 0; i < 4; i++) + get_challenge(0x60); rfid_reader_close(rh); |