@@ -18,39 +18,18 @@ void picopass_scene_read_card_success_widget_callback(
18
18
19
19
void picopass_scene_read_card_success_on_enter (void * context ) {
20
20
Picopass * picopass = context ;
21
+ PicopassDeviceAuthMethod auth = picopass -> dev -> dev_data .auth ;
21
22
22
23
FuriString * csn_str = furi_string_alloc_set ("CSN:" );
23
24
FuriString * credential_str = furi_string_alloc ();
24
- FuriString * wiegand_str = furi_string_alloc ();
25
+ FuriString * info_str = furi_string_alloc ();
25
26
FuriString * key_str = furi_string_alloc ();
26
27
27
28
dolphin_deed (DolphinDeedNfcReadSuccess );
28
29
29
30
// Send notification
30
31
notification_message (picopass -> notifications , & sequence_success );
31
32
32
- // For initial testing, print auth method
33
- switch (picopass -> dev -> dev_data .auth ) {
34
- case PicopassDeviceAuthMethodUnset :
35
- FURI_LOG_D (TAG , "Auth: Unset" );
36
- break ;
37
- case PicopassDeviceAuthMethodNone :
38
- FURI_LOG_D (TAG , "Auth: None" );
39
- break ;
40
- case PicopassDeviceAuthMethodKey :
41
- FURI_LOG_D (TAG , "Auth: Key" );
42
- break ;
43
- case PicopassDeviceAuthMethodNrMac :
44
- FURI_LOG_D (TAG , "Auth: NR-MAC" );
45
- break ;
46
- case PicopassDeviceAuthMethodFailed :
47
- FURI_LOG_D (TAG , "Auth: Failed" );
48
- break ;
49
- default :
50
- FURI_LOG_D (TAG , "Auth: Unknown" );
51
- break ;
52
- };
53
-
54
33
// Setup view
55
34
PicopassBlock * card_data = picopass -> dev -> dev_data .card_data ;
56
35
PicopassPacs * pacs = & picopass -> dev -> dev_data .pacs ;
@@ -62,19 +41,16 @@ void picopass_scene_read_card_success_on_enter(void* context) {
62
41
furi_string_cat_printf (csn_str , "%02X" , csn [i ]);
63
42
}
64
43
65
- // We can't test the pacs->key in case it is intentionally all 0's and we can't test the key block since it is populated with the diversified key before each key test, so we approximate with the PACS config block being blank.
66
- bool zero_config = picopass_is_memset (
67
- card_data [PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX ].data , 0x00 , PICOPASS_BLOCK_LEN );
68
44
bool empty = picopass_is_memset (
69
45
card_data [PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX ].data , 0xFF , PICOPASS_BLOCK_LEN );
70
- bool SE = 0x30 == card_data [ PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX ]. data [ 0 ] ;
46
+ bool SE = pacs -> se_enabled ;
71
47
bool configCard = (card_data [PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX ].data [7 ] >> 2 & 3 ) == 2 ;
72
48
bool secured = (card_data [PICOPASS_CONFIG_BLOCK_INDEX ].data [7 ] & PICOPASS_FUSE_CRYPT10 ) !=
73
49
PICOPASS_FUSE_CRYPT0 ;
74
50
bool hid_csn = picopass_device_hid_csn (picopass -> dev );
75
51
76
52
if (!secured ) {
77
- furi_string_cat_printf (wiegand_str , "Non-Secured Chip" );
53
+ furi_string_cat_printf (info_str , "Non-Secured Chip" );
78
54
79
55
if (!hid_csn ) {
80
56
furi_string_cat_printf (credential_str , "Non-HID CSN" );
@@ -86,8 +62,8 @@ void picopass_scene_read_card_success_on_enter(void* context) {
86
62
"More" ,
87
63
picopass_scene_read_card_success_widget_callback ,
88
64
picopass );
89
- } else if (zero_config ) {
90
- furi_string_cat_printf (wiegand_str , "Read Failed" );
65
+ } else if (auth == PicopassDeviceAuthMethodFailed ) {
66
+ furi_string_cat_printf (info_str , "Read Failed" );
91
67
92
68
if (pacs -> se_enabled ) {
93
69
furi_string_cat_printf (credential_str , "SE enabled" );
@@ -109,17 +85,19 @@ void picopass_scene_read_card_success_on_enter(void* context) {
109
85
picopass );
110
86
} else if (pacs -> se_enabled ) {
111
87
furi_string_cat_printf (credential_str , "SE enabled" );
112
- furi_string_cat_printf (wiegand_str , "SIO" );
88
+ furi_string_cat_printf (info_str , "SIO" );
89
+
113
90
widget_add_button_element (
114
91
widget ,
115
92
GuiButtonTypeRight ,
116
93
"More" ,
117
94
picopass_scene_read_card_success_widget_callback ,
118
95
picopass );
119
96
} else if (configCard ) {
120
- furi_string_cat_printf (wiegand_str , "Config Card" );
97
+ furi_string_cat_printf (credential_str , "Config Card" );
121
98
} else if (empty ) {
122
- furi_string_cat_printf (wiegand_str , "Empty" );
99
+ furi_string_cat_printf (credential_str , "Empty" );
100
+
123
101
widget_add_button_element (
124
102
widget ,
125
103
GuiButtonTypeCenter ,
@@ -129,10 +107,11 @@ void picopass_scene_read_card_success_on_enter(void* context) {
129
107
} else if (pacs -> bitLength == 0 || pacs -> bitLength == 255 ) {
130
108
// Neither of these are valid. Indicates the block was all 0x00 or all 0xff
131
109
if (SE ) {
132
- furi_string_cat_printf (wiegand_str , "SIO" );
110
+ furi_string_cat_printf (info_str , "SIO" );
133
111
} else {
134
- furi_string_cat_printf (wiegand_str , "Invalid PACS" );
112
+ furi_string_cat_printf (info_str , "Invalid PACS" );
135
113
}
114
+
136
115
widget_add_button_element (
137
116
widget ,
138
117
GuiButtonTypeCenter ,
@@ -148,40 +127,13 @@ void picopass_scene_read_card_success_on_enter(void* context) {
148
127
} else {
149
128
size_t bytesLength = 1 + pacs -> bitLength / 8 ;
150
129
furi_string_set (credential_str , "" );
130
+ furi_string_cat_printf (credential_str , "(%d) " , pacs -> bitLength );
151
131
for (uint8_t i = PICOPASS_BLOCK_LEN - bytesLength ; i < PICOPASS_BLOCK_LEN ; i ++ ) {
152
132
furi_string_cat_printf (credential_str , "%02X" , pacs -> credential [i ]);
153
133
}
154
- furi_string_cat_printf (wiegand_str , "%d bits" , pacs -> bitLength );
155
134
156
135
if (pacs -> sio ) {
157
- furi_string_cat_printf (credential_str , " +SIO" );
158
- }
159
-
160
- bool no_key = !card_data [PICOPASS_SECURE_KD_BLOCK_INDEX ].valid ;
161
-
162
- if (no_key ) {
163
- furi_string_cat_printf (key_str , "No Key: used NR-MAC" );
164
- } else {
165
- furi_string_cat_printf (key_str , "Key: " );
166
- uint8_t key [PICOPASS_BLOCK_LEN ];
167
- memcpy (key , & pacs -> key , PICOPASS_BLOCK_LEN );
168
-
169
- bool standard_key = true;
170
- // Handle DES key being 56bits with parity in LSB
171
- for (uint8_t i = 0 ; i < PICOPASS_BLOCK_LEN ; i ++ ) {
172
- if ((key [i ] & 0xFE ) != (picopass_iclass_key [i ] & 0xFE )) {
173
- standard_key = false;
174
- break ;
175
- }
176
- }
177
-
178
- if (standard_key ) {
179
- furi_string_cat_printf (key_str , "Standard" );
180
- } else {
181
- for (uint8_t i = 0 ; i < PICOPASS_BLOCK_LEN ; i ++ ) {
182
- furi_string_cat_printf (key_str , "%02X" , key [i ]);
183
- }
184
- }
136
+ furi_string_cat_printf (info_str , " +SIO" );
185
137
}
186
138
187
139
widget_add_button_element (
@@ -192,6 +144,37 @@ void picopass_scene_read_card_success_on_enter(void* context) {
192
144
picopass );
193
145
}
194
146
147
+ if (auth == PicopassDeviceAuthMethodUnset ) {
148
+ furi_string_cat_printf (key_str , "Error: Auth Unset" );
149
+ } else if (auth == PicopassDeviceAuthMethodNone ) {
150
+ furi_string_cat_printf (key_str , "Unsecure card" );
151
+ } else if (auth == PicopassDeviceAuthMethodNrMac ) {
152
+ furi_string_cat_printf (key_str , "No Key: used NR-MAC" );
153
+ } else if (auth == PicopassDeviceAuthMethodFailed ) {
154
+ furi_string_cat_printf (key_str , "Auth Failed" );
155
+ } else if (auth == PicopassDeviceAuthMethodKey ) {
156
+ furi_string_cat_printf (key_str , "Key: " );
157
+ uint8_t key [PICOPASS_BLOCK_LEN ];
158
+ memcpy (key , & pacs -> key , PICOPASS_BLOCK_LEN );
159
+
160
+ bool standard_key = true;
161
+ // Handle DES key being 56bits with parity in LSB
162
+ for (uint8_t i = 0 ; i < PICOPASS_BLOCK_LEN ; i ++ ) {
163
+ if ((key [i ] & 0xFE ) != (picopass_iclass_key [i ] & 0xFE )) {
164
+ standard_key = false;
165
+ break ;
166
+ }
167
+ }
168
+
169
+ if (standard_key ) {
170
+ furi_string_cat_printf (key_str , "Standard" );
171
+ } else {
172
+ for (uint8_t i = 0 ; i < PICOPASS_BLOCK_LEN ; i ++ ) {
173
+ furi_string_cat_printf (key_str , "%02X" , key [i ]);
174
+ }
175
+ }
176
+ }
177
+
195
178
widget_add_button_element (
196
179
widget ,
197
180
GuiButtonTypeLeft ,
@@ -201,22 +184,22 @@ void picopass_scene_read_card_success_on_enter(void* context) {
201
184
202
185
widget_add_string_element (
203
186
widget , 64 , 5 , AlignCenter , AlignCenter , FontSecondary , furi_string_get_cstr (csn_str ));
204
- widget_add_string_element (
205
- widget , 64 , 20 , AlignCenter , AlignCenter , FontPrimary , furi_string_get_cstr (wiegand_str ));
206
187
widget_add_string_element (
207
188
widget ,
208
189
64 ,
209
- 36 ,
190
+ 20 ,
210
191
AlignCenter ,
211
192
AlignCenter ,
212
- FontSecondary ,
193
+ FontPrimary ,
213
194
furi_string_get_cstr (credential_str ));
195
+ widget_add_string_element (
196
+ widget , 64 , 36 , AlignCenter , AlignCenter , FontSecondary , furi_string_get_cstr (info_str ));
214
197
widget_add_string_element (
215
198
widget , 64 , 46 , AlignCenter , AlignCenter , FontSecondary , furi_string_get_cstr (key_str ));
216
199
217
200
furi_string_free (csn_str );
218
201
furi_string_free (credential_str );
219
- furi_string_free (wiegand_str );
202
+ furi_string_free (info_str );
220
203
furi_string_free (key_str );
221
204
222
205
view_dispatcher_switch_to_view (picopass -> view_dispatcher , PicopassViewWidget );
0 commit comments