2 * LUKS - Linux Unified Key Setup, keyslot unlock helpers
4 * Copyright (C) 2022-2023 Red Hat, Inc. All rights reserved.
5 * Copyright (C) 2022-2023 Ondrej Kozina
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef KEYSLOT_CONTEXT_H
23 #define KEYSLOT_CONTEXT_H
30 typedef int (*keyslot_context_get_key) (
31 struct crypt_device *cd,
32 struct crypt_keyslot_context *kc,
35 struct volume_key **r_vk);
37 typedef int (*keyslot_context_get_volume_key) (
38 struct crypt_device *cd,
39 struct crypt_keyslot_context *kc,
41 struct volume_key **r_vk);
43 typedef int (*keyslot_context_get_passphrase) (
44 struct crypt_device *cd,
45 struct crypt_keyslot_context *kc,
46 const char **r_passphrase,
47 size_t *r_passphrase_size);
49 /* crypt_keyslot_context */
50 struct crypt_keyslot_context {
55 const char *passphrase;
56 size_t passphrase_size;
60 uint64_t keyfile_offset;
71 const char *volume_key;
72 size_t volume_key_size;
79 size_t i_passphrase_size;
81 keyslot_context_get_key get_luks2_key;
82 keyslot_context_get_volume_key get_luks1_volume_key;
83 keyslot_context_get_volume_key get_luks2_volume_key;
84 keyslot_context_get_passphrase get_passphrase;
87 void crypt_keyslot_context_destroy_internal(struct crypt_keyslot_context *method);
89 void crypt_keyslot_unlock_by_key_init_internal(struct crypt_keyslot_context *kc,
90 const char *volume_key,
91 size_t volume_key_size);
93 void crypt_keyslot_unlock_by_passphrase_init_internal(struct crypt_keyslot_context *kc,
94 const char *passphrase,
95 size_t passphrase_size);
97 void crypt_keyslot_unlock_by_keyfile_init_internal(struct crypt_keyslot_context *kc,
100 uint64_t keyfile_offset);
102 void crypt_keyslot_unlock_by_token_init_internal(struct crypt_keyslot_context *kc,
109 const char *keyslot_context_type_string(const struct crypt_keyslot_context *kc);
111 #endif /* KEYSLOT_CONTEXT_H */