wxtla 0.3.1

Wired eXploring Target Layer Accessor
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
//! BitLocker metadata block parsing.

use crate::{Error, Result};

pub(super) const BLOCK_SIGNATURE: &[u8; 8] = b"-FVE-FS-";
pub(super) const ENTRY_TYPE_VOLUME_MASTER_KEY: u16 = 0x0002;
pub(super) const ENTRY_TYPE_FULL_VOLUME_ENCRYPTION_KEY: u16 = 0x0003;
pub(super) const ENTRY_TYPE_STARTUP_KEY: u16 = 0x0006;
pub(super) const ENTRY_TYPE_DESCRIPTION: u16 = 0x0007;
pub(super) const ENTRY_TYPE_VOLUME_HEADER_BLOCK: u16 = 0x000F;

pub(super) const VALUE_TYPE_KEY: u16 = 0x0001;
pub(super) const VALUE_TYPE_UNICODE_STRING: u16 = 0x0002;
pub(super) const VALUE_TYPE_STRETCH_KEY: u16 = 0x0003;
pub(super) const VALUE_TYPE_AES_CCM_ENCRYPTED_KEY: u16 = 0x0005;
pub(super) const VALUE_TYPE_VOLUME_MASTER_KEY: u16 = 0x0008;
pub(super) const VALUE_TYPE_EXTERNAL_KEY: u16 = 0x0009;
pub(super) const VALUE_TYPE_OFFSET_AND_SIZE: u16 = 0x000F;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BitlockerEncryptionMethod {
  None,
  Aes128CbcDiffuser,
  Aes256CbcDiffuser,
  Aes128Cbc,
  Aes256Cbc,
  Aes128Xts,
  Aes256Xts,
}

impl BitlockerEncryptionMethod {
  pub fn from_raw(value: u32) -> Result<Self> {
    match value {
      0x0000 => Ok(Self::None),
      0x8000 => Ok(Self::Aes128CbcDiffuser),
      0x8001 => Ok(Self::Aes256CbcDiffuser),
      0x8002 => Ok(Self::Aes128Cbc),
      0x8003 => Ok(Self::Aes256Cbc),
      0x8004 => Ok(Self::Aes128Xts),
      0x8005 => Ok(Self::Aes256Xts),
      other => Err(Error::invalid_format(format!(
        "unsupported bitlocker encryption method: 0x{other:04x}"
      ))),
    }
  }

  pub fn fvek_length(self) -> usize {
    match self {
      Self::None => 0,
      Self::Aes128Cbc | Self::Aes128CbcDiffuser => 16,
      Self::Aes256Cbc | Self::Aes256CbcDiffuser | Self::Aes128Xts => 32,
      Self::Aes256Xts => 64,
    }
  }

  pub fn tweak_key_length(self) -> usize {
    match self {
      Self::Aes128CbcDiffuser | Self::Aes256CbcDiffuser => 32,
      Self::None | Self::Aes128Cbc | Self::Aes256Cbc | Self::Aes128Xts | Self::Aes256Xts => 0,
    }
  }

  pub fn uses_xts(self) -> bool {
    matches!(self, Self::Aes128Xts | Self::Aes256Xts)
  }

