+ } // end for loop
+
+ } else {
+
+ // Data start point on unsegmented cards
+ i = 8;
+
+ wrp = data_buf[7] & 0x0F;
+ wrc = (data_buf[7] & 0x70) >> 4;
+
+ bool hasWRC = (wrc > 0);
+ bool hasWRP = (wrp > wrc);
+ int wrp_len = (wrp - wrc);
+ int remain_seg_payload_len = (1024 - 22 - wrp); // Any chance to get physical card size here!?
+
+ PrintAndLog("Unsegmented card - WRP: %02u, WRC: %02u, RD: %01u",
+ wrp,
+ wrc,
+ (data_buf[7] & 0x80) >> 7
+ );
+
+ if ( hasWRC ) {
+ PrintAndLog("WRC protected area: (I %d | WRC %d)", i, wrc);
+ PrintAndLog("\nrow | data");
+ PrintAndLog("-----+------------------------------------------------");
+ print_hex_break( data_buf+i, wrc, 16);
+ i += wrc;
+ }
+
+ if ( hasWRP ) {
+ PrintAndLog("Remaining write protected area: (I %d | WRC %d | WRP %d | WRP_LEN %d)", i, wrc, wrp, wrp_len);
+ PrintAndLog("\nrow | data");
+ PrintAndLog("-----+------------------------------------------------");
+ print_hex_break( data_buf + i, wrp_len, 16);
+ i += wrp_len;
+
+ // does this one work? (Answer: Only if KGH/BGH is used with BCD encoded card number! So maybe this will show just garbage...)
+ if( wrp_len == 8 )
+ PrintAndLog("Card ID: %2X%02X%02X", data_buf[i-4], data_buf[i-3], data_buf[i-2]);
+ }
+
+ PrintAndLog("Remaining segment payload: (I %d | Remain LEN %d)", i, remain_seg_payload_len);
+ PrintAndLog("\nrow | data");
+ PrintAndLog("-----+------------------------------------------------");
+ print_hex_break( data_buf + i, remain_seg_payload_len, 16);
+ i += remain_seg_payload_len;
+
+ PrintAndLog("-----+------------------------------------------------\n");
+ }
+ }