Skip to content

Unify HF reading and PACS parsing#31

Merged
bettse merged 8 commits intobettse:mainfrom
cindersocket:feat-unify-hf
Mar 9, 2026
Merged

Unify HF reading and PACS parsing#31
bettse merged 8 commits intobettse:mainfrom
cindersocket:feat-unify-hf

Conversation

@cindersocket
Copy link
Contributor

This PR creates a unified HF read path and fixes a PAC parsing regression that showed up as soon as I started routing more credentials through the requestPacs2 flow.

Credentials which should have been showing up as 26-bit PACS were instead showing up as 40-bit in debug, which meant the Wiegand parser never recognized them and the Parse action disappeared. The root cause was in how Pacs2.bits was being handled. Seader was effectively treating that response like the older PAC path and rebuilding a synthetic DER BIT STRING, but ResponseGetContentElement2 already gives back Content Element Data where PAC bits are formatted as a BIT STRING payload. In practice that means the leading byte is the DER BIT STRING unused-bits count, and we need to trim with that instead of accidentally treating it as credential data.

What this does:

  • removes the old requestPacs path from the schema and regenerates the ASN.1 output
  • keeps SamResponse in place for version / serial / config / other non-PACS flows
  • makes PAC reads use only requestPacs2
  • removes the legacy seader_unpack_pacs() flow entirely
  • adds PACS2-only unpacking that interprets Pacs2.bits as:
  • first byte = BIT STRING unused-bits count
  • remaining bytes = actual PAC payload
  • stores the PAC using the trimmed bit length, so 26-bit credentials land as 26-bit again instead of 40-bit

A couple of related cleanups fell out of that:

  • the old dual-intent PAC state (ReadPacs vs ReadPacs2) is gone, so the read path is simpler now
  • card-detected handling now always follows into requestPacs2 for PAC reads
  • regenerated SamCommand no longer exposes the legacy request variant

@netlify
Copy link

netlify bot commented Mar 8, 2026

Deploy Preview for seader canceled.

Name Link
🔨 Latest commit 800b9be
🔍 Latest deploy log https://app.netlify.com/projects/seader/deploys/69ae0dfb1937bb00086e6886

bettse added a commit that referenced this pull request Mar 8, 2026
bettse added a commit that referenced this pull request Mar 8, 2026
bettse added a commit that referenced this pull request Mar 8, 2026
@bettse bettse merged commit 34e08a7 into bettse:main Mar 9, 2026
5 checks passed
@cindersocket cindersocket deleted the feat-unify-hf branch March 9, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants