Skip to main content

Crate ms_crtd

Crate ms_crtd 

Source
Expand description

ms-crtd — AD-CS certificate template parser and ESC1-ESC15 static analyser.

§Scope

Parses the LDAP attributes of pKICertificateTemplate and pKIEnrollmentService objects (as read by the caller) into typed Rust values, then runs template-shape checks corresponding to the Certified Pre-Owned ESC taxonomy.

This crate performs NO network I/O — consumers pass the raw attribute byte lists in via parse_template_ldap / parse_enrollment_service_ldap.

§Status: 0.1.0-dev (pre-alpha)

  • ESC1, ESC2, ESC3, ESC6, ESC9, ESC15: implemented against template shape.
  • ESC13: partial — flag emitted only when the OID→group map is provided by the caller (which we don’t yet accept). See known_gaps in README.
  • Security-descriptor DACL parsing: deferred. raw_security_descriptor is exposed as bytes.

§Example

ⓘ
use std::collections::BTreeMap;
use ms_crtd::{parse_template_ldap, detect_esc};

let mut attrs: BTreeMap<String, Vec<Vec<u8>>> = BTreeMap::new();
attrs.insert("cn".into(), vec![b"User".to_vec()]);
attrs.insert("mspki-cert-template-oid".into(),
             vec![b"1.3.6.1.4.1.311.21.8.1.2".to_vec()]);
attrs.insert("mspki-template-schema-version".into(), vec![b"2".to_vec()]);
let t = parse_template_ldap(&attrs).unwrap();
let findings = detect_esc(&t);

Re-exports§

pub use error::Error;
pub use error::Result;
pub use esc::detect_esc;
pub use esc::detect_esc6;
pub use esc::EscFinding;
pub use flags::CaEditFlag;
pub use flags::EnrollmentFlag;
pub use flags::NameFlag;
pub use flags::PrivateKeyFlag;
pub use model::CertTemplate;
pub use model::EnrollmentService;
pub use oid::Oid;
pub use parse::parse_enrollment_service_ldap;
pub use parse::parse_template_ldap;
pub use parse::Attrs;

Modules§

error
esc
ESC1-ESC15 static-analysis rules over parsed templates.
flags
bitflags for msPKI-* attributes. Values sourced from [MS-CRTD] and [MS-WCCE] public docs. Only the flags relevant to ESC1-ESC15 detection are named explicitly; the rest survive via bits() for consumers that want the raw u32.
model
Domain types for parsed ADCS objects.
oid
Minimal OID handling. We do NOT implement full X.690 encoding here — most ADCS attributes carry OIDs as UTF-16LE dotted-decimal strings (e.g. “1.3.6.1.5.5.7.3.2”), which is what we parse.
parse
LDAP-attribute -> Rust-struct decoding for pKICertificateTemplate and pKIEnrollmentService objects.