Merge branch 'dev'

This commit is contained in:
RebornedBrain 2024-01-18 12:25:20 +03:00
commit 81e4e94adf
3 changed files with 66 additions and 43 deletions

View File

@ -25,10 +25,13 @@ void lfrfid_on_system_start() {
static void lfrfid_cli_print_usage() { static void lfrfid_cli_print_usage() {
printf("Usage:\r\n"); printf("Usage:\r\n");
printf("rfid read <optional: normal | indala>\r\n"); printf("rfid read <optional: normal | indala> - read in ASK/PSK mode\r\n");
printf("rfid <write | emulate> <key_type> <key_data>\r\n"); printf("rfid <write | emulate> <key_type> <key_data> - write or emulate a card\r\n");
printf("rfid raw_read <ask | psk> <filename>\r\n"); printf("rfid raw_read <ask | psk> <filename> - read and save raw data to a file\r\n");
printf("rfid raw_emulate <filename>\r\n"); printf(
"rfid raw_emulate <filename> - emulate raw data (not very useful, but helps debug protocols)\r\n");
printf(
"rfid raw_analyze <filename> - outputs raw data to the cli and tries to decode it (useful for protocol development)\r\n");
}; };
typedef struct { typedef struct {

View File

@ -252,7 +252,12 @@ const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uin
furi_assert(count); furi_assert(count);
*count = simple_array_get_count(data->ats_data.t1_tk); *count = simple_array_get_count(data->ats_data.t1_tk);
return simple_array_cget_data(data->ats_data.t1_tk); const uint8_t* hist_bytes = NULL;
if(*count > 0) {
hist_bytes = simple_array_cget_data(data->ats_data.t1_tk);
}
return hist_bytes;
} }
bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRate bit_rate) { bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRate bit_rate) {

View File

@ -179,9 +179,11 @@ bool mf_desfire_file_settings_parse(MfDesfireFileSettings* data, const BitBuffer
const size_t data_size = bit_buffer_get_size_bytes(buf); const size_t data_size = bit_buffer_get_size_bytes(buf);
const size_t min_data_size = const size_t min_data_size =
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsData); sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsData);
const size_t max_data_size =
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsValue);
if(data_size < min_data_size) break; if(data_size < min_data_size) break;
if(data_size <= max_data_size) {
MfDesfireFileSettingsLayout layout; MfDesfireFileSettingsLayout layout;
bit_buffer_write_bytes(buf, &layout, sizeof(MfDesfireFileSettingsLayout)); bit_buffer_write_bytes(buf, &layout, sizeof(MfDesfireFileSettingsLayout));
@ -193,7 +195,6 @@ bool mf_desfire_file_settings_parse(MfDesfireFileSettings* data, const BitBuffer
if(data_size != min_data_size) break; if(data_size != min_data_size) break;
data->data.size = layout.data.size; data->data.size = layout.data.size;
} else if(data->type == MfDesfireFileTypeValue) { } else if(data->type == MfDesfireFileTypeValue) {
if(data_size != if(data_size !=
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsValue)) sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsValue))
@ -218,6 +219,14 @@ bool mf_desfire_file_settings_parse(MfDesfireFileSettings* data, const BitBuffer
} else { } else {
break; break;
} }
} else {
// TODO FL-3750: process HID Desfire command response here
// Set default fields for now
data->type = 0;
data->comm = 0;
data->access_rights = 0;
data->data.size = 0;
}
parsed = true; parsed = true;
} while(false); } while(false);
@ -478,19 +487,25 @@ bool mf_desfire_application_load(MfDesfireApplication* data, const char* prefix,
do { do {
if(!mf_desfire_key_settings_load(&data->key_settings, prefix, ff)) break; if(!mf_desfire_key_settings_load(&data->key_settings, prefix, ff)) break;
uint32_t i;
const uint32_t key_version_count = data->key_settings.max_keys; const uint32_t key_version_count = data->key_settings.max_keys;
if(key_version_count) {
simple_array_init(data->key_versions, key_version_count); simple_array_init(data->key_versions, key_version_count);
uint32_t i;
for(i = 0; i < key_version_count; ++i) { for(i = 0; i < key_version_count; ++i) {
if(!mf_desfire_key_version_load(simple_array_get(data->key_versions, i), prefix, i, ff)) if(!mf_desfire_key_version_load(
simple_array_get(data->key_versions, i), prefix, i, ff))
break; break;
} }
if(i != key_version_count) break; if(i != key_version_count) break;
}
uint32_t file_count; uint32_t file_count;
if(!mf_desfire_file_count_load(&file_count, prefix, ff)) break; if(!mf_desfire_file_count_load(&file_count, prefix, ff)) {
success = true;
break;
}
simple_array_init(data->file_ids, file_count); simple_array_init(data->file_ids, file_count);
if(!mf_desfire_file_ids_load(simple_array_get_data(data->file_ids), file_count, prefix, ff)) if(!mf_desfire_file_ids_load(simple_array_get_data(data->file_ids), file_count, prefix, ff))