2 * TCRYPT - header defitinion
4 * Copyright (C) 2012, Red Hat, Inc. All rights reserved.
5 * Copyright (C) 2012, Milan Broz
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "libcryptsetup.h"
23 #ifndef _CRYPTSETUP_TCRYPT_H
24 #define _CRYPTSETUP_TCRYPT_H
26 #define TCRYPT_HDR_SALT_LEN 64
27 #define TCRYPT_HDR_IV_LEN 16
28 #define TCRYPT_HDR_LEN 448
29 #define TCRYPT_HDR_KEY_LEN 192
30 #define TCRYPT_HDR_MAGIC "TRUE"
31 #define TCRYPT_HDR_MAGIC_LEN 4
33 #define TCRYPT_HDR_HIDDEN_OFFSET_OLD -1536
34 #define TCRYPT_HDR_HIDDEN_OFFSET 65536
36 #define TCRYPT_HDR_HIDDEN_OFFSET_BCK -65536
37 #define TCRYPT_HDR_OFFSET_BCK -131072
39 #define TCRYPT_LRW_IKEY_LEN 16
40 #define TCRYPT_KEY_POOL_LEN 64
41 #define TCRYPT_KEYFILE_LEN 1048576
43 #define TCRYPT_HDR_FLAG_SYSTEM (1 << 0)
44 #define TCRYPT_HDR_FLAG_NONSYSTEM (1 << 1)
47 char salt[TCRYPT_HDR_SALT_LEN];
49 /* encrypted part, TCRYPT_HDR_LEN bytes */
51 struct __attribute__((__packed__)) {
52 char magic[TCRYPT_HDR_MAGIC_LEN];
56 uint64_t _reserved1[2]; /* data/header ctime */
57 uint64_t hidden_volume_size;
63 uint8_t _reserved2[120];
64 uint32_t header_crc32;
67 char e[TCRYPT_HDR_LEN];
69 } __attribute__((__packed__));
71 struct crypt_dm_active_device;
75 int TCRYPT_read_phdr(struct crypt_device *cd,
76 struct tcrypt_phdr *hdr,
77 struct crypt_params_tcrypt *params);
79 int TCRYPT_init_by_name(struct crypt_device *cd, const char *name,
80 const struct crypt_dm_active_device *dmd,
81 struct device **device,
82 struct crypt_params_tcrypt *tcrypt_params,
83 struct tcrypt_phdr *tcrypt_hdr);
85 int TCRYPT_activate(struct crypt_device *cd,
87 struct tcrypt_phdr *hdr,
88 struct crypt_params_tcrypt *params,
91 int TCRYPT_deactivate(struct crypt_device *cd,
94 uint64_t TCRYPT_get_data_offset(struct tcrypt_phdr *hdr);
95 uint64_t TCRYPT_get_iv_offset(struct tcrypt_phdr *hdr);
97 int TCRYPT_get_volume_key(struct crypt_device *cd,
98 struct tcrypt_phdr *hdr,
99 struct crypt_params_tcrypt *params,
100 struct volume_key **vk);
102 int TCRYPT_dump(struct crypt_device *cd,
103 struct tcrypt_phdr *hdr,
104 struct crypt_params_tcrypt *params);