>From 734c22abe7d5d046a360415bb030baf2952d5807 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 23 Feb 2020 13:20:18 +0100 Subject: [PATCH 25/29] crypto/sha512-buffer: Use 'restrict'. * lib/sha512.h (sha512_finish_ctx, sha384_finish_ctx, sha512_read_ctx, sha384_read_ctx, sha512_buffer, sha384_buffer): Use 'restrict'. * modules/crypto/sha512-buffer (configure.ac): Require AC_C_RESTRICT. --- ChangeLog | 5 +++++ lib/sha512.h | 20 ++++++++++++-------- modules/crypto/sha512-buffer | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e782e1..8701bea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2020-02-23 Bruno Haible + crypto/sha512-buffer: Use 'restrict'. + * lib/sha512.h (sha512_finish_ctx, sha384_finish_ctx, sha512_read_ctx, + sha384_read_ctx, sha512_buffer, sha384_buffer): Use 'restrict'. + * modules/crypto/sha512-buffer (configure.ac): Require AC_C_RESTRICT. + crypto/sha256-buffer: Use 'restrict'. * lib/sha256.h (sha256_finish_ctx, sha224_finish_ctx, sha256_read_ctx, sha224_read_ctx, sha256_buffer, sha224_buffer): Use 'restrict'. diff --git a/lib/sha512.h b/lib/sha512.h index aaf35a5..21c2f58 100644 --- a/lib/sha512.h +++ b/lib/sha512.h @@ -70,8 +70,8 @@ extern void sha512_process_bytes (const void *buffer, size_t len, in first 64 (48) bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ -extern void *sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf); -extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf); +extern void *sha512_finish_ctx (struct sha512_ctx *ctx, void *restrict resbuf); +extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *restrict resbuf); /* Put result from CTX in first 64 (48) bytes following RESBUF. The result is @@ -80,16 +80,20 @@ extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf); IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf); -extern void *sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf); +extern void *sha512_read_ctx (const struct sha512_ctx *ctx, + void *restrict resbuf); +extern void *sha384_read_ctx (const struct sha512_ctx *ctx, + void *restrict resbuf); -/* Compute SHA512 (SHA384) message digest for LEN bytes beginning at BUFFER. The - result is always in little endian byte order, so that a byte-wise +/* Compute SHA512 (SHA384) message digest for LEN bytes beginning at BUFFER. + The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ -extern void *sha512_buffer (const char *buffer, size_t len, void *resblock); -extern void *sha384_buffer (const char *buffer, size_t len, void *resblock); +extern void *sha512_buffer (const char *buffer, size_t len, + void *restrict resblock); +extern void *sha384_buffer (const char *buffer, size_t len, + void *restrict resblock); # endif /* Compute SHA512 (SHA384) message digest for bytes read from STREAM. diff --git a/modules/crypto/sha512-buffer b/modules/crypto/sha512-buffer index 32170a9..7c5f64d 100644 --- a/modules/crypto/sha512-buffer +++ b/modules/crypto/sha512-buffer @@ -16,6 +16,7 @@ stdint u64 configure.ac: +AC_REQUIRE([AC_C_RESTRICT]) gl_SHA512 Makefile.am: -- 2.7.4