From 95ed9c3543fe15c330052a5f6d819f8859781e16 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Tue, 17 Aug 2021 15:06:04 +0300 Subject: [PATCH] add lrp channel --- client/src/cmdhfmfdes.c | 66 +++++++++++++-------------- client/src/mifare/desfirecore.c | 1 + client/src/mifare/desfirecrypto.c | 3 ++ client/src/mifare/desfirecrypto.h | 3 +- client/src/mifare/desfiresecurechan.c | 2 + 5 files changed, 41 insertions(+), 34 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index ce8844aae..c171a1169 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -488,7 +488,7 @@ static int CmdHF14ADesDefault(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -1311,7 +1311,7 @@ static int CmdHF14aDesDetect(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "dict", "", "File with keys dictionary"), arg_lit0(NULL, "save", "save found key and parameters to defaults"), @@ -1567,7 +1567,7 @@ static int CmdHF14aDesMAD(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID of issuer info file, (non-standard feature!) (3 hex bytes, big endian)"), arg_lit0(NULL, "auth", "Authenticate to get info from GetApplicationIDs command (non-standard feature!)"), arg_param_end @@ -1709,7 +1709,7 @@ static int CmdHF14ADesSelectApp(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID of application for some parameters (3 hex bytes, big endian)"), arg_str0(NULL, "dfname", "", "Application DF Name (string, max 16 chars). Selects application via ISO SELECT command"), arg_lit0(NULL, "mf", "Select MF (master file) via ISO channel"), @@ -1935,7 +1935,7 @@ static int CmdHF14ADesAuth(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID of application for some parameters (3 hex bytes, big endian)"), arg_lit0(NULL, "save", "saves channels parameters to defaults if authentication succeeds"), arg_param_end @@ -2022,7 +2022,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID of application for some parameters (3 hex bytes, big endian)"), arg_str0("p", "param", "", "Parameter id (HEX 1 byte)"), arg_str0("d", "data", "", "Data for parameter (HEX 1..30 bytes)"), @@ -2112,7 +2112,7 @@ static int CmdHF14ADesChangeKey(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID of application (3 hex bytes, big endian)"), arg_str0(NULL, "oldalgo", "", "Old key crypto algorithm: DES, 2TDEA, 3TDEA, AES"), arg_str0(NULL, "oldkey", "", "Old key (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)"), @@ -2271,7 +2271,7 @@ static int CmdHF14ADesCreateApp(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "rawdata", "", "Rawdata that sends to command"), arg_str0(NULL, "aid", "", "Application ID for create. Mandatory. (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "ISO file ID. Forbidden values: 0000 3F00, 3FFF, FFFF. (2 hex bytes, big endian). If specified - enable iso file id over all the files in the app."), @@ -2435,7 +2435,7 @@ static int CmdHF14ADesDeleteApp(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID of delegated application (3 hex bytes, big endian)"), arg_param_end }; @@ -2497,7 +2497,7 @@ static int CmdHF14ADesGetUID(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -2572,7 +2572,7 @@ static int CmdHF14ADesFormatPICC(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID of delegated application (3 hex bytes, big endian)"), arg_param_end }; @@ -2629,7 +2629,7 @@ static int CmdHF14ADesGetFreeMem(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end }; @@ -2690,7 +2690,7 @@ static int CmdHF14ADesChKeySettings(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0("d", "data", "", "Key settings (HEX 1 byte)"), arg_param_end @@ -2762,7 +2762,7 @@ static int CmdHF14ADesGetKeyVersions(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "keynum", "", "Key number/count (HEX 1 byte). Default 0x00."), arg_str0(NULL, "keyset", "", "Keyset number (HEX 1 byte)"), @@ -2859,7 +2859,7 @@ static int CmdHF14ADesGetKeySettings(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_param_end }; @@ -2937,7 +2937,7 @@ static int CmdHF14ADesGetAIDs(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end }; @@ -3003,7 +3003,7 @@ static int CmdHF14ADesGetAppNames(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end }; @@ -3075,7 +3075,7 @@ static int CmdHF14ADesGetFileIDs(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end @@ -3144,7 +3144,7 @@ static int CmdHF14ADesGetFileISOIDs(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end @@ -3213,7 +3213,7 @@ static int CmdHF14ADesGetFileSettings(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte). default: 1"), arg_lit0(NULL, "no-auth", "execute without authentication"), @@ -3383,7 +3383,7 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_str0(NULL, "rawdata", "", "File settings (HEX > 5 bytes). Have priority over the other settings."), @@ -3523,7 +3523,7 @@ static int CmdHF14ADesCreateFile(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_str0(NULL, "isofid", "", "ISO File ID (2 hex bytes)"), @@ -3661,7 +3661,7 @@ static int CmdHF14ADesCreateValueFile(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_str0(NULL, "amode", "", "File access mode: plain/mac/encrypt"), @@ -3787,7 +3787,7 @@ static int CmdHF14ADesCreateRecordFile(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_str0(NULL, "isofid", "", "ISO File ID (2 hex bytes)"), @@ -3904,7 +3904,7 @@ static int CmdHF14ADesCreateTrMACFile(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_str0(NULL, "amode", "", "File access mode: plain/mac/encrypt"), @@ -4017,7 +4017,7 @@ static int CmdHF14ADesDeleteFile(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_lit0(NULL, "no-auth", "execute without authentication"), @@ -4090,7 +4090,7 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_str0("o", "op", "", "Operation: get(default)/credit/limcredit(limited credit)/debit/clear. Operation clear: get-getopt-debit to min value"), @@ -4248,7 +4248,7 @@ static int CmdHF14ADesClearRecordFile(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID for clearing (1 hex byte)"), arg_lit0(NULL, "no-auth", "execute without authentication"), @@ -4582,7 +4582,7 @@ static int CmdHF14ADesReadData(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_lit0(NULL, "no-auth", "execute without authentication"), @@ -4758,7 +4758,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_str0(NULL, "fid", "", "File ID (1 hex byte)"), arg_lit0(NULL, "no-auth", "execute without authentication"), @@ -5094,7 +5094,7 @@ static int CmdHF14ADesLsFiles(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end @@ -5164,7 +5164,7 @@ static int CmdHF14ADesLsApp(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_lit0(NULL, "no-deep", "not to check authentication commands that avail for any application"), arg_lit0(NULL, "files", "scan files and print file settings for each application"), @@ -5229,7 +5229,7 @@ static int CmdHF14ADesDump(const char *Cmd) { arg_str0("i", "kdfi", "", "KDF input (HEX 1-31 bytes)"), arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), - arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2/lrp"), arg_str0(NULL, "aid", "", "Application ID (3 hex bytes, big endian)"), arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index 4651bce08..46a655cfd 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -72,6 +72,7 @@ const CLIParserOption DesfireSecureChannelOpts[] = { {DACd40, "d40"}, {DACEV1, "ev1"}, {DACEV2, "ev2"}, + {DACLRP, "lrp"}, {0, NULL}, }; const size_t DesfireSecureChannelOptsLen = ARRAY_LENGTH(DesfireSecureChannelOpts); diff --git a/client/src/mifare/desfirecrypto.c b/client/src/mifare/desfirecrypto.c index d4b1a311f..e1b0210be 100644 --- a/client/src/mifare/desfirecrypto.c +++ b/client/src/mifare/desfirecrypto.c @@ -118,6 +118,9 @@ size_t DesfireGetMACLength(DesfireContext *ctx) { case DACEV2: mac_length = 8; break; + case DACLRP: + mac_length = 8; + break; } return mac_length; } diff --git a/client/src/mifare/desfirecrypto.h b/client/src/mifare/desfirecrypto.h index a5de60a87..57fee9792 100644 --- a/client/src/mifare/desfirecrypto.h +++ b/client/src/mifare/desfirecrypto.h @@ -45,7 +45,8 @@ typedef enum { DACNone, DACd40, DACEV1, - DACEV2 + DACEV2, + DACLRP, } DesfireSecureChannel; typedef enum { diff --git a/client/src/mifare/desfiresecurechan.c b/client/src/mifare/desfiresecurechan.c index 45730ffad..551250e7a 100644 --- a/client/src/mifare/desfiresecurechan.c +++ b/client/src/mifare/desfiresecurechan.c @@ -387,6 +387,7 @@ void DesfireSecureChannelEncode(DesfireContext *ctx, uint8_t cmd, uint8_t *srcda case DACEV2: DesfireSecureChannelEncodeEV2(ctx, cmd, srcdata, srcdatalen, dstdata, dstdatalen); break; + case DACLRP: case DACNone: memcpy(dstdata, srcdata, srcdatalen); *dstdatalen = srcdatalen; @@ -603,6 +604,7 @@ void DesfireSecureChannelDecode(DesfireContext *ctx, uint8_t *srcdata, size_t sr case DACEV2: DesfireSecureChannelDecodeEV2(ctx, srcdata, srcdatalen, respcode, dstdata, dstdatalen); break; + case DACLRP: case DACNone: memcpy(dstdata, srcdata, srcdatalen); *dstdatalen = srcdatalen;