Skip to main content

Crate dpapi_ng

Crate dpapi_ng 

Source
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:

  1. LapsBlob::parse / cms::ProtectedBlob::parse — unwrap the CMS, recover the key identifier.
  2. Fetch the envelope from a DC: either ms_gkdi::rpc::get_key (feature rpc) or hand the reply bytes to ms_gkdi::gkdi::GroupKeyEnvelope::parse yourself.
  3. ms_gkdi::gkdi::compute_l2_key — walk the tree down to the exact node. Pure computation.
  4. cms::ProtectedBlob + decrypt_with_seed_key — unwrap the content key and open the AES-GCM content.

Modules§

cms
The CMS EnvelopedData wrapper 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-gkdi crate now.
kdf
DEPRECATED — the SP800-108 counter-mode KDF and the "KDS service" label live in the ms-gkdi crate now.

Structs§

LapsBlob
The header Windows LAPS puts in front of the DPAPI-NG blob in msLAPS-EncryptedPassword: an update timestamp and the blob length.

Enums§

DpapiError

Functions§

decrypt
The whole path in one call: a blob plus the GetKey envelope 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.

Type Aliases§

Result