Skip to content

Commit

Permalink
Picopass: rename RFAL_PICOPASS_BLOCK_LEN (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: hedger <hedger@users.noreply.github.com>
  • Loading branch information
bettse and hedger committed Oct 24, 2023
1 parent 692dc97 commit 77e776a
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 97 deletions.
20 changes: 8 additions & 12 deletions picopass_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static bool picopass_device_save_file_lfrfid(PicopassDevice* dev, FuriString* fi
bool result = false;
uint64_t target = 0;
uint64_t sentinel = 1ULL << pacs->bitLength;
memcpy(&target, pacs->credential, RFAL_PICOPASS_BLOCK_LEN);
memcpy(&target, pacs->credential, PICOPASS_BLOCK_LEN);
target = __builtin_bswap64(target);
FURI_LOG_D(TAG, "Original (%d): %016llx", pacs->bitLength, target);

Expand Down Expand Up @@ -132,8 +132,7 @@ static bool picopass_device_save_file(
// Write header
if(!flipper_format_write_header_cstr(file, picopass_file_header, picopass_file_version))
break;
if(!flipper_format_write_hex(
file, "Credential", pacs->credential, RFAL_PICOPASS_BLOCK_LEN))
if(!flipper_format_write_hex(file, "Credential", pacs->credential, PICOPASS_BLOCK_LEN))
break;

// TODO: Add elite
Expand All @@ -146,10 +145,7 @@ static bool picopass_device_save_file(
for(size_t i = 0; i < app_limit; i++) {
furi_string_printf(temp_str, "Block %d", i);
if(!flipper_format_write_hex(
file,
furi_string_get_cstr(temp_str),
AA1[i].data,
RFAL_PICOPASS_BLOCK_LEN)) {
file, furi_string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
block_saved = false;
break;
}
Expand Down Expand Up @@ -210,7 +206,7 @@ static bool picopass_device_load_data(PicopassDevice* dev, FuriString* path, boo
for(size_t i = 0; i < 6; i++) {
furi_string_printf(temp_str, "Block %d", i);
if(!flipper_format_read_hex(
file, furi_string_get_cstr(temp_str), AA1[i].data, RFAL_PICOPASS_BLOCK_LEN)) {
file, furi_string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
block_read = false;
break;
}
Expand All @@ -222,7 +218,7 @@ static bool picopass_device_load_data(PicopassDevice* dev, FuriString* path, boo
for(size_t i = 6; i < app_limit; i++) {
furi_string_printf(temp_str, "Block %d", i);
if(!flipper_format_read_hex(
file, furi_string_get_cstr(temp_str), AA1[i].data, RFAL_PICOPASS_BLOCK_LEN)) {
file, furi_string_get_cstr(temp_str), AA1[i].data, PICOPASS_BLOCK_LEN)) {
block_read = false;
break;
}
Expand Down Expand Up @@ -386,9 +382,9 @@ ReturnCode picopass_device_parse_credential(PicopassBlock* AA1, PicopassPacs* pa
}
} else if(pacs->encryption == PicopassDeviceEncryptionNone) {
FURI_LOG_D(TAG, "No Encryption");
memcpy(pacs->credential, AA1[7].data, RFAL_PICOPASS_BLOCK_LEN);
memcpy(pacs->pin0, AA1[8].data, RFAL_PICOPASS_BLOCK_LEN);
memcpy(pacs->pin1, AA1[9].data, RFAL_PICOPASS_BLOCK_LEN);
memcpy(pacs->credential, AA1[7].data, PICOPASS_BLOCK_LEN);
memcpy(pacs->pin0, AA1[8].data, PICOPASS_BLOCK_LEN);
memcpy(pacs->pin1, AA1[9].data, PICOPASS_BLOCK_LEN);
} else if(pacs->encryption == PicopassDeviceEncryptionDES) {
FURI_LOG_D(TAG, "DES Encrypted");
} else {
Expand Down
2 changes: 1 addition & 1 deletion picopass_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ typedef struct {
} PicopassPacs;

typedef struct {
uint8_t data[RFAL_PICOPASS_BLOCK_LEN];
uint8_t data[PICOPASS_BLOCK_LEN];
} PicopassBlock;

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion picopass_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct Picopass {

char text_store[PICOPASS_TEXT_STORE_SIZE + 1];
FuriString* text_box_store;
uint8_t byte_input_store[RFAL_PICOPASS_BLOCK_LEN];
uint8_t byte_input_store[PICOPASS_BLOCK_LEN];

// Common Views
Submenu* submenu;
Expand Down
12 changes: 6 additions & 6 deletions picopass_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "picopass_device.h"

extern const uint8_t picopass_iclass_key[RFAL_PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_factory_credit_key[RFAL_PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_factory_debit_key[RFAL_PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_xice_key[RFAL_PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_xicl_key[RFAL_PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_xics_key[RFAL_PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_iclass_key[PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_factory_credit_key[PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_factory_debit_key[PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_xice_key[PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_xicl_key[PICOPASS_BLOCK_LEN];
extern const uint8_t picopass_xics_key[PICOPASS_BLOCK_LEN];
Loading

0 comments on commit 77e776a

Please sign in to comment.