2 * BITLK (BitLocker-compatible) header definition
4 * Copyright (C) 2019-2020 Red Hat, Inc. All rights reserved.
5 * Copyright (C) 2019-2020 Milan Broz
6 * Copyright (C) 2019-2020 Vojtech Trefny
8 * This file is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This file is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this file; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef _CRYPTSETUP_BITLK_H
24 #define _CRYPTSETUP_BITLK_H
33 #define BITLK_NONCE_SIZE 12
34 #define BITLK_SALT_SIZE 16
35 #define BITLK_VMK_MAC_TAG_SIZE 16
37 #define BITLK_STATE_NORMAL 0x0004
40 BITLK_ENCRYPTION_TYPE_NORMAL = 0,
41 BITLK_ENCRYPTION_TYPE_EOW,
42 BITLK_ENCRYPTION_TYPE_UNKNOWN,
43 } BITLKEncryptionType;
46 BITLK_PROTECTION_CLEAR_KEY = 0,
48 BITLK_PROTECTION_STARTUP_KEY,
49 BITLK_PROTECTION_TPM_PIN,
50 BITLK_PROTECTION_RECOVERY_PASSPHRASE,
51 BITLK_PROTECTION_PASSPHRASE,
52 BITLK_PROTECTION_SMART_CARD,
53 BITLK_PROTECTION_UNKNOWN,
57 BITLK_ENTRY_TYPE_PROPERTY = 0x0000,
58 BITLK_ENTRY_TYPE_VMK = 0x0002,
59 BITLK_ENTRY_TYPE_FVEK = 0x0003,
60 BITLK_ENTRY_TYPE_STARTUP_KEY = 0x0006,
61 BITLK_ENTRY_TYPE_DESCRIPTION = 0x0007,
62 BITLK_ENTRY_TYPE_VOLUME_HEADER = 0x000f,
66 BITLK_ENTRY_VALUE_ERASED = 0x0000,
67 BITLK_ENTRY_VALUE_KEY = 0x0001,
68 BITLK_ENTRY_VALUE_STRING = 0x0002,
69 BITLK_ENTRY_VALUE_STRETCH_KEY = 0x0003,
70 BITLK_ENTRY_VALUE_USE_KEY = 0x0004,
71 BITLK_ENTRY_VALUE_ENCRYPTED_KEY = 0x0005,
72 BITLK_ENTRY_VALUE_TPM_KEY = 0x0006,
73 BITLK_ENTRY_VALUE_VALIDATION = 0x0007,
74 BITLK_ENTRY_VALUE_VMK = 0x0008,
75 BITLK_ENTRY_VALUE_EXTERNAL_KEY = 0x0009,
76 BITLK_ENTRY_VALUE_OFFSET_SIZE = 0x000f,
77 BITLK_ENTRY_VALUE_RECOVERY_TIME = 0x015,
83 BITLKVMKProtection protection;
84 uint8_t salt[BITLK_SALT_SIZE];
85 uint8_t mac_tag[BITLK_VMK_MAC_TAG_SIZE];
86 uint8_t nonce[BITLK_NONCE_SIZE];
87 struct volume_key *vk;
88 struct bitlk_vmk *next;
92 uint8_t mac_tag[BITLK_VMK_MAC_TAG_SIZE];
93 uint8_t nonce[BITLK_NONCE_SIZE];
94 struct volume_key *vk;
97 struct bitlk_metadata {
101 BITLKEncryptionType type;
103 const char *cipher_mode;
106 uint64_t creation_time;
108 uint64_t metadata_offset[3];
109 uint32_t metadata_version;
110 uint64_t volume_header_offset;
111 uint64_t volume_header_size;
112 struct bitlk_vmk *vmks;
113 struct bitlk_fvek *fvek;
116 int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params);
118 int BITLK_dump(struct crypt_device *cd, struct device *device, struct bitlk_metadata *params);
120 int BITLK_activate(struct crypt_device *cd,
122 const char *password,
124 const struct bitlk_metadata *params,
127 void BITLK_bitlk_fvek_free(struct bitlk_fvek *fvek);
128 void BITLK_bitlk_vmk_free(struct bitlk_vmk *vmk);
129 void BITLK_bitlk_metadata_free(struct bitlk_metadata *params);