]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/cryptsetup-util.h
tree-wide: reset the cleaned-up variable in cleanup functions
[thirdparty/systemd.git] / src / shared / cryptsetup-util.h
CommitLineData
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
18extern 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
20extern 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
22extern 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);
23extern int (*sym_crypt_deactivate_by_name)(struct crypt_device *cd, const char *name, uint32_t flags);
24extern 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);
25extern void (*sym_crypt_free)(struct crypt_device *cd);
26extern const char *(*sym_crypt_get_dir)(void);
27extern int (*sym_crypt_get_verity_info)(struct crypt_device *cd, struct crypt_params_verity *vp);
28extern int (*sym_crypt_init)(struct crypt_device **cd, const char *device);
29extern int (*sym_crypt_init_by_name)(struct crypt_device **cd, const char *name);
30extern 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);
31extern int (*sym_crypt_load)(struct crypt_device *cd, const char *requested_type, void *params);
32extern int (*sym_crypt_resize)(struct crypt_device *cd, const char *name, uint64_t new_size);
33extern int (*sym_crypt_set_data_device)(struct crypt_device *cd, const char *device);
34extern void (*sym_crypt_set_debug_level)(int level);
35extern void (*sym_crypt_set_log_callback)(struct crypt_device *cd, void (*log)(int level, const char *msg, void *usrptr), void *usrptr);
4760384d 36extern int (*sym_crypt_set_pbkdf_type)(struct crypt_device *cd, const struct crypt_pbkdf_type *pbkdf);
4098bc13
LP
37extern int (*sym_crypt_token_json_get)(struct crypt_device *cd, int token, const char **json);
38extern int (*sym_crypt_token_json_set)(struct crypt_device *cd, int token, const char *json);
0d12936d 39extern 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
41extern int (*sym_crypt_token_max)(const char *type);
42#else
43/* As a fallback, use the same hard-coded value libcryptsetup uses internally. */
44static 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
51int dlopen_cryptsetup(void);
294bd454 52
fd421c4a
ZJS
53DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, crypt_free, NULL);
54DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, sym_crypt_free, NULL);
691c2e2e 55
efc3b12f 56void cryptsetup_enable_logging(struct crypt_device *cd);
0d12936d 57
4760384d
LP
58int cryptsetup_set_minimal_pbkdf(struct crypt_device *cd);
59
4098bc13
LP
60int cryptsetup_get_token_as_json(struct crypt_device *cd, int idx, const char *verify_type, JsonVariant **ret);
61int cryptsetup_get_keyslot_from_token(JsonVariant *v);
62int cryptsetup_add_token_json(struct crypt_device *cd, JsonVariant *v);
63
294bd454 64#endif