Skip to content

Add U2F (FIDO U2F-over-HID) as a Scapy contrib protocol layer#36

Draft
Copilot wants to merge 1 commit into
masterfrom
copilot/implement-u2f-protocol
Draft

Add U2F (FIDO U2F-over-HID) as a Scapy contrib protocol layer#36
Copilot wants to merge 1 commit into
masterfrom
copilot/implement-u2f-protocol

Conversation

Copy link
Copy Markdown

Copilot AI commented May 25, 2026

This PR adds a new contrib implementation for the U2F protocol, focused on U2F HID framing and core command payload parsing. It enables Scapy to build/dissect U2F initialization, continuation, error/lock flows, and MSG-carried U2F APDU payloads.

  • New contrib layer: scapy.contrib.u2f

    • Introduces U2F HID packet model with frame-type dispatch:
      • U2FHID (dispatcher)
      • U2FHIDInit (init frame)
      • U2FHIDCont (continuation frame)
    • Adds U2F HID command/error enums for readable dissections.
  • Command-specific payload decoding

    • Implements payload packets for core HID commands:
      • U2FHIDInitReq (nonce request)
      • U2FHIDInitResp (channel/version/capability response)
      • U2FHIDLock
      • U2FHIDError
    • Adds command-aware payload guessing from U2FHIDInit (INIT, LOCK, ERROR, MSG).
  • U2F message payload support

    • Adds U2FAPDU for CMD_MSG content:
      • cla, ins, p1, p2, lc, and length-bound data
    • Supports common U2F instructions (REGISTER, AUTHENTICATE, VERSION).
  • Contrib campaign coverage

    • Adds test/contrib/u2f.uts with focused build/dissect roundtrip checks for init request/response, error frame, APDU message frame, and continuation frame parsing.
load_contrib("u2f")

pkt = U2FHIDInit(cid=0xFFFFFFFF, cmd="INIT") / U2FHIDInitReq(
    nonce=hex_bytes("0102030405060708")
)
assert raw(pkt) == hex_bytes("ffffffff8600080102030405060708")

msg = U2FHIDInit(cid=0x01020304, cmd="MSG") / U2FAPDU(
    ins="AUTHENTICATE", p1=0x03, lc=2, data=hex_bytes("aabb")
)

Agent-Logs-Url: https://github.com/polybassa/scapy-1/sessions/2eccc377-9d89-4047-a17c-1fcdfee95dfd

Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
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