mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
style
This commit is contained in:
+1
-1
@@ -541,7 +541,7 @@ static int b64dec(const char *src, int n, char *dst) {
|
||||
int len = 0;
|
||||
while (src + 3 < end) {
|
||||
int a = b64rev(src[0]), b = b64rev(src[1]), c = b64rev(src[2]),
|
||||
d = b64rev(src[3]);
|
||||
d = b64rev(src[3]);
|
||||
dst[len++] = (a << 2) | (b >> 4);
|
||||
if (src[2] != '=') {
|
||||
dst[len++] = (b << 4) | (c >> 2);
|
||||
|
||||
+1
-1
@@ -478,7 +478,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
|
||||
uint8_t tlv_idx = 1 + offset;
|
||||
|
||||
dynamic_response_info.response[tlv_idx++] = 0x7C; // Tag: mutual auth
|
||||
dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC) +2; // Length
|
||||
dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC) + 2; // Length
|
||||
dynamic_response_info.response[tlv_idx++] = 0x81; // Tag: request for RND.ICC
|
||||
dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC); // Length
|
||||
memcpy(dynamic_response_info.response + tlv_idx, RND_ICC, sizeof(RND_ICC));
|
||||
|
||||
@@ -103,7 +103,7 @@ struct Bad_arg_to_ARRAY_SIZE2 {
|
||||
class Is_pointer; /* incomplete */
|
||||
class Is_array {};
|
||||
template <typename T>
|
||||
static Is_pointer check_type(T const *, T const * const *);
|
||||
static Is_pointer check_type(T const *, T const *const *);
|
||||
static Is_array check_type(void const *, void const *);
|
||||
};
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ static bool verify_alternatives(void) {
|
||||
|
||||
for (uint16_t q = 0; q < ARRAY_SIZE2(verification_table); ++q) {
|
||||
bool any_failures_this_table = false;
|
||||
VERIFICATION_T const * vt = &verification_table[q];
|
||||
VERIFICATION_T const *vt = &verification_table[q];
|
||||
const char *fstr = vt->output_name;
|
||||
uint16_t limit = 1u << vt->input_count;
|
||||
|
||||
@@ -718,7 +718,7 @@ static bool verify_lut_XX(void) {
|
||||
|
||||
// order of input_names is based on resulting .PLA output,
|
||||
// so least significant bit is at input_names[input_count-1]
|
||||
static bool generate_espresso_file(uint8_t input_count, const char * const * input_names, const char * output_name, const uint8_t * lut_table_start, FILE* f_output) {
|
||||
static bool generate_espresso_file(uint8_t input_count, const char *const *input_names, const char *output_name, const uint8_t *lut_table_start, FILE *f_output) {
|
||||
if (input_count > 8) {
|
||||
printf("FAILURE - Cannot generate espresso file for more than 8 inputs (code would need update)\n");
|
||||
}
|
||||
@@ -760,10 +760,10 @@ bool generate_all_lut_espresso_files(void) {
|
||||
bool any_failures = false;
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE2(verification_table); ++i) {
|
||||
VERIFICATION_T const * args = &verification_table[i];
|
||||
VERIFICATION_T const *args = &verification_table[i];
|
||||
|
||||
bool current_result = false;
|
||||
FILE* file = NULL;
|
||||
FILE *file = NULL;
|
||||
char filename[20] = {0}; // needs: 14 for two-letter output name
|
||||
|
||||
// First create the filename to be written
|
||||
|
||||
@@ -103,7 +103,7 @@ struct Bad_arg_to_ARRAY_SIZE2 {
|
||||
class Is_pointer; /* incomplete */
|
||||
class Is_array {};
|
||||
template <typename T>
|
||||
static Is_pointer check_type(T const *, T const * const *);
|
||||
static Is_pointer check_type(T const *, T const *const *);
|
||||
static Is_array check_type(void const *, void const *);
|
||||
};
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ struct Bad_arg_to_ARRAY_SIZE2 {
|
||||
class Is_pointer; /* incomplete */
|
||||
class Is_array {};
|
||||
template <typename T>
|
||||
static Is_pointer check_type(T const *, T const * const *);
|
||||
static Is_pointer check_type(T const *, T const *const *);
|
||||
static Is_array check_type(void const *, void const *);
|
||||
};
|
||||
|
||||
|
||||
@@ -73,10 +73,10 @@ main(int argc, char *argv[]) {
|
||||
setbmp();
|
||||
if (BMP_BIT != bmpbit || BMP_SUB != bmpsub) {
|
||||
fprintf(stderr, "reveng: configuration fault. Update "
|
||||
"reveng/config.h with these definitions and "
|
||||
"recompile:\n"
|
||||
"\t#define BMP_BIT %d\n"
|
||||
"\t#define BMP_SUB %d\n",
|
||||
"reveng/config.h with these definitions and "
|
||||
"recompile:\n"
|
||||
"\t#define BMP_BIT %d\n"
|
||||
"\t#define BMP_SUB %d\n",
|
||||
bmpbit, bmpsub);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -84,8 +84,8 @@ main(int argc, char *argv[]) {
|
||||
/* check the bitmap constant macro */
|
||||
if (~(bmp_t) 0 != ~BMP_C(0)) {
|
||||
fprintf(stderr, "reveng: configuration fault. Edit "
|
||||
"the definition of BMP_C() in config.h to "
|
||||
"match BMP_T and recompile.\n");
|
||||
"the definition of BMP_C() in config.h to "
|
||||
"match BMP_T and recompile.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
+229
-229
File diff suppressed because it is too large
Load Diff
@@ -467,7 +467,7 @@ static int CmdFlashMemSpiFFSWipe(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "mem spiffs wipe",
|
||||
_RED_("* * * Warning * * *") " \n"
|
||||
_CYAN_("This command wipes all files on the device SPIFFS file system"),
|
||||
"mem spiffs wipe");
|
||||
"mem spiffs wipe");
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
||||
@@ -3025,7 +3025,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
int16_t fsci = card.ats[1] & 0x0f;
|
||||
|
||||
PrintAndLogEx(INFO, " ..." _YELLOW_("%02X") "............ T0 TA1 is%s present, TB1 is%s present, "
|
||||
"TC1 is%s present, FSCI is %d (FSC = %d)",
|
||||
"TC1 is%s present, FSCI is %d (FSC = %d)",
|
||||
card.ats[1],
|
||||
(ta1 ? "" : _RED_(" NOT")),
|
||||
(tb1 ? "" : _RED_(" NOT")),
|
||||
@@ -3047,7 +3047,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
if (strlen(ds) != 0) ds[strlen(ds) - 2] = '\0';
|
||||
if (strlen(dr) != 0) dr[strlen(dr) - 2] = '\0';
|
||||
PrintAndLogEx(INFO, " ......" _YELLOW_("%02X") "......... TA1 different divisors are%s supported, "
|
||||
"DR: [%s], DS: [%s]",
|
||||
"DR: [%s], DS: [%s]",
|
||||
card.ats[pos],
|
||||
((card.ats[pos] & 0x80) ? _RED_(" NOT") : ""),
|
||||
dr,
|
||||
|
||||
@@ -1102,7 +1102,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||
|
||||
if (d[8] == 0x04) {
|
||||
// NXP
|
||||
|
||||
|
||||
// from: SL2S6002_SDS
|
||||
// Bit 37 Bit 36 ICODE Type
|
||||
// -------------------------
|
||||
@@ -1120,14 +1120,14 @@ static int CmdHF15Info(const char *Cmd) {
|
||||
// --------------------------------------
|
||||
// 0 1 0 0 ICODE 3
|
||||
// --> it can be mismached with a ICODE SLI, but lets assume Bit 39 & Bit 38 at 0 when ICODE SLI*/DNA...
|
||||
|
||||
|
||||
if (d[7] == 0x01 && nxp_version == 0x08) {
|
||||
PrintAndLogEx(DEBUG, "SLIX2 Detected, getting NXP System Info");
|
||||
return NxpSysInfo(uid);
|
||||
} else if (d[7] == 0x01 && nxp_version == 0x18) { // If it is an NTAG 5 / ICODE DNA
|
||||
PrintAndLogEx(DEBUG, "NTAG 5 / ICODE DNA Detected, getting NXP System Info");
|
||||
return NxpSysInfo(uid);
|
||||
} else if (d[7] == 0x01 && ((d[6] & 0x78) == 0x20)) { // If it is an NTAG ICODE 3
|
||||
} else if (d[7] == 0x01 && ((d[6] & 0x78) == 0x20)) { // If it is an NTAG ICODE 3
|
||||
PrintAndLogEx(DEBUG, "ICODE 3 Detected, getting NXP System Info");
|
||||
return NxpSysInfo(uid);
|
||||
} else if ((d[7] == 0x01 || d[7] == 0x02 || d[7] == 0x03)) { // If SLI, SLIX, SLIX-l, or SLIX-S check EAS status
|
||||
|
||||
@@ -1075,9 +1075,9 @@ static uint8_t calypso_icc_check_value(const uint8_t *data, size_t len) {
|
||||
static bool calypso_bcd_country(const uint8_t *data, uint16_t *country_code) {
|
||||
uint8_t nibbles[] = {
|
||||
data[0] >> 4,
|
||||
data[0] & 0x0F,
|
||||
data[1] >> 4,
|
||||
data[1] & 0x0F,
|
||||
data[0] & 0x0F,
|
||||
data[1] >> 4,
|
||||
data[1] & 0x0F,
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < ARRAYLEN(nibbles); i++) {
|
||||
|
||||
+42
-42
@@ -350,10 +350,10 @@ static void print_status_flag1_interpretation(void) {
|
||||
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
|
||||
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
|
||||
PrintAndLogEx(INFO, " FF | If an error occurs during the processing of a command that includes no list in the command packet, \n"
|
||||
" | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1.");
|
||||
" | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1.");
|
||||
PrintAndLogEx(INFO, " XX | If an error occurs while processing a command that includes Service Code List or Block List \n"
|
||||
" | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n"
|
||||
" | indicating the location of the error.");
|
||||
" | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n"
|
||||
" | indicating the location of the error.");
|
||||
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
@@ -362,28 +362,28 @@ static void print_status_flag2_interpration(void) {
|
||||
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
|
||||
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
|
||||
PrintAndLogEx(INFO, " 01 | The calculated result is either less than zero when the purse data is decremented, or exceeds 4\n"
|
||||
" | Bytes when the purse data is incremented.");
|
||||
" | Bytes when the purse data is incremented.");
|
||||
PrintAndLogEx(INFO, " 02 | The specified data exceeds the value of cashback data at cashback of purse.");
|
||||
PrintAndLogEx(INFO, " 70 | Memory error (fatal error).");
|
||||
PrintAndLogEx(INFO, " 71 | The number of memory rewrites exceeds the upper limit (this is only a warning; data writing is performed as normal).\n"
|
||||
" | The maximum number of rewrites can differ, depending on the product being used.\n"
|
||||
" | In addition, Status Flag1 is either 00h or FFh depending on the product being used.");
|
||||
" | The maximum number of rewrites can differ, depending on the product being used.\n"
|
||||
" | In addition, Status Flag1 is either 00h or FFh depending on the product being used.");
|
||||
|
||||
PrintAndLogEx(INFO, " A1 | Illegal Number of Service| Number of Service or Number of Node specified by the command \n"
|
||||
" | falls outside the range of the prescribed value.");
|
||||
" | falls outside the range of the prescribed value.");
|
||||
PrintAndLogEx(INFO, " A2 | Illegal command packet (specified Number of Block) : Number of Block specified by the \n"
|
||||
" | command falls outside the range of the prescribed values for the product.");
|
||||
" | command falls outside the range of the prescribed values for the product.");
|
||||
PrintAndLogEx(INFO, " A3 | Illegal Block List (specified order of Service) : Service Code List Order specified by \n"
|
||||
" | Block List Element falls outside the Number of Service specified by the command \n"
|
||||
" | (or the Number of Service specified at the times of mutual authentication).");
|
||||
" | Block List Element falls outside the Number of Service specified by the command \n"
|
||||
" | (or the Number of Service specified at the times of mutual authentication).");
|
||||
PrintAndLogEx(INFO, " A4 | Illegal Service type : Area Attribute specified by the command or Service Attribute of Service Code is incorrect.");
|
||||
PrintAndLogEx(INFO, " A5 | Access is not allowed : Area or Service specified by the command cannot be accessed.\n"
|
||||
" | The parameter specified by the command does not satisfy the conditions for success.");
|
||||
" | The parameter specified by the command does not satisfy the conditions for success.");
|
||||
PrintAndLogEx(INFO, " A6 | Illegal Service Code List : Target to be accessed, identified by Service Code List Order, specified by Block\n"
|
||||
" | List Element does not exist. Or, Node specified by Node Code List does not exist.");
|
||||
" | List Element does not exist. Or, Node specified by Node Code List does not exist.");
|
||||
PrintAndLogEx(INFO, " A7 | Illegal Block List (Access Mode) : Access Mode specified by Block List Element is incorrect.");
|
||||
PrintAndLogEx(INFO, " A8 | Illegal Block Number Block Number (access to the specified data is inhibited) :\n"
|
||||
" | specified by Block List Element exceeds the number of Blocks assigned to Service.");
|
||||
" | specified by Block List Element exceeds the number of Blocks assigned to Service.");
|
||||
PrintAndLogEx(INFO, " A9 | Data write failure : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " AA | Key-change failure : Key change failed.");
|
||||
PrintAndLogEx(INFO, " AB | Illegal Package Parity or illegal Package MAC : This is the error that occurs in issuance commands.");
|
||||
@@ -391,7 +391,7 @@ static void print_status_flag2_interpration(void) {
|
||||
PrintAndLogEx(INFO, " AD | Service exists already : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " AE | Illegal System Code : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " AF | Too many simultaneous cyclic write operations : Number of simultaneous write Blocks\n"
|
||||
" | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service.");
|
||||
" | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service.");
|
||||
PrintAndLogEx(INFO, " C0 | Illegal Package Identifier : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " C1 | Discrepancy of parameters inside and outside Package : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " C2 | Command is disabled already : This is the error that occurs in issuance commands.");
|
||||
@@ -415,16 +415,16 @@ static void print_number_of_service_constraints(void) {
|
||||
|
||||
static void print_number_of_block_constraints(void) {
|
||||
PrintAndLogEx(INFO, " - Number of Block: shall be less than or equal to the maximum number of Blocks that can be read simultaneously.\n"
|
||||
" The maximum number of Blocks that can be read simultaneously can differ, depending on the product being used.\n"
|
||||
" Use as default 01");
|
||||
" The maximum number of Blocks that can be read simultaneously can differ, depending on the product being used.\n"
|
||||
" Use as default 01");
|
||||
}
|
||||
|
||||
static void print_service_code_list_constraints(void) {
|
||||
PrintAndLogEx(INFO, " - Service Code List: For Service Code List, only Service Code existing in the product shall be specified:");
|
||||
PrintAndLogEx(INFO, " - Even when Service Code exists in the product, Service Code not referenced from Block List shall not \n"
|
||||
" be specified to Service Code List.");
|
||||
" be specified to Service Code List.");
|
||||
PrintAndLogEx(INFO, " - For existence or nonexistence of Service in a product, please check using the Request Service \n"
|
||||
" (or Request Service v2) command.");
|
||||
" (or Request Service v2) command.");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -846,8 +846,8 @@ static bool felica_parse_block_list_element(const char *ble_hex, uint8_t *ble_ou
|
||||
}
|
||||
|
||||
static size_t felica_parse_service_node_matchers(const json_t *node_json,
|
||||
felica_system_service_node_matcher_t *matchers,
|
||||
size_t matcher_capacity) {
|
||||
felica_system_service_node_matcher_t *matchers,
|
||||
size_t matcher_capacity) {
|
||||
if (node_json == NULL || matchers == NULL || matcher_capacity == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -888,9 +888,9 @@ static size_t felica_parse_service_node_matchers(const json_t *node_json,
|
||||
}
|
||||
|
||||
static int felica_read_service_block_for_node(uint8_t flags, const uint8_t *idm,
|
||||
uint16_t node_code_le,
|
||||
const uint8_t *block_list_element, uint8_t block_list_element_len,
|
||||
uint8_t *block_data_out, size_t block_data_out_capacity, size_t *block_data_len_out) {
|
||||
uint16_t node_code_le,
|
||||
const uint8_t *block_list_element, uint8_t block_list_element_len,
|
||||
uint8_t *block_data_out, size_t block_data_out_capacity, size_t *block_data_len_out) {
|
||||
if (idm == NULL || block_list_element == NULL || block_data_out == NULL || block_data_len_out == NULL) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
@@ -934,7 +934,7 @@ static int felica_read_service_block_for_node(uint8_t flags, const uint8_t *idm,
|
||||
}
|
||||
|
||||
static bool felica_block_number_from_block_list_element(const uint8_t *block_list_element,
|
||||
uint8_t block_list_element_len, uint16_t *block_number) {
|
||||
uint8_t block_list_element_len, uint16_t *block_number) {
|
||||
if (block_list_element == NULL || block_number == NULL) {
|
||||
return false;
|
||||
}
|
||||
@@ -953,7 +953,7 @@ static bool felica_block_number_from_block_list_element(const uint8_t *block_lis
|
||||
}
|
||||
|
||||
static bool felica_service_block_data_cache_entry_matches(const felica_service_block_data_cache_entry_t *entry,
|
||||
const uint8_t *idm, uint16_t service_code_le, uint16_t block_number) {
|
||||
const uint8_t *idm, uint16_t service_code_le, uint16_t block_number) {
|
||||
return entry && entry->valid &&
|
||||
memcmp(entry->idm, idm, sizeof(entry->idm)) == 0 &&
|
||||
entry->service_code_le == service_code_le &&
|
||||
@@ -961,10 +961,10 @@ static bool felica_service_block_data_cache_entry_matches(const felica_service_b
|
||||
}
|
||||
|
||||
static int felica_read_service_block_for_node_cached(uint8_t flags, const uint8_t *idm,
|
||||
uint16_t service_code_le,
|
||||
const uint8_t *block_list_element, uint8_t block_list_element_len,
|
||||
uint8_t *block_data_out, size_t block_data_out_capacity, size_t *block_data_len_out,
|
||||
felica_service_block_data_cache_t *cache) {
|
||||
uint16_t service_code_le,
|
||||
const uint8_t *block_list_element, uint8_t block_list_element_len,
|
||||
uint8_t *block_data_out, size_t block_data_out_capacity, size_t *block_data_len_out,
|
||||
felica_service_block_data_cache_t *cache) {
|
||||
if (idm == NULL || block_list_element == NULL || block_data_out == NULL || block_data_len_out == NULL) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
@@ -977,7 +977,7 @@ static int felica_read_service_block_for_node_cached(uint8_t flags, const uint8_
|
||||
|
||||
uint16_t block_number = 0;
|
||||
if (felica_block_number_from_block_list_element(block_list_element,
|
||||
block_list_element_len, &block_number) == false) {
|
||||
block_list_element_len, &block_number) == false) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -1021,8 +1021,8 @@ static int felica_read_service_block_for_node_cached(uint8_t flags, const uint8_
|
||||
}
|
||||
|
||||
static bool felica_match_service_node_data(uint8_t flags, const uint8_t *idm, uint16_t node_code_le,
|
||||
const felica_system_service_node_matcher_t *matchers, size_t matcher_count,
|
||||
felica_service_block_data_cache_t *block_data_cache) {
|
||||
const felica_system_service_node_matcher_t *matchers, size_t matcher_count,
|
||||
felica_service_block_data_cache_t *block_data_cache) {
|
||||
if (idm == NULL || matchers == NULL || matcher_count == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -1056,8 +1056,8 @@ static bool felica_is_lite_assumed_node(uint16_t node_code_le) {
|
||||
}
|
||||
|
||||
static int felica_request_service_key_versions(uint8_t flags, const uint8_t *idm,
|
||||
const uint16_t *node_codes_le, size_t node_count,
|
||||
uint16_t *key_versions_le_out, size_t *returned_nodes_out) {
|
||||
const uint16_t *node_codes_le, size_t node_count,
|
||||
uint16_t *key_versions_le_out, size_t *returned_nodes_out) {
|
||||
if (idm == NULL || node_codes_le == NULL || key_versions_le_out == NULL) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
@@ -1115,8 +1115,8 @@ static int felica_request_service_key_versions(uint8_t flags, const uint8_t *idm
|
||||
}
|
||||
|
||||
static void felica_info_process_system_services(int level, uint8_t flags,
|
||||
uint16_t system_code, const uint8_t *idm, const json_t *system_entry,
|
||||
felica_service_block_data_cache_t *block_data_cache) {
|
||||
uint16_t system_code, const uint8_t *idm, const json_t *system_entry,
|
||||
felica_service_block_data_cache_t *block_data_cache) {
|
||||
if (idm == NULL || system_entry == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -1173,8 +1173,8 @@ static void felica_info_process_system_services(int level, uint8_t flags,
|
||||
json_t *data_json = json_object_get(node_json, "data");
|
||||
const bool has_data_matchers = json_is_object(data_json) && (json_object_size(data_json) > 0);
|
||||
const size_t matcher_count = felica_parse_service_node_matchers(node_json,
|
||||
nodes[node_count].matchers,
|
||||
ARRAYLEN(nodes[node_count].matchers));
|
||||
nodes[node_count].matchers,
|
||||
ARRAYLEN(nodes[node_count].matchers));
|
||||
if (has_data_matchers && matcher_count == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -1414,7 +1414,7 @@ static void felica_system_code_to_bytes(uint16_t system_code, uint8_t *system_co
|
||||
}
|
||||
|
||||
static bool felica_add_unique_discovered_system(felica_discovered_system_t *systems, size_t *count,
|
||||
uint16_t system_code, const uint8_t *idm) {
|
||||
uint16_t system_code, const uint8_t *idm) {
|
||||
if (systems == NULL || count == NULL) {
|
||||
return false;
|
||||
}
|
||||
@@ -1510,9 +1510,9 @@ static int discover_systems(uint8_t flags, const uint8_t *primary_idm, bool requ
|
||||
|
||||
felica_syscode_response_t system_code_response;
|
||||
const int request_system_code_status = send_request_system_code(flags,
|
||||
sizeof(request_system_code_request), (uint8_t *)&request_system_code_request,
|
||||
false, FELICA_OPTIONAL_CMD_TIMEOUT_MS, FELICA_OPTIONAL_CMD_RETRIES, false,
|
||||
&system_code_response);
|
||||
sizeof(request_system_code_request), (uint8_t *)&request_system_code_request,
|
||||
false, FELICA_OPTIONAL_CMD_TIMEOUT_MS, FELICA_OPTIONAL_CMD_RETRIES, false,
|
||||
&system_code_response);
|
||||
|
||||
if (request_system_code_status == PM3_SUCCESS) {
|
||||
const size_t reported_systems = system_code_response.number_of_systems[0];
|
||||
|
||||
@@ -381,7 +381,7 @@ static int hfgal_create_creds_app(DesfireContext_t *ctx, uint8_t *site_key, uint
|
||||
// UID is required for key diversification
|
||||
if (ctx->uidlen == 0) {
|
||||
PM3_RET_ERR(PM3_EINVARG, "UID is required for key diversification. "
|
||||
"Please fetch it before calling `hfgal_create_creds_app`");
|
||||
"Please fetch it before calling `hfgal_create_creds_app`");
|
||||
}
|
||||
|
||||
// Create application
|
||||
@@ -871,11 +871,11 @@ static int hfgal_read_desfire_card(uint32_t aid, uint8_t *site_key, bool verbose
|
||||
PM3_RET_IF_ERR_MAYBE_MSG(res, !quiet, "Failed reading card application credentials");
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Gallagher (AID %06X) - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )"
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
current_aid,
|
||||
'A' + creds.region_code,
|
||||
'A' + creds.region_code,
|
||||
creds.region_code,
|
||||
creds.facility_code,
|
||||
creds.card_number,
|
||||
@@ -1696,10 +1696,10 @@ static int CmdGallagherDecode(const char *cmd) {
|
||||
gallagher_decode_creds(data_buf, &creds);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Gallagher - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )"
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
'A' + creds.region_code,
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
'A' + creds.region_code,
|
||||
creds.region_code,
|
||||
creds.facility_code,
|
||||
creds.card_number,
|
||||
|
||||
+33
-18
@@ -8079,26 +8079,39 @@ static int sam_sc_dispatch(uint8_t flags, uint8_t scflag_in,
|
||||
// A0 15 AF 13 80 01 <ver> 81 01 <kref> 82 08 <rnd_a> 83 01 <tca>
|
||||
static uint16_t sam_sc_build_init_auth(uint8_t kref, const uint8_t rnd_a[8],
|
||||
uint8_t out[23]) {
|
||||
out[0] = 0xA0; out[1] = 0x15;
|
||||
out[2] = 0xAF; out[3] = 0x13;
|
||||
out[4] = 0x80; out[5] = 0x01; out[6] = 0x00; // version=0
|
||||
out[7] = 0x81; out[8] = 0x01; out[9] = kref;
|
||||
out[10] = 0x82; out[11] = 0x08;
|
||||
out[0] = 0xA0;
|
||||
out[1] = 0x15;
|
||||
out[2] = 0xAF;
|
||||
out[3] = 0x13;
|
||||
out[4] = 0x80;
|
||||
out[5] = 0x01;
|
||||
out[6] = 0x00; // version=0
|
||||
out[7] = 0x81;
|
||||
out[8] = 0x01;
|
||||
out[9] = kref;
|
||||
out[10] = 0x82;
|
||||
out[11] = 0x08;
|
||||
memcpy(out + 12, rnd_a, 8);
|
||||
out[20] = 0x83; out[21] = 0x01; out[22] = 0x00; // tca=0
|
||||
out[20] = 0x83;
|
||||
out[21] = 0x01;
|
||||
out[22] = 0x00; // tca=0
|
||||
return 23;
|
||||
}
|
||||
|
||||
// Build the ContinueAuth SAM payload (40 bytes):
|
||||
// A0 26 B0 24 80 10 <clientCryptogram> 81 10 <clientCmac>
|
||||
static uint16_t sam_sc_build_continue_auth(const uint8_t client_crypto[16],
|
||||
const uint8_t client_cmac[16],
|
||||
uint8_t out[40]) {
|
||||
out[0] = 0xA0; out[1] = 0x26;
|
||||
out[2] = 0xB0; out[3] = 0x24;
|
||||
out[4] = 0x80; out[5] = 0x10;
|
||||
const uint8_t client_cmac[16],
|
||||
uint8_t out[40]) {
|
||||
out[0] = 0xA0;
|
||||
out[1] = 0x26;
|
||||
out[2] = 0xB0;
|
||||
out[3] = 0x24;
|
||||
out[4] = 0x80;
|
||||
out[5] = 0x10;
|
||||
memcpy(out + 6, client_crypto, 16);
|
||||
out[22] = 0x81; out[23] = 0x10;
|
||||
out[22] = 0x81;
|
||||
out[23] = 0x10;
|
||||
memcpy(out + 24, client_cmac, 16);
|
||||
return 40;
|
||||
}
|
||||
@@ -8197,7 +8210,7 @@ static int sam_sc_peel_envelope(const uint8_t *resp, uint16_t resp_len,
|
||||
char *path) {
|
||||
if (resp_len < 2) return -1;
|
||||
|
||||
#define SAM_SC_READ_BER_LEN(buf, buflen, off, out_len) \
|
||||
#define SAM_SC_READ_BER_LEN(buf, buflen, off, out_len) \
|
||||
do { \
|
||||
if ((off) >= (buflen)) return -1; \
|
||||
uint8_t b0 = (buf)[(off)++]; \
|
||||
@@ -8240,14 +8253,16 @@ static int sam_sc_peel_envelope(const uint8_t *resp, uint16_t resp_len,
|
||||
*inner_len = in_len;
|
||||
return 0;
|
||||
|
||||
#undef SAM_SC_READ_BER_LEN
|
||||
#undef SAM_SC_READ_BER_LEN
|
||||
}
|
||||
|
||||
// Encode a BER length (short form < 128, otherwise 0x81/0x82).
|
||||
static uint8_t sam_sc_emit_ber_len(uint8_t *out, uint16_t len) {
|
||||
if (len < 0x80) { out[0] = (uint8_t)len; return 1; }
|
||||
if (len < 0x100) { out[0] = 0x81; out[1] = (uint8_t)len; return 2; }
|
||||
out[0] = 0x82; out[1] = (uint8_t)(len >> 8); out[2] = (uint8_t)(len & 0xFF);
|
||||
out[0] = 0x82;
|
||||
out[1] = (uint8_t)(len >> 8);
|
||||
out[2] = (uint8_t)(len & 0xFF);
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -8893,7 +8908,7 @@ static int CmdHFiClassLiberate(const char *Cmd) {
|
||||
memcpy(key, iClass_Key_Table[0], PICOPASS_BLOCK_SIZE);
|
||||
|
||||
int res = iclass_read_block_ex(key, MKF_KNOWN_BLOCK, ICLASS_DEBIT_KEYTYPE, false, false, false,
|
||||
verbose, true, shallow_mod, blk18, false, false);
|
||||
verbose, true, shallow_mod, blk18, false, false);
|
||||
if (res == PM3_SUCCESS) {
|
||||
// build 2-key 3DES key: CSN || 0570F69A06975CD8
|
||||
uint8_t des_key[16] = {0};
|
||||
@@ -8995,7 +9010,7 @@ static int CmdHFiClassLiberate(const char *Cmd) {
|
||||
case CARD_TYPE_ICOPY_ICL:
|
||||
case CARD_TYPE_ICOPY_ICS: {
|
||||
// change KD from DRM key to default key (ki 0)
|
||||
PrintAndLogEx(INFO, "Changing KD from iCopy-X DRM key to default");
|
||||
PrintAndLogEx(INFO, "Changing KD from iCopy-X DRM key to default");
|
||||
|
||||
// calculate XOR div key
|
||||
uint8_t xor_div_key[PICOPASS_BLOCK_SIZE] = {0};
|
||||
@@ -9023,7 +9038,7 @@ static int CmdHFiClassLiberate(const char *Cmd) {
|
||||
memcpy(default_key, iClass_Key_Table[0], PICOPASS_BLOCK_SIZE);
|
||||
|
||||
res = iclass_read_block_ex(default_key, 6, ICLASS_DEBIT_KEYTYPE, false, false, false,
|
||||
verbose, true, shallow_mod, verify, false, false);
|
||||
verbose, true, shallow_mod, verify, false, false);
|
||||
if (res == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "Verified default key ( %s )", _GREEN_("ok"));
|
||||
} else {
|
||||
|
||||
@@ -262,7 +262,7 @@ static int decode_and_print_memory(uint16_t card_size, const uint8_t *input_buff
|
||||
// for printing the complete segment we need at least wrc + wrp_len + remain_seg_payload_len bytes
|
||||
if ((i + wrc + wrp_len + remain_seg_payload_len) > card_size) {
|
||||
PrintAndLogEx(FAILED, "Cannot read segment body, because the input buffer is too small. "
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
return_value = PM3_EOUTOFBOUND;
|
||||
goto out;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ static int decode_and_print_memory(uint16_t card_size, const uint8_t *input_buff
|
||||
// for printing the complete segment we need at least wrc + wrp_len + remain_seg_payload_len bytes
|
||||
if ((i + wrc + wrp_len + remain_seg_payload_len) > card_size) {
|
||||
PrintAndLogEx(FAILED, "Cannot read segment body, because the input buffer is too small. "
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
return_value = PM3_EOUTOFBOUND;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -2049,7 +2049,7 @@ void annotateSeos(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is
|
||||
snprintf(exp, size, "CREATE ADF");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (memcmp(cmd + pos, "\x00\xD4\x00\x00\x00", 5) == 0) {
|
||||
snprintf(exp, size, "GET REMAINING CREDITS");
|
||||
return;
|
||||
@@ -2059,7 +2059,7 @@ void annotateSeos(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is
|
||||
snprintf(exp, size, "GET APPLET INFO");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (memcmp(cmd + pos, "\xA0\xD3\x00\x00\x00", 5) == 0) {
|
||||
snprintf(exp, size, "GET APPLET VERSION");
|
||||
return;
|
||||
@@ -2090,7 +2090,7 @@ void annotateSeos(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is
|
||||
return ;
|
||||
}
|
||||
|
||||
// CLA 0x90 Proprietary class - DESFire's "ISO 7816 wrap of native commands" indicator.
|
||||
// CLA 0x90 Proprietary class - DESFire's "ISO 7816 wrap of native commands" indicator.
|
||||
// Tells the card "the next byte is a DESFire native opcode, not an ISO 7816 standard INS."
|
||||
// INS 0x5A DESFire native opcode SelectApplication (3-byte AID).
|
||||
|
||||
|
||||
@@ -5049,7 +5049,7 @@ void printKeyTableEx(size_t sectorscnt, sector_t *e_sector, uint8_t start_sector
|
||||
_YELLOW_("H") ":Hardnested / "
|
||||
_YELLOW_("C") ":statiCnested / "
|
||||
_YELLOW_("A") ":keyA "
|
||||
" )"
|
||||
" )"
|
||||
);
|
||||
if (sectorscnt == 18) {
|
||||
PrintAndLogEx(INFO, "( " _MAGENTA_("*") " ) These sectors used for signature. Lays outside of user memory");
|
||||
|
||||
+56
-56
@@ -6387,9 +6387,9 @@ static int CmdHF14ADesClearRecordFile(const char *Cmd) {
|
||||
|
||||
/**
|
||||
* Parse MFC blocks given on the command line
|
||||
*
|
||||
*
|
||||
* If given for making the license, the blocks must be unique and in ascending order.
|
||||
*
|
||||
*
|
||||
* If given for the CreateMFCMapping command, the blocks must be unique and either all data blocks or all trailer blocks.
|
||||
*/
|
||||
static int parse_mfc_blocks(const char *in, uint8_t blocks_out[], size_t *blocks_out_len, bool for_license) {
|
||||
@@ -6398,7 +6398,7 @@ static int parse_mfc_blocks(const char *in, uint8_t blocks_out[], size_t *blocks
|
||||
}
|
||||
*blocks_out_len = 0;
|
||||
char blk_str[512];
|
||||
if (strlen(in) + 1 > sizeof (blk_str)) {
|
||||
if (strlen(in) + 1 > sizeof(blk_str)) {
|
||||
PrintAndLogEx(ERR, "Argument too long");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
@@ -6520,7 +6520,7 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
|
||||
PrintAndLogEx(ERR, "At most one instance of --key is required");
|
||||
goto mfclicense_parsing_error;
|
||||
}
|
||||
if (CLIParamHexToBuf(key_arg, mac_key, sizeof (mac_key), &mac_key_len) != 0) {
|
||||
if (CLIParamHexToBuf(key_arg, mac_key, sizeof(mac_key), &mac_key_len) != 0) {
|
||||
goto mfclicense_parsing_error;
|
||||
}
|
||||
if (mac_key_len != 16) {
|
||||
@@ -6529,15 +6529,15 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
|
||||
}
|
||||
|
||||
switch (mfc_keys_arg->count) {
|
||||
case 0:
|
||||
use_default_keys = true;
|
||||
break;
|
||||
case 1:
|
||||
use_default_keys = false;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(ERR, "At most instance of --mfc-keys is required");
|
||||
goto mfclicense_parsing_error;
|
||||
case 0:
|
||||
use_default_keys = true;
|
||||
break;
|
||||
case 1:
|
||||
use_default_keys = false;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(ERR, "At most instance of --mfc-keys is required");
|
||||
goto mfclicense_parsing_error;
|
||||
}
|
||||
|
||||
if (raw_arg->count + blk_str_arg->count != 1) {
|
||||
@@ -6546,7 +6546,7 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (has_raw) {
|
||||
if (CLIParamHexToBuf(raw_arg, license, sizeof (license), &license_len) != 0) {
|
||||
if (CLIParamHexToBuf(raw_arg, license, sizeof(license), &license_len) != 0) {
|
||||
goto mfclicense_parsing_error;
|
||||
}
|
||||
if (allow_key_a_update || allow_key_b_update || allow_restrict || allow_map || allow_ac) {
|
||||
@@ -6565,8 +6565,8 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
|
||||
int last_block = -1;
|
||||
|
||||
for (int i = 0; i < num_blocks; i++) {
|
||||
uint8_t block_nr = license[1 + 2*i];
|
||||
uint8_t permissions = license[1 + 2*i + 1];
|
||||
uint8_t block_nr = license[1 + 2 * i];
|
||||
uint8_t permissions = license[1 + 2 * i + 1];
|
||||
|
||||
if (block_nr / 4 != last_sector) {
|
||||
num_sectors++;
|
||||
@@ -6584,8 +6584,8 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
|
||||
goto mfclicense_parsing_error;
|
||||
}
|
||||
|
||||
if ( (((block_nr + 1) % 4 == 0) && (permissions & ~MFDES_EV3C_ALLOWED_TRAILER_PERMISSIONS)) ||
|
||||
(((block_nr + 1) % 4 != 0) && (permissions & ~MFDES_EV3C_ALLOWED_DATA_PERMISSIONS))) {
|
||||
if ((((block_nr + 1) % 4 == 0) && (permissions & ~MFDES_EV3C_ALLOWED_TRAILER_PERMISSIONS)) ||
|
||||
(((block_nr + 1) % 4 != 0) && (permissions & ~MFDES_EV3C_ALLOWED_DATA_PERMISSIONS))) {
|
||||
PrintAndLogEx(ERR, "Invalid permissions %02X", permissions);
|
||||
goto mfclicense_parsing_error;
|
||||
}
|
||||
@@ -6637,17 +6637,17 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
|
||||
last_sector = blocks[i] / 4;
|
||||
}
|
||||
|
||||
license[1 + 2*i] = blocks[i];
|
||||
license[1 + 2 * i] = blocks[i];
|
||||
if ((blocks[i] + 1) % 4 == 0) {
|
||||
// mapping a trailer block
|
||||
license[1 + 2*i + 1] = trailer_permissions;
|
||||
license[1 + 2 * i + 1] = trailer_permissions;
|
||||
} else {
|
||||
// mapping a data block
|
||||
license[1 + 2*i + 1] = data_permissions;
|
||||
license[1 + 2 * i + 1] = data_permissions;
|
||||
}
|
||||
PrintAndLogEx(loglevel, "[%d] Block %d: permissions %02X", i, license[1 + 2*i], license[1 + 2*i + 1]);
|
||||
PrintAndLogEx(loglevel, "[%d] Block %d: permissions %02X", i, license[1 + 2 * i], license[1 + 2 * i + 1]);
|
||||
}
|
||||
license_len = 1 + 2*num_blocks;
|
||||
license_len = 1 + 2 * num_blocks;
|
||||
}
|
||||
|
||||
PrintAndLogEx(loglevel, "Covering %lu sector%s in total", num_sectors, num_sectors != 1 ? "s" : "");
|
||||
@@ -6657,7 +6657,7 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
|
||||
memset(mfc_keys, '\xFF', 6 * num_sectors);
|
||||
mfc_keys_len = 6 * num_sectors;
|
||||
} else {
|
||||
if (CLIParamHexToBuf(mfc_keys_arg, mfc_keys, sizeof (mfc_keys), &mfc_keys_len) != 0) {
|
||||
if (CLIParamHexToBuf(mfc_keys_arg, mfc_keys, sizeof(mfc_keys), &mfc_keys_len) != 0) {
|
||||
goto mfclicense_parsing_error;
|
||||
}
|
||||
if (mfc_keys_len % 6 != 0) {
|
||||
@@ -7940,8 +7940,8 @@ static int MfdSelectionSelectApplication(DesfireContext_t *dctx, const mfd_app_s
|
||||
// Assumes the application is already selected.
|
||||
// On PM3_SUCCESS: out_card_random[DUOX_INTAUTH_CHALLENGE_LEN] and out_sig_rs[DUOX_INTAUTH_SIG_LEN] are filled.
|
||||
static int duox_intauth_exchange(bool apdu_logging, bool verbose, uint8_t keynum,
|
||||
const uint8_t *challenge,
|
||||
uint8_t *out_card_random, uint8_t *out_sig_rs) {
|
||||
const uint8_t *challenge,
|
||||
uint8_t *out_card_random, uint8_t *out_sig_rs) {
|
||||
// Build ISO Internal Authenticate APDU
|
||||
//
|
||||
// Data field:
|
||||
@@ -8062,8 +8062,8 @@ static int duox_intauth_exchange(bool apdu_logging, bool verbose, uint8_t keynum
|
||||
// Build the Internal Authenticate verify message (F0F0 || OptsA || RndB || RndA)
|
||||
// and verify the ECDSA-P256-SHA256 signature. Returns PM3_SUCCESS if valid.
|
||||
static int duox_intauth_verify_sig(bool verbose, const uint8_t *pubkey_point,
|
||||
const uint8_t *challenge, const uint8_t *card_random,
|
||||
const uint8_t *sig_rs) {
|
||||
const uint8_t *challenge, const uint8_t *card_random,
|
||||
const uint8_t *sig_rs) {
|
||||
// Message = F0F0 || OptsA TLV || RndB (card random) || RndA (our challenge)
|
||||
static const uint8_t optsa_tlv[] = {DUOX_TAG_OPTSA, 0x00};
|
||||
uint8_t message[2 + 2 + DUOX_INTAUTH_CHALLENGE_LEN + DUOX_INTAUTH_CHALLENGE_LEN];
|
||||
@@ -8075,16 +8075,16 @@ static int duox_intauth_verify_sig(bool verbose, const uint8_t *pubkey_point,
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Verify msg... %s", sprint_hex_inrow(message, sizeof(message)));
|
||||
|
||||
|
||||
return ecdsa_signature_r_s_verify(
|
||||
MBEDTLS_ECP_DP_SECP256R1,
|
||||
(uint8_t *)pubkey_point,
|
||||
message,
|
||||
(int)sizeof(message),
|
||||
(uint8_t *)sig_rs,
|
||||
DUOX_INTAUTH_SIG_LEN,
|
||||
true // hash message with SHA-256 before verifying
|
||||
);
|
||||
MBEDTLS_ECP_DP_SECP256R1,
|
||||
(uint8_t *)pubkey_point,
|
||||
message,
|
||||
(int)sizeof(message),
|
||||
(uint8_t *)sig_rs,
|
||||
DUOX_INTAUTH_SIG_LEN,
|
||||
true // hash message with SHA-256 before verifying
|
||||
);
|
||||
}
|
||||
|
||||
static int CmdHF14ADesIntAuth(const char *Cmd) {
|
||||
@@ -8356,14 +8356,14 @@ static int CmdHF14ADesVdeSign(const char *Cmd) {
|
||||
PrintAndLogEx(INFO, "Verify msg... %s", sprint_hex_inrow(challenge, sizeof(challenge)));
|
||||
|
||||
int sig_res = ecdsa_signature_r_s_verify(
|
||||
MBEDTLS_ECP_DP_BP256R1,
|
||||
pubkey_point,
|
||||
challenge,
|
||||
(int)sizeof(challenge),
|
||||
signature_rs,
|
||||
sizeof(signature_rs),
|
||||
true
|
||||
);
|
||||
MBEDTLS_ECP_DP_BP256R1,
|
||||
pubkey_point,
|
||||
challenge,
|
||||
(int)sizeof(challenge),
|
||||
signature_rs,
|
||||
sizeof(signature_rs),
|
||||
true
|
||||
);
|
||||
|
||||
if (sig_res == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "ECDSA signature " _GREEN_("verified"));
|
||||
@@ -8704,9 +8704,9 @@ static int mfdes_verify_certificate_variants(const uint8_t *data, size_t data_le
|
||||
bool verbose, mfdes_verified_cert_t *out, size_t *matched_index) {
|
||||
duox_cert_info_t cert = {0};
|
||||
int res = duox_parse_or_verify_certificate_variants(data, data_len,
|
||||
ca_anchors, ca_anchor_count,
|
||||
verify_signature,
|
||||
verbose, &cert, matched_index);
|
||||
ca_anchors, ca_anchor_count,
|
||||
verify_signature,
|
||||
verbose, &cert, matched_index);
|
||||
if (res == PM3_SUCCESS || res == PM3_ECRYPTO) {
|
||||
mfdes_cert_info_from_duox(&cert, out);
|
||||
}
|
||||
@@ -9170,11 +9170,11 @@ static int CmdHF14ADesVerifyCert(const char *Cmd) {
|
||||
DesfireContext_t dctx = {0};
|
||||
int securechann = defaultSecureChannel;
|
||||
res = CmdDesGetSessionParameters(ctx, &dctx,
|
||||
4, 5, 6, 7, 8, 9, 10, 11,
|
||||
0, 0, 0,
|
||||
&securechann,
|
||||
force_auth ? DCMMACed : DCMPlain,
|
||||
NULL, NULL);
|
||||
4, 5, 6, 7, 8, 9, 10, 11,
|
||||
0, 0, 0,
|
||||
&securechann,
|
||||
force_auth ? DCMMACed : DCMPlain,
|
||||
NULL, NULL);
|
||||
if (res) {
|
||||
CLIParserFree(ctx);
|
||||
return res;
|
||||
@@ -9284,7 +9284,7 @@ static int CmdHF14ADesVerifyCert(const char *Cmd) {
|
||||
DesfireSetKeyNoClear(&aes_dctx, aes_dctx.keyNum, T_AES, zero_key);
|
||||
cert_buf_len = 0;
|
||||
int read_res = mfdes_read_cert_file_desfire(&aes_dctx, (DesfireSecureChannel)securechann, cert_fid,
|
||||
false, true, verbose, cert_buf, &cert_buf_len);
|
||||
false, true, verbose, cert_buf, &cert_buf_len);
|
||||
if (read_res == PM3_SUCCESS && cert_buf_len > 0) {
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, " retry file size....: " _YELLOW_("%zu bytes"), cert_buf_len);
|
||||
@@ -9338,8 +9338,8 @@ static int CmdHF14ADesVerifyCert(const char *Cmd) {
|
||||
}
|
||||
|
||||
res = mfdes_run_key_possession_verification(APDULogging, verbose, validate_methods,
|
||||
validate_method_count, validate_method_forced,
|
||||
&key_select, keyidx, &cert_info);
|
||||
validate_method_count, validate_method_forced,
|
||||
&key_select, keyidx, &cert_info);
|
||||
if (res != PM3_SUCCESS) {
|
||||
retval = res;
|
||||
goto out;
|
||||
|
||||
+17
-17
@@ -867,7 +867,7 @@ static bool ndef_detect_message(const uint8_t *d, uint16_t n) {
|
||||
|
||||
// start at OTP block and detect a CC container instead
|
||||
const uint8_t *p = d + (3 * MFU_BLOCK_SIZE);
|
||||
|
||||
|
||||
// no NDEF capability container
|
||||
if (p[0] != 0xE1 && p[0] != 0xF1) {
|
||||
return false;
|
||||
@@ -3451,22 +3451,22 @@ void mfu_print_dump(mfu_dump_t *card, uint16_t pages, uint8_t startpage, bool de
|
||||
if (i == 3) {
|
||||
// otp block
|
||||
PrintAndLogEx(INFO, "%3d/0x%02X | " _CYAN_("%s")"| %s | %s"
|
||||
, i + startpage
|
||||
, i + startpage
|
||||
, sprint_hex(data + i * 4, 4)
|
||||
, lckbitchar
|
||||
, sprint_ascii(data + i * 4, 4)
|
||||
);
|
||||
, i + startpage
|
||||
, i + startpage
|
||||
, sprint_hex(data + i * 4, 4)
|
||||
, lckbitchar
|
||||
, sprint_ascii(data + i * 4, 4)
|
||||
);
|
||||
|
||||
} else {
|
||||
// normal block
|
||||
PrintAndLogEx(INFO, "%3d/0x%02X | %s| %s | %s"
|
||||
, i + startpage
|
||||
, i + startpage
|
||||
, sprint_hex(data + i * 4, 4)
|
||||
, lckbitchar
|
||||
, sprint_ascii(data + i * 4, 4)
|
||||
);
|
||||
, i + startpage
|
||||
, i + startpage
|
||||
, sprint_hex(data + i * 4, 4)
|
||||
, lckbitchar
|
||||
, sprint_ascii(data + i * 4, 4)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5935,7 +5935,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) {
|
||||
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t *)&payload, sizeof(payload));
|
||||
if (WaitForResponseTimeout(CMD_HF_MFU_COUNTER_TEAROFF, &resp, 2000) == false) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(WARNING, "\nTear off command failed");
|
||||
@@ -6057,7 +6057,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) {
|
||||
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t *)&payload, sizeof(payload));
|
||||
if (WaitForResponseTimeout(CMD_HF_MFU_COUNTER_TEAROFF, &resp, 2000) == false) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(WARNING, "\nTear off command failed");
|
||||
@@ -6146,7 +6146,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) {
|
||||
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t *)&payload, sizeof(payload));
|
||||
if (WaitForResponseTimeout(CMD_HF_MFU_COUNTER_TEAROFF, &resp, 2000) == false) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(WARNING, "\nTear off command failed");
|
||||
@@ -6168,7 +6168,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) {
|
||||
memcpy(payload.value, (uint8_t[]) {0x00, 0x00, 0x00}, sizeof(payload.value));
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t *)&payload, sizeof(payload));
|
||||
if (WaitForResponseTimeout(CMD_HF_MFU_COUNTER_TEAROFF, &resp, 2000) == false) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(WARNING, "\nTear off command failed");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user