From d1ae38d85ae458ba8126465d25789e2721a75dba Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Tue, 16 Mar 2021 20:13:28 +0100 Subject: Add support for systemd-tpm2 libcryptsetup plugin. Add support for systemd-tpm2 based LUKS2 device activation via libcryptsetup plugin. This make the feature (tpm2 sealed LUKS2 keyslot passphrase) usable from both systemd utilities and cryptsetup cli. The feature is configured via -Dlibcryptsetup-plugins combo with default value set to 'auto'. It get's enabled automatically when cryptsetup 2.4.0 or later is installed in build system. --- .../cryptsetup-tokens/cryptsetup-token-util.h | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h (limited to 'src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h') diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h new file mode 100644 index 0000000000..b8ea4c2422 --- /dev/null +++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#pragma once + +#include + +/* crypt_dump() internal indentation magic */ +#define CRYPT_DUMP_LINE_SEP "\n\t " + +#define crypt_log_debug(cd, ...) crypt_logf(cd, CRYPT_LOG_DEBUG, __VA_ARGS__) +#define crypt_log_error(cd, ...) crypt_logf(cd, CRYPT_LOG_ERROR, __VA_ARGS__) +#define crypt_log(cd, ...) crypt_logf(cd, CRYPT_LOG_NORMAL, __VA_ARGS__) + +#define crypt_log_debug_errno(cd, e, ...) ({ \ + int _e = abs(e), _s = errno; \ + errno = _e; \ + crypt_logf(cd, CRYPT_LOG_DEBUG, __VA_ARGS__); \ + errno = _s; \ + -_e; \ +}) + +int crypt_dump_buffer_to_hex_string( + const char *buf, + size_t buf_size, + char **ret_dump_str); + +int crypt_dump_hex_string(const char *hex_str, char **ret_dump_str); -- cgit v1.2.3