]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
f18edd8a | 2 | #pragma once |
294bd454 | 3 | |
4098bc13 | 4 | #include "json.h" |
0d12936d LP |
5 | #include "macro.h" |
6 | ||
294bd454 ZJS |
7 | #if HAVE_LIBCRYPTSETUP |
8 | #include <libcryptsetup.h> | |
9 | ||
227acf00 JU |
10 | /* These next two are defined in libcryptsetup.h from cryptsetup version 2.3.4 forwards. */ |
11 | #ifndef CRYPT_ACTIVATE_NO_READ_WORKQUEUE | |
12 | #define CRYPT_ACTIVATE_NO_READ_WORKQUEUE (1 << 24) | |
13 | #endif | |
14 | #ifndef CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE | |
15 | #define CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE (1 << 25) | |
16 | #endif | |
17 | ||
0d12936d LP |
18 | extern int (*sym_crypt_activate_by_passphrase)(struct crypt_device *cd, const char *name, int keyslot, const char *passphrase, size_t passphrase_size, uint32_t flags); |
19 | #if HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY | |
20 | extern int (*sym_crypt_activate_by_signed_key)(struct crypt_device *cd, const char *name, const char *volume_key, size_t volume_key_size, const char *signature, size_t signature_size, uint32_t flags); | |
21 | #endif | |
22 | extern int (*sym_crypt_activate_by_volume_key)(struct crypt_device *cd, const char *name, const char *volume_key, size_t volume_key_size, uint32_t flags); | |
23 | extern int (*sym_crypt_deactivate_by_name)(struct crypt_device *cd, const char *name, uint32_t flags); | |
24 | extern int (*sym_crypt_format)(struct crypt_device *cd, const char *type, const char *cipher, const char *cipher_mode, const char *uuid, const char *volume_key, size_t volume_key_size, void *params); | |
25 | extern void (*sym_crypt_free)(struct crypt_device *cd); | |
26 | extern const char *(*sym_crypt_get_dir)(void); | |
27 | extern int (*sym_crypt_get_verity_info)(struct crypt_device *cd, struct crypt_params_verity *vp); | |
28 | extern int (*sym_crypt_init)(struct crypt_device **cd, const char *device); | |
29 | extern int (*sym_crypt_init_by_name)(struct crypt_device **cd, const char *name); | |
30 | extern int (*sym_crypt_keyslot_add_by_volume_key)(struct crypt_device *cd, int keyslot, const char *volume_key, size_t volume_key_size, const char *passphrase, size_t passphrase_size); | |
31 | extern int (*sym_crypt_load)(struct crypt_device *cd, const char *requested_type, void *params); | |
32 | extern int (*sym_crypt_resize)(struct crypt_device *cd, const char *name, uint64_t new_size); | |
33 | extern int (*sym_crypt_set_data_device)(struct crypt_device *cd, const char *device); | |
34 | extern void (*sym_crypt_set_debug_level)(int level); | |
35 | extern void (*sym_crypt_set_log_callback)(struct crypt_device *cd, void (*log)(int level, const char *msg, void *usrptr), void *usrptr); | |
4760384d | 36 | extern int (*sym_crypt_set_pbkdf_type)(struct crypt_device *cd, const struct crypt_pbkdf_type *pbkdf); |
4098bc13 LP |
37 | extern int (*sym_crypt_token_json_get)(struct crypt_device *cd, int token, const char **json); |
38 | extern int (*sym_crypt_token_json_set)(struct crypt_device *cd, int token, const char *json); | |
0d12936d | 39 | extern int (*sym_crypt_volume_key_get)(struct crypt_device *cd, int keyslot, char *volume_key, size_t *volume_key_size, const char *passphrase, size_t passphrase_size); |
3c2c8e62 LB |
40 | #if HAVE_CRYPT_TOKEN_MAX |
41 | extern int (*sym_crypt_token_max)(const char *type); | |
42 | #else | |
43 | /* As a fallback, use the same hard-coded value libcryptsetup uses internally. */ | |
44 | static inline int sym_crypt_token_max(_unused_ const char *type) { | |
45 | assert(streq(type, CRYPT_LUKS2)); | |
46 | ||
47 | return 32; | |
48 | } | |
49 | #endif | |
0d12936d LP |
50 | |
51 | int dlopen_cryptsetup(void); | |
294bd454 | 52 | |
fd421c4a ZJS |
53 | DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, crypt_free, NULL); |
54 | DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, sym_crypt_free, NULL); | |
691c2e2e | 55 | |
efc3b12f | 56 | void cryptsetup_enable_logging(struct crypt_device *cd); |
0d12936d | 57 | |
4760384d LP |
58 | int cryptsetup_set_minimal_pbkdf(struct crypt_device *cd); |
59 | ||
4098bc13 LP |
60 | int cryptsetup_get_token_as_json(struct crypt_device *cd, int idx, const char *verify_type, JsonVariant **ret); |
61 | int cryptsetup_get_keyslot_from_token(JsonVariant *v); | |
62 | int cryptsetup_add_token_json(struct crypt_device *cd, JsonVariant *v); | |
63 | ||
294bd454 | 64 | #endif |