]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: bitlocker: use volume identifier as UUID
authorVictor Westerhuis <victor.westerhuis@alliander.com>
Wed, 24 Jul 2024 15:31:04 +0000 (17:31 +0200)
committerVictor Westerhuis <victor.westerhuis@alliander.com>
Thu, 25 Jul 2024 13:12:17 +0000 (15:12 +0200)
libblkid/src/superblocks/bitlocker.c
tests/expected/blkid/low-probe-bitlocker-win7

index 170a67605ee2df70a6239bcef57f59923d484720..e68c2b2300ea2a356d86c2a4d13ab6dab130d6dc 100644 (file)
@@ -38,11 +38,25 @@ struct bde_header_togo {
 } __attribute__((packed));
 
 
-struct bde_fve_metadata {
+struct bde_fve_metadata_block_header {
 /*   0 */ unsigned char  signature[8];
-/*   8 */ uint16_t       size;
+/*   8 */ unsigned char  __dummy1[10 - 8];
 /*  10 */ uint16_t       version;
-};
+/*  12 */ unsigned char  __dummy2[64 - 12];
+} __attribute__((packed));
+
+struct bde_fve_metadata_header {
+/*   0 */ uint32_t      size;
+/*   4 */ uint32_t      version;
+/*   8 */ uint32_t      header_size;
+/*  12 */ uint32_t      size_copy;
+/*  16 */ unsigned char volume_identifier[16];
+} __attribute__((packed));
+
+struct bde_fve_metadata {
+       struct bde_fve_metadata_block_header block_header;
+       struct bde_fve_metadata_header header;
+} __attribute__((packed));
 
 enum {
        BDE_VERSION_VISTA = 0,
@@ -124,7 +138,7 @@ static int get_bitlocker_headers(blkid_probe pr,
                return errno ? -errno : 1;
 
        fve = (const struct bde_fve_metadata *) buf;
-       if (memcmp(fve->signature, BDE_MAGIC_FVE, sizeof(fve->signature)) != 0)
+       if (memcmp(fve->block_header.signature, BDE_MAGIC_FVE, sizeof(fve->block_header.signature)) != 0)
                goto nothing;
        if (buf_fve)
                *buf_fve = buf;
@@ -155,20 +169,24 @@ static int probe_bitlocker(blkid_probe pr,
        if (rc)
                return rc;
 
-       if (kind == BDE_VERSION_WIN7) {
-               const struct bde_header_win7 *hdr = (const struct bde_header_win7 *) buf_hdr;
-
-               /* Unfortunately, it seems volume_serial is always zero */
-               blkid_probe_sprintf_uuid(pr,
-                               (const unsigned char *) &hdr->volume_serial,
-                               sizeof(hdr->volume_serial),
-                               "%016d", le32_to_cpu(hdr->volume_serial));
-       }
-
        if (buf_fve) {
                const struct bde_fve_metadata *fve = (const struct bde_fve_metadata *) buf_fve;
 
-               blkid_probe_sprintf_version(pr, "%d", le16_to_cpu(fve->version));
+               blkid_probe_sprintf_version(pr, "%d", le16_to_cpu(fve->block_header.version));
+
+               /* Microsoft GUID format, interpreted as explained by Raymond Chen:
+                * https://devblogs.microsoft.com/oldnewthing/20220928-00/?p=107221
+                */
+               blkid_probe_sprintf_uuid(pr, fve->header.volume_identifier, 16,
+                       "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+                       fve->header.volume_identifier[3], fve->header.volume_identifier[2], /* uint32_t Data1 */
+                       fve->header.volume_identifier[1], fve->header.volume_identifier[0],
+                       fve->header.volume_identifier[5], fve->header.volume_identifier[4], /* uint16_t Data2 */
+                       fve->header.volume_identifier[7], fve->header.volume_identifier[6], /* uint16_t Data3 */
+                       fve->header.volume_identifier[8], fve->header.volume_identifier[9], /* uint8_t Data4[8] */
+                       fve->header.volume_identifier[10], fve->header.volume_identifier[11],
+                       fve->header.volume_identifier[12], fve->header.volume_identifier[13],
+                       fve->header.volume_identifier[14], fve->header.volume_identifier[15]);
        }
        return 0;
 }
index 4c54c60599a13465fcb68ae94240cc6a9b2077f9..7ef347c9a2bc264318e71faf48c579fb9a573cc0 100644 (file)
@@ -1,3 +1,5 @@
 ID_FS_TYPE=BitLocker
 ID_FS_USAGE=crypto
+ID_FS_UUID=83330ba8-07b7-4ea8-b641-ff7bdf18f6b3
+ID_FS_UUID_ENC=83330ba8-07b7-4ea8-b641-ff7bdf18f6b3
 ID_FS_VERSION=2