summaryrefslogtreecommitdiffstats
path: root/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h
diff options
context:
space:
mode:
authorOndrej Kozina <okozina@redhat.com>2021-05-17 15:26:14 +0200
committerOndrej Kozina <okozina@redhat.com>2021-08-19 13:58:10 +0200
commit351716e11166bb4b703cc85f5f7c2f18b7e91e08 (patch)
tree06295d423cfc6924e0702796433852ef08c33f6e /src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h
parentpo: Translated using Weblate (Sinhala) (diff)
downloadsystemd-351716e11166bb4b703cc85f5f7c2f18b7e91e08.tar.xz
systemd-351716e11166bb4b703cc85f5f7c2f18b7e91e08.zip
Add support for systemd-fido2 libcryptsetup plugin.
Add support for systemd-fido2 based LUKS2 device activation via libcryptsetup plugin. This make the feature (fido2 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.
Diffstat (limited to 'src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h')
-rw-r--r--src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h
index b8ea4c2422..124bfab63b 100644
--- a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h
+++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-util.h
@@ -2,6 +2,7 @@
#pragma once
+#include <stdbool.h>
#include <stddef.h>
/* crypt_dump() internal indentation magic */
@@ -11,14 +12,22 @@
#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, ...) ({ \
+#define crypt_log_full_errno(cd, e, lvl, ...) ({ \
int _e = abs(e), _s = errno; \
errno = _e; \
- crypt_logf(cd, CRYPT_LOG_DEBUG, __VA_ARGS__); \
+ crypt_logf(cd, lvl, __VA_ARGS__); \
errno = _s; \
-_e; \
})
+#define crypt_log_debug_errno(cd, e, ...) \
+ crypt_log_full_errno(cd, e, CRYPT_LOG_DEBUG, __VA_ARGS__)
+
+#define crypt_log_error_errno(cd, e, ...) \
+ crypt_log_full_errno(cd, e, CRYPT_LOG_ERROR, __VA_ARGS__)
+
+#define crypt_log_oom(cd) crypt_log_error_errno(cd, ENOMEM, "Not enough memory.")
+
int crypt_dump_buffer_to_hex_string(
const char *buf,
size_t buf_size,