>From 7c69c58720bc2b3cdfca4a3d8564f77aa662e576 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 23 Feb 2020 13:27:35 +0100 Subject: [PATCH 28/29] crypto/hmac-*: Use 'restrict'. * lib/hmac.h (hmac_md5, hmac_sha1, hmac_sha256, hmac_sha512): Use 'restrict'. * modules/crypto/hmac-md5 (configure.ac): Require AC_C_RESTRICT. * modules/crypto/hmac-sha1 (configure.ac): Likewise. * modules/crypto/hmac-sha256 (configure.ac): Likewise. * modules/crypto/hmac-sha512 (configure.ac): Likewise. --- ChangeLog | 8 ++++++++ lib/hmac.h | 8 ++++---- modules/crypto/hmac-md5 | 1 + modules/crypto/hmac-sha1 | 1 + modules/crypto/hmac-sha256 | 1 + modules/crypto/hmac-sha512 | 1 + 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a1c591..e62e1aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2020-02-23 Bruno Haible + crypto/hmac-*: Use 'restrict'. + * lib/hmac.h (hmac_md5, hmac_sha1, hmac_sha256, hmac_sha512): Use + 'restrict'. + * modules/crypto/hmac-md5 (configure.ac): Require AC_C_RESTRICT. + * modules/crypto/hmac-sha1 (configure.ac): Likewise. + * modules/crypto/hmac-sha256 (configure.ac): Likewise. + * modules/crypto/hmac-sha512 (configure.ac): Likewise. + crypto/sm3: Use 'restrict'. * lib/sm3.h (sm3_finish_ctx, sm3_read_ctx, sm3_buffer): Use 'restrict'. * m4/sm3.m4 (gl_SM3): Require AC_C_RESTRICT. diff --git a/lib/hmac.h b/lib/hmac.h index a390702..135eb2a 100644 --- a/lib/hmac.h +++ b/lib/hmac.h @@ -27,7 +27,7 @@ RESBUF buffer. Return 0 on success. */ int hmac_md5 (const void *key, size_t keylen, - const void *buffer, size_t buflen, void *resbuf); + const void *buffer, size_t buflen, void *restrict resbuf); /* Compute Hashed Message Authentication Code with SHA-1, over BUFFER data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the @@ -35,7 +35,7 @@ hmac_md5 (const void *key, size_t keylen, success. */ int hmac_sha1 (const void *key, size_t keylen, - const void *in, size_t inlen, void *resbuf); + const void *in, size_t inlen, void *restrict resbuf); /* Compute Hashed Message Authentication Code with SHA-256, over BUFFER data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the @@ -43,7 +43,7 @@ hmac_sha1 (const void *key, size_t keylen, success. */ int hmac_sha256 (const void *key, size_t keylen, - const void *in, size_t inlen, void *resbuf); + const void *in, size_t inlen, void *restrict resbuf); /* Compute Hashed Message Authentication Code with SHA-512, over BUFFER data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the @@ -51,6 +51,6 @@ hmac_sha256 (const void *key, size_t keylen, success. */ int hmac_sha512 (const void *key, size_t keylen, - const void *in, size_t inlen, void *resbuf); + const void *in, size_t inlen, void *restrict resbuf); #endif /* HMAC_H */ diff --git a/modules/crypto/hmac-md5 b/modules/crypto/hmac-md5 index a2bb9ed..8739c06 100644 --- a/modules/crypto/hmac-md5 +++ b/modules/crypto/hmac-md5 @@ -11,6 +11,7 @@ memxor crypto/md5 configure.ac: +AC_REQUIRE([AC_C_RESTRICT]) Makefile.am: lib_SOURCES += hmac-md5.c diff --git a/modules/crypto/hmac-sha1 b/modules/crypto/hmac-sha1 index 6bec8ae..d49d68d 100644 --- a/modules/crypto/hmac-sha1 +++ b/modules/crypto/hmac-sha1 @@ -11,6 +11,7 @@ memxor crypto/sha1 configure.ac: +AC_REQUIRE([AC_C_RESTRICT]) Makefile.am: lib_SOURCES += hmac-sha1.c diff --git a/modules/crypto/hmac-sha256 b/modules/crypto/hmac-sha256 index 8bd47e8..e67ffd4 100644 --- a/modules/crypto/hmac-sha256 +++ b/modules/crypto/hmac-sha256 @@ -11,6 +11,7 @@ memxor crypto/sha256 configure.ac: +AC_REQUIRE([AC_C_RESTRICT]) Makefile.am: lib_SOURCES += hmac-sha256.c diff --git a/modules/crypto/hmac-sha512 b/modules/crypto/hmac-sha512 index ad0e81b..53e11f8 100644 --- a/modules/crypto/hmac-sha512 +++ b/modules/crypto/hmac-sha512 @@ -11,6 +11,7 @@ memxor crypto/sha512 configure.ac: +AC_REQUIRE([AC_C_RESTRICT]) Makefile.am: lib_SOURCES += hmac-sha512.c -- 2.7.4