pub struct KeyIdentifier {Show 14 fields
pub version: u32,
pub flags: u32,
pub l0: i32,
pub l1: i32,
pub l2: i32,
pub root_key_id: RootKeyId,
pub kdf_algorithm: String,
pub kdf_parameters: Vec<u8>,
pub secret_algorithm: String,
pub secret_parameters: Vec<u8>,
pub private_key_length: u32,
pub public_key_length: u32,
pub domain_name: String,
pub forest_name: String,
}Expand description
The KEY_IDENTIFIER carried in a protected blob: which root key and which tree node the
content was encrypted for.
Fields§
§version: u32§flags: u32§l0: i32§l1: i32§l2: i32§root_key_id: RootKeyId§kdf_algorithm: String§kdf_parameters: Vec<u8>§secret_algorithm: String§secret_parameters: Vec<u8>§private_key_length: u32§public_key_length: u32§domain_name: String§forest_name: StringImplementations§
Source§impl KeyIdentifier
impl KeyIdentifier
Sourcepub fn is_public_key(&self) -> bool
pub fn is_public_key(&self) -> bool
true when the blob was protected with the public-key half of the node (the
key-agreement path) rather than the seed key directly.
Examples found in repository?
examples/inspect_blob.rs (line 68)
16fn main() -> ExitCode {
17 let args: Vec<String> = std::env::args().skip(1).collect();
18 let raw_mode = args.iter().any(|a| a == "--raw");
19 let Some(path) = args.iter().find(|a| !a.starts_with("--")) else {
20 eprintln!("usage: inspect_blob [--raw] <blob.bin>");
21 return ExitCode::FAILURE;
22 };
23
24 let bytes = match std::fs::read(path) {
25 Ok(b) => b,
26 Err(e) => {
27 eprintln!("cannot read {path}: {e}");
28 return ExitCode::FAILURE;
29 }
30 };
31
32 let blob_bytes = if raw_mode {
33 bytes
34 } else {
35 match LapsBlob::parse(&bytes) {
36 Ok(l) => {
37 println!(
38 "LAPS header: updated {} (FILETIME {}), {} byte blob",
39 filetime_to_iso(l.update_timestamp),
40 l.update_timestamp,
41 l.blob.len()
42 );
43 l.blob
44 }
45 Err(e) => {
46 eprintln!(
47 "not a LAPS attribute value ({e}); retry with --raw if this is a bare CMS blob"
48 );
49 return ExitCode::FAILURE;
50 }
51 }
52 };
53
54 let blob = match ProtectedBlob::parse(&blob_bytes) {
55 Ok(b) => b,
56 Err(e) => {
57 eprintln!("CMS parse failed: {e}");
58 return ExitCode::FAILURE;
59 }
60 };
61
62 let id = &blob.key_identifier;
63 println!("key identifier");
64 println!(" version {}", id.version);
65 println!(
66 " flags {:#010x}{}",
67 id.flags,
68 if id.is_public_key() {
69 " (public key)"
70 } else {
71 ""
72 }
73 );
74 println!(" root key {}", id.root_key_id);
75 println!(
76 " tree node L0 {} · L1 {} · L2 {}",
77 id.l0, id.l1, id.l2
78 );
79 println!(" kdf {} ", id.kdf_algorithm);
80 match id.hash() {
81 Ok(h) => println!(" kdf hash {}", h.name()),
82 Err(e) => println!(" kdf hash UNPARSED: {e}"),
83 }
84 println!(" secret algorithm {}", id.secret_algorithm);
85 println!(
86 " private/public len {} / {}",
87 id.private_key_length, id.public_key_length
88 );
89 println!(
90 " domain / forest {} / {}",
91 id.domain_name, id.forest_name
92 );
93 println!("content");
94 println!(" key wrap {}", blob.key_wrap_oid);
95 println!(" content cipher {}", blob.content_cipher_oid);
96 println!(
97 " nonce {} ({} bytes)",
98 hex(&blob.nonce),
99 blob.nonce.len()
100 );
101 println!(" tag length {}", blob.tag_len);
102 println!(" wrapped key {} bytes", blob.encrypted_key.len());
103 println!(
104 " ciphertext {} bytes",
105 blob.encrypted_content.len()
106 );
107 println!(
108 "\nTo decrypt: ask a DC for root key {} at L0 {} (MS-GKDI GetKey), then\n\
109 GroupKeyEnvelope::parse(response) and dpapi_ng::decrypt(&blob, &envelope).",
110 id.root_key_id, id.l0
111 );
112
113 ExitCode::SUCCESS
114}pub fn parse(b: &[u8]) -> Result<KeyIdentifier, GkdiError>
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Sourcepub fn hash(&self) -> Result<HashAlg, GkdiError>
pub fn hash(&self) -> Result<HashAlg, GkdiError>
The hash the key tree for this blob is derived with.
Examples found in repository?
examples/inspect_blob.rs (line 80)
16fn main() -> ExitCode {
17 let args: Vec<String> = std::env::args().skip(1).collect();
18 let raw_mode = args.iter().any(|a| a == "--raw");
19 let Some(path) = args.iter().find(|a| !a.starts_with("--")) else {
20 eprintln!("usage: inspect_blob [--raw] <blob.bin>");
21 return ExitCode::FAILURE;
22 };
23
24 let bytes = match std::fs::read(path) {
25 Ok(b) => b,
26 Err(e) => {
27 eprintln!("cannot read {path}: {e}");
28 return ExitCode::FAILURE;
29 }
30 };
31
32 let blob_bytes = if raw_mode {
33 bytes
34 } else {
35 match LapsBlob::parse(&bytes) {
36 Ok(l) => {
37 println!(
38 "LAPS header: updated {} (FILETIME {}), {} byte blob",
39 filetime_to_iso(l.update_timestamp),
40 l.update_timestamp,
41 l.blob.len()
42 );
43 l.blob
44 }
45 Err(e) => {
46 eprintln!(
47 "not a LAPS attribute value ({e}); retry with --raw if this is a bare CMS blob"
48 );
49 return ExitCode::FAILURE;
50 }
51 }
52 };
53
54 let blob = match ProtectedBlob::parse(&blob_bytes) {
55 Ok(b) => b,
56 Err(e) => {
57 eprintln!("CMS parse failed: {e}");
58 return ExitCode::FAILURE;
59 }
60 };
61
62 let id = &blob.key_identifier;
63 println!("key identifier");
64 println!(" version {}", id.version);
65 println!(
66 " flags {:#010x}{}",
67 id.flags,
68 if id.is_public_key() {
69 " (public key)"
70 } else {
71 ""
72 }
73 );
74 println!(" root key {}", id.root_key_id);
75 println!(
76 " tree node L0 {} · L1 {} · L2 {}",
77 id.l0, id.l1, id.l2
78 );
79 println!(" kdf {} ", id.kdf_algorithm);
80 match id.hash() {
81 Ok(h) => println!(" kdf hash {}", h.name()),
82 Err(e) => println!(" kdf hash UNPARSED: {e}"),
83 }
84 println!(" secret algorithm {}", id.secret_algorithm);
85 println!(
86 " private/public len {} / {}",
87 id.private_key_length, id.public_key_length
88 );
89 println!(
90 " domain / forest {} / {}",
91 id.domain_name, id.forest_name
92 );
93 println!("content");
94 println!(" key wrap {}", blob.key_wrap_oid);
95 println!(" content cipher {}", blob.content_cipher_oid);
96 println!(
97 " nonce {} ({} bytes)",
98 hex(&blob.nonce),
99 blob.nonce.len()
100 );
101 println!(" tag length {}", blob.tag_len);
102 println!(" wrapped key {} bytes", blob.encrypted_key.len());
103 println!(
104 " ciphertext {} bytes",
105 blob.encrypted_content.len()
106 );
107 println!(
108 "\nTo decrypt: ask a DC for root key {} at L0 {} (MS-GKDI GetKey), then\n\
109 GroupKeyEnvelope::parse(response) and dpapi_ng::decrypt(&blob, &envelope).",
110 id.root_key_id, id.l0
111 );
112
113 ExitCode::SUCCESS
114}Trait Implementations§
Source§impl Clone for KeyIdentifier
impl Clone for KeyIdentifier
Source§fn clone(&self) -> KeyIdentifier
fn clone(&self) -> KeyIdentifier
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyIdentifier
impl Debug for KeyIdentifier
impl Eq for KeyIdentifier
Source§impl PartialEq for KeyIdentifier
impl PartialEq for KeyIdentifier
impl StructuralPartialEq for KeyIdentifier
Auto Trait Implementations§
impl Freeze for KeyIdentifier
impl RefUnwindSafe for KeyIdentifier
impl Send for KeyIdentifier
impl Sync for KeyIdentifier
impl Unpin for KeyIdentifier
impl UnsafeUnpin for KeyIdentifier
impl UnwindSafe for KeyIdentifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more