  pub fn raw(self) -> u16 {
    match self {
      Self::None => 0x0000,
      Self::Aes128CbcDiffuser => 0x8000,
      Self::Aes256CbcDiffuser => 0x8001,
      Self::Aes128Cbc => 0x8002,
      Self::Aes256Cbc => 0x8003,
      Self::Aes128Xts => 0x8004,
      Self::Aes256Xts => 0x8005,
    }
  }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BitlockerKeyProtectorKind {
  ClearKey,
  Tpm,
  StartupKey,
  TpmAndPin,
  RecoveryPassword,
  Password,
  Unknown(u16),
}

impl BitlockerKeyProtectorKind {
  fn from_raw(value: u16) -> Self {
    match value {
      0x0000 => Self::ClearKey,
      0x0100 => Self::Tpm,
      0x0200 => Self::StartupKey,
      0x0500 => Self::TpmAndPin,
      0x0800 => Self::RecoveryPassword,
      0x2000 => Self::Password,
      other => Self::Unknown(other),
    }
  }
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerMetadataBlockHeader {
  pub version: u16,
  pub encrypted_volume_size: u64,
  pub volume_header_sector_count: u32,
  pub metadata_offsets: [u64; 3],
  pub volume_header_offset: u64,
  pub mft_mirror_cluster_block_number: Option<u64>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerMetadataHeader {
  pub metadata_size: u32,
  pub version: u32,
  pub header_size: u32,
  pub metadata_size_copy: u32,
  pub volume_identifier: [u8; 16],
  pub next_nonce_counter: u32,
  pub raw_encryption_method: u32,
  pub encryption_method: BitlockerEncryptionMethod,
  pub creation_time: u64,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerKeyBlob {
  pub encryption_method: u32,
  pub data: Vec<u8>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerStretchKey {
  pub encryption_method: u32,
  pub salt: [u8; 16],
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerAesCcmEncryptedKey {
  pub nonce: [u8; 12],
  pub data: Vec<u8>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerVolumeMasterKey {
  pub identifier: [u8; 16],
  pub protection_type: BitlockerKeyProtectorKind,
  pub key: Option<BitlockerKeyBlob>,
  pub stretch_key: Option<BitlockerStretchKey>,
  pub aes_ccm_encrypted_key: Option<BitlockerAesCcmEncryptedKey>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerExternalKey {
  pub identifier: [u8; 16],
  pub key: Option<BitlockerKeyBlob>,
  pub description: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitlockerMetadata {
  pub block_header: BitlockerMetadataBlockHeader,
  pub header: BitlockerMetadataHeader,
  pub description: Option<String>,
  pub volume_header_size: u64,
  pub volume_master_keys: Vec<BitlockerVolumeMasterKey>,
  pub startup_key_external_key: Option<BitlockerExternalKey>,
  pub full_volume_encryption_key: Option<BitlockerAesCcmEncryptedKey>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(super) struct MetadataEntry {
  entry_type: u16,
  value_type: u16,
  version: u16,
  value_data: Vec<u8>,
}

impl BitlockerMetadataBlockHeader {
  pub fn from_bytes(data: &[u8]) -> Result<Self> {
    if data.len() < 64 {
      return Err(Error::invalid_format(
        "bitlocker metadata block header must be 64 bytes".to_string(),
      ));
    }
    if &data[0..8] != BLOCK_SIGNATURE {
      return Err(Error::invalid_format(
        "bitlocker metadata block signature is missing".to_string(),
      ));
    }

    let version = u16::from_le_bytes([data[10], data[11]]);
    match version {
      1 => Ok(Self {
        version,
        encrypted_volume_size: 0,
        volume_header_sector_count: 0,
        metadata_offsets: [
          le_u64(&data[32..40])?,
          le_u64(&data[40..48])?,
          le_u64(&data[48..56])?,
        ],
        volume_header_offset: 0,
        mft_mirror_cluster_block_number: Some(le_u64(&data[56..64])?),
      }),
      2 => Ok(Self {
        version,
        encrypted_volume_size: le_u64(&data[16..24])?,
        volume_header_sector_count: u32::from_le_bytes([data[28], data[29], data[30], data[31]]),
        metadata_offsets: [
          le_u64(&data[32..40])?,
          le_u64(&data[40..48])?,
          le_u64(&data[48..56])?,
        ],
        volume_header_offset: le_u64(&data[56..64])?,
        mft_mirror_cluster_block_number: None,
      }),
      other => Err(Error::invalid_format(format!(
        "unsupported bitlocker metadata block version: {other}"
      ))),
    }
  }
}

impl BitlockerMetadataHeader {
  pub fn from_bytes(data: &[u8]) -> Result<Self> {
    if data.len() < 48 {
      return Err(Error::invalid_format(
        "bitlocker metadata header must be 48 bytes".to_string(),
      ));
    }

    let metadata_size = u32::from_le_bytes([data[0], data[1], data[2], data[3]]);
    let header_size = u32::from_le_bytes([data[8], data[9], data[10], data[11]]);
    if metadata_size < 48 || header_size != 48 {
      return Err(Error::invalid_format(
        "unsupported bitlocker metadata header layout".to_string(),
      ));
    }

    let raw_encryption_method = le_u32(&data[36..40])?;

    Ok(Self {
      metadata_size,
      version: u32::from_le_bytes([data[4], data[5], data[6], data[7]]),
      header_size,
      metadata_size_copy: u32::from_le_bytes([data[12], data[13], data[14], data[15]]),
      volume_identifier: data[16..32]
        .try_into()
        .map_err(|_| Error::invalid_format("bitlocker metadata identifier length mismatch"))?,
      next_nonce_counter: u32::from_le_bytes([data[32], data[33], data[34], data[35]]),
      raw_encryption_method,
      encryption_method: parse_metadata_encryption_method(raw_encryption_method)?,
      creation_time: le_u64(&data[40..48])?,
    })
  }
}

impl BitlockerMetadata {
  pub fn read_block(source: &dyn crate::ByteSource, offset: u64) -> Result<Self> {
    let block_header =
      BitlockerMetadataBlockHeader::from_bytes(&source.read_bytes_at(offset, 64)?)?;
    let header = BitlockerMetadataHeader::from_bytes(&source.read_bytes_at(offset + 64, 48)?)?;
    let entry_size = usize::try_from(header.metadata_size.saturating_sub(header.header_size))
      .map_err(|_| Error::invalid_range("bitlocker metadata entry size is too large"))?;
    let entries = parse_entries(
      &source.read_bytes_at(offset + 64 + u64::from(header.header_size), entry_size)?,
    )?;
    Self::from_parts(block_header, header, &entries)
  }

  pub fn read_startup_key_file(source: &dyn crate::ByteSource) -> Result<BitlockerExternalKey> {
    let header = BitlockerMetadataHeader::from_bytes(&source.read_bytes_at(0, 48)?)?;
    let entry_size = usize::try_from(header.metadata_size.saturating_sub(header.header_size))
      .map_err(|_| Error::invalid_range("bitlocker startup key entry size is too large"))?;
    let entries = parse_entries(&source.read_bytes_at(u64::from(header.header_size), entry_size)?)?;
    let startup = entries
      .iter()
      .find(|entry| entry.entry_type == ENTRY_TYPE_STARTUP_KEY)
      .ok_or_else(|| {
        Error::invalid_format(
          "bitlocker startup key file is missing an external key entry".to_string(),
        )
      })?;
    parse_external_key(startup)
  }

  pub fn clear_key_vmk(&self) -> Option<&BitlockerVolumeMasterKey> {
    self
      .volume_master_keys
      .iter()
      .find(|vmk| vmk.protection_type == BitlockerKeyProtectorKind::ClearKey)
  }

  pub fn password_vmk(&self) -> Option<&BitlockerVolumeMasterKey> {
    self
      .volume_master_keys
      .iter()
      .find(|vmk| vmk.protection_type == BitlockerKeyProtectorKind::Password)
  }

  pub fn recovery_password_vmk(&self) -> Option<&BitlockerVolumeMasterKey> {
    self
      .volume_master_keys
      .iter()
      .find(|vmk| vmk.protection_type == BitlockerKeyProtectorKind::RecoveryPassword)
  }

  pub fn startup_key_vmk(
    &self, startup_identifier: Option<&[u8; 16]>,
  ) -> Option<&BitlockerVolumeMasterKey> {
    self.volume_master_keys.iter().find(|vmk| {
      vmk.protection_type == BitlockerKeyProtectorKind::StartupKey
        && startup_identifier
          .map(|identifier| identifier == &vmk.identifier)
          .unwrap_or(true)
    })
  }

  pub(super) fn from_parts(
    block_header: BitlockerMetadataBlockHeader, header: BitlockerMetadataHeader,
    entries: &[MetadataEntry],
  ) -> Result<Self> {
    let mut description = None;
    let mut volume_header_size = 0u64;
    let mut volume_master_keys = Vec::new();
    let mut startup_key_external_key = None;
    let mut full_volume_encryption_key = None;

    for entry in entries {
      match entry.entry_type {
        ENTRY_TYPE_VOLUME_MASTER_KEY => {
          volume_master_keys.push(parse_volume_master_key(entry)?);
        }
        ENTRY_TYPE_FULL_VOLUME_ENCRYPTION_KEY | 0x000B if full_volume_encryption_key.is_none() => {
          full_volume_encryption_key = Some(parse_aes_ccm_encrypted_key(entry)?);
        }
        ENTRY_TYPE_STARTUP_KEY if startup_key_external_key.is_none() => {
          startup_key_external_key = Some(parse_external_key(entry)?);
        }
        ENTRY_TYPE_DESCRIPTION
          if description.is_none() && entry.value_type == VALUE_TYPE_UNICODE_STRING =>
        {
          description = Some(parse_utf16le_string(&entry.value_data)?);
        }
        ENTRY_TYPE_VOLUME_HEADER_BLOCK
          if entry.value_type == VALUE_TYPE_OFFSET_AND_SIZE && entry.value_data.len() >= 16 =>
        {
          let offset = le_u64(&entry.value_data[0..8])?;
          if offset != block_header.volume_header_offset {
            return Err(Error::invalid_format(
              "bitlocker metadata volume header offset does not match the metadata block header"
                .to_string(),
            ));
          }
          volume_header_size = le_u64(&entry.value_data[8..16])?;
        }
        _ => {}
      }
    }

    Ok(Self {
      block_header,
      header,
      description,
      volume_header_size,
      volume_master_keys,
      startup_key_external_key,
      full_volume_encryption_key,
    })
  }
}

pub(super) fn parse_entries(data: &[u8]) -> Result<Vec<MetadataEntry>> {
  let mut offset = 0usize;
  let mut entries = Vec::new();
  while offset + 8 <= data.len() {
    if data[offset..offset + 8].iter().all(|byte| *byte == 0) {
      break;
    }
    let size = usize::from(u16::from_le_bytes([data[offset], data[offset + 1]]));
    let entry_type = u16::from_le_bytes([data[offset + 2], data[offset + 3]]);
    let value_type = u16::from_le_bytes([data[offset + 4], data[offset + 5]]);
    let version = u16::from_le_bytes([data[offset + 6], data[offset + 7]]);
    if !matches!(version, 1 | 3) || size < 8 || offset + size > data.len() {
      return Err(Error::invalid_format(
        "bitlocker metadata entry size is invalid".to_string(),
      ));
    }
    entries.push(MetadataEntry {
      entry_type,
      value_type,
      version,
      value_data: data[offset + 8..offset + size].to_vec(),
    });
    offset += size;
  }
  Ok(entries)
}

fn parse_volume_master_key(entry: &MetadataEntry) -> Result<BitlockerVolumeMasterKey> {
  if entry.value_type != VALUE_TYPE_VOLUME_MASTER_KEY || entry.value_data.len() < 28 {
    return Err(Error::invalid_format(
      "bitlocker VMK metadata entry is malformed".to_string(),
    ));
  }
  let properties = parse_entries(&entry.value_data[28..])?;
  let mut key = None;
  let mut stretch_key = None;
  let mut aes_ccm_encrypted_key = None;
  for property in &properties {
    match property.value_type {
      VALUE_TYPE_KEY => key = Some(parse_key_blob(property)?),
      VALUE_TYPE_STRETCH_KEY => stretch_key = Some(parse_stretch_key(property)?),
      VALUE_TYPE_AES_CCM_ENCRYPTED_KEY => {
        aes_ccm_encrypted_key = Some(parse_aes_ccm_encrypted_key(property)?)
      }
      _ => {}
    }
  }

  Ok(BitlockerVolumeMasterKey {
    identifier: entry.value_data[0..16]
      .try_into()
      .map_err(|_| Error::invalid_format("bitlocker VMK identifier length mismatch"))?,
    protection_type: BitlockerKeyProtectorKind::from_raw(u16::from_le_bytes([
      entry.value_data[26],
      entry.value_data[27],
    ])),
    key,
    stretch_key,
    aes_ccm_encrypted_key,
  })
}

fn parse_external_key(entry: &MetadataEntry) -> Result<BitlockerExternalKey> {
  if entry.value_type != VALUE_TYPE_EXTERNAL_KEY || entry.value_data.len() < 24 {
    return Err(Error::invalid_format(
      "bitlocker external key metadata entry is malformed".to_string(),
    ));
  }

  let properties = parse_entries(&entry.value_data[24..])?;
  let mut key = None;
  let mut description = None;
  for property in &properties {
    match property.value_type {
      VALUE_TYPE_KEY => key = Some(parse_key_blob(property)?),
      VALUE_TYPE_UNICODE_STRING => description = Some(parse_utf16le_string(&property.value_data)?),
      _ => {}
    }
  }

  Ok(BitlockerExternalKey {
    identifier: entry.value_data[0..16]
      .try_into()
      .map_err(|_| Error::invalid_format("bitlocker external key identifier length mismatch"))?,
    key,
    description,
  })
}

fn parse_key_blob(entry: &MetadataEntry) -> Result<BitlockerKeyBlob> {
  if entry.value_type != VALUE_TYPE_KEY || entry.value_data.len() < 4 {
    return Err(Error::invalid_format(
      "bitlocker key entry is malformed".to_string(),
    ));
  }
  Ok(BitlockerKeyBlob {
    encryption_method: le_u32(&entry.value_data[0..4])?,
    data: entry.value_data[4..].to_vec(),
  })
}

fn parse_stretch_key(entry: &MetadataEntry) -> Result<BitlockerStretchKey> {
  if entry.value_type != VALUE_TYPE_STRETCH_KEY || entry.value_data.len() < 20 {
    return Err(Error::invalid_format(
      "bitlocker stretch key entry is malformed".to_string(),
    ));
  }
  Ok(BitlockerStretchKey {
    encryption_method: le_u32(&entry.value_data[0..4])?,
    salt: entry.value_data[4..20]
      .try_into()
      .map_err(|_| Error::invalid_format("bitlocker stretch key salt length mismatch"))?,
  })
}

fn parse_aes_ccm_encrypted_key(entry: &MetadataEntry) -> Result<BitlockerAesCcmEncryptedKey> {
  if entry.value_type != VALUE_TYPE_AES_CCM_ENCRYPTED_KEY || entry.value_data.len() < 12 {
    return Err(Error::invalid_format(
      "bitlocker AES-CCM key entry is malformed".to_string(),
    ));
  }
  Ok(BitlockerAesCcmEncryptedKey {
    nonce: entry.value_data[0..12]
      .try_into()
      .map_err(|_| Error::invalid_format("bitlocker nonce length mismatch"))?,
    data: entry.value_data[12..].to_vec(),
  })
}

fn parse_utf16le_string(data: &[u8]) -> Result<String> {
  if !data.len().is_multiple_of(2) {
    return Err(Error::invalid_format(
      "bitlocker UTF-16 string length must be even".to_string(),
    ));
  }
  let mut units = data
    .chunks_exact(2)
    .map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]]))
    .collect::<Vec<_>>();
  while matches!(units.last(), Some(0)) {
    units.pop();
  }
  String::from_utf16(&units)
    .map_err(|_| Error::invalid_format("bitlocker UTF-16 string is invalid"))
}

fn parse_metadata_encryption_method(raw: u32) -> Result<BitlockerEncryptionMethod> {
  let low = raw as u16;
  let high = (raw >> 16) as u16;
  if high != 0 && high != low {
    return Err(Error::invalid_format(format!(
      "unsupported bitlocker metadata encryption method layout: 0x{raw:08x}"
    )));
  }
  BitlockerEncryptionMethod::from_raw(u32::from(low))
}

fn le_u32(data: &[u8]) -> Result<u32> {
  Ok(u32::from_le_bytes(data.try_into().map_err(|_| {
    Error::invalid_format("bitlocker integer length mismatch")
  })?))
}

fn le_u64(data: &[u8]) -> Result<u64> {
  Ok(u64::from_le_bytes(data.try_into().map_err(|_| {
    Error::invalid_format("bitlocker integer length mismatch")
  })?))
}

#[cfg(test)]
mod tests {
  use super::*;

  #[test]
  fn parses_metadata_block_header_sample() {
    let bytes = std::fs::read(concat!(
      env!("CARGO_MANIFEST_DIR"),
      "/formats/bitlocker/metadata_block_header.1"
    ))
    .unwrap();
    let header = BitlockerMetadataBlockHeader::from_bytes(&bytes).unwrap();

    assert_eq!(header.version, 2);
    assert_eq!(header.encrypted_volume_size, 262_144_000);
    assert_eq!(header.volume_header_sector_count, 10_480);
  }

  #[test]
  fn parses_metadata_header_sample() {
    let bytes = std::fs::read(concat!(
      env!("CARGO_MANIFEST_DIR"),
      "/formats/bitlocker/metadata_header.1"
    ))
    .unwrap();
    let header = BitlockerMetadataHeader::from_bytes(&bytes).unwrap();

    assert_eq!(header.version, 1);
    assert_eq!(header.header_size, 48);
    assert_eq!(header.raw_encryption_method, 0x0000_8000);
    assert_eq!(
      header.encryption_method,
      BitlockerEncryptionMethod::Aes128CbcDiffuser
    );
  }

  #[test]
  fn accepts_metadata_encryption_method_with_duplicated_upper_word() {
    assert_eq!(
      parse_metadata_encryption_method(0x8002_8002).unwrap(),
      BitlockerEncryptionMethod::Aes128Cbc
    );
  }

  #[test]
  fn parses_utf16le_description_values() {
    let data = b"b\0i\0t\0l\0o\0c\0k\0e\0r\0\0\0";
    assert_eq!(parse_utf16le_string(data).unwrap(), "bitlocker");
  }
}