Skip to content

feat(internet): verify HIP's RVS_HMAC and RELAY_HMAC parameters (#3187) - #3193

Merged
JarryShaw merged 1 commit into
developfrom
feat/3187-hip-rvs-relay-hmac
Nov 29, 2026
Merged

JarryShaw merged 1 commit into
developfrom
feat/3187-hip-rvs-relay-hmac

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

  • Put an x into every box [ ] that applies to your pull request (like this: [x])

  • Use the Preview tab to see how your pull request will look

  • Searched for similar pull requests

  • Followed the coding style (make pylint, make mypy, make isort)

  • make test passes, and a test case covers the change

  • Described the user-visible change below and left its changelog entry to the maintainer, keeping docs/source/changelog/ and CHANGELOG.md out of the diff, if the change is user-visible: N/A — centralised

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect

  • feat — adds a feature

  • perf — changes performance, not behaviour

  • refactor — changes neither behaviour nor performance

  • test — tests only

  • docs — documentation only

  • ci — workflows or build tooling

  • release — bumps the version or rolls up a distribution

  • chore — anything else

  • Also tick if it regenerates constant or registry tables, members keeping their numeric values (the const label)


Description of your pull request and other information

Closes #3187.

  • New HIPRegistration(association, *, registrar, reg_type): a requester's registration (RFC 8003) with its rendezvous server or relay, registered in HIPContext beside identities and associations. HIPContext.match_registrations() returns every one a packet may flow through; REGISTRATION_HMAC maps RVS_HMAC to RENDEZVOUS (RFC 8004 §4.2.1) and RELAY_HMAC to RELAY_UDP_HIP / RELAY_UDP_ESP (RFC 9028 §5.8, §4.1, §4.12.2).
  • _verify_hip_mac() now takes both: same _auth_scope() (header and every parameter before the HMAC, Checksum zeroed, Header Length recounted), keyed by the sending side, so a packet the server relays to its client (third-party Sender's HIT) is under the server's HIP-gl/HIP-lg and one the client sends under its own. A packet's HITs need not identify its registration (one registrar serving both hosts, one requester with several registrars), so each match is tried: VALID if any verifies, INVALID if none, NO_KEY if none matches. Records hmac_status; parsing and rebuilds are unchanged. HIPv1 (RFC 5770's base) reports UNSUPPORTED, as feat(internet): verify HIP's HMAC and signature parameters #2939 does.
  • HIPContext.__repr__ gains registrations=N; test_hip_auth_2939_unit updated for it.
  • test_hip_registration_hmac_3187_unit (19 tests): relayed I1 with FROM + RVS_HMAC, relayed I1/I2 with RELAY_FROM + RELAY_HMAC, client↔server packets, and ambiguous registrations in both context orders, each against HMACs computed with hmac, plus tamper cases (FROM / RELAY_FROM / Sender's HIT, the other side's key, on-wire Header Length, non-zero Checksum) that must report INVALID. All fail on an untouched origin/develop export. Key-direction mutations (swapped sides, key by role instead of by greater HIT, swapped HITs, first match only) each fail the suite.
  • Tests (3.14, after make_samples.py, -n 2): tests/project 2428 passed; tests/protocols/test_*.py 741; the HIP modules 213. HIP protocol.py coverage over the HIP tests 99.39% → 99.47%; no pins moved.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 28, 2026
@github-actions github-actions Bot added this to the PyPCAPKit v1.9 milestone Nov 28, 2026
@JarryShaw JarryShaw linked an issue Nov 28, 2026 that may be closed by this pull request
@JarryShaw JarryShaw added feat Pull requests that add a new capability (feat: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Nov 28, 2026
@read-the-docs-community

Copy link
Copy Markdown

@JarryShaw

Copy link
Copy Markdown
Owner Author

Needs changes at 1f6f83ecaa. A Sonnet review found one blocking defect, and I confirmed it on the head.

  • match_registration returns the first registration whose requester is the sender or the receiver.
  • When two clients I and R share an RVS, a valid RVS_HMAC on an I1 from I to R reports INVALID with context (regI, regR) and VALID with (regR, regI). The result depends on registration order.
  • Fix: try every matching registration, and report INVALID only if none of them verifies. Test both orders and the case of two registrars for one requester.

Confirmed and unchanged: the HMAC scope and key direction against the RFC text, RELAY_UDP_ESP keying RELAY_HMAC, and HIPv1 reporting UNSUPPORTED. The original worker is amending.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Nov 28, 2026
- HIPRegistration holds a requester's registration with its rendezvous
  server or relay (RFC 8003): the association, the registrar's HIT and
  the Registration Types granted. HIPContext registers it, and
  match_registrations() returns every one a packet may flow through.
- REGISTRATION_HMAC maps RVS_HMAC to RENDEZVOUS (RFC 8004 section 4.2.1)
  and RELAY_HMAC to RELAY_UDP_HIP and RELAY_UDP_ESP (RFC 9028 section 5.8).
- _verify_hip_mac() verifies both over _auth_scope(), keyed by the
  sending side, trying each matching registration: VALID if any verifies,
  INVALID if none does, NO_KEY if none matches. Parsing is unchanged.
@JarryShaw
JarryShaw force-pushed the feat/3187-hip-rvs-relay-hmac branch from 1f6f83e to f73c547 Compare November 28, 2026 15:13
@JarryShaw

Copy link
Copy Markdown
Owner Author

Good to go at f73c547490. I checked the fix on the head myself.

  • match_registrations returns every registration of a wanted type that matches.
  • _verify_hip_mac tries each candidate's key in order. It reports VALID on the first that verifies, INVALID only if none does, and NO_KEY if nothing matches. HIP_MAC and HIP_MAC_2 run through the same loop with their single association.
  • New tests: two clients sharing one registrar and two registrars serving one requester, each run in both context orders. All 19 tests in the module fail on develop.
  • Four mutations each make the module fail: a key-direction swap, choosing the key by role instead of by greater HIT, swapped HITs, and first-match-only.
  • tests/project passes (2428), and so do the protocol sweeps (741). It is one commit and merges cleanly.

The old name match_registration was never released, so the rename needs no note.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 94.81% (unit tier, Python 3.15, f73c54749, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 110 4 20 2 95.38%
pcapkit/const 21941 215 3126 188 98.31%
pcapkit/corekit 3160 83 1058 40 96.85%
pcapkit/dumpkit 423 3 148 5 98.60%
pcapkit/foundation 4129 24 1330 26 99.08%
pcapkit/interface 103 4 34 3 94.89%
pcapkit/protocols 27458 158 7194 129 99.16%
pcapkit/toolkit 1016 26 360 8 96.80%
pcapkit/utilities 596 7 162 5 98.42%
pcapkit/vendor 6356 2388 1436 250 59.11%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 4fae8d7 into develop Nov 29, 2026
72 of 73 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 29, 2026
@JarryShaw
JarryShaw deleted the feat/3187-hip-rvs-relay-hmac branch November 29, 2026 02:37
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Pull requests that add a new capability (feat: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(internet): verify HIP's RVS_HMAC and RELAY_HMAC parameters

1 participant