Expand description
DPAPI-NG (CNG “group protection”), 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.
0.2 wiring. The MS-GKDI structures, KDF, tree walk and ISDKey::GetKey RPC now live
in the ms-gkdi crate. The gkdi, [kdf] and
[rpc] modules in this crate are thin pub use shims marked #[deprecated]. New code
should depend on ms-gkdi directly; existing 0.1.x code keeps compiling unchanged
(ms_gkdi::GkdiError converts into DpapiError via From).
The full pipeline:
LapsBlob::parse/cms::ProtectedBlob::parse— unwrap the CMS, recover the key identifier.- Fetch the envelope from a DC: either
ms_gkdi::rpc::get_key(featurerpc) or hand the reply bytes toms_gkdi::gkdi::GroupKeyEnvelope::parseyourself. ms_gkdi::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.
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
- DEPRECATED — the MS-GKDI structures, tree walk and KDF context live in the
ms-gkdicrate now. - kdf
- DEPRECATED — the SP800-108 counter-mode KDF and the
"KDS service"label live in thems-gkdicrate now.
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.