Skip to content

feat(ntp): RFC 5905 symmetric-key MD5 MAC authentication (#361) - #698

Merged
alexis900 merged 1 commit into
developfrom
feat/361-ntp-mac
Oct 13, 2026
Merged

alexis900 merged 1 commit into
developfrom
feat/361-ntp-mac

Conversation

@alexis900

Copy link
Copy Markdown
Collaborator

Fixes #361.

What

RFC 5905 Appendix A symmetric-key authentication (key id + MD5 MAC). NTS (RFC 8915) stays out of scope (no TLS).

  • libntp: MD5 (RFC 1321); build_request_authed / sign_request_md5 / parse_reply_authed (constant-time MAC compare; rejects missing authenticator, key-id mismatch, bad MAC) + parse_key_hex. MAC = MD5(key || packet-through-key-id).
  • ntpd: reads KeyId/Key/Mac from Ntpd\Parameters; sends authenticated requests and requires verified replies when a key is set. Off by default (no Key) — unconfigured behaviour unchanged.
  • docs: docs/services/ntpd.md config table + authentication section + MD5/NTS limitations.

Acceptance criteria (#361)

  • Configured keys cause unauthenticated replies to be rejected — parse_reply_authed enforces it; tested (plain 48-byte reply → AuthMissing).
  • MAC verification tested against known vectors — MD5 RFC 1321 vectors + signed-reply accept/tamper-reject tests. libntp 24/24.
  • Configuration documented in docs/services/ntpd.md.

Limits

MD5 is the RFC 5905 default and is not collision-resistant; NTS is not implemented. The authenticated success path could not be exercised against a real server (no pre-shared key with a public server), so it is covered by unit tests at the parse boundary; the unauthenticated path is unchanged and still syncs in VirtualBox.

QEMU neodev test: 953/953; check-deps clean.

- libntp: MD5 (RFC 1321), RFC 5905 authenticator: build_request_authed,
  sign_request_md5, parse_reply_authed (rejects missing key id / bad MAC via
  constant-time compare), parse_key_hex. MAC = MD5(key || packet-through-keyid).
  New errors AuthMissing/AuthKeyMismatch/AuthFailed.
- ntpd: reads KeyId/Key/Mac from Ntpd\Parameters; when a key is configured it
  sends authenticated requests and rejects unauthenticated replies. Off by
  default (no Key) so unconfigured behaviour is unchanged.
- tests (libntp, host): MD5 RFC 1321 vectors, request key id, valid-MAC accept,
  and rejection of unauthenticated / key-id-mismatch / wrong-key / tampered
  replies, hex key parsing. 24/24.
- docs/services/ntpd.md: KeyId/Key/Mac + authentication and NTS-unsupported note.

NTS (RFC 8915) is out of scope (no TLS). Verified: libntp 24/24; QEMU 953/953.
@alexis900
alexis900 merged commit 992c6c8 into develop Oct 13, 2026
3 checks passed
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.

[NET] NTP authentication (NTS / symmetric MAC)

1 participant