diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 38079b304..6f8c09046 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -4913,7 +4913,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { bool APDULogging = arg_get_lit(ctx, 1); bool verbose = arg_get_lit(ctx, 2); - + DesfireContext dctx; int securechann = defaultSecureChannel; uint32_t appid = 0x000000; @@ -4922,7 +4922,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { CLIParserFree(ctx); return res; } - + uint32_t paramid = 0; res = arg_get_u32_hexstr_def_nlen(ctx, 12, 0, ¶mid, 1, true); if (res == 2) { @@ -4930,7 +4930,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { CLIParserFree(ctx); return PM3_EINVARG; } - + uint8_t param[250] = {0}; int paramlen = sizeof(param); CLIGetHexWithReturn(ctx, 13, param, ¶mlen); @@ -4942,7 +4942,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { PrintAndLogEx(ERR, "Parameter data length must be less than 50 instead of %d.", paramlen); return PM3_EINVARG; } - + SetAPDULogging(APDULogging); CLIParserFree(ctx); @@ -4952,7 +4952,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { else PrintAndLogEx(INFO, _CYAN_("Application %06x") " param ID: 0x%02x param[%d]: %s", appid, paramid, paramlen, sprint_hex(param, paramlen)); } - + res = DesfireSelectAndAuthenticate(&dctx, securechann, appid, verbose); if (res != PM3_SUCCESS) { DropField(); diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index 0b237762b..a0611120d 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -1108,7 +1108,7 @@ int DesfireChangeKey(DesfireContext *dctx, bool change_master_key, uint8_t newke uint8_t pckcdata[DESFIRE_MAX_KEY_SIZE + 10] = {0}; uint8_t *cdata = &pckcdata[2]; uint8_t keynodata = newkeynum & 0x3f; - + /* * Because new crypto methods can be setup only at application creation, * changing the card master key to one of them require a key_no tweak. @@ -1116,7 +1116,7 @@ int DesfireChangeKey(DesfireContext *dctx, bool change_master_key, uint8_t newke if (change_master_key) { keynodata |= (DesfireKeyAlgoToType(newkeytype) & 0x03) << 6; } - + pckcdata[0] = MFDES_CHANGE_KEY; // TODO pckcdata[1] = keynodata; @@ -1206,13 +1206,13 @@ int DesfireSetConfiguration(DesfireContext *dctx, uint8_t paramid, uint8_t *para desfire_crc32_append(cdata, datalen + 1); datalen += 4; } - + // dynamic length if (paramid == 0x02) { data[datalen] = 0x80; datalen++; - } - + } + // send command uint8_t resp[257] = {0}; size_t resplen = 0; @@ -1221,6 +1221,6 @@ int DesfireSetConfiguration(DesfireContext *dctx, uint8_t paramid, uint8_t *para // check response if (res == 0 && resplen > 0) res = -20; - + return res; }