From 13e14a6bfd9f29cbfeab0c5161d2a994f97532e7 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 26 Mar 2026 12:53:53 +0100 Subject: Update/gnulib 2026 03 (#2247) * Sync with the 202601-stable Gnulib code (4a3650d887) * Ignore more deps stuff in gnulib * Remove autogenerated gnulib files * Ignore more gnulib generated headers --- gl/sha256.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'gl/sha256.c') diff --git a/gl/sha256.c b/gl/sha256.c index 9358faff..bada2d07 100644 --- a/gl/sha256.c +++ b/gl/sha256.c @@ -1,7 +1,7 @@ /* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or memory blocks according to the NIST specification FIPS-180-2. - Copyright (C) 2005-2006, 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -96,10 +96,9 @@ set_uint32 (char *cp, uint32_t v) void * sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf) { - int i; char *r = resbuf; - for (i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); return resbuf; @@ -108,10 +107,9 @@ sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf) void * sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf) { - int i; char *r = resbuf; - for (i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); return resbuf; @@ -326,8 +324,8 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) + S0(x[(I-15)&0x0f]) + x[I&0x0f] \ , x[I&0x0f] = tm ) -#define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \ - t1 = H + SS1(E) \ +#define R(A,B,C,D,E,F,G,H,K,M) do { uint32_t t0 = SS0(A) + F2(A,B,C); \ + uint32_t t1 = H + SS1(E) \ + F1(E,F,G) \ + K \ + M; \ @@ -336,16 +334,15 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) while (words < endp) { - uint32_t tm; - uint32_t t0, t1; - int t; /* FIXME: see sha1.c for a better implementation. */ - for (t = 0; t < 16; t++) + for (int t = 0; t < 16; t++) { x[t] = SWAP (*words); words++; } + uint32_t tm; + R( a, b, c, d, e, f, g, h, K( 0), x[ 0] ); R( h, a, b, c, d, e, f, g, K( 1), x[ 1] ); R( g, h, a, b, c, d, e, f, K( 2), x[ 2] ); -- cgit v1.2.3-74-g34f1