This commit is contained in:
iceman1001 2022-10-29 01:26:12 +02:00
commit 3f92d5ee67
7 changed files with 803 additions and 803 deletions

View file

@ -595,41 +595,41 @@ int EPA_Setup(void) {
void EPA_PACE_Simulate(PacketCommandNG *c) { void EPA_PACE_Simulate(PacketCommandNG *c) {
//---------Initializing--------- //---------Initializing---------
// Get password from arguments // Get password from arguments
unsigned char pwd[6]; unsigned char pwd[6];
memcpy(pwd, c->data.asBytes, 6); memcpy(pwd, c->data.asBytes, 6);
// Set up communication with the card // Set up communication with the card
int res = EPA_Setup(); int res = EPA_Setup();
if (res != 0){ if (res != 0) {
EPA_PACE_Collect_Nonce_Abort(CMD_HF_EPA_PACE_SIMULATE, 1, res); EPA_PACE_Collect_Nonce_Abort(CMD_HF_EPA_PACE_SIMULATE, 1, res);
return; return;
} }
// Read EF.CardAccess // Read EF.CardAccess
uint8_t card_access[210] = {0}; uint8_t card_access[210] = {0};
int card_access_length = EPA_Read_CardAccess(card_access, 210); int card_access_length = EPA_Read_CardAccess(card_access, 210);
// The response has to be at least this big to hold the OID // The response has to be at least this big to hold the OID
if (card_access_length < 18) { if (card_access_length < 18) {
EPA_PACE_Collect_Nonce_Abort(CMD_HF_EPA_PACE_SIMULATE, 2, card_access_length); EPA_PACE_Collect_Nonce_Abort(CMD_HF_EPA_PACE_SIMULATE, 2, card_access_length);
return; return;
} }
// PACEInfo of the card // PACEInfo of the card
pace_version_info_t pace_version_info; pace_version_info_t pace_version_info;
// Search for the PACE OID // Search for the PACE OID
res = EPA_Parse_CardAccess(card_access, card_access_length, &pace_version_info); res = EPA_Parse_CardAccess(card_access, card_access_length, &pace_version_info);
if (res != 0 || pace_version_info.version == 0) { if (res != 0 || pace_version_info.version == 0) {
EPA_PACE_Collect_Nonce_Abort(CMD_HF_EPA_PACE_SIMULATE, 3, res); EPA_PACE_Collect_Nonce_Abort(CMD_HF_EPA_PACE_SIMULATE, 3, res);
return; return;
} }
Dbprintf("Standardized Domain Parameter: %i", pace_version_info.parameter_id); Dbprintf("Standardized Domain Parameter: %i", pace_version_info.parameter_id);
DbpString(""); DbpString("");
DbpString("finished"); DbpString("finished");
} }

View file

@ -578,18 +578,18 @@ int rdv40_spiffs_make_symlink(char *linkdest, char *filename, RDV40SpiFFSSafetyL
int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, RDV40SpiFFSSafetyLevel level) { int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, RDV40SpiFFSSafetyLevel level) {
RDV40_SPIFFS_SAFE_FUNCTION( RDV40_SPIFFS_SAFE_FUNCTION(
RDV40SpiFFSFileType filetype = filetype_in_spiffs((char *)filename); RDV40SpiFFSFileType filetype = filetype_in_spiffs((char *)filename);
switch (filetype) { switch (filetype) {
case RDV40_SPIFFS_FILETYPE_REAL: case RDV40_SPIFFS_FILETYPE_REAL:
rdv40_spiffs_read((char *)filename, (uint8_t *)dst, size, level); rdv40_spiffs_read((char *)filename, (uint8_t *)dst, size, level);
break; break;
case RDV40_SPIFFS_FILETYPE_SYMLINK: case RDV40_SPIFFS_FILETYPE_SYMLINK:
rdv40_spiffs_read_as_symlink(filename, (uint8_t *)dst, size, level); rdv40_spiffs_read_as_symlink(filename, (uint8_t *)dst, size, level);
break; break;
case RDV40_SPIFFS_FILETYPE_BOTH: case RDV40_SPIFFS_FILETYPE_BOTH:
case RDV40_SPIFFS_FILETYPE_UNKNOWN: case RDV40_SPIFFS_FILETYPE_UNKNOWN:
default: default:
break; break;
} }
) )
} }

