Require only up to last keyslot area for header device (ignore data offset).
[platform/upstream/cryptsetup.git] / lib / verity / verity.h
1 /*
2  * dm-verity volume handling
3  *
4  * Copyright (C) 2012, Red Hat, Inc. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19
20 #ifndef _VERITY_H
21 #define _VERITY_H
22
23 #include <unistd.h>
24 #include "config.h"
25
26 #define VERITY_MAX_HASH_TYPE 1
27 #define VERITY_BLOCK_SIZE_OK(x) ((x) % 512 || (x) < 512 || \
28                                 (x) > (512 * 1024) || (x) & ((x)-1))
29
30 struct crypt_device;
31 struct crypt_params_verity;
32
33 int VERITY_read_sb(struct crypt_device *cd,
34                    const char *device,
35                    uint64_t sb_offset,
36                    char **uuid,
37                    struct crypt_params_verity *params);
38
39 int VERITY_write_sb(struct crypt_device *cd,
40                    const char *device,
41                    uint64_t sb_offset,
42                    const char *uuid_string,
43                    struct crypt_params_verity *params);
44
45 int VERITY_activate(struct crypt_device *cd,
46                      const char *name,
47                      const char *hash_device,
48                      const char *root_hash,
49                      size_t root_hash_size,
50                      struct crypt_params_verity *verity_hdr,
51                      uint32_t activation_flags);
52
53 int VERITY_verify(struct crypt_device *cd,
54                 struct crypt_params_verity *verity_hdr,
55                 const char *data_device,
56                 const char *hash_device,
57                 const char *root_hash,
58                 size_t root_hash_size);
59
60 int VERITY_create(struct crypt_device *cd,
61                   struct crypt_params_verity *verity_hdr,
62                   const char *data_device,
63                   const char *hash_device,
64                   char *root_hash,
65                   size_t root_hash_size);
66
67 uint64_t VERITY_hash_offset_block(struct crypt_params_verity *params);
68
69 int VERITY_UUID_generate(struct crypt_device *cd, char **uuid_string);
70
71 #endif