2 * Integrity header definition
4 * Copyright (C) 2016-2020 Milan Broz
6 * This file 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 file 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 file; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef _CRYPTSETUP_INTEGRITY_H
22 #define _CRYPTSETUP_INTEGRITY_H
28 struct crypt_params_integrity;
30 struct crypt_dm_active_device;
32 /* dm-integrity helper */
33 #define SB_MAGIC "integrt"
34 #define SB_VERSION_1 1
35 #define SB_VERSION_2 2
36 #define SB_VERSION_3 3
37 #define SB_VERSION_4 4
39 #define SB_FLAG_HAVE_JOURNAL_MAC (1 << 0)
40 #define SB_FLAG_RECALCULATING (1 << 1) /* V2 only */
41 #define SB_FLAG_DIRTY_BITMAP (1 << 2) /* V3 only */
42 #define SB_FLAG_FIXED_PADDING (1 << 3) /* V4 only */
47 int8_t log2_interleave_sectors;
48 uint16_t integrity_tag_size;
49 uint32_t journal_sections;
50 uint64_t provided_data_sectors;
52 uint8_t log2_sectors_per_block;
53 uint8_t log2_blocks_per_bitmap_bit; /* V3 only */
55 uint64_t recalc_sector; /* V2 only */
56 } __attribute__ ((packed));
58 int INTEGRITY_read_sb(struct crypt_device *cd,
59 struct crypt_params_integrity *params,
62 int INTEGRITY_dump(struct crypt_device *cd, struct device *device, uint64_t offset);
64 int INTEGRITY_data_sectors(struct crypt_device *cd,
65 struct device *device, uint64_t offset,
66 uint64_t *data_sectors);
67 int INTEGRITY_key_size(struct crypt_device *cd,
68 const char *integrity);
69 int INTEGRITY_tag_size(struct crypt_device *cd,
70 const char *integrity,
72 const char *cipher_mode);
73 int INTEGRITY_hash_tag_size(const char *integrity);
75 int INTEGRITY_format(struct crypt_device *cd,
76 const struct crypt_params_integrity *params,
77 struct volume_key *journal_crypt_key,
78 struct volume_key *journal_mac_key);
80 int INTEGRITY_activate(struct crypt_device *cd,
82 const struct crypt_params_integrity *params,
83 struct volume_key *vk,
84 struct volume_key *journal_crypt_key,
85 struct volume_key *journal_mac_key,
86 uint32_t flags, uint32_t sb_flags);
88 int INTEGRITY_create_dmd_device(struct crypt_device *cd,
89 const struct crypt_params_integrity *params,
90 struct volume_key *vk,
91 struct volume_key *journal_crypt_key,
92 struct volume_key *journal_mac_key,
93 struct crypt_dm_active_device *dmd,
94 uint32_t flags, uint32_t sb_flags);
96 int INTEGRITY_activate_dmd_device(struct crypt_device *cd,
99 struct crypt_dm_active_device *dmd,