Merge pull request #2593 from Akury83/master
[RRG-proxmark3.git] / include / iso14b.h
blobde2692e58c6cccec66e2ef4d03a2a2cf6c694bf4
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // ISO 14443B type prototyping
17 //-----------------------------------------------------------------------------
19 #ifndef _ISO14B_H_
20 #define _ISO14B_H_
22 #include "common.h"
23 typedef struct {
24 uint8_t uid[10];
25 uint8_t uidlen;
26 uint8_t atqb[7];
27 uint8_t chipid;
28 uint8_t cid;
29 } PACKED iso14b_card_select_t;
31 typedef struct {
32 uint8_t uid[4];
33 uint8_t pc;
34 uint8_t fc;
35 } PACKED iso14b_cts_card_select_t;
37 typedef enum ISO14B_COMMAND {
38 ISO14B_CONNECT = (1 << 0),
39 ISO14B_DISCONNECT = (1 << 1),
40 ISO14B_APDU = (1 << 2),
41 ISO14B_RAW = (1 << 3),
42 ISO14B_REQUEST_TRIGGER = (1 << 4),
43 ISO14B_APPEND_CRC = (1 << 5),
44 ISO14B_SELECT_STD = (1 << 6),
45 ISO14B_SELECT_SR = (1 << 7),
46 ISO14B_SET_TIMEOUT = (1 << 8),
47 ISO14B_SEND_CHAINING = (1 << 9),
48 ISO14B_SELECT_CTS = (1 << 10),
49 ISO14B_CLEARTRACE = (1 << 11),
50 ISO14B_SELECT_XRX = (1 << 12),
51 ISO14B_SELECT_PICOPASS = (1 << 13),
52 } iso14b_command_t;
54 typedef enum ISO14B_TYPE {
55 ISO14B_NONE = 0,
56 ISO14B_STANDARD = 1,
57 ISO14B_SR = 2,
58 ISO14B_CT = 4,
59 } iso14b_type_t;
61 typedef struct {
62 uint16_t flags; // the ISO14B_COMMAND enum
63 uint32_t timeout;
64 uint16_t rawlen;
65 uint8_t raw[];
66 } PACKED iso14b_raw_cmd_t;
68 typedef struct {
69 uint8_t response_byte;
70 uint16_t datalen;
71 uint8_t data[];
72 } PACKED iso14b_raw_apdu_response_t;
74 #define US_TO_SSP(x) ( (int32_t) ((x) * 3.39) )
75 #define SSP_TO_US(x) ( (int32_t)((x) / 3.39) )
77 #define HF14_ETU_TO_SSP(x) ((x) << 5) // 1 ETU = 32 SSP
78 #define HF14_SSP_TO_ETU(x) ((x) >> 5) //
80 #define HF14_ETU_TO_US(x) ( (float)((x) * 9.4396) )
81 #define HF14_ETU_TO_US_2(x) ( (int32_t)( ((x) * 9439600) / 1000000) )
83 // #define US_TO_ETU(x) ( (int32_t)( ((x) * 1000000) / 9439600) )
85 #define US_TO_ETU(x) ( (float)((x) / 9.4396) )
87 #endif // _ISO14B_H_