4f457cbce4889b5b02d12ed978b809e8d38c0082
[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 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.
10  *
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.
15  *
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.
19  */
20
21 #ifndef _VERITY_H
22 #define _VERITY_H
23
24 #include <unistd.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                    uint64_t sb_offset,
35                    char **uuid,
36                    struct crypt_params_verity *params);
37
38 int VERITY_write_sb(struct crypt_device *cd,
39                    uint64_t sb_offset,
40                    const char *uuid_string,
41                    struct crypt_params_verity *params);
42
43 int VERITY_activate(struct crypt_device *cd,
44                      const char *name,
45                      const char *root_hash,
46                      size_t root_hash_size,
47                      struct crypt_params_verity *verity_hdr,
48                      uint32_t activation_flags);
49
50 int VERITY_verify(struct crypt_device *cd,
51                 struct crypt_params_verity *verity_hdr,
52                 const char *root_hash,
53                 size_t root_hash_size);
54
55 int VERITY_create(struct crypt_device *cd,
56                   struct crypt_params_verity *verity_hdr,
57                   char *root_hash,
58                   size_t root_hash_size);
59
60 uint64_t VERITY_hash_offset_block(struct crypt_params_verity *params);
61
62 int VERITY_UUID_generate(struct crypt_device *cd, char **uuid_string);
63
64 #endif