Add FIDO U2F protocol as a Scapy contrib layer#37
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/polybassa/scapy-1/sessions/9e30e1f3-386e-48d2-b4b7-edad0d79a1fb Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Agent-Logs-Url: https://github.com/polybassa/scapy-1/sessions/9e30e1f3-386e-48d2-b4b7-edad0d79a1fb Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
polybassa
May 25, 2026 20:01
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the FIDO U2F (Universal 2nd Factor) protocol stack as
scapy/contrib/u2f.py, covering both the HID transport framing and the application-layer APDU messages.HID Transport (
U2FHID)U2FHIDInitializationPacket—CID(4) | CMD(1) | BCNT(2) | payload; auto-computesbcnton build, strips HID frame zero-padding on dissect, dispatches payload class viaguess_payload_classbased oncmdandbcntU2FHIDContinuationPacket—CID(4) | SEQ(1) | payloadfor multi-packet messagesU2FHIDINITRequest/U2FHIDINITResponse— INIT command nonce exchange + channel allocation with capability flags (WINK,CBOR,NMSG)U2FHIDError— single-byte error payloadAPDU Layer
U2FCommandAPDU— ISO 7816-4 extended-length encoding:CLA | INS | P1 | P2 | 0x00 | Lc(2) | data | Le(2);lcauto-computed fromdataU2FResponseAPDU—data(var) | SW1 | SW2; uses a custom field that peels the trailing 2-byte status word before handing remaining bytes toSW1/SW2fieldsApplication Messages
U2FRegisterRequest—challenge_parameter(32) | application_parameter(32)U2FRegisterResponse—reserved | user_public_key(65) | key_handle_length | key_handle; DER attestation cert + signature remain as Raw payloadU2FAuthenticateRequest—challenge_parameter(32) | application_parameter(32) | key_handle_length | key_handleU2FAuthenticateResponse—user_presence | counter(4); ECDSA signature as Raw payloadUsage
Layer binding
U2FHIDInitializationPacket(cmd=0x83) → U2FCommandAPDUis registered viabind_layers.