From bad7b80036d5914bef9c81c981677515571ed9b1 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Tue, 27 Nov 2018 12:07:33 +0200 Subject: [PATCH] added file name to fido2 command --- client/cmdhffido.c | 55 +++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/client/cmdhffido.c b/client/cmdhffido.c index 359fb3660..e2d53560d 100644 --- a/client/cmdhffido.c +++ b/client/cmdhffido.c @@ -876,7 +876,7 @@ int CmdHFFido2MakeCredential(const char *cmd) { arg_litn("vV", "verbose", 0, 2, "show technical data. vv - show full certificates data"), arg_lit0("tT", "tlv", "Show DER certificate contents in TLV representation"), arg_lit0("cC", "cbor", "show CBOR decoded data"), - arg_str0(NULL, NULL, "fido2.json", "JSON input / output file name for parameters. Default `fido2.json`"), + arg_str0(NULL, NULL, "", "JSON input / output file name for parameters. Default `fido2.json`"), arg_param_end }; CLIExecWithReturn(cmd, argtable, true); @@ -887,15 +887,21 @@ int CmdHFFido2MakeCredential(const char *cmd) { bool showDERTLV = arg_get_lit(3); bool showCBOR = arg_get_lit(4); + uint8_t jsonname[250] ={0}; + char *cjsonname = (char *)jsonname; + int jsonnamelen = 0; + CLIGetStrWithReturn(5, jsonname, &jsonnamelen); + if (!jsonnamelen) { + strcat(cjsonname, "fido2"); + jsonnamelen = strlen(cjsonname); + } - - CLIParserFree(); SetAPDULogging(APDULogging); - int res = GetExistsFileNameJson("fido", "fido2", fname); + int res = GetExistsFileNameJson("fido", cjsonname, fname); if(res) { PrintAndLog("ERROR: Can't found the json file."); return res; @@ -986,21 +992,40 @@ int CmdHFFido2GetAssertion(const char *cmd) { json_t *root = NULL; char fname[300] = {0}; - - bool APDULogging = false; - bool verbose = true; - bool verbose2 = true; - bool showCBOR = true; - - + 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 -> execute command with parameters file `text.json`"); + void* argtable[] = { + arg_param_begin, + arg_lit0("aA", "apdu", "show APDU reqests and responses"), + arg_litn("vV", "verbose", 0, 2, "show technical data. vv - show full certificates data"), + arg_lit0("cC", "cbor", "show CBOR decoded data"), + arg_str0(NULL, NULL, "", "JSON input / output file name for parameters. Default `fido2.json`"), + arg_param_end + }; + CLIExecWithReturn(cmd, argtable, true); - - //CLIParserFree(); + bool APDULogging = arg_get_lit(1); + bool verbose = arg_get_lit(2); + bool verbose2 = arg_get_lit(2) > 1; + bool showCBOR = arg_get_lit(3); + + uint8_t jsonname[250] ={0}; + char *cjsonname = (char *)jsonname; + int jsonnamelen = 0; + CLIGetStrWithReturn(4, jsonname, &jsonnamelen); + + if (!jsonnamelen) { + strcat(cjsonname, "fido2"); + jsonnamelen = strlen(cjsonname); + } + + CLIParserFree(); SetAPDULogging(APDULogging); - - + int res = GetExistsFileNameJson("fido", "fido2", fname); if(res) { PrintAndLog("ERROR: Can't found the json file.");