Imported Upstream version 2.6.1
[platform/upstream/cryptsetup.git] / lib / fvault2 / fvault2.h
1 /*
2  * FVAULT2 (FileVault2-compatible) volume handling
3  *
4  * Copyright (C) 2021-2022 Pavel Tobias
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 _CRYPTSETUP_FVAULT2_H
22 #define _CRYPTSETUP_FVAULT2_H
23
24 #include <stddef.h>
25 #include <stdint.h>
26
27 #define FVAULT2_WRAPPED_KEY_SIZE 24
28 #define FVAULT2_PBKDF2_SALT_SIZE 16
29 #define FVAULT2_UUID_LEN 37
30
31 struct crypt_device;
32 struct volume_key;
33
34 struct fvault2_params {
35         const char *cipher;
36         const char *cipher_mode;
37         uint16_t key_size;
38         uint32_t pbkdf2_iters;
39         char pbkdf2_salt[FVAULT2_PBKDF2_SALT_SIZE];
40         char wrapped_kek[FVAULT2_WRAPPED_KEY_SIZE];
41         char wrapped_vk[FVAULT2_WRAPPED_KEY_SIZE];
42         char family_uuid[FVAULT2_UUID_LEN];
43         char ph_vol_uuid[FVAULT2_UUID_LEN];
44         uint64_t log_vol_off;
45         uint64_t log_vol_size;
46 };
47
48 int FVAULT2_read_metadata(
49         struct crypt_device *cd,
50         struct fvault2_params *params);
51
52 int FVAULT2_get_volume_key(
53         struct crypt_device *cd,
54         const char *passphrase,
55         size_t passphrase_len,
56         const struct fvault2_params *params,
57         struct volume_key **vol_key);
58
59 int FVAULT2_dump(
60         struct crypt_device *cd,
61         struct device *device,
62         const struct fvault2_params *params);
63
64 int FVAULT2_activate_by_passphrase(
65         struct crypt_device *cd,
66         const char *name,
67         const char *passphrase,
68         size_t passphrase_len,
69         const struct fvault2_params *params,
70         uint32_t flags);
71
72 int FVAULT2_activate_by_volume_key(
73         struct crypt_device *cd,
74         const char *name,
75         const char *key,
76         size_t key_size,
77         const struct fvault2_params *params,
78         uint32_t flags);
79
80 #endif