pub struct Luks2Header {
pub version: u16,
pub hdr_size: u64,
pub seqid: u64,
pub label: String,
pub checksum_alg: String,
pub salt: [u8; 64],
pub uuid: LuksUuid,
pub subsystem: String,
pub hdr_offset: u64,
pub checksum: [u8; 64],
pub metadata: Luks2Metadata,
}Fields§
§version: u16§hdr_size: u64§seqid: u64§label: String§checksum_alg: String§salt: [u8; 64]§uuid: LuksUuid§subsystem: String§hdr_offset: u64§checksum: [u8; 64]§metadata: Luks2MetadataImplementations§
Source§impl Luks2Header
impl Luks2Header
Sourcepub fn num_keyslots(&self) -> usize
pub fn num_keyslots(&self) -> usize
Returns the number of configured keyslots.
Examples found in repository?
examples/read_header.rs (line 28)
6fn main() {
7 let args: Vec<String> = env::args().collect();
8 if args.len() < 2 {
9 eprintln!("Usage: {} <device>", args[0]);
10 process::exit(1);
11 }
12
13 let device_path = &args[1];
14 let file = File::open(device_path).unwrap_or_else(|e| {
15 eprintln!("Error opening {}: {}", device_path, e);
16 process::exit(1);
17 });
18
19 match LuksHeader::from_reader(file) {
20 Ok(LuksHeader::V1) => println!("LUKS1 detected on {}", device_path),
21 Ok(LuksHeader::V2(h)) => {
22 println!("LUKS2 detected on {}", device_path);
23 println!(" Label: {}", h.label);
24 println!(" UUID: {}", h.uuid);
25 println!(" Subsystem: {}", h.subsystem);
26 println!(" Checksum Alg: {}", h.checksum_alg);
27 println!(" Header Size: {}", h.hdr_size);
28 println!(" Keyslots: {}", h.num_keyslots());
29 for (id, slot) in &h.metadata.keyslots {
30 match slot {
31 luks::Luks2Keyslot::Luks2 {
32 priority, area, kdf, ..
33 } => {
34 println!(" Keyslot {}:", id);
35 println!(" Type: luks2");
36 if let Some(p) = priority {
37 println!(" Priority: {:?}", p);
38 }
39 print_area(area);
40 print_kdf(kdf);
41 }
42 luks::Luks2Keyslot::Reencrypt {
43 mode,
44 priority,
45 area,
46 kdf,
47 ..
48 } => {
49 println!(" Keyslot {}:", id);
50 println!(" Type: reencrypt");
51 println!(" Mode: {:?}", mode);
52 if let Some(p) = priority {
53 println!(" Priority: {:?}", p);
54 }
55 print_area(area);
56 print_kdf(kdf);
57 }
58 }
59 }
60 }
61 Err(e) => {
62 eprintln!("Error reading LUKS header: {}", e);
63 process::exit(1);
64 }
65 }
66}Trait Implementations§
Source§impl Clone for Luks2Header
impl Clone for Luks2Header
Source§fn clone(&self) -> Luks2Header
fn clone(&self) -> Luks2Header
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Luks2Header
impl RefUnwindSafe for Luks2Header
impl Send for Luks2Header
impl Sync for Luks2Header
impl Unpin for Luks2Header
impl UnsafeUnpin for Luks2Header
impl UnwindSafe for Luks2Header
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