Expand description
§ccache-io — MIT Kerberos credential-cache (v4) read + write, pure Rust.
Consumers of a Kerberos ticket rarely acquire it themselves — an operator drops in a
krb5cc_* file from MIT kinit, from a pentest toolkit, or from Windows via .kirbi
export. To interop with any of it, you need to parse the on-disk format. ccache-io
is a pure-Rust MIT ccache v4 codec with no dependency on libkrb5, krb5-config,
or any FFI — one crate, one file, one thiserror dep.
§Wire format
v0.1 targets the v4 format only (MIT krb5 ≥ 1.4, ubiquitous since 2005):
file = header : primary : cred*
header= u16 version(=0x0504) : u16 header_len : header_len bytes of tagged fields
principal = u32 name_type : u32 num_components : counted-str realm : counted-str * num_components
cred = principal client : principal server : keyblock :
u32 authtime : u32 starttime : u32 endtime : u32 renew_till :
u8 is_skey : u32 tktflags :
u32 num_addresses : address*
u32 num_authdata : authdata*
counted-bytes ticket : counted-bytes second_ticket
keyblock = u16 keytype : u16 etype(=0) : counted-bytes key
counted-str/bytes = u32 len : len bytesMulti-byte integers are big-endian (network order), matching MIT convention. This
implementation is intentionally strict: an unrecognized version, a length that overflows
the buffer, or a truncated field is a decoded CcacheError, never a panic — safe to
feed attacker-controlled bytes at the boundary.
§Example
use ccache_io::Ccache;
let cc = Ccache::parse(&bytes).unwrap();
for c in &cc.credentials {
println!(
"{} → {} (endtime={})",
c.client.canonical(),
c.server.canonical(),
c.endtime,
);
}
let round = cc.to_bytes();
assert_eq!(round, bytes);Structs§
- Address
- A network address the ticket is bound to (rarely populated in modern deployments). v0.1 keeps the raw wire triple so a round-trip is byte-exact even for exotic values.
- Auth
Data - An
AuthorizationDataentry (RFC 4120 §5.2.6) — the shape the KDC uses to attach a Windows PAC to a ticket. v0.1 exposes the raw ASN.1 blob for byte-exact round-trip. - Ccache
- A parsed ccache file — a default principal and every credential the KDC issued it.
- Credential
- One cached credential — client, server, key, times, and the encrypted ticket blob.
- KeyBlock
- Symmetric key material for the credential — session key for a TGT, service key for a
ticket. MIT stores an
etypealongside the keytype for historical reasons; it is always zero in v4 files and mirrored back on write. - Principal
- A Kerberos principal — realm + one or more name components (
user,host/dc01,krbtgt/REALM). Thename_typedistinguishes user principals from services.
Enums§
- Ccache
Error - Every fatal shape/length problem this crate produces. Marked
#[non_exhaustive]so new diagnostics land as patch bumps rather than breaking downstreammatchblocks.
Constants§
- NT_
PRINCIPAL - MIT
KRB5_NT_PRINCIPAL(1) — a client account principal. - NT_
SRV_ INST - MIT
KRB5_NT_SRV_INST(2) — the standard shape forkrbtgt,HOST/…, service SPNs. - V4_
MAGIC - v4 file magic (
0x0504). v3 (0x0503) is little-endian and predates 2005; v0.1 does not accept it — a widerVersionenum can be added in v0.2 without a break because ofCcacheError’s#[non_exhaustive].