2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2005 W. Michael Petullo <mike@flyn.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include <asm/types.h>
37 #include "volume_id.h"
42 #define SECTOR_SHIFT 9
43 #define SECTOR_SIZE (1 << SECTOR_SHIFT)
45 #define LUKS_CIPHERNAME_L 32
46 #define LUKS_CIPHERMODE_L 32
47 #define LUKS_HASHSPEC_L 32
48 #define LUKS_DIGESTSIZE 20
49 #define LUKS_SALTSIZE 32
50 #define LUKS_NUMKEYS 8
52 const __u8 LUKS_MAGIC[] = {'L','U','K','S', 0xba, 0xbe};
53 #define LUKS_MAGIC_L 6
54 #define LUKS_PHDR_SIZE (sizeof(struct luks_phdr)/SECTOR_SIZE+1)
55 #define UUID_STRING_L 40
58 __u8 magic[LUKS_MAGIC_L];
60 __u8 cipherName[LUKS_CIPHERNAME_L];
61 __u8 cipherMode[LUKS_CIPHERMODE_L];
62 __u8 hashSpec[LUKS_HASHSPEC_L];
65 __u8 mkDigest[LUKS_DIGESTSIZE];
66 __u8 mkDigestSalt[LUKS_SALTSIZE];
67 __u32 mkDigestIterations;
68 __u8 uuid[UUID_STRING_L];
71 __u32 passwordIterations;
72 __u8 passwordSalt[LUKS_SALTSIZE];
73 __u32 keyMaterialOffset;
75 } keyblock[LUKS_NUMKEYS];
78 int volume_id_probe_luks(struct volume_id *id, __u64 off)
80 struct luks_phdr *header;
82 header = (struct luks_phdr*) volume_id_get_buffer(id, off, LUKS_PHDR_SIZE);
86 if (memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L))
89 volume_id_set_usage(id, VOLUME_ID_CRYPTO);
90 volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING);
92 id->type = "crypto_LUKS";