summaryrefslogtreecommitdiffstats
path: root/src/basic/memory-util.c
diff options
context:
space:
mode:
authorVladimir Stoiakin <VStoiakin@lavabit.com>2023-10-02 15:37:26 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-02-02 19:00:51 +0100
commit85686b37b098b5de4707776ad89598727bf7453f (patch)
tree11df28e9cebef20211c593abe7a010c79b43907a /src/basic/memory-util.c
parentman/systemd-bsod: fix command path (diff)
downloadsystemd-85686b37b098b5de4707776ad89598727bf7453f.tar.xz
systemd-85686b37b098b5de4707776ad89598727bf7453f.zip
cryptenroll: allow to use a public key on a token
This patch allows systemd-cryptenroll to enroll directly with a public key if a certificate is missing on a token. Fixes: #30675
Diffstat (limited to 'src/basic/memory-util.c')
-rw-r--r--src/basic/memory-util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/basic/memory-util.c b/src/basic/memory-util.c
index fcedae2d41..ed6024fa4a 100644
--- a/src/basic/memory-util.c
+++ b/src/basic/memory-util.c
@@ -39,3 +39,19 @@ bool memeqbyte(uint8_t byte, const void *data, size_t length) {
/* Now we know first 16 bytes match, memcmp() with self. */
return memcmp(data, p + 16, length) == 0;
}
+
+void *memdup_reverse(const void *mem, size_t size) {
+ assert(mem);
+ assert(size != 0);
+
+ void *p = malloc(size);
+ if (!p)
+ return NULL;
+
+ uint8_t *p_dst = p;
+ const uint8_t *p_src = mem;
+ for (size_t i = 0, k = size; i < size; i++, k--)
+ p_dst[i] = p_src[k-1];
+
+ return p;
+}