Merge pull request #2761 from jmichelp/master

Add support for proprietary 46bit wiegand H800002 format
This commit is contained in:
Iceman 2025-02-20 11:27:53 +01:00 committed by GitHub
commit 280f340041
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -877,6 +877,47 @@ static bool Unpack_HGeneric37(wiegand_message_t *packed, wiegand_card_t *card) {
return true; return true;
} }
static bool Pack_H800002(int format_idx, wiegand_card_t *card,
wiegand_message_t *packed, bool preamble) {
int even_parity = 0;
memset(packed, 0, sizeof(wiegand_message_t));
if (!validate_card_limit(format_idx, card)) {
return false;
}
packed->Length = 46;
set_linear_field(packed, card->FacilityCode, 1, 14);
set_linear_field(packed, card->CardNumber, 15, 30);
// Parity over 44 bits
even_parity = evenparity32((packed->Bot >> 1) ^ (packed->Mid & 0x1fff));
set_bit_by_position(packed, even_parity, 0);
// Invert parity for setting odd parity
set_bit_by_position(packed, even_parity ^ 1, 45);
if (preamble) {
return add_HID_header(packed);
}
return true;
}
static bool Unpack_H800002(wiegand_message_t *packed, wiegand_card_t *card) {
int even_parity = 0;
memset(card, 0, sizeof(wiegand_card_t));
if (packed->Length != 46) {
return false; // Wrong length? Stop here.
}
card->FacilityCode = get_linear_field(packed, 1, 14);
card->CardNumber = get_linear_field(packed, 15, 30);
even_parity = evenparity32((packed->Bot >> 1) ^ (packed->Mid & 0x1fff));
card->ParityValid = get_bit_by_position(packed, 0) == even_parity;
// Invert logic to compare against oddparity
card->ParityValid &= get_bit_by_position(packed, 45) != even_parity;
return true;
}
static bool Pack_MDI37(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) { static bool Pack_MDI37(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) {
memset(packed, 0, sizeof(wiegand_message_t)); memset(packed, 0, sizeof(wiegand_message_t));
@ -1413,6 +1454,7 @@ static const cardformat_t FormatTable[] = {
{"H10320", Pack_H10320, Unpack_H10320, "HID H10320 37-bit BCD", {1, 0, 0, 0, 1, 0, 99999999, 0, 0}}, // from Proxmark forums {"H10320", Pack_H10320, Unpack_H10320, "HID H10320 37-bit BCD", {1, 0, 0, 0, 1, 0, 99999999, 0, 0}}, // from Proxmark forums
{"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1, 0, 0x7FFFFFFFF, 0, 0}}, // from Proxmark forums {"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1, 0, 0x7FFFFFFFF, 0, 0}}, // from Proxmark forums
{"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1, 0xFFFF, 0x7FFFF, 0, 0}}, // from cardinfo.barkweb.com.au {"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1, 0xFFFF, 0x7FFFF, 0, 0}}, // from cardinfo.barkweb.com.au
{"H800002", Pack_H800002, Unpack_H800002, "HID H800002 46-bit", {1, 1, 0, 0, 1, 0x3FFF, 0x3FFFFFFF, 0, 0}},
{"P10004", Pack_P10004, Unpack_P10004, "HID P10004 37-bit PCSC", {1, 1, 0, 0, 0, 0x1FFF, 0x3FFFF, 0, 0}}, // from @bthedorff; PR #1559 {"P10004", Pack_P10004, Unpack_P10004, "HID P10004 37-bit PCSC", {1, 1, 0, 0, 0, 0x1FFF, 0x3FFFF, 0, 0}}, // from @bthedorff; PR #1559
{"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1, 0, 0x7FFFF, 0, 0}}, // from cardinfo.barkweb.com.au {"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1, 0, 0x7FFFF, 0, 0}}, // from cardinfo.barkweb.com.au
{"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1, 0xF, 0x1FFFFFFF, 0, 0}}, // from cardinfo.barkweb.com.au {"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1, 0xF, 0x1FFFFFFF, 0, 0}}, // from cardinfo.barkweb.com.au