fix const params, logic, casting
[RRG-proxmark3.git] / include / iso18.h
blob377f864d038759d6c809716b760e48d0826786b9
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 18002 / FeliCa type prototyping
17 //-----------------------------------------------------------------------------
18 #ifndef _ISO18_H_
19 #define _ISO18_H_
21 #include "common.h"
23 typedef enum FELICA_COMMAND {
24 FELICA_CONNECT = (1 << 0),
25 FELICA_NO_DISCONNECT = (1 << 1),
26 FELICA_RAW = (1 << 3),
27 FELICA_APPEND_CRC = (1 << 5),
28 FELICA_NO_SELECT = (1 << 6),
29 } felica_command_t;
31 //-----------------------------------------------------------------------------
32 // FeliCa
33 //-----------------------------------------------------------------------------
34 // IDm = ID manufacturer
35 // mc = manufactureCode
36 // mc1 mc2 u1 u2 u3 u4 u5 u6
37 // PMm = Product manufacturer
38 // icCode =
39 // ic1 = ROM
40 // ic2 = IC
41 // maximum response time =
42 // B3(request service)
43 // B4(request response)
44 // B5(authenticate)
45 // B6(read)
46 // B7(write)
47 // B8()
49 // ServiceCode 2bytes (access-rights)
50 // FileSystem = 1 Block = 16 bytes
53 typedef struct {
54 uint8_t IDm[8];
55 uint8_t code[2];
56 uint8_t uid[6];
57 uint8_t PMm[8];
58 uint8_t iccode[2];
59 uint8_t mrt[6];
60 uint8_t servicecode[2];
61 } PACKED felica_card_select_t;
63 typedef struct {
64 uint8_t sync[2];
65 uint8_t length[1];
66 uint8_t cmd_code[1];
67 uint8_t IDm[8];
68 } PACKED felica_frame_response_t;
70 typedef struct {
71 uint8_t status_flag1[1];
72 uint8_t status_flag2[1];
73 } PACKED felica_status_flags_t;
75 typedef struct {
76 felica_frame_response_t frame_response;
77 uint8_t node_number[1];
78 uint8_t node_key_versions[2];
79 } PACKED felica_request_service_response_t;
81 typedef struct {
82 felica_frame_response_t frame_response;
83 uint8_t mode[1];
84 } PACKED felica_request_request_response_t;
86 typedef struct {
87 felica_frame_response_t frame_response;
88 felica_status_flags_t status_flags;
89 uint8_t number_of_block[1];
90 uint8_t block_data[16];
91 uint8_t block_element_number[1];
92 } PACKED felica_read_without_encryption_response_t;
94 typedef struct {
95 felica_frame_response_t frame_response;
96 felica_status_flags_t status_flags;
97 } PACKED felica_status_response_t;
99 typedef struct {
100 felica_frame_response_t frame_response;
101 uint8_t number_of_systems[1];
102 uint8_t system_code_list[32];
103 } PACKED felica_syscode_response_t;
105 typedef struct {
106 felica_frame_response_t frame_response;
107 felica_status_flags_t status_flags;
108 uint8_t format_version[1];
109 uint8_t basic_version[2];
110 uint8_t number_of_option[1];
111 uint8_t option_version_list[4];
112 } PACKED felica_request_spec_response_t;
114 typedef struct {
115 felica_frame_response_t frame_response;
116 uint8_t m2c[8];
117 uint8_t m3c[8];
118 } PACKED felica_auth1_response_t;
120 typedef struct {
121 uint8_t code[1];
122 uint8_t IDtc[8];
123 uint8_t IDi[8];
124 uint8_t PMi[8];
125 } PACKED felica_auth2_response_t;
127 #endif // _ISO18_H_