[FL-2245] Introduce Mifare Classic Emulation (#1242)
* digital signal: introduce digital signal * nfca: add nfca signal encoder * nfc: add mifare classic emulation scene * nfca: add classic emulation support to lib and hal * mifare classic: support basic read commands * nfc: add mifare classic menu scene * mifare classic: start parsing commands in emulation * mifare classic: add nested auth * nfc: fix errors * mifare classic: add encrypt function * nfc: fix mifare classic save * lib hex: add hex uint64_t ASCII parser * flipper format: add uint64 hex format support * nfc: add mifare classic key map * nfc: hide mifare classic keys on emulation * mifare classic: add NACK responce * nfc: add partial bytes support in transparent mode * nfc: mifare classic add shadow file support * digital signal: move arr buffer from BSS to heap * mifare classic: process access bits more careful * nfca: fix memory leack * nfc: format sources * mifare classic: cleun up Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -185,6 +185,37 @@ bool flipper_format_write_string_cstr(
|
||||
return result;
|
||||
}
|
||||
|
||||
bool flipper_format_read_hex_uint64(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
uint64_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
return flipper_format_stream_read_value_line(
|
||||
flipper_format->stream,
|
||||
key,
|
||||
FlipperStreamValueHexUint64,
|
||||
data,
|
||||
data_size,
|
||||
flipper_format->strict_mode);
|
||||
}
|
||||
|
||||
bool flipper_format_write_hex_uint64(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
const uint64_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueHexUint64,
|
||||
.data = data,
|
||||
.data_size = data_size,
|
||||
};
|
||||
bool result = flipper_format_stream_write_value_line(flipper_format->stream, &write_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool flipper_format_read_uint32(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
|
@@ -273,6 +273,34 @@ bool flipper_format_write_string_cstr(
|
||||
const char* key,
|
||||
const char* data);
|
||||
|
||||
/**
|
||||
* Read array of uint64 in hex format by key
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @param key Key
|
||||
* @param data Value
|
||||
* @param data_size Values count
|
||||
* @return True on success
|
||||
*/
|
||||
bool flipper_format_read_hex_uint64(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
uint64_t* data,
|
||||
const uint16_t data_size);
|
||||
|
||||
/**
|
||||
* Write key and array of uint64 in hex format
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @param key Key
|
||||
* @param data Value
|
||||
* @param data_size Values count
|
||||
* @return True on success
|
||||
*/
|
||||
bool flipper_format_write_hex_uint64(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
const uint64_t* data,
|
||||
const uint16_t data_size);
|
||||
|
||||
/**
|
||||
* Read array of uint32 by key
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
|
@@ -287,6 +287,11 @@ bool flipper_format_stream_write_value_line(Stream* stream, FlipperStreamWriteDa
|
||||
const uint32_t* data = write_data->data;
|
||||
string_printf(value, "%" PRId32, data[i]);
|
||||
}; break;
|
||||
case FlipperStreamValueHexUint64: {
|
||||
const uint64_t* data = write_data->data;
|
||||
string_printf(
|
||||
value, "%08lX%08lX", (uint32_t)(data[i] >> 32), (uint32_t)data[i]);
|
||||
}; break;
|
||||
case FlipperStreamValueBool: {
|
||||
const bool* data = write_data->data;
|
||||
string_printf(value, data[i] ? "true" : "false");
|
||||
@@ -380,6 +385,14 @@ bool flipper_format_stream_read_value_line(
|
||||
uint32_t* data = _data;
|
||||
scan_values = sscanf(string_get_cstr(value), "%" PRId32, &data[i]);
|
||||
}; break;
|
||||
case FlipperStreamValueHexUint64: {
|
||||
uint64_t* data = _data;
|
||||
if(string_size(value) >= 16) {
|
||||
if(hex_chars_to_uint64(string_get_cstr(value), &data[i])) {
|
||||
scan_values = 1;
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
case FlipperStreamValueBool: {
|
||||
bool* data = _data;
|
||||
data[i] = !string_cmpi_str(value, "true");
|
||||
|
@@ -15,6 +15,7 @@ typedef enum {
|
||||
FlipperStreamValueFloat,
|
||||
FlipperStreamValueInt32,
|
||||
FlipperStreamValueUint32,
|
||||
FlipperStreamValueHexUint64,
|
||||
FlipperStreamValueBool,
|
||||
} FlipperStreamValue;
|
||||
|
||||
|
Reference in New Issue
Block a user