Fix some strings, fix sb_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_SIGNATURE        "verity\0\0"
27 #define VERITY_MAX_LEVELS       63
28 #define VERITY_MAX_SALT_SIZE    384
29
30 struct crypt_device;
31 struct crypt_params_verity;
32
33 /* FIXME: not yet final on-disk format! Add UUID etc */
34 struct verity_sb {
35         uint8_t signature[8];
36         uint8_t version;
37         uint8_t data_block_bits;
38         uint8_t hash_block_bits;
39         uint8_t pad1[1];
40         uint16_t salt_size;
41         uint8_t pad2[2];
42         uint32_t data_blocks_hi;
43         uint32_t data_blocks_lo;
44         uint8_t algorithm[16];
45         uint8_t salt[VERITY_MAX_SALT_SIZE];
46         uint8_t pad3[88];
47 };
48
49 int VERITY_read_sb(struct crypt_device *cd,
50                    const char *device,
51                    uint64_t sb_offset,
52                    struct crypt_params_verity *params);
53
54 int VERITY_write_sb(struct crypt_device *cd,
55                    const char *device,
56                    uint64_t sb_offset,
57                    struct crypt_params_verity *params);
58
59 int VERITY_activate(struct crypt_device *cd,
60                      const char *name,
61                      const char *hash_device,
62                      const char *root_hash,
63                      size_t root_hash_size,
64                      struct crypt_params_verity *verity_hdr,
65                      uint32_t flags);
66
67 int VERITY_verify(struct crypt_device *cd,
68                 struct crypt_params_verity *verity_hdr,
69                 const char *data_device,
70                 const char *hash_device,
71                 const char *root_hash,
72                 size_t root_hash_size);
73
74 int VERITY_create(struct crypt_device *cd,
75                   struct crypt_params_verity *verity_hdr,
76                   const char *data_device,
77                   const char *hash_device,
78                   char *root_hash,
79                   size_t root_hash_size);
80
81 uint64_t VERITY_hash_offset_block(struct crypt_params_verity *params);
82
83 #endif