summaryrefslogtreecommitdiff
path: root/src/fundamental
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-07 18:13:12 +0100
committerLennart Poettering <lennart@poettering.net>2022-12-08 15:18:47 +0100
commit22e339761be66ae5b7c92b27b4e2b59074ebfbb1 (patch)
tree35b2608b9598df2e26b4481ef19203c94fceb9ff /src/fundamental
parentd8007e7aacdadc57d2fd9ee3f80f620be781248e (diff)
downloadsystemd-22e339761be66ae5b7c92b27b4e2b59074ebfbb1.tar.gz
sha256: move to unaligned_write_ne32()
Diffstat (limited to 'src/fundamental')
-rw-r--r--src/fundamental/sha256.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/fundamental/sha256.c b/src/fundamental/sha256.c
index 9b717645b3..fcbf531bd2 100644
--- a/src/fundamental/sha256.c
+++ b/src/fundamental/sha256.c
@@ -30,6 +30,7 @@
#include "macro-fundamental.h"
#include "sha256.h"
+#include "unaligned-fundamental.h"
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define SWAP(n) \
@@ -128,11 +129,7 @@ uint8_t *sha256_finish_ctx(struct sha256_ctx *ctx, uint8_t resbuf[static SHA256_
/* Put result from CTX in first 32 bytes following RESBUF. */
for (size_t i = 0; i < 8; ++i)
- if (UNALIGNED_P(resbuf))
- memcpy(resbuf + i * sizeof(uint32_t), (uint32_t[]) { SWAP(ctx->H[i]) }, sizeof(uint32_t));
- else
- ((uint32_t *) resbuf)[i] = SWAP(ctx->H[i]);
-
+ unaligned_write_ne32(resbuf + i * sizeof(uint32_t), SWAP(ctx->H[i]));
return resbuf;
}