From: Lennart Poettering Date: Wed, 7 Dec 2022 17:13:12 +0000 (+0100) Subject: sha256: move to unaligned_write_ne32() X-Git-Tag: v253-rc1~331^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22e339761be66ae5b7c92b27b4e2b59074ebfbb1;p=thirdparty%2Fsystemd.git sha256: move to unaligned_write_ne32() --- diff --git a/src/fundamental/sha256.c b/src/fundamental/sha256.c index 9b717645b37..fcbf531bd2c 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; }