Expand description
DPAPI-NG (CNG “group protection”) and MS-GKDI, in pure Rust.
Windows LAPS (msLAPS-EncryptedPassword), gMSA and dMSA managed passwords are all
protected the same way: a CMS EnvelopedData whose content key is wrapped under a KEK
derived from a KDS root key held by the domain controllers. The blob itself carries no
key — only a gkdi::KeyIdentifier saying which root key and which node of its
L0/L1/L2 tree. A principal allowed to read the secret asks a DC for that node
(GetKey over MS-GKDI), then derives downwards.
This crate does everything except the RPC call:
LapsBlob::parse/cms::ProtectedBlob::parse— unwrap the CMS, recover the key identifier.gkdi::GroupKeyEnvelope::parse— decode whatGetKeyreturned.gkdi::compute_l2_key— walk the tree down to the exact node. Pure computation.cms::ProtectedBlob+decrypt_with_seed_key— unwrap the content key and open the AES-GCM content.
Transport is deliberately out of scope: bring your own DCE/RPC and hand the bytes here.
Modules§
- cms
- The CMS
EnvelopedDatawrapper a DPAPI-NG blob is packaged in. - der
- Just enough DER to walk a CMS
EnvelopedData. No schema, no codegen — a tag/length/value reader with bounds checks, because the only ASN.1 this crate meets is one known shape. - gkdi
- MS-GKDI: the Group Key Distribution structures and the L0/L1/L2 key-tree walk.
- kdf
- SP800-108 counter-mode KDF — the one MS-GKDI uses to walk the key tree.
Structs§
- Laps
Blob - The header Windows LAPS puts in front of the DPAPI-NG blob in
msLAPS-EncryptedPassword: an update timestamp and the blob length.
Enums§
Functions§
- decrypt
- The whole path in one call: a blob plus the
GetKeyenvelope that covers it. - decrypt_
content - Open the AES-256-GCM content with an already-unwrapped content-encryption key.
- decrypt_
with_ kek - Decrypt a blob with a known key-encryption key: AES key-unwrap the content key, then open the AES-256-GCM content.
- decrypt_
with_ seed_ key - Decrypt a blob given the L2 seed key for its node.
- laps_
password_ from_ json - Windows LAPS stores the decrypted password as UTF-16LE JSON:
{"n":"<account>","t":"<hex time>","p":"<password>"}. Pull the password out without pulling in a JSON dependency.