mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 22:32:29 +03:00
Merge branch 'dev'
This commit is contained in:
commit
81e4e94adf
@ -25,10 +25,13 @@ void lfrfid_on_system_start() {
|
||||
|
||||
static void lfrfid_cli_print_usage() {
|
||||
printf("Usage:\r\n");
|
||||
printf("rfid read <optional: normal | indala>\r\n");
|
||||
printf("rfid <write | emulate> <key_type> <key_data>\r\n");
|
||||
printf("rfid raw_read <ask | psk> <filename>\r\n");
|
||||
printf("rfid raw_emulate <filename>\r\n");
|
||||
printf("rfid read <optional: normal | indala> - read in ASK/PSK mode\r\n");
|
||||
printf("rfid <write | emulate> <key_type> <key_data> - write or emulate a card\r\n");
|
||||
printf("rfid raw_read <ask | psk> <filename> - read and save raw data to a file\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 {
|
||||
|
@ -252,7 +252,12 @@ const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uin
|
||||
furi_assert(count);
|
||||
|
||||
*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) {
|
||||
|
@ -179,44 +179,53 @@ bool mf_desfire_file_settings_parse(MfDesfireFileSettings* data, const BitBuffer
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
const size_t min_data_size =
|
||||
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsData);
|
||||
const size_t max_data_size =
|
||||
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsValue);
|
||||
|
||||
if(data_size < min_data_size) break;
|
||||
if(data_size <= max_data_size) {
|
||||
MfDesfireFileSettingsLayout layout;
|
||||
bit_buffer_write_bytes(buf, &layout, sizeof(MfDesfireFileSettingsLayout));
|
||||
|
||||
MfDesfireFileSettingsLayout layout;
|
||||
bit_buffer_write_bytes(buf, &layout, sizeof(MfDesfireFileSettingsLayout));
|
||||
data->type = layout.header.type;
|
||||
data->comm = layout.header.comm;
|
||||
data->access_rights = layout.header.access_rights;
|
||||
|
||||
data->type = layout.header.type;
|
||||
data->comm = layout.header.comm;
|
||||
data->access_rights = layout.header.access_rights;
|
||||
if(data->type == MfDesfireFileTypeStandard || data->type == MfDesfireFileTypeBackup) {
|
||||
if(data_size != min_data_size) break;
|
||||
|
||||
if(data->type == MfDesfireFileTypeStandard || data->type == MfDesfireFileTypeBackup) {
|
||||
if(data_size != min_data_size) break;
|
||||
data->data.size = layout.data.size;
|
||||
} else if(data->type == MfDesfireFileTypeValue) {
|
||||
if(data_size !=
|
||||
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsValue))
|
||||
break;
|
||||
|
||||
data->data.size = layout.data.size;
|
||||
data->value.lo_limit = layout.value.lo_limit;
|
||||
data->value.hi_limit = layout.value.hi_limit;
|
||||
data->value.limited_credit_value = layout.value.limited_credit_value;
|
||||
data->value.limited_credit_enabled = layout.value.limited_credit_enabled;
|
||||
|
||||
} else if(data->type == MfDesfireFileTypeValue) {
|
||||
if(data_size !=
|
||||
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsValue))
|
||||
} else if(
|
||||
data->type == MfDesfireFileTypeLinearRecord ||
|
||||
data->type == MfDesfireFileTypeCyclicRecord) {
|
||||
if(data_size !=
|
||||
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsRecord))
|
||||
break;
|
||||
|
||||
data->record.size = layout.record.size;
|
||||
data->record.max = layout.record.max;
|
||||
data->record.cur = layout.record.cur;
|
||||
|
||||
} else {
|
||||
break;
|
||||
|
||||
data->value.lo_limit = layout.value.lo_limit;
|
||||
data->value.hi_limit = layout.value.hi_limit;
|
||||
data->value.limited_credit_value = layout.value.limited_credit_value;
|
||||
data->value.limited_credit_enabled = layout.value.limited_credit_enabled;
|
||||
|
||||
} else if(
|
||||
data->type == MfDesfireFileTypeLinearRecord ||
|
||||
data->type == MfDesfireFileTypeCyclicRecord) {
|
||||
if(data_size !=
|
||||
sizeof(MfDesfireFileSettingsHeader) + sizeof(MfDesfireFileSettingsRecord))
|
||||
break;
|
||||
|
||||
data->record.size = layout.record.size;
|
||||
data->record.max = layout.record.max;
|
||||
data->record.cur = layout.record.cur;
|
||||
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
// 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;
|
||||
@ -478,19 +487,25 @@ bool mf_desfire_application_load(MfDesfireApplication* data, const char* prefix,
|
||||
do {
|
||||
if(!mf_desfire_key_settings_load(&data->key_settings, prefix, ff)) break;
|
||||
|
||||
const uint32_t key_version_count = data->key_settings.max_keys;
|
||||
simple_array_init(data->key_versions, key_version_count);
|
||||
|
||||
uint32_t 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))
|
||||
break;
|
||||
const uint32_t key_version_count = data->key_settings.max_keys;
|
||||
if(key_version_count) {
|
||||
simple_array_init(data->key_versions, key_version_count);
|
||||
|
||||
for(i = 0; i < key_version_count; ++i) {
|
||||
if(!mf_desfire_key_version_load(
|
||||
simple_array_get(data->key_versions, i), prefix, i, ff))
|
||||
break;
|
||||
}
|
||||
|
||||
if(i != key_version_count) break;
|
||||
}
|
||||
|
||||
if(i != key_version_count) break;
|
||||
|
||||
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);
|
||||
if(!mf_desfire_file_ids_load(simple_array_get_data(data->file_ids), file_count, prefix, ff))
|
||||
|
Loading…
Reference in New Issue
Block a user