mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
remove spurious spaces & tabs at end of lines
This commit is contained in:
parent
edc19f202a
commit
60f292b18e
249 changed files with 8481 additions and 8481 deletions
|
@ -50,17 +50,17 @@
|
|||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int CmdHFFidoInfo(const char *cmd) {
|
||||
|
||||
|
||||
if (cmd && strlen(cmd) > 0)
|
||||
PrintAndLog("WARNING: command don't have any parameters.\n");
|
||||
|
||||
|
||||
// info about 14a part
|
||||
CmdHF14AInfo("");
|
||||
|
||||
// FIDO info
|
||||
PrintAndLog("--------------------------------------------");
|
||||
PrintAndLog("--------------------------------------------");
|
||||
SetAPDULogging(false);
|
||||
|
||||
|
||||
uint8_t buf[APDU_RES_LEN] = {0};
|
||||
size_t len = 0;
|
||||
uint16_t sw = 0;
|
||||
|
@ -70,27 +70,27 @@ int CmdHFFidoInfo(const char *cmd) {
|
|||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
if (sw)
|
||||
PrintAndLog("Not a FIDO card! APDU response: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("Not a FIDO card! APDU response: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
else
|
||||
PrintAndLog("APDU exchange error. Card returns 0x0000.");
|
||||
|
||||
PrintAndLog("APDU exchange error. Card returns 0x0000.");
|
||||
|
||||
DropField();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!strncmp((char *)buf, "U2F_V2", 7)) {
|
||||
if (!strncmp((char *)buf, "FIDO_2_0", 8)) {
|
||||
PrintAndLog("FIDO2 authenricator detected. Version: %.*s", len, buf);
|
||||
PrintAndLog("FIDO2 authenricator detected. Version: %.*s", len, buf);
|
||||
} else {
|
||||
PrintAndLog("FIDO authenricator detected (not standard U2F).");
|
||||
PrintAndLog("Non U2F authenticator version:");
|
||||
PrintAndLog("FIDO authenricator detected (not standard U2F).");
|
||||
PrintAndLog("Non U2F authenticator version:");
|
||||
dump_buffer((const unsigned char *)buf, len, NULL, 0);
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("FIDO U2F authenricator detected. Version: %.*s", len, buf);
|
||||
PrintAndLog("FIDO U2F authenricator detected. Version: %.*s", len, buf);
|
||||
}
|
||||
|
||||
res = FIDO2GetInfo(buf, sizeof(buf), &len, &sw);
|
||||
|
@ -99,32 +99,32 @@ int CmdHFFidoInfo(const char *cmd) {
|
|||
return res;
|
||||
}
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("FIDO2 version not exists (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
|
||||
PrintAndLog("FIDO2 version not exists (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if(buf[0]) {
|
||||
PrintAndLog("FIDO2 ger version error: %d - %s", buf[0], fido2GetCmdErrorDescription(buf[0]));
|
||||
PrintAndLog("FIDO2 ger version error: %d - %s", buf[0], fido2GetCmdErrorDescription(buf[0]));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len > 1) {
|
||||
// if (false) {
|
||||
// PrintAndLog("FIDO2 version: (len=%d)", len);
|
||||
// PrintAndLog("FIDO2 version: (len=%d)", len);
|
||||
// dump_buffer((const unsigned char *)buf, len, NULL, 0);
|
||||
// }
|
||||
|
||||
PrintAndLog("FIDO2 version CBOR decoded:");
|
||||
PrintAndLog("FIDO2 version CBOR decoded:");
|
||||
TinyCborPrintFIDOPackage(fido2CmdGetInfo, true, &buf[1], len - 1);
|
||||
} else {
|
||||
PrintAndLog("FIDO2 version length error");
|
||||
PrintAndLog("FIDO2 version length error");
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
json_t *OpenJson(int paramnum, char *fname, void* argtable[], bool *err) {
|
||||
json_t *OpenJson(int paramnum, char *fname, void* argtable[], bool *err) {
|
||||
json_t *root = NULL;
|
||||
json_error_t error;
|
||||
*err = false;
|
||||
|
@ -132,17 +132,17 @@ json_t *OpenJson(int paramnum, char *fname, void* argtable[], bool *err) {
|
|||
uint8_t jsonname[250] ={0};
|
||||
char *cjsonname = (char *)jsonname;
|
||||
int jsonnamelen = 0;
|
||||
|
||||
|
||||
// CLIGetStrWithReturn(paramnum, jsonname, &jsonnamelen);
|
||||
if (CLIParamStrToBuf(arg_get_str(paramnum), jsonname, sizeof(jsonname), &jsonnamelen)) {
|
||||
CLIParserFree();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// current path + file name
|
||||
if (!strstr(cjsonname, ".json"))
|
||||
strcat(cjsonname, ".json");
|
||||
|
||||
|
||||
if (jsonnamelen) {
|
||||
strcpy(fname, get_my_executable_directory());
|
||||
strcat(fname, cjsonname);
|
||||
|
@ -151,16 +151,16 @@ json_t *OpenJson(int paramnum, char *fname, void* argtable[], bool *err) {
|
|||
if (!root) {
|
||||
PrintAndLog("ERROR: json error on line %d: %s", error.line, error.text);
|
||||
*err = true;
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!json_is_object(root)) {
|
||||
PrintAndLog("ERROR: Invalid json format. root must be an object.");
|
||||
json_decref(root);
|
||||
*err = true;
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
root = json_object();
|
||||
}
|
||||
|
@ -175,9 +175,9 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
int applen = 0;
|
||||
uint8_t adata[250] = {0};
|
||||
json_t *root = NULL;
|
||||
|
||||
CLIParserInit("hf fido reg",
|
||||
"Initiate a U2F token registration. Needs two 32-byte hash number. \nchallenge parameter (32b) and application parameter (32b).",
|
||||
|
||||
CLIParserInit("hf fido reg",
|
||||
"Initiate a U2F token registration. Needs two 32-byte hash number. \nchallenge parameter (32b) and application parameter (32b).",
|
||||
"Usage:\n\thf fido reg -> execute command with 2 parameters, filled 0x00\n"
|
||||
"\thf fido reg 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f -> execute command with parameters"
|
||||
"\thf fido reg -p s0 s1 -> execute command with plain parameters");
|
||||
|
@ -194,7 +194,7 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(cmd, argtable, true);
|
||||
|
||||
|
||||
bool APDULogging = arg_get_lit(1);
|
||||
bool verbose = arg_get_lit(2);
|
||||
bool verbose2 = arg_get_lit(2) > 1;
|
||||
|
@ -206,12 +206,12 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
root = OpenJson(5, fname, argtable, &err);
|
||||
if(err)
|
||||
return 1;
|
||||
if (root) {
|
||||
if (root) {
|
||||
size_t jlen;
|
||||
JsonLoadBufAsHex(root, "$.ChallengeParam", data, 32, &jlen);
|
||||
JsonLoadBufAsHex(root, "$.ApplicationParam", &data[32], 32, &jlen);
|
||||
}
|
||||
|
||||
|
||||
if (paramsPlain) {
|
||||
memset(cdata, 0x00, 32);
|
||||
CLIGetStrWithReturn(6, cdata, &chlen);
|
||||
|
@ -228,8 +228,8 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
}
|
||||
if (chlen)
|
||||
memmove(data, cdata, 32);
|
||||
|
||||
|
||||
|
||||
|
||||
if (paramsPlain) {
|
||||
memset(adata, 0x00, 32);
|
||||
CLIGetStrWithReturn(7, adata, &applen);
|
||||
|
@ -246,14 +246,14 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
}
|
||||
if (applen)
|
||||
memmove(&data[32], adata, 32);
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
SetAPDULogging(APDULogging);
|
||||
|
||||
// challenge parameter [32 bytes] - The challenge parameter is the SHA-256 hash of the Client Data, a stringified JSON data structure that the FIDO Client prepares
|
||||
// application parameter [32 bytes] - The application parameter is the SHA-256 hash of the UTF-8 encoding of the application identity
|
||||
|
||||
|
||||
uint8_t buf[2048] = {0};
|
||||
size_t len = 0;
|
||||
uint16_t sw = 0;
|
||||
|
@ -266,9 +266,9 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
DropField();
|
||||
return 2;
|
||||
}
|
||||
|
@ -279,12 +279,12 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
PrintAndLog("Can't execute register command. res=%x. Exit...", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("ERROR execute register command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("ERROR execute register command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLog("");
|
||||
if (APDULogging)
|
||||
PrintAndLog("---------------------------------------------------------------");
|
||||
|
@ -300,10 +300,10 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
return 5;
|
||||
}
|
||||
PrintAndLog("User public key: %s", sprint_hex(&buf[1], 65));
|
||||
|
||||
|
||||
uint8_t keyHandleLen = buf[66];
|
||||
PrintAndLog("Key handle[%d]: %s", keyHandleLen, sprint_hex(&buf[67], keyHandleLen));
|
||||
|
||||
|
||||
int derp = 67 + keyHandleLen;
|
||||
int derLen = (buf[derp + 2] << 8) + buf[derp + 3] + 4;
|
||||
if (verbose2) {
|
||||
|
@ -315,26 +315,26 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
PrintAndLog("------------------DER-------------------");
|
||||
PrintAndLog("DER certificate[%d]: %s...", derLen, sprint_hex(&buf[derp], 20));
|
||||
}
|
||||
|
||||
|
||||
// check and print DER certificate
|
||||
uint8_t public_key[65] = {0};
|
||||
|
||||
|
||||
// print DER certificate in TLV view
|
||||
if (showDERTLV) {
|
||||
PrintAndLog("----------------DER TLV-----------------");
|
||||
asn1_print(&buf[derp], derLen, " ");
|
||||
PrintAndLog("----------------DER TLV-----------------");
|
||||
}
|
||||
|
||||
|
||||
FIDOCheckDERAndGetKey(&buf[derp], derLen, verbose, public_key, sizeof(public_key));
|
||||
|
||||
|
||||
// get hash
|
||||
int hashp = 1 + 65 + 1 + keyHandleLen + derLen;
|
||||
PrintAndLog("Hash[%d]: %s", len - hashp, sprint_hex(&buf[hashp], len - hashp));
|
||||
|
||||
// check ANSI X9.62 format ECDSA signature (on P-256)
|
||||
uint8_t rval[300] = {0};
|
||||
uint8_t sval[300] = {0};
|
||||
uint8_t rval[300] = {0};
|
||||
uint8_t sval[300] = {0};
|
||||
res = ecdsa_asn1_get_signature(&buf[hashp], len - hashp, rval, sval);
|
||||
if (!res) {
|
||||
if (verbose) {
|
||||
|
@ -346,7 +346,7 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
size_t xbuflen = 0;
|
||||
res = FillBuffer(xbuf, sizeof(xbuf), &xbuflen,
|
||||
"\x00", 1,
|
||||
&data[32], 32, // application parameter
|
||||
&data[32], 32, // application parameter
|
||||
&data[0], 32, // challenge parameter
|
||||
&buf[67], keyHandleLen, // keyHandle
|
||||
&buf[1], 65, // user public key
|
||||
|
@ -362,11 +362,11 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
} else {
|
||||
PrintAndLog("Signature is OK.");
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
PrintAndLog("Invalid signature. res=%d.", res);
|
||||
}
|
||||
|
||||
|
||||
PrintAndLog("\nauth command: ");
|
||||
printf("hf fido auth %s%s", paramsPlain?"-p ":"", sprint_hex_inrow(&buf[67], keyHandleLen));
|
||||
if(chlen || applen)
|
||||
|
@ -374,7 +374,7 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
if(applen)
|
||||
printf(" %s", paramsPlain?(char *)adata:sprint_hex_inrow(adata, 32));
|
||||
printf("\n");
|
||||
|
||||
|
||||
if (root) {
|
||||
JsonSaveBufAsHex(root, "ChallengeParam", data, 32);
|
||||
JsonSaveBufAsHex(root, "ApplicationParam", &data[32], 32);
|
||||
|
@ -382,18 +382,18 @@ int CmdHFFidoRegister(const char *cmd) {
|
|||
JsonSaveInt(root, "KeyHandleLen", keyHandleLen);
|
||||
JsonSaveBufAsHexCompact(root, "KeyHandle", &buf[67], keyHandleLen);
|
||||
JsonSaveBufAsHexCompact(root, "DER", &buf[67 + keyHandleLen], derLen);
|
||||
|
||||
|
||||
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||
if (res) {
|
||||
PrintAndLog("ERROR: can't save the file: %s", fname);
|
||||
return 200;
|
||||
}
|
||||
PrintAndLog("File `%s` saved.", fname);
|
||||
|
||||
|
||||
// free json object
|
||||
json_decref(root);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
@ -401,13 +401,13 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
uint8_t data[512] = {0};
|
||||
uint8_t hdata[250] = {0};
|
||||
bool public_key_loaded = false;
|
||||
uint8_t public_key[65] = {0};
|
||||
uint8_t public_key[65] = {0};
|
||||
int hdatalen = 0;
|
||||
uint8_t keyHandleLen = 0;
|
||||
json_t *root = NULL;
|
||||
|
||||
CLIParserInit("hf fido auth",
|
||||
"Initiate a U2F token authentication. Needs key handle and two 32-byte hash number. \nkey handle(var 0..255), challenge parameter (32b) and application parameter (32b).",
|
||||
|
||||
CLIParserInit("hf fido auth",
|
||||
"Initiate a U2F token authentication. Needs key handle and two 32-byte hash number. \nkey handle(var 0..255), challenge parameter (32b) and application parameter (32b).",
|
||||
"Usage:\n\thf fido auth 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f -> execute command with 2 parameters, filled 0x00 and key handle\n"
|
||||
"\thf fido auth 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f "
|
||||
"000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f -> execute command with parameters");
|
||||
|
@ -428,7 +428,7 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(cmd, argtable, true);
|
||||
|
||||
|
||||
bool APDULogging = arg_get_lit(1);
|
||||
bool verbose = arg_get_lit(2);
|
||||
bool paramsPlain = arg_get_lit(3);
|
||||
|
@ -443,7 +443,7 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
root = OpenJson(7, fname, argtable, &err);
|
||||
if(err)
|
||||
return 1;
|
||||
if (root) {
|
||||
if (root) {
|
||||
size_t jlen;
|
||||
JsonLoadBufAsHex(root, "$.ChallengeParam", data, 32, &jlen);
|
||||
JsonLoadBufAsHex(root, "$.ApplicationParam", &data[32], 32, &jlen);
|
||||
|
@ -452,7 +452,7 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
data[64] = keyHandleLen;
|
||||
JsonLoadBufAsHex(root, "$.PublicKey", public_key, 65, &jlen);
|
||||
public_key_loaded = (jlen > 0);
|
||||
}
|
||||
}
|
||||
|
||||
// public key
|
||||
CLIGetHexWithReturn(8, hdata, &hdatalen);
|
||||
|
@ -463,8 +463,8 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
if (hdatalen) {
|
||||
memmove(public_key, hdata, hdatalen);
|
||||
public_key_loaded = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CLIGetHexWithReturn(9, hdata, &hdatalen);
|
||||
if (hdatalen > 255) {
|
||||
PrintAndLog("ERROR: application parameter length must be less than 255.");
|
||||
|
@ -510,8 +510,8 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
if (hdatalen)
|
||||
memmove(&data[32], hdata, 32);
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
SetAPDULogging(APDULogging);
|
||||
|
||||
// (in parameter) conrtol byte 0x07 - check only, 0x03 - user presense + cign. 0x08 - sign only
|
||||
|
@ -521,7 +521,7 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
// key handle [N]
|
||||
|
||||
uint8_t datalen = 32 + 32 + 1 + keyHandleLen;
|
||||
|
||||
|
||||
uint8_t buf[2048] = {0};
|
||||
size_t len = 0;
|
||||
uint16_t sw = 0;
|
||||
|
@ -534,9 +534,9 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
DropField();
|
||||
return 2;
|
||||
}
|
||||
|
@ -547,12 +547,12 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
PrintAndLog("Can't execute authentication command. res=%x. Exit...", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("ERROR execute authentication command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("ERROR execute authentication command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLog("---------------------------------------------------------------");
|
||||
PrintAndLog("User presence: %s", (buf[0]?"verified":"not verified"));
|
||||
uint32_t cntr = (uint32_t)bytes_to_num(&buf[1], 4);
|
||||
|
@ -560,8 +560,8 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
PrintAndLog("Hash[%d]: %s", len - 5, sprint_hex(&buf[5], len - 5));
|
||||
|
||||
// check ANSI X9.62 format ECDSA signature (on P-256)
|
||||
uint8_t rval[300] = {0};
|
||||
uint8_t sval[300] = {0};
|
||||
uint8_t rval[300] = {0};
|
||||
uint8_t sval[300] = {0};
|
||||
res = ecdsa_asn1_get_signature(&buf[5], len - 5, rval, sval);
|
||||
if (!res) {
|
||||
if (verbose) {
|
||||
|
@ -588,27 +588,27 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
} else {
|
||||
PrintAndLog("Signature is OK.");
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
PrintAndLog("No public key provided. can't check signature.");
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("Invalid signature. res=%d.", res);
|
||||
}
|
||||
|
||||
|
||||
if (root) {
|
||||
JsonSaveBufAsHex(root, "ChallengeParam", data, 32);
|
||||
JsonSaveBufAsHex(root, "ApplicationParam", &data[32], 32);
|
||||
JsonSaveInt(root, "KeyHandleLen", keyHandleLen);
|
||||
JsonSaveBufAsHexCompact(root, "KeyHandle", &data[65], keyHandleLen);
|
||||
JsonSaveInt(root, "Counter", cntr);
|
||||
|
||||
|
||||
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||
if (res) {
|
||||
PrintAndLog("ERROR: can't save the file: %s", fname);
|
||||
return 200;
|
||||
}
|
||||
PrintAndLog("File `%s` saved.", fname);
|
||||
|
||||
|
||||
// free json object
|
||||
json_decref(root);
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ int CmdHFFidoAuthenticate(const char *cmd) {
|
|||
};
|
||||
|
||||
void CheckSlash(char *fileName) {
|
||||
if ((fileName[strlen(fileName) - 1] != '/') &&
|
||||
if ((fileName[strlen(fileName) - 1] != '/') &&
|
||||
(fileName[strlen(fileName) - 1] != '\\'))
|
||||
strcat(fileName, "/");
|
||||
}
|
||||
|
@ -625,22 +625,22 @@ int GetExistsFileNameJson(char *prefixDir, char *reqestedFileName, char *fileNam
|
|||
fileName[0] = 0x00;
|
||||
strcpy(fileName, get_my_executable_directory());
|
||||
CheckSlash(fileName);
|
||||
|
||||
|
||||
strcat(fileName, prefixDir);
|
||||
CheckSlash(fileName);
|
||||
|
||||
|
||||
strcat(fileName, reqestedFileName);
|
||||
if (!strstr(fileName, ".json"))
|
||||
strcat(fileName, ".json");
|
||||
|
||||
|
||||
if (access(fileName, F_OK) < 0) {
|
||||
strcpy(fileName, get_my_executable_directory());
|
||||
CheckSlash(fileName);
|
||||
|
||||
|
||||
strcat(fileName, reqestedFileName);
|
||||
if (!strstr(fileName, ".json"))
|
||||
strcat(fileName, ".json");
|
||||
|
||||
|
||||
if (access(fileName, F_OK) < 0) {
|
||||
return 1; // file not found
|
||||
}
|
||||
|
@ -652,9 +652,9 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
json_error_t error;
|
||||
json_t *root = NULL;
|
||||
char fname[300] = {0};
|
||||
|
||||
CLIParserInit("hf fido make",
|
||||
"Execute a FIDO2 Make Credentional command. Needs json file with parameters. Sample file `fido2.json`. File can be placed in proxmark directory or in `proxmark/fido` directory.",
|
||||
|
||||
CLIParserInit("hf fido make",
|
||||
"Execute a FIDO2 Make Credentional command. Needs json file with parameters. Sample file `fido2.json`. File can be placed in proxmark directory or in `proxmark/fido` directory.",
|
||||
"Usage:\n\thf fido make -> execute command default parameters file `fido2.json`\n"
|
||||
"\thf fido make test.json -> execute command with parameters file `text.json`");
|
||||
|
||||
|
@ -668,7 +668,7 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(cmd, argtable, true);
|
||||
|
||||
|
||||
bool APDULogging = arg_get_lit(1);
|
||||
bool verbose = arg_get_lit(2);
|
||||
bool verbose2 = arg_get_lit(2) > 1;
|
||||
|
@ -685,8 +685,8 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
jsonnamelen = strlen(cjsonname);
|
||||
}
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
SetAPDULogging(APDULogging);
|
||||
|
||||
int res = GetExistsFileNameJson("fido", cjsonname, fname);
|
||||
|
@ -695,12 +695,12 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
return res;
|
||||
}
|
||||
PrintAndLog("fname: %s\n", fname);
|
||||
root = json_load_file(fname, 0, &error);
|
||||
root = json_load_file(fname, 0, &error);
|
||||
if (!root) {
|
||||
PrintAndLog("ERROR: json error on line %d: %s", error.line, error.text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t data[2048] = {0};
|
||||
size_t datalen = 0;
|
||||
uint8_t buf[2048] = {0};
|
||||
|
@ -715,9 +715,9 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
DropField();
|
||||
return 2;
|
||||
}
|
||||
|
@ -725,28 +725,28 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
res = FIDO2CreateMakeCredentionalReq(root, data, sizeof(data), &datalen);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
|
||||
if (showCBOR) {
|
||||
PrintAndLog("CBOR make credentional request:");
|
||||
PrintAndLog("---------------- CBOR ------------------");
|
||||
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, false, data, datalen);
|
||||
PrintAndLog("---------------- CBOR ------------------");
|
||||
}
|
||||
|
||||
|
||||
res = FIDO2MakeCredential(data, datalen, buf, sizeof(buf), &len, &sw);
|
||||
DropField();
|
||||
if (res) {
|
||||
PrintAndLog("Can't execute make credential command. res=%x. Exit...", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("ERROR execute make credential command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("ERROR execute make credential command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
if(buf[0]) {
|
||||
PrintAndLog("FIDO2 make credential error: %d - %s", buf[0], fido2GetCmdErrorDescription(buf[0]));
|
||||
PrintAndLog("FIDO2 make credential error: %d - %s", buf[0], fido2GetCmdErrorDescription(buf[0]));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -760,7 +760,7 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
|
||||
// parse returned cbor
|
||||
FIDO2MakeCredentionalParseRes(root, &buf[1], len - 1, verbose, verbose2, showCBOR, showDERTLV);
|
||||
|
||||
|
||||
if (root) {
|
||||
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||
if (res) {
|
||||
|
@ -769,7 +769,7 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
}
|
||||
PrintAndLog("File `%s` saved.", fname);
|
||||
}
|
||||
|
||||
|
||||
json_decref(root);
|
||||
|
||||
return 0;
|
||||
|
@ -779,9 +779,9 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
json_error_t error;
|
||||
json_t *root = NULL;
|
||||
char fname[300] = {0};
|
||||
|
||||
CLIParserInit("hf fido assert",
|
||||
"Execute a FIDO2 Get Assertion command. Needs json file with parameters. Sample file `fido2.json`. File can be placed in proxmark directory or in `proxmark/fido` directory.",
|
||||
|
||||
CLIParserInit("hf fido assert",
|
||||
"Execute a FIDO2 Get Assertion command. Needs json file with parameters. Sample file `fido2.json`. File can be placed in proxmark directory or in `proxmark/fido` directory.",
|
||||
"Usage:\n\thf fido assert -> execute command default parameters file `fido2.json`\n"
|
||||
"\thf fido assert test.json -l -> execute command with parameters file `text.json` and add to request CredentialId");
|
||||
|
||||
|
@ -795,7 +795,7 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(cmd, argtable, true);
|
||||
|
||||
|
||||
bool APDULogging = arg_get_lit(1);
|
||||
bool verbose = arg_get_lit(2);
|
||||
bool verbose2 = arg_get_lit(2) > 1;
|
||||
|
@ -812,8 +812,8 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
jsonnamelen = strlen(cjsonname);
|
||||
}
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
CLIParserFree();
|
||||
|
||||
SetAPDULogging(APDULogging);
|
||||
|
||||
int res = GetExistsFileNameJson("fido", "fido2", fname);
|
||||
|
@ -822,12 +822,12 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
return res;
|
||||
}
|
||||
PrintAndLog("fname: %s\n", fname);
|
||||
root = json_load_file(fname, 0, &error);
|
||||
root = json_load_file(fname, 0, &error);
|
||||
if (!root) {
|
||||
PrintAndLog("ERROR: json error on line %d: %s", error.line, error.text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t data[2048] = {0};
|
||||
size_t datalen = 0;
|
||||
uint8_t buf[2048] = {0};
|
||||
|
@ -842,9 +842,9 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("Can't select FIDO application. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
DropField();
|
||||
return 2;
|
||||
}
|
||||
|
@ -852,28 +852,28 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
res = FIDO2CreateGetAssertionReq(root, data, sizeof(data), &datalen, createAllowList);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
|
||||
if (showCBOR) {
|
||||
PrintAndLog("CBOR get assertion request:");
|
||||
PrintAndLog("---------------- CBOR ------------------");
|
||||
TinyCborPrintFIDOPackage(fido2CmdGetAssertion, false, data, datalen);
|
||||
PrintAndLog("---------------- CBOR ------------------");
|
||||
}
|
||||
|
||||
|
||||
res = FIDO2GetAssertion(data, datalen, buf, sizeof(buf), &len, &sw);
|
||||
DropField();
|
||||
if (res) {
|
||||
PrintAndLog("Can't execute get assertion command. res=%x. Exit...", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (sw != 0x9000) {
|
||||
PrintAndLog("ERROR execute get assertion command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
PrintAndLog("ERROR execute get assertion command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
if(buf[0]) {
|
||||
PrintAndLog("FIDO2 get assertion error: %d - %s", buf[0], fido2GetCmdErrorDescription(buf[0]));
|
||||
PrintAndLog("FIDO2 get assertion error: %d - %s", buf[0], fido2GetCmdErrorDescription(buf[0]));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -887,7 +887,7 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
|
||||
// parse returned cbor
|
||||
FIDO2GetAssertionParseRes(root, &buf[1], len - 1, verbose, verbose2, showCBOR);
|
||||
|
||||
|
||||
if (root) {
|
||||
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||
if (res) {
|
||||
|
@ -898,7 +898,7 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
|||
}
|
||||
|
||||
json_decref(root);
|
||||
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue