From 22e339761be66ae5b7c92b27b4e2b59074ebfbb1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 7 Dec 2022 18:13:12 +0100 Subject: [PATCH] sha256: move to unaligned_write_ne32() --- src/fundamental/sha256.c | 7 ++----- 1 file 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; } -- 2.25.1