pub enum LuksHeader {
V1,
V2(Luks2Header),
}Variants§
V1
V2(Luks2Header)
Implementations§
Source§impl LuksHeader
impl LuksHeader
Sourcepub fn num_keyslots(&self) -> usize
pub fn num_keyslots(&self) -> usize
Returns the number of configured keyslots.
Source§impl LuksHeader
impl LuksHeader
Sourcepub fn from_reader<R: Read + Seek>(reader: R) -> Result<Self, LuksError>
pub fn from_reader<R: Read + Seek>(reader: R) -> Result<Self, LuksError>
Examples found in repository?
examples/read_header.rs (line 19)
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 LuksHeader
impl Clone for LuksHeader
Source§fn clone(&self) -> LuksHeader
fn clone(&self) -> LuksHeader
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 LuksHeader
impl RefUnwindSafe for LuksHeader
impl Send for LuksHeader
impl Sync for LuksHeader
impl Unpin for LuksHeader
impl UnsafeUnpin for LuksHeader
impl UnwindSafe for LuksHeader
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