Skip to content

Commit

Permalink
Squashed 'applications/external/' changes from ea5d532d8c..746531bdf1
Browse files Browse the repository at this point in the history
746531bdf1 VgmTool: Add RGB fw for MNTM VGM options
3da3a125fe Merge picopass from https://github.com/flipperdevices/flipperzero-good-faps
200f9dc382 Merge nfc_magic from https://github.com/flipperdevices/flipperzero-good-faps
573634ece1 Merge air_arkanoid from https://github.com/flipperdevices/flipperzero-good-faps
cc9223968d AirArkanoid: Fix python3 on Windows (#155)
a70b5c5840 Picopass block tracking (#125)
15c7c2d66e NFC Magic: update with latest API (#167)
3219fe82fa Picopass: update with latest API (#165)

git-subtree-dir: applications/external
git-subtree-split: 746531bdf1646328448533f1d3c9612ec6c061a1
  • Loading branch information
RogueMaster committed Mar 8, 2024
1 parent 61c1fa8 commit 11f41e2
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 77 deletions.
3 changes: 1 addition & 2 deletions air_arkanoid/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ App(
fap_extbuild=(
ExtFile(
path="${FAP_SRC_DIR}/assets",
command=("python" if __import__("sys").platform == "win32" else "python3")
+ " ${FAP_SRC_DIR}/engine/scripts/sprite_builder.py ${FAP_SRC_DIR.abspath}/sprites ${TARGET.abspath}/sprites",
command="${PYTHON3} ${FAP_SRC_DIR}/engine/scripts/sprite_builder.py ${FAP_SRC_DIR.abspath}/sprites ${TARGET.abspath}/sprites",
),
),
)
5 changes: 3 additions & 2 deletions nfc_magic/.catalog/changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## 1.4
## 1.6
- Rework with new bit lib API

## 1.5
- Fix incorrect max sector configuration

## 1.4

- Auth with password option moved into new submenu "Gen4 actions"
- New function: Get gen4 card revision
- New function: Get gen4 card config (shows only when debug ON)
Expand Down
4 changes: 2 additions & 2 deletions nfc_magic/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ App(
],
stack_size=4 * 1024,
fap_description="Application for writing to NFC tags with modifiable sector 0",
fap_version="1.5",
fap_icon="125_10px.png",
fap_version="1.6",
fap_icon="assets/125_10px.png",
fap_category="NFC",
fap_private_libs=[
Lib(
Expand Down
File renamed without changes
1 change: 0 additions & 1 deletion nfc_magic/lib/magic/protocols/gen4/gen4_poller_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "bit_buffer.h"
#include "protocols/gen4/gen4_poller.h"
#include <nfc/protocols/iso14443_3a/iso14443_3a_poller.h>
#include <bit_lib.h>

#define GEN4_CMD_PREFIX (0xCF)

Expand Down
1 change: 1 addition & 0 deletions nfc_magic/lib/magic/protocols/gen4/gen4_poller_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "gen4_poller.h"
#include <nfc/nfc_poller.h>
#include <nfc/protocols/iso14443_3a/iso14443_3a_poller.h>
#include <bit_lib/bit_lib.h>

#define TAG "Gen4Poller"

Expand Down
2 changes: 1 addition & 1 deletion nfc_magic/scenes/nfc_magic_scene_key_input.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../nfc_magic_app_i.h"

#include <bit_lib.h>
#include <bit_lib/bit_lib.h>

void nfc_magic_scene_key_input_byte_input_callback(void* context) {
NfcMagicApp* instance = context;
Expand Down
2 changes: 2 additions & 0 deletions picopass/.catalog/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.13
- Rework loclass writer with datetime lib
## 1.12
- Add support for non-secure Picopass
- Change Read to use all dictionaries
Expand Down
2 changes: 1 addition & 1 deletion picopass/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ App(
],
stack_size=4 * 1024,
fap_description="App to communicate with NFC tags using the PicoPass(iClass) format",
fap_version="1.12",
fap_version="1.13",
fap_icon="125_10px.png",
fap_category="NFC",
fap_libs=["mbedtls"],
Expand Down
9 changes: 7 additions & 2 deletions picopass/loclass_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <storage/storage.h>
#include <stream/stream.h>
#include <stream/buffered_file_stream.h>
#include <datetime/datetime.h>

struct LoclassWriter {
Stream* file_stream;
Expand Down Expand Up @@ -41,7 +42,9 @@ void loclass_writer_free(LoclassWriter* instance) {
bool loclass_writer_write_start_stop(LoclassWriter* instance, bool start) {
furi_assert(instance != NULL);

uint32_t curr_ts = furi_hal_rtc_get_timestamp();
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

FuriString* str = furi_string_alloc_printf(
"loclass-v1-info ts %lu %s\n", curr_ts, start ? "started" : "finished");
Expand All @@ -59,7 +62,9 @@ bool loclass_writer_write_params(
const uint8_t mac[4]) {
furi_assert(instance != NULL);

uint32_t curr_ts = furi_hal_rtc_get_timestamp();
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

FuriString* str = furi_string_alloc_printf(
"loclass-v1-mac ts %lu no %u "
Expand Down
1 change: 1 addition & 0 deletions picopass/picopass_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ bool picopass_file_select(PicopassDevice* dev) {
void picopass_device_data_clear(PicopassDeviceData* dev_data) {
for(size_t i = 0; i < PICOPASS_MAX_APP_LIMIT; i++) {
memset(dev_data->card_data[i].data, 0, sizeof(dev_data->card_data[i].data));
dev_data->card_data[i].valid = false;
}
dev_data->pacs.legacy = false;
dev_data->pacs.se_enabled = false;
Expand Down
1 change: 1 addition & 0 deletions picopass/picopass_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ typedef struct {

typedef struct {
uint8_t data[PICOPASS_BLOCK_LEN];
bool valid;
} PicopassBlock;

typedef struct {
Expand Down
24 changes: 11 additions & 13 deletions picopass/protocol/picopass_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ static void picopass_listener_loclass_update_csn(PicopassListener* instance) {
// collect LOCLASS_NUM_PER_CSN nonces in a row for each CSN
const uint8_t* csn =
loclass_csns[(instance->key_block_num / LOCLASS_NUM_PER_CSN) % LOCLASS_NUM_CSNS];
memcpy(instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data, csn, sizeof(PicopassBlock));
memcpy(instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data, csn, PICOPASS_BLOCK_LEN);

uint8_t key[PICOPASS_BLOCK_LEN] = {};
loclass_iclass_calc_div_key(csn, picopass_iclass_key, key, false);
memcpy(
instance->data->card_data[PICOPASS_SECURE_KD_BLOCK_INDEX].data,
key,
sizeof(PicopassBlock));
instance->data->card_data[PICOPASS_SECURE_KD_BLOCK_INDEX].data, key, PICOPASS_BLOCK_LEN);

picopass_listener_init_cipher_state_key(instance, key);
}
Expand Down Expand Up @@ -122,7 +120,7 @@ PicopassListenerCommand
bit_buffer_copy_bytes(
instance->tmp_buffer,
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data,
sizeof(PicopassBlock));
PICOPASS_BLOCK_LEN);
} else {
picopass_listener_write_anticoll_csn(instance, instance->tmp_buffer);
}
Expand All @@ -143,7 +141,7 @@ PicopassListenerCommand
bit_buffer_copy_bytes(
instance->tx_buffer,
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data,
sizeof(PicopassBlock));
PICOPASS_BLOCK_LEN);

PicopassError error = picopass_listener_send_frame(instance, instance->tx_buffer);
if(error != PicopassErrorNone) {
Expand Down Expand Up @@ -181,7 +179,7 @@ PicopassListenerCommand
bit_buffer_copy_bytes(
instance->tx_buffer,
instance->data->card_data[block_num].data,
sizeof(PicopassBlock));
PICOPASS_BLOCK_LEN);
}
PicopassError error = picopass_listener_send_frame(instance, instance->tx_buffer);
if(error != PicopassErrorNone) {
Expand Down Expand Up @@ -216,7 +214,7 @@ static PicopassListenerCommand

// DATA(8)
bit_buffer_copy_bytes(
instance->tx_buffer, instance->data->card_data[block_num].data, sizeof(PicopassBlock));
instance->tx_buffer, instance->data->card_data[block_num].data, PICOPASS_BLOCK_LEN);
NfcError error = nfc_listener_tx(instance->nfc, instance->tx_buffer);
if(error != NfcErrorNone) {
FURI_LOG_D(TAG, "Failed to tx read check response: %d", error);
Expand Down Expand Up @@ -508,15 +506,15 @@ PicopassListenerCommand
case PICOPASS_SECURE_KC_BLOCK_INDEX:
if(!pers_mode && secured) {
new_block = instance->data->card_data[block_num];
for(size_t i = 0; i < sizeof(PicopassBlock); i++) {
for(size_t i = 0; i < PICOPASS_BLOCK_LEN; i++) {
new_block.data[i] ^= rx_data[i + 2];
}
break;
}
// Use default case when in personalisation mode
// fallthrough
default:
memcpy(new_block.data, &rx_data[2], sizeof(PicopassBlock));
memcpy(new_block.data, &rx_data[2], PICOPASS_BLOCK_LEN);
break;
}

Expand All @@ -537,7 +535,7 @@ PicopassListenerCommand
bit_buffer_copy_bytes(
instance->tx_buffer,
instance->data->card_data[block_num].data,
sizeof(PicopassBlock));
PICOPASS_BLOCK_LEN);
}

PicopassError error = picopass_listener_send_frame(instance, instance->tx_buffer);
Expand Down Expand Up @@ -572,12 +570,12 @@ PicopassListenerCommand
for(uint8_t i = block_start; i < block_start + 4; i++) {
if(secured &&
((i == PICOPASS_SECURE_KD_BLOCK_INDEX) || (i == PICOPASS_SECURE_KC_BLOCK_INDEX))) {
for(size_t j = 0; j < sizeof(PicopassBlock); j++) {
for(size_t j = 0; j < PICOPASS_BLOCK_LEN; j++) {
bit_buffer_append_byte(instance->tx_buffer, 0xff);
}
} else {
bit_buffer_append_bytes(
instance->tx_buffer, instance->data->card_data[i].data, sizeof(PicopassBlock));
instance->tx_buffer, instance->data->card_data[i].data, PICOPASS_BLOCK_LEN);
}
}

Expand Down
4 changes: 2 additions & 2 deletions picopass/protocol/picopass_listener_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ void picopass_listener_init_cipher_state_key(PicopassListener* instance, const u
memcpy(
cc,
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data,
sizeof(PicopassBlock));
PICOPASS_BLOCK_LEN);

instance->cipher_state = loclass_opt_doTagMAC_1(cc, key);
}

void picopass_listener_init_cipher_state(PicopassListener* instance) {
uint8_t key[PICOPASS_BLOCK_LEN] = {};
memcpy(key, instance->data->card_data[instance->key_block_num].data, sizeof(PicopassBlock));
memcpy(key, instance->data->card_data[instance->key_block_num].data, PICOPASS_BLOCK_LEN);

picopass_listener_init_cipher_state_key(instance, key);
}
Expand Down
82 changes: 35 additions & 47 deletions picopass/protocol/picopass_poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ NfcCommand picopass_poller_select_handler(PicopassPoller* instance) {
return command;
}

void picopass_poller_print_block(char* str, PicopassBlock block) {
FURI_LOG_D(
TAG,
str,
block.data[0],
block.data[1],
block.data[2],
block.data[3],
block.data[4],
block.data[5],
block.data[6],
block.data[7]);
}

NfcCommand picopass_poller_pre_auth_handler(PicopassPoller* instance) {
NfcCommand command = NfcCommandContinue;
PicopassError error = PicopassErrorNone;
Expand All @@ -79,17 +93,10 @@ NfcCommand picopass_poller_pre_auth_handler(PicopassPoller* instance) {
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data,
instance->serial_num.data,
sizeof(PicopassSerialNum));
FURI_LOG_D(
TAG,
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].valid = true;
picopass_poller_print_block(
"csn %02x%02x%02x%02x%02x%02x%02x%02x",
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[0],
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[1],
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[2],
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[3],
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[4],
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[5],
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[6],
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX].data[7]);
instance->data->card_data[PICOPASS_CSN_BLOCK_INDEX]);

PicopassBlock block = {};
error = picopass_poller_read_block(instance, PICOPASS_CONFIG_BLOCK_INDEX, &block);
Expand All @@ -100,18 +107,11 @@ NfcCommand picopass_poller_pre_auth_handler(PicopassPoller* instance) {
memcpy(
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data,
block.data,
sizeof(PicopassBlock));
FURI_LOG_D(
TAG,
PICOPASS_BLOCK_LEN);
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].valid = true;
picopass_poller_print_block(
"config %02x%02x%02x%02x%02x%02x%02x%02x",
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[0],
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[1],
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[2],
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[3],
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[4],
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[5],
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[6],
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[7]);
instance->data->card_data[PICOPASS_CONFIG_BLOCK_INDEX]);

error = picopass_poller_read_block(instance, PICOPASS_SECURE_EPURSE_BLOCK_INDEX, &block);
if(error != PicopassErrorNone) {
Expand All @@ -121,18 +121,11 @@ NfcCommand picopass_poller_pre_auth_handler(PicopassPoller* instance) {
memcpy(
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data,
block.data,
sizeof(PicopassBlock));
FURI_LOG_D(
TAG,
PICOPASS_BLOCK_LEN);
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].valid = true;
picopass_poller_print_block(
"epurse %02x%02x%02x%02x%02x%02x%02x%02x",
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[0],
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[1],
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[2],
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[3],
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[4],
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[5],
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[6],
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX].data[7]);
instance->data->card_data[PICOPASS_SECURE_EPURSE_BLOCK_INDEX]);

error = picopass_poller_read_block(instance, PICOPASS_SECURE_AIA_BLOCK_INDEX, &block);
if(error != PicopassErrorNone) {
Expand All @@ -142,18 +135,11 @@ NfcCommand picopass_poller_pre_auth_handler(PicopassPoller* instance) {
memcpy(
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data,
block.data,
sizeof(PicopassBlock));
FURI_LOG_D(
TAG,
PICOPASS_BLOCK_LEN);
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].valid = true;
picopass_poller_print_block(
"aia %02x%02x%02x%02x%02x%02x%02x%02x",
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[0],
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[1],
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[2],
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[3],
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[4],
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[5],
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[6],
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data[7]);
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX]);

instance->state = PicopassPollerStateCheckSecurity;
} while(false);
Expand Down Expand Up @@ -188,20 +174,20 @@ NfcCommand picopass_poller_check_security(PicopassPoller* instance) {

// Thank you proxmark!
PicopassBlock temp_block = {};
memset(temp_block.data, 0xff, sizeof(PicopassBlock));
memset(temp_block.data, 0xff, PICOPASS_BLOCK_LEN);
instance->data->pacs.legacy =
(memcmp(
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data,
temp_block.data,
sizeof(PicopassBlock)) == 0);
PICOPASS_BLOCK_LEN) == 0);

temp_block.data[3] = 0x00;
temp_block.data[4] = 0x06;
instance->data->pacs.se_enabled =
(memcmp(
instance->data->card_data[PICOPASS_SECURE_AIA_BLOCK_INDEX].data,
temp_block.data,
sizeof(PicopassBlock)) == 0);
PICOPASS_BLOCK_LEN) == 0);

if(instance->data->pacs.se_enabled) {
FURI_LOG_D(TAG, "SE enabled");
Expand Down Expand Up @@ -401,6 +387,7 @@ NfcCommand picopass_poller_auth_handler(PicopassPoller* instance) {
if(instance->mode == PicopassPollerModeRead) {
memcpy(
instance->data->pacs.key, instance->event_data.req_key.key, PICOPASS_KEY_LEN);
instance->data->card_data[PICOPASS_SECURE_KD_BLOCK_INDEX].valid = true;
instance->data->pacs.elite_kdf = instance->event_data.req_key.is_elite_key;
picopass_poller_prepare_read(instance);
instance->state = PicopassPollerStateReadBlock;
Expand Down Expand Up @@ -457,7 +444,8 @@ NfcCommand picopass_poller_read_block_handler(PicopassPoller* instance) {
memcpy(
instance->data->card_data[instance->current_block].data,
block.data,
sizeof(PicopassBlock));
PICOPASS_BLOCK_LEN);
instance->data->card_data[instance->current_block].valid = true;
instance->current_block++;
} while(false);

Expand Down
Loading

0 comments on commit 11f41e2

Please sign in to comment.