Split out of #37344.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <fcntl.h>
+#include <stdlib.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include "alloc-util.h"
#include "cryptsetup-util.h"
#include "specifier.h"
#include "string-util.h"
#include "strv.h"
+#include "time-util.h"
#include "unit-name.h"
typedef struct crypto_device {
#include "alloc-util.h"
#include "cryptsetup-keyfile.h"
#include "fileio.h"
+#include "iovec-util.h"
#include "log.h"
#include "path-util.h"
-#include "string-util.h"
#include "strv.h"
int find_key_file(const char *key_file, char **search_path, const char *bindname, struct iovec *ret_key) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <sys/types.h>
-
-#include "iovec-util.h"
+#include "forward.h"
int find_key_file(const char *key_file, char **search_path, const char *bindname, struct iovec *ret_key);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <fcntl.h>
-#include <p11-kit/p11-kit.h>
-#include <p11-kit/uri.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
#include "sd-json.h"
#include "alloc-util.h"
#include "ask-password-api.h"
#include "cryptsetup-pkcs11.h"
-#include "escape.h"
-#include "fd-util.h"
+#include "cryptsetup-util.h"
#include "fileio.h"
-#include "format-util.h"
-#include "hexdecoct.h"
#include "iovec-util.h"
-#include "macro.h"
-#include "memory-util.h"
-#include "parse-util.h"
+#include "log.h"
#include "pkcs11-util.h"
#include "random-util.h"
-#include "stat-util.h"
-#include "strv.h"
int decrypt_pkcs11_key(
const char *volume_name,
AskPasswordFlags askpw_flags,
void **ret_decrypted_key,
size_t *ret_decrypted_key_size) {
-
+#if HAVE_P11KIT
_cleanup_(pkcs11_crypt_device_callback_data_release) pkcs11_crypt_device_callback_data data = {
.friendly_name = friendly_name,
.askpw_flags = askpw_flags,
*ret_decrypted_key_size = data.decrypted_key_size;
return 0;
+#else
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 Token support not available.");
+#endif
}
int find_pkcs11_auto_data(
size_t *ret_encrypted_key_size,
int *ret_keyslot) {
+#if HAVE_P11KIT
_cleanup_free_ char *uri = NULL;
_cleanup_free_ void *key = NULL;
int r, keyslot = -1;
*ret_encrypted_key_size = key_size;
*ret_keyslot = keyslot;
return 0;
+#else
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 Token support not available.");
+#endif
}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/types.h>
-
-#include "ask-password-api.h"
-#include "cryptsetup-util.h"
-#include "log.h"
-#include "time-util.h"
-
-#if HAVE_P11KIT
+#include "forward.h"
int decrypt_pkcs11_key(
const char *volume_name,
void **ret_encrypted_key,
size_t *ret_encrypted_key_size,
int *ret_keyslot);
-
-#else
-
-static inline int decrypt_pkcs11_key(
- const char *volume_name,
- const char *friendly_name,
- const char *pkcs11_uri,
- const char *key_file,
- size_t key_file_size,
- uint64_t key_file_offset,
- const struct iovec *key_data,
- usec_t until,
- AskPasswordFlags askpw_flags,
- void **ret_decrypted_key,
- size_t *ret_decrypted_key_size) {
-
- return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
- "PKCS#11 Token support not available.");
-}
-
-static inline int find_pkcs11_auto_data(
- struct crypt_device *cd,
- char **ret_uri,
- void **ret_encrypted_key,
- size_t *ret_encrypted_key_size,
- int *ret_keyslot) {
-
- return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
- "PKCS#11 Token support not available.");
-}
-
-#endif
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <libcryptsetup.h>
#include <string.h>
+#include "sd-json.h"
+
#include "alloc-util.h"
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
-#include "hexdecoct.h"
-#include "json-util.h"
#include "luks2-fido2.h"
#include "memory-util.h"
#include "version.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <libcryptsetup.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
-#include "hexdecoct.h"
#include "luks2-pkcs11.h"
#include "memory-util.h"
#include "pkcs11-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <libcryptsetup.h>
#include "alloc-util.h"
#include "json-util.h"
#include "luks2-tpm2.h"
#include "memory-util.h"
-#include "strv.h"
+#include "string-util.h"
#include "tpm2-util.h"
#include "version.h"
#pragma once
#include <libcryptsetup.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include "macro.h"
+#include "forward.h"
/* crypt_dump() internal indentation magic */
#define CRYPT_DUMP_LINE_SEP "\n\t "
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stddef.h>
-
-struct crypt_device;
+#include "forward.h"
/* for more information see libcryptsetup.h crypt-tokens section */
#pragma once
-#include <stddef.h>
-
-struct crypt_device;
+#include "forward.h"
int acquire_luks2_key(
struct crypt_device *cd,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <getopt.h>
#include <mntent.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <unistd.h>
#include "sd-device.h"
+#include "sd-event.h"
#include "sd-json.h"
#include "sd-messages.h"
#include "cryptsetup-pkcs11.h"
#include "cryptsetup-tpm2.h"
#include "cryptsetup-util.h"
-#include "device-util.h"
#include "efi-api.h"
#include "efi-loader.h"
+#include "efivars.h"
#include "env-util.h"
+#include "errno-util.h"
#include "escape.h"
#include "extract-word.h"
#include "fileio.h"
#include "path-util.h"
#include "pkcs11-util.h"
#include "pretty-print.h"
-#include "process-util.h"
#include "random-util.h"
#include "string-table.h"
+#include "string-util.h"
#include "strv.h"
+#include "time-util.h"
#include "tpm2-pcr.h"
#include "tpm2-util.h"
#include "verbs.h"
subdir('cryptsetup-tokens')
systemd_cryptsetup_sources = files(
- 'cryptsetup-keyfile.c',
'cryptsetup.c',
+ 'cryptsetup-keyfile.c',
+ 'cryptsetup-pkcs11.c',
)
-if conf.get('HAVE_P11KIT') == 1
- systemd_cryptsetup_sources += files('cryptsetup-pkcs11.c')
-endif
-
executables += [
executable_template + {
'name' : 'systemd-cryptsetup',