View file

@ -106,7 +106,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
CLIParserInit(&ctx, "hf epa replay", CLIParserInit(&ctx, "hf epa replay",
"Perform PACE protocol by replaying given APDUs", "Perform PACE protocol by replaying given APDUs",
"hf epa replay --mse 0022C1A4 --get 1068000000 --map 1086000002 --pka 1234ABCDEF --ma 1A2B3C4D" "hf epa replay --mse 0022C1A4 --get 1068000000 --map 1086000002 --pka 1234ABCDEF --ma 1A2B3C4D"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -216,7 +216,7 @@ static int CmdHFEPAPACESimulate(const char *Cmd) {
"The crypto is performed on pc or proxmark", "The crypto is performed on pc or proxmark",
"hf epa sim --pwd 112233445566\n" "hf epa sim --pwd 112233445566\n"
"hf epa sim --pc --pty 1 --pwd 112233445566" "hf epa sim --pc --pty 1 --pwd 112233445566"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -236,36 +236,36 @@ static int CmdHFEPAPACESimulate(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
PrintAndLogEx(INFO, "Starting PACE simulation..."); PrintAndLogEx(INFO, "Starting PACE simulation...");
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(CMD_HF_EPA_PACE_SIMULATE, 0, 0, 0, pwd, plen); SendCommandMIX(CMD_HF_EPA_PACE_SIMULATE, 0, 0, 0, pwd, plen);
PacketResponseNG resp; PacketResponseNG resp;
WaitForResponse(CMD_ACK, &resp); WaitForResponse(CMD_ACK, &resp);
uint32_t *data = resp.data.asDwords; uint32_t *data = resp.data.asDwords;
if (resp.oldarg[0] != 0) { if (resp.oldarg[0] != 0) {
PrintAndLogEx(INFO, "\nPACE failed in step %u!", (uint32_t)resp.oldarg[0]); PrintAndLogEx(INFO, "\nPACE failed in step %u!", (uint32_t)resp.oldarg[0]);
PrintAndLogEx(INFO, "MSE Set AT: %u us", data[0]); PrintAndLogEx(INFO, "MSE Set AT: %u us", data[0]);
PrintAndLogEx(INFO, "GA Get Nonce: %u us", data[1]); PrintAndLogEx(INFO, "GA Get Nonce: %u us", data[1]);
PrintAndLogEx(INFO, "GA Map Nonce: %u us", data[2]); PrintAndLogEx(INFO, "GA Map Nonce: %u us", data[2]);
PrintAndLogEx(INFO, "GA Perform Key Agreement: %u us", data[3]); PrintAndLogEx(INFO, "GA Perform Key Agreement: %u us", data[3]);
PrintAndLogEx(INFO, "GA Mutual Authenticate: %u us", data[4]); PrintAndLogEx(INFO, "GA Mutual Authenticate: %u us", data[4]);
PrintAndLogEx(INFO, "----------------"); PrintAndLogEx(INFO, "----------------");
} else { } else {
PrintAndLogEx(INFO, "PACE successful!"); PrintAndLogEx(INFO, "PACE successful!");
PrintAndLogEx(INFO, "MSE Set AT: %u us", data[0]); PrintAndLogEx(INFO, "MSE Set AT: %u us", data[0]);
PrintAndLogEx(INFO, "GA Get Nonce: %u us", data[1]); PrintAndLogEx(INFO, "GA Get Nonce: %u us", data[1]);
PrintAndLogEx(INFO, "GA Map Nonce: %u us", data[2]); PrintAndLogEx(INFO, "GA Map Nonce: %u us", data[2]);
PrintAndLogEx(INFO, "GA Perform Key Agreement: %u us", data[3]); PrintAndLogEx(INFO, "GA Perform Key Agreement: %u us", data[3]);
PrintAndLogEx(INFO, "GA Mutual Authenticate: %u us", data[4]); PrintAndLogEx(INFO, "GA Mutual Authenticate: %u us", data[4]);
PrintAndLogEx(INFO, "----------------"); PrintAndLogEx(INFO, "----------------");
} }
return PM3_SUCCESS; return PM3_SUCCESS;
} }