@@ -27,65 +27,51 @@ MfPlusError mf_plus_get_type_from_version(
27
27
28
28
MfPlusError error = MfPlusErrorProtocol ;
29
29
30
- if (mf_plus_data -> version .hw_major == 0x02 || mf_plus_data -> version .hw_major == 0x82 ) {
30
+ if (mf_plus_data -> version .hw_type == 0x02 || mf_plus_data -> version .hw_type == 0x82 ) {
31
31
error = MfPlusErrorNone ;
32
- if (iso14443_4a_data -> iso14443_3a_data -> sak == 0x10 ) {
33
- // Mifare Plus 2K SL2
34
- mf_plus_data -> type = MfPlusTypePlus ;
32
+ // Mifare Plus EV1/EV2
33
+
34
+ // Revision
35
+ switch (mf_plus_data -> version .hw_major ) {
36
+ case 0x11 :
37
+ mf_plus_data -> type = MfPlusTypeEV1 ;
38
+ FURI_LOG_D (TAG , "Mifare Plus EV1" );
39
+ break ;
40
+ case 0x22 :
41
+ mf_plus_data -> type = MfPlusTypeEV2 ;
42
+ FURI_LOG_D (TAG , "Mifare Plus EV2" );
43
+ break ;
44
+ default :
45
+ mf_plus_data -> type = MfPlusTypeUnknown ;
46
+ FURI_LOG_D (TAG , "Unknown Mifare Plus EV type" );
47
+ break ;
48
+ }
49
+
50
+ // Storage size
51
+ switch (mf_plus_data -> version .hw_storage ) {
52
+ case 0x16 :
35
53
mf_plus_data -> size = MfPlusSize2K ;
36
- mf_plus_data -> security_level = MfPlusSecurityLevel2 ;
37
- FURI_LOG_D (TAG , "Mifare Plus 2K SL2" );
38
- } else if (iso14443_4a_data -> iso14443_3a_data -> sak == 0x11 ) {
39
- // Mifare Plus 4K SL3
40
- mf_plus_data -> type = MfPlusTypePlus ;
54
+ FURI_LOG_D (TAG , "2K" );
55
+ break ;
56
+ case 0x18 :
41
57
mf_plus_data -> size = MfPlusSize4K ;
58
+ FURI_LOG_D (TAG , "4K" );
59
+ break ;
60
+ default :
61
+ mf_plus_data -> size = MfPlusSizeUnknown ;
62
+ FURI_LOG_D (TAG , "Unknown storage size" );
63
+ break ;
64
+ }
65
+
66
+ // Security level
67
+ if (iso14443_4a_data -> iso14443_3a_data -> sak == 0x20 ) {
68
+ // Mifare Plus EV1/2 SL3
42
69
mf_plus_data -> security_level = MfPlusSecurityLevel3 ;
43
- FURI_LOG_D (TAG , "Mifare Plus 4K SL3" );
70
+ FURI_LOG_D (TAG , "Mifare Plus EV1/2 SL3" );
44
71
} else {
45
- // Mifare Plus EV1/EV2
46
-
47
- // Revision
48
- switch (mf_plus_data -> version .hw_major ) {
49
- case 0x11 :
50
- mf_plus_data -> type = MfPlusTypeEV1 ;
51
- FURI_LOG_D (TAG , "Mifare Plus EV1" );
52
- break ;
53
- case 0x22 :
54
- mf_plus_data -> type = MfPlusTypeEV2 ;
55
- FURI_LOG_D (TAG , "Mifare Plus EV2" );
56
- break ;
57
- default :
58
- mf_plus_data -> type = MfPlusTypeUnknown ;
59
- FURI_LOG_D (TAG , "Unknown Mifare Plus EV type" );
60
- break ;
61
- }
62
-
63
- // Storage size
64
- switch (mf_plus_data -> version .hw_storage ) {
65
- case 0x16 :
66
- mf_plus_data -> size = MfPlusSize2K ;
67
- FURI_LOG_D (TAG , "2K" );
68
- break ;
69
- case 0x18 :
70
- mf_plus_data -> size = MfPlusSize4K ;
71
- FURI_LOG_D (TAG , "4K" );
72
- break ;
73
- default :
74
- mf_plus_data -> size = MfPlusSizeUnknown ;
75
- FURI_LOG_D (TAG , "Unknown storage size" );
76
- break ;
77
- }
78
-
79
- // Security level
80
- if (iso14443_4a_data -> iso14443_3a_data -> sak == 0x20 ) {
81
- // Mifare Plus EV1/2 SL3
82
- mf_plus_data -> security_level = MfPlusSecurityLevel3 ;
83
- FURI_LOG_D (TAG , "Miare Plus EV1/2 SL3" );
84
- } else {
85
- // Mifare Plus EV1/2 SL1
86
- mf_plus_data -> security_level = MfPlusSecurityLevel1 ;
87
- FURI_LOG_D (TAG , "Miare Plus EV1/2 SL1" );
88
- }
72
+ // Mifare Plus EV1/2 SL1
73
+ mf_plus_data -> security_level = MfPlusSecurityLevel1 ;
74
+ FURI_LOG_D (TAG , "Mifare Plus EV1/2 SL1" );
89
75
}
90
76
}
91
77
@@ -148,6 +134,24 @@ MfPlusError
148
134
FURI_LOG_D (TAG , "Sak 08 but no known Mifare Plus type" );
149
135
}
150
136
137
+ break ;
138
+ case 0x10 :
139
+ // Mifare Plus X 2K SL2
140
+ mf_plus_data -> type = MfPlusTypeX ;
141
+ mf_plus_data -> size = MfPlusSize2K ;
142
+ mf_plus_data -> security_level = MfPlusSecurityLevel2 ;
143
+ FURI_LOG_D (TAG , "Mifare Plus X 2K SL2" );
144
+ error = MfPlusErrorNone ;
145
+
146
+ break ;
147
+ case 0x11 :
148
+ // Mifare Plus X 4K SL2
149
+ mf_plus_data -> type = MfPlusTypeX ;
150
+ mf_plus_data -> size = MfPlusSize4K ;
151
+ mf_plus_data -> security_level = MfPlusSecurityLevel2 ;
152
+ FURI_LOG_D (TAG , "Mifare Plus X 4K SL2" );
153
+ error = MfPlusErrorNone ;
154
+
151
155
break ;
152
156
case 0x18 :
153
157
if (memcmp (
@@ -234,10 +238,22 @@ MfPlusError
234
238
}
235
239
236
240
MfPlusError mf_plus_version_parse (MfPlusVersion * data , const BitBuffer * buf ) {
237
- const bool can_parse = bit_buffer_get_size_bytes (buf ) == sizeof (MfPlusVersion );
241
+ bool can_parse = bit_buffer_get_size_bytes (buf ) == sizeof (MfPlusVersion );
238
242
239
243
if (can_parse ) {
240
244
bit_buffer_write_bytes (buf , data , sizeof (MfPlusVersion ));
245
+ } else if (
246
+ bit_buffer_get_size_bytes (buf ) == 8 &&
247
+ bit_buffer_get_byte (buf , 0 ) == MF_PLUS_STATUS_ADDITIONAL_FRAME ) {
248
+ // HACK(-nofl): There are supposed to be three parts to the GetVersion command,
249
+ // with the second and third parts fetched by sending the AdditionalFrame
250
+ // command. I don't know whether the entire MIFARE Plus line uses status as
251
+ // the first byte, so let's just assume we only have the first part of
252
+ // the response if it's size 8 and starts with the AF status. The second
253
+ // part of the response is the same size and status byte, but so far
254
+ // we're only reading one response.
255
+ can_parse = true;
256
+ bit_buffer_write_bytes_mid (buf , data , 1 , bit_buffer_get_size_bytes (buf ) - 1 );
241
257
}
242
258
243
259
return can_parse ? MfPlusErrorNone : MfPlusErrorProtocol ;
0 commit comments