]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/cmdhftopaz.c
aed5f023c4789a76ac0d4a7063b68dea8f6f79ba
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2015 Piwi
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // High frequency Topaz (NFC Type 1) commands
9 //-----------------------------------------------------------------------------
16 #include "cmdparser.h"
17 #include "cmdhftopaz.h"
21 #include "proxmark3.h"
22 #include "iso14443crc.h"
23 #include "protocols.h"
27 static void topaz_switch_on_field(void)
29 UsbCommand c
= {CMD_READER_ISO_14443a
, {ISO14A_CONNECT
| ISO14A_NO_SELECT
| ISO14A_NO_DISCONNECT
| ISO14A_TOPAZMODE
, 0, 0}};
33 WaitForResponse(CMD_ACK
, &resp
);
37 static void topaz_switch_off_field(void)
39 UsbCommand c
= {CMD_READER_ISO_14443a
, {0, 0, 0}};
43 WaitForResponse(CMD_ACK
, &resp
);
47 static void topaz_send_cmd_raw(uint8_t *cmd
, uint8_t len
, uint8_t *response
)
49 UsbCommand c
= {CMD_READER_ISO_14443a
, {ISO14A_RAW
| ISO14A_NO_DISCONNECT
| ISO14A_TOPAZMODE
, len
, 0}};
50 memcpy(c
.d
.asBytes
, cmd
, len
);
54 WaitForResponse(CMD_ACK
, &resp
);
56 memcpy(response
, resp
.d
.asBytes
, resp
.arg
[0]);
60 static void topaz_send_cmd(uint8_t *cmd
, uint8_t len
, uint8_t *response
)
63 uint8_t first
, second
;
64 ComputeCrc14443(CRC_14443_B
, cmd
, len
, &first
, &second
);
69 topaz_send_cmd_raw(cmd
, len
+2, response
);
73 static void topaz_select(uint8_t *atqa
, uint8_t *uid
)
75 // ToDo: implement anticollision
76 uint8_t rid_cmd
[] = {TOPAZ_RID
, 0, 0, 0, 0, 0, 0, 0, 0};
77 uint8_t wupa_cmd
[] = {TOPAZ_WUPA
};
79 topaz_switch_on_field();
80 topaz_send_cmd(wupa_cmd
, sizeof(wupa_cmd
), atqa
);
81 topaz_send_cmd(rid_cmd
, sizeof(rid_cmd
) - 2, uid
);
82 topaz_switch_off_field();
86 int CmdHFTopazReader(const char *Cmd
)
88 PrintAndLog("not yet implemented");
93 int CmdHFTopazSim(const char *Cmd
)
95 PrintAndLog("not yet implemented");
100 int CmdHFTopazCmdRaw(const char *Cmd
)
102 PrintAndLog("not yet implemented");
107 static int CmdHelp(const char *Cmd
);
110 static command_t CommandTable
[] =
112 {"help", CmdHelp
, 1, "This help"},
113 {"reader", CmdHFTopazReader
, 0, "Act like a Topaz reader"},
114 {"sim", CmdHFTopazSim
, 0, "<UID> -- Simulate Topaz tag"},
115 {"snoop", CmdHF14ASnoop
, 0, "Eavesdrop a Topaz reader-tag communication"},
116 {"raw", CmdHFTopazCmdRaw
, 0, "Send raw hex data to tag"},
117 {NULL
, NULL
, 0, NULL
}
121 int CmdHFTopaz(const char *Cmd
) {
123 WaitForResponseTimeout(CMD_ACK
,NULL
,100);
126 CmdsParse(CommandTable
, Cmd
);
130 static int CmdHelp(const char *Cmd
)
132 CmdsHelp(CommandTable
);