Skip to main content

Crate kerbcore

Crate kerbcore 

Source
Expand description

§kerbcore

Pure-Rust Kerberos building blocks — no FFI, no dependency on a host krb5, #![forbid(unsafe_code)]. Three layers, each cross-checked against RFC known-answer vectors and (for the codec) a differential re-encode oracle:

  • crypto — RFC 3961 / 3962 AES-CTS-HMAC-SHA1 (etypes 17 & 18): n-fold, AES CBC-CTS, DR/DK, HMAC-SHA1-96, subkey derivation, PBKDF2 string-to-key, and the generic encrypt-then-integrity primitive.
  • rfc8009 — RFC 8009 AES-SHA2 (etypes 19 & 20): SP800-108 KDF, encrypt-then-MAC, string-to-key. rc4 — RFC 4757 RC4-HMAC (etype 23).
  • der + types + messages — a hand-rolled X.690 DER codec (total, never-panicking decoder) and the RFC 4120 message set (Ticket, AS/TGS REQ+REP, KRB-ERROR, PA-DATA). client assembles AS-REQ / TGS-REQ and parses the KDC’s reply — including the AP exchange (AP-REQ builder + AP-REP mutual-auth verification), EncKDCRepPart nonce anti-replay, ETYPE-INFO2 s2kparams, and RFC 6806 cross-realm referral detection + credential lifecycle (renew/validate).
  • Higher protocol layers: gss (RFC 4121 krb5-gss context token + MIC + Wrap), spnego (RFC 4178 negotiation), kkdcp (MS-KKDCP HTTPS proxy container), kpasswd (RFC 3244 change/set-password + a KRB-PRIV codec), and fast (RFC 6113 FAST wire codec + KRB-FX-CF2 armor-key math — the end-to-end AES-SHA1 PRF + a live-DC round-trip are the remaining gap; see the module docs).

This is the crate that replaces picky-krb inside ADhammer’s Kerberos stack. Offensive compositions (golden / silver / diamond / S4U-abuse / PKINIT-relay) intentionally do not live here — they stay in the ADhammer CLI per its dual-use rule.

§Status

0.2.x — the AS/TGS crypto + codec + client are complete and live-validated (real TGT + service ticket) against Windows Server 2019 / 2022 / 2025. The API is pre-1.0 and may change. 0.2.0 adds the typed KerberosKey / Enctype abstraction: one key value dispatches encrypt / decrypt / checksum / string-to-key across the whole etype matrix (17/18/19/20/23), zeroizes its bytes on drop, and never prints them via Debug. (The client::build_tgs_req wire path still targets the AES-SHA1 session-key profile AD issues; migrating it onto KerberosKey is next.)

Re-exports§

pub use keys::Enctype;
pub use keys::KerberosKey;
pub use keys::KeyError;
pub use crypto::*;

Modules§

acceptor
Server-side AP-REQ acceptor scaffold — the half kerbcore was missing.
client
AS-exchange client helpers — assemble an AS-REQ, build the PA-ENC-TIMESTAMP pre-auth, and parse the pieces of the KDC’s reply. Pure (no I/O): the caller owns the socket. This is the glue that ties crate::crypto / crate::rfc8009 (keys) to crate::messages (wire) into a real Kerberos AS handshake — the last layer before kerbcore can replace picky-krb.
config
MIT krb5.conf loader — the migration path for callers coming from libgssapi.
crypto
RFC 3961 / RFC 3962 crypto for the AES-CTS-HMAC-SHA1 Kerberos profiles — aes128-cts-hmac-sha1-96 (etype 17) and aes256-cts-hmac-sha1-96 (etype 18), the AES profiles every modern Active Directory KDC negotiates.
der
Minimal DER (X.690) codec — only the subset RFC 4120 Kerberos needs.
fast
RFC 6113 — Kerberos FAST (Flexible Authentication Secure Tunneling), the ms-kile-fast armoring layer. FAST wraps an AS/TGS exchange inside an armored tunnel keyed by an armor key, defeating offline pre-auth dictionary attacks and enabling PKINIT/OTP secure channels.
gss
RFC 4121 — the Kerberos V5 GSS-API mechanism (krb5-gss).
keys
Typed enctype + key abstraction (0.2.0). One KerberosKey carries its Enctype and dispatches encrypt / decrypt / checksum / string-to-key to the correct family, so a caller can no longer (a) advertise the wrong etype, (b) feed a mis-sized key into an AES primitive (previously a panic!), or (c) leak key bytes through Debug. This wraps the proven per-family code in crate::crypto / crate::rfc8009 / crate::rc4 — it is a dispatch layer, not a reimplementation.
kkdcp
MS-KKDCP — the Kerberos KDC Proxy Protocol. Tunnels AS/TGS exchanges to a KDC over HTTPS (POST to https://<proxy>/KdcProxy) when UDP/TCP 88 is not reachable — the common path for Kerberos from outside a network boundary.
kpasswd
RFC 3244 / MS-KPWD — the Kerberos change-password / set-password protocol (port 464).
messages
RFC 4120 message layer — Ticket, KDC-REQ (AS-REQ / TGS-REQ), KDC-REP (AS-REP / TGS-REP), and KRB-ERROR. Built on crate::der and crate::types; every decode() is total (no panics on hostile bytes).
rc4
etype 23 — rc4-hmac (RFC 4757 / MS-KILE).
rfc8009
etypes 19 & 20 — the RFC 8009 AES-SHA2 Kerberos profiles: aes128-cts-hmac-sha256-128 (19) and aes256-cts-hmac-sha384-192 (20).
spnego
RFC 4178 — SPNEGO (the 1.3.6.1.5.5.2 GSS pseudo-mechanism used by SMB/HTTP/LDAP on Windows). SPNEGO negotiates which real mechanism (here: crate::gss krb5) both sides speak, then carries that mechanism’s tokens inside its own frames.
types
RFC 4120 foundational data types — the shared vocabulary every Kerberos message is built from. Each type owns its DER encode() and a total decode() (no panics on hostile bytes; see crate::der).

Enums§

KerbError
Umbrella error covering every failure mode kerbcore surfaces. Per-module errors (DerError, KeyError, GssError, …) are the precise types the individual APIs return; KerbError is what a caller uses at their public API boundary when they want ONE error type to bubble.