+ out->parityValid =
+ (evenparity32((hi & 0x00000001) ^ (lo & 0xB6DB6DB6)) == ((hi >> 1) & 1)) &&
+ (oddparity32( (hi & 0x00000003) ^ (lo & 0x6DB6DB6C)) == ((lo >> 0) & 1)) &&
+ (oddparity32( (hi & 0x00000003) ^ (lo & 0xFFFFFFFF)) == ((hi >> 2) & 1));
+ if (g_debugMode) {
+ PrintAndLog("Parity check: calculated {%d, %d, %d}, provided {%d, %d, %d}",
+ evenparity32((hi & 0x00000001) ^ (lo & 0xB6DB6DB6)),
+ oddparity32( (hi & 0x00000003) ^ (lo & 0x6DB6DB6C)),
+ oddparity32( (hi & 0x00000003) ^ (lo & 0xFFFFFFFF)),
+ ((hi >> 1) & 1),
+ ((lo >> 0) & 1),
+ ((hi >> 2) & 1)
+ );
+ }
+ break;
+
+ case 37: // HID H10304
+ out->fmtLen = 37;
+ out->cardnum = (lo >> 1) & 0x7FFFF;
+ out->fc = ((hi & 0xF) << 12) | (lo >> 20);
+ out->parityValid =
+ (evenparity32((hi & 0x0000000F) ^ (lo & 0xFFFC0000)) == ((hi >> 4) & 1)) &&
+ (oddparity32( lo & 0x0007FFFE) == (lo & 1));
+ break;
+
+ case 48: // HID Corporate 1000-48
+ out->cardnum = (lo >> 1) & 0x7FFFFF; //Start 24, 23 length
+ out->fc = ((hi & 0x3FFF) << 8 ) | (lo >> 24); //Start 2, 22 length
+ out->parityValid =
+ (evenparity32((hi & 0x00001B6D) ^ (lo & 0xB6DB6DB6)) == ((hi >> 14) & 1)) &&
+ (oddparity32( (hi & 0x000036DB) ^ (lo & 0x6DB6DB6C)) == ((lo >> 0) & 1)) &&
+ (oddparity32( (hi & 0x00007FFF) ^ (lo & 0xFFFFFFFF)) == ((hi >> 15) & 1));
+ if (g_debugMode) {
+ PrintAndLog("Parity check: calculated {%d, %d, %d}, provided {%d, %d, %d}",
+ evenparity32((hi & 0x00001B6D) ^ (lo & 0xB6DB6DB6)),
+ oddparity32( (hi & 0x000036DB) ^ (lo & 0x6DB6DB6C)),
+ oddparity32( (hi & 0x00007FFF) ^ (lo & 0xFFFFFFFF)),
+ ((hi >> 14) & 1),
+ ((lo >> 0) & 1),
+ ((hi >> 15) & 1)
+ );
+ }