From 6a95f161024baaf5f7f38b64d0ef99a685dd46d1 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 25 Aug 2024 15:17:02 +0200 Subject: [PATCH] style and text --- client/src/cmdhf14a.c | 5 +- client/src/cmdhficlass.c | 2 +- client/src/cmdhfjooki.c | 4 +- client/src/cmdlfem410x.c | 11 +- client/src/cmdlfindala.c | 6 +- client/src/cmdtrace.c | 8 +- client/src/fileutils.c | 9 +- client/src/wiegand_formats.c | 34 +-- doc/commands.json | 69 +++--- tools/mfc/protocol/mfc-protocol-demo.c | 310 ++++++++++++------------- tools/pm3_tests.sh | 4 +- 11 files changed, 243 insertions(+), 219 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 8838b5a25..38c726171 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -2273,10 +2273,11 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { } if (card.ats[0] != card.ats_len - 2) { - PrintAndLogEx(WARNING, _RED_("ATS may be corrupted.") " Length of ATS (%d bytes incl. 2 Bytes CRC) doesn't match TL", card.ats_len); + PrintAndLogEx(WARNING, _RED_("ATS may be corrupted.")); + PrintAndLogEx(INFO, "Length of ATS (%d bytes incl. 2 Bytes CRC) doesn't match TL", card.ats_len); } - PrintAndLogEx(SUCCESS, "ATS: " _YELLOW_("%s")"[ %02X %02X ]", sprint_hex(card.ats, card.ats_len - 2), card.ats[card.ats_len - 1], card.ats[card.ats_len]); + PrintAndLogEx(SUCCESS, "ATS: " _YELLOW_("%s")"[ %02X %02X ]", sprint_hex(card.ats, card.ats_len - 2), card.ats[card.ats_len - 2], card.ats[card.ats_len - 1]); PrintAndLogEx(INFO, " " _YELLOW_("%02X") "............... TL length is " _GREEN_("%d") " bytes", card.ats[0], card.ats[0]); if ((card.ats[0] > 1) && (card.ats_len > 3)) { // there is a format byte (T0) diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 26cf1e1f4..78c53b309 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -4653,7 +4653,7 @@ static int CmdHFiClassEncode(const char *Cmd) { char format[16] = {0}; int format_len = 0; - + CLIParamStrToBuf(arg_get_str(ctx, 10), (uint8_t *)format, sizeof(format), &format_len); bool shallow_mod = arg_get_lit(ctx, 12); diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index 3b7d9b63e..03ce6cf77 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -286,7 +286,7 @@ static int CmdHF14AJookiEncode(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf jooki encode", "Encode a Jooki token to base64 NDEF URI format", - "hf jooki encode -t --> selftest\n" + "hf jooki encode --test --> self tests\n" "hf jooki encode -r --dragon --> read uid from tag and use for encoding\n" "hf jooki encode --uid 04010203040506 --dragon\n" "hf jooki encode --uid 04010203040506 --tid 1 --fid 1" @@ -296,7 +296,7 @@ static int CmdHF14AJookiEncode(const char *Cmd) { arg_param_begin, arg_str0("u", "uid", "", "uid bytes"), arg_lit0("r", NULL, "read uid from tag instead"), - arg_lit0("t", NULL, "self test"), + arg_lit0(NULL, "test", "self test"), arg_lit0("v", "verbose", "verbose output"), arg_lit0(NULL, "dragon", "figurine type"), arg_lit0(NULL, "fox", "figurine type"), diff --git a/client/src/cmdlfem410x.c b/client/src/cmdlfem410x.c index 0f832ac60..0182083c5 100644 --- a/client/src/cmdlfem410x.c +++ b/client/src/cmdlfem410x.c @@ -767,9 +767,14 @@ static int CmdEM410xClone(const char *Cmd) { // 64 -> 0x20 2 kBit/s packet.data[1] = 0x04; switch (clk) { - case 32: break; - case 16: packet.data[1] |= 0x10; break; - case 64: packet.data[1] |= 0x20; break; + case 32: + break; + case 16: + packet.data[1] |= 0x10; + break; + case 64: + packet.data[1] |= 0x20; + break; } packet.data[2] = 0; packet.data[3] = 0; //TODO: keep PWDH0? diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index d0c9557d9..89922c0ac 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -1169,14 +1169,14 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) { // 92 = 62 // 93 = 63 - + bits[34] = 0; // parity for odd bits bits[38] = 0; // parity for even bits uint8_t p1 = 1; uint8_t p2 = 1; - for (int i=33; i < 64; i++) { - if (i%2) + for (int i = 33; i < 64; i++) { + if (i % 2) p1 ^= bits[i]; else p2 ^= bits[i]; diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index da8382118..b76cb9453 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -1386,7 +1386,13 @@ int CmdTraceList(const char *Cmd) { if (use_buffer == false) { download_trace(); } else if (gs_traceLen == 0 || gs_trace == NULL) { - PrintAndLogEx(FAILED, "You requested a trace list in offline mode but there is no trace."); + + if (IfPm3Present() == false) { + PrintAndLogEx(FAILED, "You requested a trace list in offline mode but there is no trace."); + } else { + PrintAndLogEx(FAILED, "You requested a trace list but there is no trace."); + } + PrintAndLogEx(FAILED, "Consider using `" _YELLOW_("trace load") "` or removing parameter `" _YELLOW_("-1") "`"); return PM3_EINVARG; } diff --git a/client/src/fileutils.c b/client/src/fileutils.c index fc9f08deb..a28ec1cfd 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -2344,9 +2344,12 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key continue; } - uint64_t key = strtoull(line, NULL, 16); - - num_to_bytes(key, keylen >> 1, (uint8_t *)*pdata + (*keycnt * (keylen >> 1))); + if (hex_to_bytes( + line, + (uint8_t *)*pdata + (*keycnt * (keylen >> 1)), + keylen >> 1) != (keylen >> 1)) { + continue; + } (*keycnt)++; diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index 95e976810..bf08e0908 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -24,7 +24,7 @@ static bool Pack_Defcon32(wiegand_card_t *card, wiegand_message_t *packed, bool memset(packed, 0, sizeof(wiegand_message_t)); if (card->FacilityCode > 0x00FFFF) return false; // Can't encode FC. if (card->CardNumber > 0x0fffff) return false; // Can't encode CN. - if (card->IssueLevel > 0x00000F) return false; // Can't encode Issue + if (card->IssueLevel > 0x00000F) return false; // Can't encode Issue if (card->OEM > 0) return false; // Not used in this format packed->Length = 42; @@ -35,11 +35,11 @@ static bool Pack_Defcon32(wiegand_card_t *card, wiegand_message_t *packed, bool |Mid part| | Bot part of the packed data | PFFFFFFFFF FFFFFFFIIIICCCCCCCCCCCCCCCCCCCCP 1111111111 11111111111000000000000000001000 -FC 111111111 1111111 = FF FF -//FC Mid 111111111 0000000 = FF 80 These where used to split data between bot/mid -//FC Bot 000000000 1111111 = 00 7F -Issuance 1111 = 0F -Card Number 11111111111111111111 = 0FFFFF + FC 111111111 1111111 = FF FF + //FC Mid 111111111 0000000 = FF 80 These where used to split data between bot/mid + //FC Bot 000000000 1111111 = 00 7F + Issuance 1111 = 0F + Card Number 11111111111111111111 = 0FFFFF */ @@ -51,14 +51,14 @@ Card Number 11111111111111111111 = 0FFFFF // Parity calc //0123456789|0123456789|0123456789|0123456789|01 //E E E E E |E E E E E |EO O O O O| O O O O O| O - set_bit_by_position(packed, - evenparity32( - get_nonlinear_field(packed, 10, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20})) + set_bit_by_position(packed, + evenparity32( + get_nonlinear_field(packed, 10, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20})) , 0); - set_bit_by_position(packed, - oddparity32( - get_nonlinear_field(packed, 10, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39})) + set_bit_by_position(packed, + oddparity32( + get_nonlinear_field(packed, 10, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39})) , 41); if (preamble) return add_HID_header(packed); @@ -73,12 +73,12 @@ static bool Unpack_Defcon32(wiegand_message_t *packed, wiegand_card_t *card) { card->FacilityCode = get_linear_field(packed, 1, 16); card->IssueLevel = get_linear_field(packed, 17, 4); card->CardNumber = get_linear_field(packed, 21, 20); - - card->ParityValid = + + card->ParityValid = (get_bit_by_position(packed, 41) == oddparity32( - get_nonlinear_field(packed, 10, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39})))&& - (get_bit_by_position(packed, 0) == - evenparity32(get_nonlinear_field(packed, 10, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}))); + get_nonlinear_field(packed, 10, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39}))) && + (get_bit_by_position(packed, 0) == + evenparity32(get_nonlinear_field(packed, 10, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}))); return true; } diff --git a/doc/commands.json b/doc/commands.json index bcee83649..35a6c7ac5 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -3289,7 +3289,9 @@ "notes": [ "hf iclass encode --bin 10001111100000001010100011 --ki 0 -> FC 31 CN 337 (H10301)", "hf iclass encode -w H10301 --fc 31 --cn 337 --ki 0 -> FC 31 CN 337 (H10301)", - "hf iclass encode --bin 10001111100000001010100011 --ki 0 --elite -> FC 31 CN 337 (H10301), writing w elite key" + "hf iclass encode --bin 10001111100000001010100011 --ki 0 --elite -> FC 31 CN 337 (H10301), writing w elite key", + "hf iclass encode -w H10301 --fc 31 --cn 337 --emu -> Writes the ecoded data to emulator memory", + "When using emulator you have to first load a credential into emulator memory" ], "offline": true, "options": [ @@ -3302,11 +3304,13 @@ "--enckey 3DES transport key, 16 hex bytes", "--fc facility code", "--cn card number", + "--issue issue level", "-w, --wiegand see `wiegand list` for available formats", + "--emu Write to emulation memory instead of card", "--shallow use shallow (ASK) reader modulation instead of OOK", "-v verbose (print encoded blocks)" ], - "usage": "hf iclass encode [-hv] [--bin ] --ki [--credit] [--elite] [--raw] [--enckey ] [--fc ] [--cn ] [-w ] [--shallow]" + "usage": "hf iclass encode [-hv] [--bin ] [--ki ] [--credit] [--elite] [--raw] [--enckey ] [--fc ] [--cn ] [--issue ] [-w ] [--emu] [--shallow]" }, "hf iclass encrypt": { "command": "hf iclass encrypt", @@ -3735,7 +3739,7 @@ "command": "hf jooki encode", "description": "Encode a Jooki token to base64 NDEF URI format", "notes": [ - "hf jooki encode -t -> selftest", + "hf jooki encode --test -> self tests", "hf jooki encode -r --dragon -> read uid from tag and use for encoding", "hf jooki encode --uid 04010203040506 --dragon", "hf jooki encode --uid 04010203040506 --tid 1 --fid 1" @@ -3745,7 +3749,7 @@ "-h, --help This help", "-u, --uid uid bytes", "-r read uid from tag instead", - "-t self test", + "--test self test", "-v, --verbose verbose output", "--dragon figurine type", "--fox figurine type", @@ -3763,7 +3767,7 @@ "--tid figurine type id", "--fid figurine id" ], - "usage": "hf jooki encode [-hrtv] [-u ] [--dragon] [--fox] [--ghost] [--knight] [--whale] [--blackdragon] [--blackfox] [--blackknight] [--blackwhale] [--whitedragon] [--whitefox] [--whiteknight] [--whitewhale] [--tid ] [--fid ]" + "usage": "hf jooki encode [-hrv] [-u ] [--test] [--dragon] [--fox] [--ghost] [--knight] [--whale] [--blackdragon] [--blackfox] [--blackknight] [--blackwhale] [--whitedragon] [--whitefox] [--whiteknight] [--whitewhale] [--tid ] [--fid ]" }, "hf jooki help": { "command": "hf jooki help", @@ -4253,6 +4257,7 @@ "--1k MIFARE Classic 1k / S50 (default)", "--2k MIFARE Classic/Plus 2k", "--4k MIFARE Classic 4k / S70", + "--ns No save", "--in None (use CPU regular instruction set)", "--im MMX", "--is SSE2", @@ -4260,7 +4265,7 @@ "--i2 AVX2", "--i5 AVX512" ], - "usage": "hf mf autopwn [-hablv] [-k ]... [-s ] [-f ] [--slow] [--mini] [--1k] [--2k] [--4k] [--in] [--im] [--is] [--ia] [--i2] [--i5]" + "usage": "hf mf autopwn [-hablv] [-k ]... [-s ] [-f ] [--slow] [--mini] [--1k] [--2k] [--4k] [--ns] [--in] [--im] [--is] [--ia] [--i2] [--i5]" }, "hf mf brute": { "command": "hf mf brute", @@ -7032,7 +7037,7 @@ }, "hf mfu keygen": { "command": "hf mfu keygen", - "description": "Set the DES/3DES/AES key on MIFARE Ultralight-C tag.", + "description": "Calculate MFC keys based", "notes": [ "hf mfu keygen -r", "hf mfu keygen --uid 11223344556677" @@ -7091,17 +7096,17 @@ "description": "Generate different passwords from known pwdgen algos", "notes": [ "hf mfu pwdgen -r", - "hf mfu pwdgen -t", - "hf mfu pwdgen --uid 11223344556677" + "hf mfu pwdgen --uid 11223344556677", + "hf mfu pwdgen --test" ], "offline": true, "options": [ "-h, --help This help", "-u, --uid UID (7 hex bytes)", "-r Read UID from tag", - "-t Selftest" + "--test self test" ], - "usage": "hf mfu pwdgen [-hrt] [-u ]" + "usage": "hf mfu pwdgen [-hr] [-u ] [--test]" }, "hf mfu rdbl": { "command": "hf mfu rdbl", @@ -7223,9 +7228,10 @@ }, "hf mfu wipe": { "command": "hf mfu wipe", - "description": "Wipe card to zeros. It will ignore block0,1,2,3 you will need to call it with password in order to wipe the config and sett default pwd/pack Abort by pressing a key New password... FFFFFFFF", + "description": "Wipe card to zeros. It will ignore block0,1,2,3 you will need to call it with password in order to wipe the config and sett default pwd/pack Abort by pressing a key New password.... FFFFFFFF New 3-DES key... 425245414B4D454946594F5543414E21", "notes": [ - "hf mfu wipe" + "hf mfu wipe", + "hf mfu wipe -k 425245414B4D454946594F5543414E21" ], "offline": false, "options": [ @@ -8416,10 +8422,11 @@ "command": "lf cmdread", "description": "Modulate LF reader field to send command before read. All periods in microseconds. - use `lf config` to set parameters", "notes": [ - "lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W00110 -> probing for Hitag1/S", - "lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11000 -> probing for Hitag2", - "lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11000 -s 2000 -@ -> probing for Hitag2, oscilloscope style", - "lf cmdread -d 48 -z 112 -o 176 -e W3000 -e S240 -e E336 -c W0S00000010000E -> probing for Hitag (us)" + "lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W00110 -> probing for Hitag 1/S", + "lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11000 -> probing for Hitag 2/S", + "lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11010 -> probing for Hitag S", + "lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11000 -s 2000 -@ -> probing for Hitag 2/S, oscilloscope style", + "lf cmdread -d 48 -z 112 -o 176 -e W3000 -e S240 -e E336 -c W0S00000010000E -> probing for Hitag \u00b5(micro)" ], "offline": false, "options": [ @@ -8540,11 +8547,12 @@ }, "lf em 410x clone": { "command": "lf em 410x clone", - "description": "clone a EM410x ID to a T55x7, Q5/T5555 or EM4305/4469 tag.", + "description": "clone a EM410x ID to a T55x7, Q5/T5555, EM4305/4469 or Hitag S/8211 tag.", "notes": [ "lf em 410x clone --id 0F0368568B -> encode for T55x7 tag", "lf em 410x clone --id 0F0368568B --q5 -> encode for Q5/T5555 tag", - "lf em 410x clone --id 0F0368568B --em -> encode for EM4305/4469" + "lf em 410x clone --id 0F0368568B --em -> encode for EM4305/4469", + "lf em 410x clone --id 0F0368568B --hs -> encode for Hitag S/8211" ], "offline": false, "options": [ @@ -8553,9 +8561,10 @@ "--id EM Tag ID number (5 hex bytes)", "--q5 optional - specify writing to Q5/T5555 tag", "--em optional - specify writing to EM4305/4469 tag", + "--hs optional - specify writing to Hitag S/8211 tag", "--electra optional - add Electra blocks to tag" ], - "usage": "lf em 410x clone [-h] [--clk ] --id [--q5] [--em] [--electra]" + "usage": "lf em 410x clone [-h] [--clk ] --id [--q5] [--em] [--hs] [--electra]" }, "lf em 410x reader": { "command": "lf em 410x reader", @@ -9607,7 +9616,7 @@ }, "lf hitag crack2": { "command": "lf hitag crack2", - "description": "This command tries to recover 2048 bits of Hitag2 crypto stream data.", + "description": "This command tries to recover 2048 bits of Hitag 2 crypto stream data.", "notes": [ "lf hitag crack2 --nrar 73AA5A62EAB8529C" ], @@ -9693,7 +9702,7 @@ }, "lf hitag info": { "command": "lf hitag info", - "description": "Hitag2 tag information", + "description": "Hitag 2 tag information", "notes": [ "lf hitag info" ], @@ -9705,7 +9714,7 @@ }, "lf hitag lookup": { "command": "lf hitag lookup", - "description": "This command take sniffed trace data and try to recovery a Hitag2 crypto key. You can either - verify that NR/AR matches a known crypto key - verify if NR/AR matches a known 6 byte crypto key in a dictionary", + "description": "This command take sniffed trace data and try to recovery a Hitag 2 crypto key. You can either - verify that NR/AR matches a known crypto key - verify if NR/AR matches a known 6 byte crypto key in a dictionary", "notes": [ "lf hitag lookup --uid 11223344 --nr 73AA5A62 --ar EAB8529C -k 010203040506 -> check key", "lf hitag lookup --uid 11223344 --nr 73AA5A62 --ar EAB8529C -> use def dictionary", @@ -9726,12 +9735,12 @@ }, "lf hitag read": { "command": "lf hitag read", - "description": "Read Hitag memory. It support HitagS and Hitag 2 Password mode: - default key 4D494B52 (MIKR) Crypto mode: - key format ISK high + ISK low - default key 4F4E4D494B52 (ONMIKR)", + "description": "Read Hitag memory. It support Hitag S and Hitag 2 Password mode: - default key 4D494B52 (MIKR) Crypto mode: - key format ISK high + ISK low - default key 4F4E4D494B52 (ONMIKR)", "notes": [ - "lf hitag read --hts -> HitagS, plain mode", - "lf hitag read --hts --nrar 0102030411223344 -> HitagS, challenge mode", - "lf hitag read --hts --crypto -> HitagS, crypto mode, def key", - "lf hitag read --hts -k 4F4E4D494B52 -> HitagS, crypto mode", + "lf hitag read --hts -> Hitag S, plain mode", + "lf hitag read --hts --nrar 0102030411223344 -> Hitag S, challenge mode", + "lf hitag read --hts --crypto -> Hitag S, crypto mode, def key", + "lf hitag read --hts -k 4F4E4D494B52 -> Hitag S, crypto mode", "", "lf hitag read --ht2 --pwd -> Hitag 2, pwd mode, def key", "lf hitag read --ht2 -k 4D494B52 -> Hitag 2, pwd mode", @@ -9753,7 +9762,7 @@ }, "lf hitag reader": { "command": "lf hitag reader", - "description": "Act as a Hitag2 reader. Look for Hitag2 tags until Enter or the pm3 button is pressed", + "description": "Act as a Hitag 2 reader. Look for Hitag 2 tags until Enter or the pm3 button is pressed", "notes": [ "lf hitag reader", "lf hitag reader -@ -> Continuous mode" @@ -12813,6 +12822,6 @@ "metadata": { "commands_extracted": 740, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2024-08-14T11:49:06" + "extracted_on": "2024-08-25T12:04:45" } } diff --git a/tools/mfc/protocol/mfc-protocol-demo.c b/tools/mfc/protocol/mfc-protocol-demo.c index 41a3832e0..5109e4da8 100644 --- a/tools/mfc/protocol/mfc-protocol-demo.c +++ b/tools/mfc/protocol/mfc-protocol-demo.c @@ -38,9 +38,9 @@ static void append_crc16_a(uint8_t *buf, uint32_t buflen) { int main(void) { printf("Reader <> Tag\n"); printf("====== <> ===\n"); - uint32_t tag_uid = UID; + uint32_t tag_uid = UID; printf(" <- uid (via anticol) < "); - printf("%08X\n", tag_uid); + printf("%08X\n", tag_uid); uint32_t reader_uid = tag_uid; printf("s = crypto1_create(key)\n"); uint64_t reader_ui64Key = KEY1; @@ -49,28 +49,28 @@ int main(void) { uint8_t cmd[4] = {0x60, 0x00}; append_crc16_a(cmd, sizeof(cmd)); printf("auth A/B+blk + CRC -> > "); - for (uint32_t i=0; i> 24) & 0xFF; - uint8_t tag_nt2 = (tag_nt >> 16) & 0xFF; - uint8_t tag_nt3 = (tag_nt >> 8) & 0xFF; - uint8_t tag_nt4 = (tag_nt >> 0) & 0xFF; - printf("%02X ", tag_nt1); - printf("%02X ", tag_nt2); - printf("%02X ", tag_nt3); - printf("%02X ", tag_nt4); - printf("\n"); + uint8_t tag_nt1 = (tag_nt >> 24) & 0xFF; + uint8_t tag_nt2 = (tag_nt >> 16) & 0xFF; + uint8_t tag_nt3 = (tag_nt >> 8) & 0xFF; + uint8_t tag_nt4 = (tag_nt >> 0) & 0xFF; + printf("%02X ", tag_nt1); + printf("%02X ", tag_nt2); + printf("%02X ", tag_nt3); + printf("%02X ", tag_nt4); + printf("\n"); uint32_t reader_nt = tag_nt; printf("ks0 = crypto1_word(s, uid ^ nT, 0) "); uint32_t reader_ks0 = crypto1_word(&reader_state, reader_uid ^ reader_nt, 0); @@ -97,71 +97,71 @@ int main(void) { printf("{nR}|{aR} -> > "); printf("%02X%s ", (reader_nr_enc >> 24) & 0xFF, - oddparity8((reader_nr >> 24) & 0xFF) == - (oddparity8((reader_nr_enc >> 24) & 0xFF) ^ ((reader_ks1 >> 16) & 1)) ? " " : "!"); + oddparity8((reader_nr >> 24) & 0xFF) == + (oddparity8((reader_nr_enc >> 24) & 0xFF) ^ ((reader_ks1 >> 16) & 1)) ? " " : "!"); printf("%02X%s ", (reader_nr_enc >> 16) & 0xFF, - oddparity8((reader_nr >> 16) & 0xFF) == - (oddparity8((reader_nr_enc >> 16) & 0xFF) ^ ((reader_ks1 >> 8) & 1)) ? " " : "!"); + oddparity8((reader_nr >> 16) & 0xFF) == + (oddparity8((reader_nr_enc >> 16) & 0xFF) ^ ((reader_ks1 >> 8) & 1)) ? " " : "!"); printf("%02X%s ", (reader_nr_enc >> 8) & 0xFF, - oddparity8((reader_nr >> 8) & 0xFF) == - (oddparity8((reader_nr_enc >> 8) & 0xFF) ^ ((reader_ks1 >> 0) & 1)) ? " " : "!"); + oddparity8((reader_nr >> 8) & 0xFF) == + (oddparity8((reader_nr_enc >> 8) & 0xFF) ^ ((reader_ks1 >> 0) & 1)) ? " " : "!"); printf("%02X%s ", (reader_nr_enc >> 0) & 0xFF, - oddparity8((reader_nr >> 0) & 0xFF) == - (oddparity8((reader_nr_enc >> 0) & 0xFF) ^ ((reader_ks2 >> 24) & 1)) ? " " : "!"); + oddparity8((reader_nr >> 0) & 0xFF) == + (oddparity8((reader_nr_enc >> 0) & 0xFF) ^ ((reader_ks2 >> 24) & 1)) ? " " : "!"); printf("%02X%s ", (reader_ar_enc >> 24) & 0xFF, - oddparity8((reader_ar >> 24) & 0xFF) == - (oddparity8((reader_ar_enc >> 24) & 0xFF) ^ ((reader_ks2 >> 16) & 1)) ? " " : "!"); + oddparity8((reader_ar >> 24) & 0xFF) == + (oddparity8((reader_ar_enc >> 24) & 0xFF) ^ ((reader_ks2 >> 16) & 1)) ? " " : "!"); printf("%02X%s ", (reader_ar_enc >> 16) & 0xFF, - oddparity8((reader_ar >> 16) & 0xFF) == - (oddparity8((reader_ar_enc >> 16) & 0xFF) ^ ((reader_ks2 >> 8) & 1)) ? " " : "!"); + oddparity8((reader_ar >> 16) & 0xFF) == + (oddparity8((reader_ar_enc >> 16) & 0xFF) ^ ((reader_ks2 >> 8) & 1)) ? " " : "!"); printf("%02X%s ", (reader_ar_enc >> 8) & 0xFF, - oddparity8((reader_ar >> 8) & 0xFF) == - (oddparity8((reader_ar_enc >> 8) & 0xFF) ^ ((reader_ks2 >> 0) & 1)) ? " " : "!"); + oddparity8((reader_ar >> 8) & 0xFF) == + (oddparity8((reader_ar_enc >> 8) & 0xFF) ^ ((reader_ks2 >> 0) & 1)) ? " " : "!"); printf("%02X%s ", (reader_ar_enc >> 0) & 0xFF, - oddparity8((reader_ar >> 0) & 0xFF) == - (oddparity8((reader_ar_enc >> 0) & 0xFF) ^ reader_ks_next_bit) ? " " : "!"); + oddparity8((reader_ar >> 0) & 0xFF) == + (oddparity8((reader_ar_enc >> 0) & 0xFF) ^ reader_ks_next_bit) ? " " : "!"); printf("\n"); - uint32_t tag_nr_enc = reader_nr_enc; - uint32_t tag_ar_enc = reader_ar_enc; + uint32_t tag_nr_enc = reader_nr_enc; + uint32_t tag_ar_enc = reader_ar_enc; printf(" ks1 = crypto1_word(s, {nR}, 1) "); - uint32_t tag_ks1 = crypto1_word(&tag_state, tag_nr_enc, 1); - printf("%08X\n", tag_ks1); + uint32_t tag_ks1 = crypto1_word(&tag_state, tag_nr_enc, 1); + printf("%08X\n", tag_ks1); printf(" nR = ks1 ^ {nR} "); - uint32_t tag_nr = tag_ks1 ^ tag_nr_enc; - printf("%08X\n", tag_nr); + uint32_t tag_nr = tag_ks1 ^ tag_nr_enc; + printf("%08X\n", tag_nr); printf(" ks2 = crypto1_word(s, 0, 0) "); - uint32_t tag_ks2 = crypto1_word(&tag_state, 0, 0); - printf("%08X\n", tag_ks2); + uint32_t tag_ks2 = crypto1_word(&tag_state, 0, 0); + printf("%08X\n", tag_ks2); printf(" aR = ks2 ^ {aR} "); - uint32_t tag_ar = tag_ks2 ^ tag_ar_enc; - printf("%08X\n", tag_ar); + uint32_t tag_ar = tag_ks2 ^ tag_ar_enc; + printf("%08X\n", tag_ar); printf(" aR == suc64(nT) ? "); - printf("%08X %s\n", prng_successor(tag_nt, 64), tag_ar == prng_successor(tag_nt, 64) ? "OK" : "FAIL"); + printf("%08X %s\n", prng_successor(tag_nt, 64), tag_ar == prng_successor(tag_nt, 64) ? "OK" : "FAIL"); printf(" aT = suc96(nT) "); - uint32_t tag_at = prng_successor(tag_nt, 96); - printf("%08X\n", tag_at); + uint32_t tag_at = prng_successor(tag_nt, 96); + printf("%08X\n", tag_at); printf(" ks3 = crypto1_word(s, 0, 0) "); - uint32_t tag_ks3 = crypto1_word(&tag_state, 0, 0); - printf("%08X\n", tag_ks3); + uint32_t tag_ks3 = crypto1_word(&tag_state, 0, 0); + printf("%08X\n", tag_ks3); printf(" {aT} = ks3 ^ aT "); - uint32_t tag_at_enc = tag_ks3 ^ tag_at; - printf("%08X\n", tag_at_enc); - uint32_t tag_ks_next_bit = filter(tag_state.odd); + uint32_t tag_at_enc = tag_ks3 ^ tag_at; + printf("%08X\n", tag_at_enc); + uint32_t tag_ks_next_bit = filter(tag_state.odd); printf(" <- {aT} < "); - printf("%02X%s ", (tag_at_enc >> 24) & 0xFF, - oddparity8((tag_at >> 24) & 0xFF) == - (oddparity8((tag_at_enc >> 24) & 0xFF) ^ ((tag_ks3 >> 16) & 1)) ? " " : "!"); - printf("%02X%s ", (tag_at_enc >> 16) & 0xFF, - oddparity8((tag_at >> 16) & 0xFF) == - (oddparity8((tag_at_enc >> 16) & 0xFF) ^ ((tag_ks3 >> 8) & 1)) ? " " : "!"); - printf("%02X%s ", (tag_at_enc >> 8) & 0xFF, - oddparity8((tag_at >> 8) & 0xFF) == - (oddparity8((tag_at_enc >> 8) & 0xFF) ^ ((tag_ks3 >> 0) & 1)) ? " " : "!"); - printf("%02X%s ", (tag_at_enc >> 0) & 0xFF, - oddparity8((tag_at >> 0) & 0xFF) == - (oddparity8((tag_at_enc >> 0) & 0xFF) ^ tag_ks_next_bit) ? " " : "!"); - printf("\n"); + printf("%02X%s ", (tag_at_enc >> 24) & 0xFF, + oddparity8((tag_at >> 24) & 0xFF) == + (oddparity8((tag_at_enc >> 24) & 0xFF) ^ ((tag_ks3 >> 16) & 1)) ? " " : "!"); + printf("%02X%s ", (tag_at_enc >> 16) & 0xFF, + oddparity8((tag_at >> 16) & 0xFF) == + (oddparity8((tag_at_enc >> 16) & 0xFF) ^ ((tag_ks3 >> 8) & 1)) ? " " : "!"); + printf("%02X%s ", (tag_at_enc >> 8) & 0xFF, + oddparity8((tag_at >> 8) & 0xFF) == + (oddparity8((tag_at_enc >> 8) & 0xFF) ^ ((tag_ks3 >> 0) & 1)) ? " " : "!"); + printf("%02X%s ", (tag_at_enc >> 0) & 0xFF, + oddparity8((tag_at >> 0) & 0xFF) == + (oddparity8((tag_at_enc >> 0) & 0xFF) ^ tag_ks_next_bit) ? " " : "!"); + printf("\n"); uint32_t reader_at_enc = tag_at_enc; printf("ks3 = crypto1_word(s, 0, 0) "); uint32_t reader_ks3 = crypto1_word(&reader_state, 0, 0); @@ -178,7 +178,7 @@ int main(void) { printf("ks4 = crypto1_word(s, 0, 0) "); uint32_t reader_ks4 = crypto1_word(&reader_state, 0, 0); printf("%08X\n", reader_ks4); - uint32_t reader_cmd = (cmd[0] << 24)|(cmd[1] << 16)|(cmd[2] << 8)|(cmd[3] << 0); + uint32_t reader_cmd = (cmd[0] << 24) | (cmd[1] << 16) | (cmd[2] << 8) | (cmd[3] << 0); uint32_t reader_cmd_enc = reader_ks4 ^ reader_cmd; printf("{cmd} = ks4 ^ cmd "); printf("%08X\n", reader_cmd_enc); @@ -186,48 +186,48 @@ int main(void) { printf("{auth A/B+blk} -> > "); printf("%02X%s ", (reader_cmd_enc >> 24) & 0xFF, - oddparity8((reader_cmd >> 24) & 0xFF) == - (oddparity8((reader_cmd_enc >> 24) & 0xFF) ^ ((reader_ks4 >> 16) & 1)) ? " " : "!"); + oddparity8((reader_cmd >> 24) & 0xFF) == + (oddparity8((reader_cmd_enc >> 24) & 0xFF) ^ ((reader_ks4 >> 16) & 1)) ? " " : "!"); printf("%02X%s ", (reader_cmd_enc >> 16) & 0xFF, - oddparity8((reader_cmd >> 16) & 0xFF) == - (oddparity8((reader_cmd_enc >> 16) & 0xFF) ^ ((reader_ks4 >> 8) & 1)) ? " " : "!"); + oddparity8((reader_cmd >> 16) & 0xFF) == + (oddparity8((reader_cmd_enc >> 16) & 0xFF) ^ ((reader_ks4 >> 8) & 1)) ? " " : "!"); printf("%02X%s ", (reader_cmd_enc >> 8) & 0xFF, - oddparity8((reader_cmd >> 8) & 0xFF) == - (oddparity8((reader_cmd_enc >> 8) & 0xFF) ^ ((reader_ks4 >> 0) & 1)) ? " " : "!"); + oddparity8((reader_cmd >> 8) & 0xFF) == + (oddparity8((reader_cmd_enc >> 8) & 0xFF) ^ ((reader_ks4 >> 0) & 1)) ? " " : "!"); printf("%02X%s ", (reader_cmd_enc >> 0) & 0xFF, - oddparity8((reader_cmd >> 0) & 0xFF) == - (oddparity8((reader_cmd_enc >> 0) & 0xFF) ^ reader_ks_next_bit) ? " " : "!"); + oddparity8((reader_cmd >> 0) & 0xFF) == + (oddparity8((reader_cmd_enc >> 0) & 0xFF) ^ reader_ks_next_bit) ? " " : "!"); printf("\n"); printf(" s = crypto1_create(key)\n"); - uint64_t tag2_ui64Key = NESTED_KEY; - struct Crypto1State tag2_state = {0, 0}; - crypto1_init(&tag2_state, tag2_ui64Key); + uint64_t tag2_ui64Key = NESTED_KEY; + struct Crypto1State tag2_state = {0, 0}; + crypto1_init(&tag2_state, tag2_ui64Key); printf(" gen nT "); - uint32_t tag2_nt = NESTED_NT; - printf("%08X\n", tag2_nt); + uint32_t tag2_nt = NESTED_NT; + printf("%08X\n", tag2_nt); printf(" ks0 = crypto1_word(s, uid ^ nT, 0) "); - uint32_t tag2_ks0 = crypto1_word(&tag2_state, tag_uid ^ tag2_nt, 0); - printf("%08X\n", tag2_ks0); - uint32_t tag2_nt_enc = tag2_ks0 ^ tag2_nt; + uint32_t tag2_ks0 = crypto1_word(&tag2_state, tag_uid ^ tag2_nt, 0); + printf("%08X\n", tag2_ks0); + uint32_t tag2_nt_enc = tag2_ks0 ^ tag2_nt; printf(" {nT} = ks0 ^ nT "); - printf("%08X\n", tag2_nt_enc); - uint32_t tag2_ks_next_bit = filter(tag2_state.odd); + printf("%08X\n", tag2_nt_enc); + uint32_t tag2_ks_next_bit = filter(tag2_state.odd); printf(" <- {nT} < "); - printf("%02X%s ", (tag2_nt_enc >> 24) & 0xFF, - oddparity8((tag2_nt >> 24) & 0xFF) == - (oddparity8((tag2_nt_enc >> 24) & 0xFF) ^ ((tag2_ks0 >> 16) & 1)) ? " " : "!"); - printf("%02X%s ", (tag2_nt_enc >> 16) & 0xFF, - oddparity8((tag2_nt >> 16) & 0xFF) == - (oddparity8((tag2_nt_enc >> 16) & 0xFF) ^ ((tag2_ks0 >> 8) & 1)) ? " " : "!"); - printf("%02X%s ", (tag2_nt_enc >> 8) & 0xFF, - oddparity8((tag2_nt >> 8) & 0xFF) == - (oddparity8((tag2_nt_enc >> 8) & 0xFF) ^ ((tag2_ks0 >> 0) & 1)) ? " " : "!"); - printf("%02X%s ", (tag2_nt_enc >> 0) & 0xFF, - oddparity8((tag2_nt >> 0) & 0xFF) == - (oddparity8((tag2_nt_enc >> 0) & 0xFF) ^ tag2_ks_next_bit) ? " " : "!"); - printf("\n"); + printf("%02X%s ", (tag2_nt_enc >> 24) & 0xFF, + oddparity8((tag2_nt >> 24) & 0xFF) == + (oddparity8((tag2_nt_enc >> 24) & 0xFF) ^ ((tag2_ks0 >> 16) & 1)) ? " " : "!"); + printf("%02X%s ", (tag2_nt_enc >> 16) & 0xFF, + oddparity8((tag2_nt >> 16) & 0xFF) == + (oddparity8((tag2_nt_enc >> 16) & 0xFF) ^ ((tag2_ks0 >> 8) & 1)) ? " " : "!"); + printf("%02X%s ", (tag2_nt_enc >> 8) & 0xFF, + oddparity8((tag2_nt >> 8) & 0xFF) == + (oddparity8((tag2_nt_enc >> 8) & 0xFF) ^ ((tag2_ks0 >> 0) & 1)) ? " " : "!"); + printf("%02X%s ", (tag2_nt_enc >> 0) & 0xFF, + oddparity8((tag2_nt >> 0) & 0xFF) == + (oddparity8((tag2_nt_enc >> 0) & 0xFF) ^ tag2_ks_next_bit) ? " " : "!"); + printf("\n"); printf("s = crypto1_create(key)\n"); uint64_t reader2_ui64Key = NESTED_KEY; struct Crypto1State reader2_state = {0, 0}; @@ -261,73 +261,73 @@ int main(void) { uint32_t reader2_ks_next_bit = filter(reader2_state.odd); printf("{nR}|{aR} -> > "); printf("%02X%s ", (reader2_nr_enc >> 24) & 0xFF, - oddparity8((reader2_nr >> 24) & 0xFF) == - (oddparity8((reader2_nr_enc >> 24) & 0xFF) ^ ((reader2_ks1 >> 16) & 1)) ? " " : "!"); + oddparity8((reader2_nr >> 24) & 0xFF) == + (oddparity8((reader2_nr_enc >> 24) & 0xFF) ^ ((reader2_ks1 >> 16) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_nr_enc >> 16) & 0xFF, - oddparity8((reader2_nr >> 16) & 0xFF) == - (oddparity8((reader2_nr_enc >> 16) & 0xFF) ^ ((reader2_ks1 >> 8) & 1)) ? " " : "!"); + oddparity8((reader2_nr >> 16) & 0xFF) == + (oddparity8((reader2_nr_enc >> 16) & 0xFF) ^ ((reader2_ks1 >> 8) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_nr_enc >> 8) & 0xFF, - oddparity8((reader2_nr >> 8) & 0xFF) == - (oddparity8((reader2_nr_enc >> 8) & 0xFF) ^ ((reader2_ks1 >> 0) & 1)) ? " " : "!"); + oddparity8((reader2_nr >> 8) & 0xFF) == + (oddparity8((reader2_nr_enc >> 8) & 0xFF) ^ ((reader2_ks1 >> 0) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_nr_enc >> 0) & 0xFF, - oddparity8((reader2_nr >> 0) & 0xFF) == - (oddparity8((reader2_nr_enc >> 0) & 0xFF) ^ ((reader2_ks2 >> 24) & 1)) ? " " : "!"); + oddparity8((reader2_nr >> 0) & 0xFF) == + (oddparity8((reader2_nr_enc >> 0) & 0xFF) ^ ((reader2_ks2 >> 24) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_ar_enc >> 24) & 0xFF, - oddparity8((reader2_ar >> 24) & 0xFF) == - (oddparity8((reader2_ar_enc >> 24) & 0xFF) ^ ((reader2_ks2 >> 16) & 1)) ? " " : "!"); + oddparity8((reader2_ar >> 24) & 0xFF) == + (oddparity8((reader2_ar_enc >> 24) & 0xFF) ^ ((reader2_ks2 >> 16) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_ar_enc >> 16) & 0xFF, - oddparity8((reader2_ar >> 16) & 0xFF) == - (oddparity8((reader2_ar_enc >> 16) & 0xFF) ^ ((reader2_ks2 >> 8) & 1)) ? " " : "!"); + oddparity8((reader2_ar >> 16) & 0xFF) == + (oddparity8((reader2_ar_enc >> 16) & 0xFF) ^ ((reader2_ks2 >> 8) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_ar_enc >> 8) & 0xFF, - oddparity8((reader2_ar >> 8) & 0xFF) == - (oddparity8((reader2_ar_enc >> 8) & 0xFF) ^ ((reader2_ks2 >> 0) & 1)) ? " " : "!"); + oddparity8((reader2_ar >> 8) & 0xFF) == + (oddparity8((reader2_ar_enc >> 8) & 0xFF) ^ ((reader2_ks2 >> 0) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_ar_enc >> 0) & 0xFF, - oddparity8((reader2_ar >> 0) & 0xFF) == - (oddparity8((reader2_ar_enc >> 0) & 0xFF) ^ reader2_ks_next_bit) ? " " : "!"); + oddparity8((reader2_ar >> 0) & 0xFF) == + (oddparity8((reader2_ar_enc >> 0) & 0xFF) ^ reader2_ks_next_bit) ? " " : "!"); printf("\n"); - uint32_t tag2_nr_enc = reader2_nr_enc; - uint32_t tag2_ar_enc = reader2_ar_enc; + uint32_t tag2_nr_enc = reader2_nr_enc; + uint32_t tag2_ar_enc = reader2_ar_enc; printf(" ks1 = crypto1_word(s, {nR}, 1) "); - uint32_t tag2_ks1 = crypto1_word(&tag2_state, tag2_nr_enc, 1); - printf("%08X\n", tag2_ks1); + uint32_t tag2_ks1 = crypto1_word(&tag2_state, tag2_nr_enc, 1); + printf("%08X\n", tag2_ks1); printf(" nR = ks1 ^ {nR} "); - uint32_t tag2_nr = tag2_ks1 ^ tag2_nr_enc; - printf("%08X\n", tag2_nr); + uint32_t tag2_nr = tag2_ks1 ^ tag2_nr_enc; + printf("%08X\n", tag2_nr); printf(" ks2 = crypto1_word(s, 0, 0) "); - uint32_t tag2_ks2 = crypto1_word(&tag2_state, 0, 0); - printf("%08X\n", tag2_ks2); + uint32_t tag2_ks2 = crypto1_word(&tag2_state, 0, 0); + printf("%08X\n", tag2_ks2); printf(" aR = ks2 ^ {aR} "); - uint32_t tag2_ar = tag2_ks2 ^ tag2_ar_enc; - printf("%08X\n", tag2_ar); + uint32_t tag2_ar = tag2_ks2 ^ tag2_ar_enc; + printf("%08X\n", tag2_ar); printf(" aR == suc64(nT) ? "); - printf("%08X %s\n", prng_successor(tag2_nt, 64), tag2_ar == prng_successor(tag2_nt, 64) ? "OK" : "FAIL"); + printf("%08X %s\n", prng_successor(tag2_nt, 64), tag2_ar == prng_successor(tag2_nt, 64) ? "OK" : "FAIL"); printf(" aT = suc96(nT) "); - uint32_t tag2_at = prng_successor(tag2_nt, 96); - printf("%08X\n", tag2_at); + uint32_t tag2_at = prng_successor(tag2_nt, 96); + printf("%08X\n", tag2_at); printf(" ks3 = crypto1_word(s, 0, 0) "); - uint32_t tag2_ks3 = crypto1_word(&tag2_state, 0, 0); - printf("%08X\n", tag2_ks3); + uint32_t tag2_ks3 = crypto1_word(&tag2_state, 0, 0); + printf("%08X\n", tag2_ks3); printf(" ks4 = crypto1_word(s, 0, 0) "); - uint32_t tag2_ks4 = crypto1_word(&tag2_state, 0, 0); - printf("%08X\n", tag2_ks4); + uint32_t tag2_ks4 = crypto1_word(&tag2_state, 0, 0); + printf("%08X\n", tag2_ks4); printf(" {aT} = ks3 ^ aT "); - uint32_t tag2_at_enc = tag2_ks3 ^ tag2_at; - printf("%08X\n", tag2_at_enc); + uint32_t tag2_at_enc = tag2_ks3 ^ tag2_at; + printf("%08X\n", tag2_at_enc); printf(" <- {aT} < "); - printf("%02X%s ", (tag2_at_enc >> 24) & 0xFF, - oddparity8((tag2_at >> 24) & 0xFF) == - (oddparity8((tag2_at_enc >> 24) & 0xFF) ^ ((tag2_ks3 >> 16) & 1)) ? " " : "!"); - printf("%02X%s ", (tag2_at_enc >> 16) & 0xFF, - oddparity8((tag2_at >> 16) & 0xFF) == - (oddparity8((tag2_at_enc >> 16) & 0xFF) ^ ((tag2_ks3 >> 8) & 1)) ? " " : "!"); - printf("%02X%s ", (tag2_at_enc >> 8) & 0xFF, - oddparity8((tag2_at >> 8) & 0xFF) == - (oddparity8((tag2_at_enc >> 8) & 0xFF) ^ ((tag2_ks3 >> 0) & 1)) ? " " : "!"); - printf("%02X%s ", (tag2_at_enc >> 0) & 0xFF, - oddparity8((tag2_at >> 0) & 0xFF) == - (oddparity8((tag2_at_enc >> 0) & 0xFF) ^ ((tag2_ks4 >> 24) & 1)) ? " " : "!"); - printf("\n"); + printf("%02X%s ", (tag2_at_enc >> 24) & 0xFF, + oddparity8((tag2_at >> 24) & 0xFF) == + (oddparity8((tag2_at_enc >> 24) & 0xFF) ^ ((tag2_ks3 >> 16) & 1)) ? " " : "!"); + printf("%02X%s ", (tag2_at_enc >> 16) & 0xFF, + oddparity8((tag2_at >> 16) & 0xFF) == + (oddparity8((tag2_at_enc >> 16) & 0xFF) ^ ((tag2_ks3 >> 8) & 1)) ? " " : "!"); + printf("%02X%s ", (tag2_at_enc >> 8) & 0xFF, + oddparity8((tag2_at >> 8) & 0xFF) == + (oddparity8((tag2_at_enc >> 8) & 0xFF) ^ ((tag2_ks3 >> 0) & 1)) ? " " : "!"); + printf("%02X%s ", (tag2_at_enc >> 0) & 0xFF, + oddparity8((tag2_at >> 0) & 0xFF) == + (oddparity8((tag2_at_enc >> 0) & 0xFF) ^ ((tag2_ks4 >> 24) & 1)) ? " " : "!"); + printf("\n"); uint32_t reader2_at_enc = tag2_at_enc; printf("ks3 = crypto1_word(s, 0, 0) "); @@ -345,7 +345,7 @@ int main(void) { printf("ks4 = crypto1_word(s, 0, 0) "); uint32_t reader2_ks4 = crypto1_word(&reader2_state, 0, 0); printf("%08X\n", reader2_ks4); - uint32_t reader2_cmd = (cmd[0] << 24)|(cmd[1] << 16)|(cmd[2] << 8)|(cmd[3] << 0); + uint32_t reader2_cmd = (cmd[0] << 24) | (cmd[1] << 16) | (cmd[2] << 8) | (cmd[3] << 0); uint32_t reader2_cmd_enc = reader2_ks4 ^ reader2_cmd; printf("{cmd} = ks4 ^ cmd "); printf("%08X\n", reader2_cmd_enc); @@ -353,17 +353,17 @@ int main(void) { printf("{auth A/B+blk} -> > "); printf("%02X%s ", (reader2_cmd_enc >> 24) & 0xFF, - oddparity8((reader2_cmd >> 24) & 0xFF) == - (oddparity8((reader2_cmd_enc >> 24) & 0xFF) ^ ((reader2_ks4 >> 16) & 1)) ? " " : "!"); + oddparity8((reader2_cmd >> 24) & 0xFF) == + (oddparity8((reader2_cmd_enc >> 24) & 0xFF) ^ ((reader2_ks4 >> 16) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_cmd_enc >> 16) & 0xFF, - oddparity8((reader2_cmd >> 16) & 0xFF) == - (oddparity8((reader2_cmd_enc >> 16) & 0xFF) ^ ((reader2_ks4 >> 8) & 1)) ? " " : "!"); + oddparity8((reader2_cmd >> 16) & 0xFF) == + (oddparity8((reader2_cmd_enc >> 16) & 0xFF) ^ ((reader2_ks4 >> 8) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_cmd_enc >> 8) & 0xFF, - oddparity8((reader2_cmd >> 8) & 0xFF) == - (oddparity8((reader2_cmd_enc >> 8) & 0xFF) ^ ((reader2_ks4 >> 0) & 1)) ? " " : "!"); + oddparity8((reader2_cmd >> 8) & 0xFF) == + (oddparity8((reader2_cmd_enc >> 8) & 0xFF) ^ ((reader2_ks4 >> 0) & 1)) ? " " : "!"); printf("%02X%s ", (reader2_cmd_enc >> 0) & 0xFF, - oddparity8((reader2_cmd >> 0) & 0xFF) == - (oddparity8((reader2_cmd_enc >> 0) & 0xFF) ^ reader2_ks_next_bit) ? " " : "!"); + oddparity8((reader2_cmd >> 0) & 0xFF) == + (oddparity8((reader2_cmd_enc >> 0) & 0xFF) ^ reader2_ks_next_bit) ? " " : "!"); printf("\n"); return 0; diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index a93015d71..eabf8b5e4 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -421,9 +421,9 @@ while true; do if ! CheckExecute "reveng readline test" "$CLIENTBIN -c 'reveng -h;reveng -D'" "CRC-64/GO-ISO"; then break; fi if ! CheckExecute "reveng -g test" "$CLIENTBIN -c 'reveng -g abda202c'" "CRC-16/ISO-IEC-14443-3-A"; then break; fi if ! CheckExecute "reveng -w test" "$CLIENTBIN -c 'reveng -w 8 -s 01020304e3 010204039d'" "CRC-8/SMBUS"; then break; fi - if ! CheckExecute "mfu pwdgen test" "$CLIENTBIN -c 'hf mfu pwdgen -t'" "Selftest ok"; then break; fi + if ! CheckExecute "mfu pwdgen test" "$CLIENTBIN -c 'hf mfu pwdgen --test'" "Selftest ok"; then break; fi if ! CheckExecute "mfu keygen test" "$CLIENTBIN -c 'hf mfu keygen --uid 11223344556677'" "80 B1 C2 71 D8 A0"; then break; fi - if ! CheckExecute "jooki encode test" "$CLIENTBIN -c 'hf jooki encode -t'" "04 28 F4 DA F0 4A 81 \( ok \)"; then break; fi + if ! CheckExecute "jooki encode test" "$CLIENTBIN -c 'hf jooki encode --test'" "04 28 F4 DA F0 4A 81 \( ok \)"; then break; fi if ! CheckExecute "trace load/list 14a" "$CLIENTBIN -c 'trace load -f traces/hf_14a_mfu.trace; trace list -1 -t 14a;'" "READBLOCK\(8\)"; then break; fi if ! CheckExecute "trace load/list x" "$CLIENTBIN -c 'trace load -f traces/hf_14a_mfu.trace; trace list -x1 -t 14a;'" "0.0101840425"; then break; fi if ! CheckExecute "nfc decode test - oob" "$CLIENTBIN -c 'nfc decode -d DA2010016170706C69636174696F6E2F766E642E626C7565746F6F74682E65702E6F6F62301000649201B96DFB0709466C65782032'" "Flex 2"; then break; fi