From: merlokk Date: Wed, 12 Sep 2018 17:20:27 +0000 (+0300) Subject: `hf emv challenge` works X-Git-Tag: v3.1.0~9^2~10 X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/8ffdccffa0e7ec45c785495116b77b3f0b85bd49 `hf emv challenge` works --- diff --git a/client/emv/cmdemv.c b/client/emv/cmdemv.c index 030eaa0b..3114c46a 100644 --- a/client/emv/cmdemv.c +++ b/client/emv/cmdemv.c @@ -321,6 +321,41 @@ int CmdHFEMVAC(const char *cmd) { int CmdHFEMVGenerateChallenge(const char *cmd) { + CLIParserInit("hf 14a challenge", + "Executes Generate Challenge command. It returns 4-byte random number from card:\n", + "Usage:\n\thf emv challenge -> get challenge\n\thf emv challenge -k -> get challenge, keep fileld ON\n"); + + void* argtable[] = { + arg_param_begin, + arg_lit0("kK", "keep", "keep field ON for next command"), + arg_lit0("aA", "apdu", "show APDU reqests and responses"), + arg_param_end + }; + CLIExecWithReturn(cmd, argtable, true); + + bool leaveSignalON = arg_get_lit(1); + bool APDULogging = arg_get_lit(2); + CLIParserFree(); + + SetAPDULogging(APDULogging); + + // exec + uint8_t buf[APDU_RES_LEN] = {0}; + size_t len = 0; + uint16_t sw = 0; + int res = EMVGenerateChallenge(leaveSignalON, buf, sizeof(buf), &len, &sw, NULL); + + if (sw) + PrintAndLog("APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); + + if (res) + return res; + + PrintAndLog("Challenge: %s", sprint_hex(buf, len)); + + if (len != 4 && len != 8) + PrintAndLog("WARNING: length of challenge must be 4 or 8, but it %d", len); + return 0; }