pub struct Luks2Header {
pub version: u16,
pub hdr_size: u64,
pub seqid: u64,
pub label: String,
pub checksum_alg: Luks2HashAlg,
pub salt: [u8; 64],
pub uuid: LuksDeviceUuid,
pub subsystem: String,
pub hdr_offset: u64,
pub checksum: [u8; 64],
pub metadata: Luks2Metadata,
}Expand description
The primary binary header for LUKS2.
Fields§
§version: u16The LUKS version (should be 2).
hdr_size: u64The total size of the header, including the binary part and the JSON area.
seqid: u64The sequence ID, incremented on each header update.
label: StringAn optional label for the device.
checksum_alg: Luks2HashAlgThe hash algorithm used for calculating the header checksum.
salt: [u8; 64]The salt used for the header.
uuid: LuksDeviceUuidThe UUID of the device.
subsystem: StringAn optional subsystem label for the device.
hdr_offset: u64The offset of this header in bytes from the start of the device.
checksum: [u8; 64]The header checksum.
metadata: Luks2MetadataThe associated JSON metadata.
Implementations§
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,
33 af,
34 area,
35 kdf,
36 ..
37 } => {
38 println!(" Keyslot {}:", id);
39 println!(" Type: luks2");
40 if let Some(p) = priority {
41 println!(" Priority: {:?}", p);
42 }
43 print_af(af);
44 print_area(area);
45 print_kdf(kdf);
46 }
47 luks::Luks2Keyslot::Reencrypt {
48 mode,
49 priority,
50 af,
51 area,
52 kdf,
53 ..
54 } => {
55 println!(" Keyslot {}:", id);
56 println!(" Type: reencrypt");
57 println!(" Mode: {:?}", mode);
58 if let Some(p) = priority {
59 println!(" Priority: {:?}", p);
60 }
61 print_af(af);
62 print_area(area);
63 print_kdf(kdf);
64 }
65 }
66 }
67 }
68 Err(e) => {
69 eprintln!("Error reading LUKS header: {}", e);
70 process::exit(1);
71 }
72 }
73}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 moreSource§impl Debug for Luks2Header
impl Debug for Luks2Header
Source§impl<'de> Deserialize<'de> for Luks2Header
impl<'de> Deserialize<'de> for Luks2Header
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto 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