Use ‘restrict’ on pointer args when appropriate.
It suffices to do this in .h files, as .c files inherit it.
For style, prefer qualifiers after types, to be consistent with
putting ‘restrict’ after types.
* lib/af_alg.h (afalg_buffer, afalg_stream):
* lib/arcfour.h (arcfour_stream, arcfour_setkey):
* lib/arctwo.h (arctwo_setkey_ekb, arctwo_encrypt, arctwo_decrypt):
* lib/des.h (gl_des_setkey, gl_des_makekey, gl_des_ecb_crypt)
(gl_3des_set2keys, gl_3des_set3keys, gl_3des_makekey)
(gl_3des_ecb_crypt):
* lib/gc.h (gc_cipher_setkey, gc_cipher_setiv)
(gc_cipher_encrypt_inline, gc_cipher_decrypt_inline, gc_hash_clone)
(gc_hash_hmac_setkey, gc_hash_write, gc_hash_buffer, gc_md2)
(gc_md4, gc_md5, gc_sha1, gc_sha256, gc_sha512, gc_sm3)
(gc_hmac_md5, gc_hmac_sha1, gc_hmac_sha256, gc_hmac_sha512)
(gc_pbkdf2_hmac, gc_pbkdf2_sha1):
* lib/gl_openssl.h (GL_CRYPTO_FN (_process_bytes))
(GL_CRYPTO_FN (_process_block), GL_CRYPTO_FN (_finish_ctx))
(GL_CRYPTO_FN (_buffer), GL_CRYPTO_FN (_read_ctx)):
* lib/hmac.h (hmac_md5, hmac_sha1, hmac_sha256, hmac_sha512):
* lib/md2.h (md2_process_block, md2_process_bytes, md2_finish_ctx)
(md2_read_ctx, md2_buffer, md2_stream):
* lib/md4.h (md4_process_block, md4_process_bytes, md4_finish_ctx)
(md4_read_ctx, md4_buffer, md4_stream):
* lib/md5.h (__md5_process_block, __md5_process_bytes, __md5_finish_ctx)
(__md5_read_ctx, __md5_buffer, __md5_stream):
* lib/rijndael-alg-fst.h (rijndaelKeySetupEnc)
(rijndaelKeySetupDec, rijndaelEncrypt, rijndaelDecrypt):
* lib/rijndael-api-fst.h (rijndaelMakeKey, rijndaelCipherInit)
(rijndaelBlockEncrypt, rijndaelPadEncrypt, rijndaelBlockDecrypt)
(rijndaelPadDecrypt):
* lib/sha1.h (sha1_process_block, sha1_process_bytes)
(sha1_finish_ctx, sha1_read_ctx, sha1_buffer, sha1_stream):
* lib/sha256.h (sha256_process_block, sha256_process_bytes)
(sha256_finish_ctx, sha224_finish_ctx, sha256_read_ctx)
(sha224_read_ctx, sha256_buffer, sha224_buffer, sha256_stream)
(sha224_stream):
* lib/sha3.h (sha3_process_block, sha3_process_bytes)
(sha3_finish_ctx, sha3_read_ctx, sha3_224_buffer, sha3_256_buffer)
(sha3_384_buffer, sha3_512_buffer, sha3_224_stream)
(sha3_256_stream, sha3_384_stream, sha3_512_stream):
* lib/sha512.h (sha512_process_block, sha512_process_bytes)
(sha512_finish_ctx, sha384_finish_ctx, sha512_read_ctx)
(sha384_read_ctx, sha512_buffer, sha384_buffer, sha512_stream)
(sha384_stream):
* lib/sm3.h (sm3_process_block, sm3_process_bytes, sm3_finish_ctx)
(sm3_read_ctx, sm3_buffer, sm3_stream):
Add ‘restrict’ to pointer args.  All implementations changed.
---
 ChangeLog              | 50 +++++++++++++++++++++++++++++++
 lib/af_alg.c           |  9 +++---
 lib/af_alg.h           | 16 +++++-----
 lib/arcfour.c          |  6 ++--
 lib/arcfour.h          |  8 +++--
 lib/arctwo.c           | 13 ++++----
 lib/arctwo.h           |  9 +++---
 lib/des.c              | 26 +++++++++-------
 lib/des.h              | 32 ++++++++++----------
 lib/gc-gnulib.c        | 51 +++++++++++++++++--------------
 lib/gc-libgcrypt.c     | 54 +++++++++++++++++++--------------
 lib/gc-pbkdf2-sha1.c   |  6 ++--
 lib/gc-pbkdf2.c        | 17 ++++++-----
 lib/gc.h               | 68 ++++++++++++++++++++++--------------------
 lib/gl_openssl.h       | 14 +++++----
 lib/hmac.h             | 16 +++++-----
 lib/md2-stream.c       |  2 +-
 lib/md2.c              | 12 ++++----
 lib/md2.h              | 18 ++++++-----
 lib/md4-stream.c       |  2 +-
 lib/md4.c              | 12 ++++----
 lib/md4.h              | 18 ++++++-----
 lib/md5.h              | 19 +++++++-----
 lib/rijndael-alg-fst.c | 16 +++++-----
 lib/rijndael-alg-fst.h | 16 +++++-----
 lib/rijndael-api-fst.c | 41 ++++++++++++-------------
 lib/rijndael-api-fst.h | 33 ++++++++++----------
 lib/sha1-stream.c      |  2 +-
 lib/sha1.c             | 12 ++++----
 lib/sha1.h             | 18 ++++++-----
 lib/sha256-stream.c    | 10 ++++---
 lib/sha256.c           | 18 ++++++-----
 lib/sha256.h           | 26 ++++++++--------
 lib/sha3-stream.c      |  8 ++---
 lib/sha3.c             | 23 ++++++++------
 lib/sha3.h             | 29 +++++++++---------
 lib/sha512-stream.c    | 10 ++++---
 lib/sha512.c           | 18 ++++++-----
 lib/sha512.h           | 26 ++++++++--------
 lib/sm3-stream.c       |  2 +-
 lib/sm3.c              | 12 ++++----
 lib/sm3.h              | 18 ++++++-----
 42 files changed, 471 insertions(+), 345 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9144f8a0c2..73b0c46649 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,55 @@
 2026-02-22  Paul Eggert  <[email protected]>
 
+       crypto: add ‘restrict’ to .h files
+       Use ‘restrict’ on pointer args when appropriate.
+       It suffices to do this in .h files, as .c files inherit it.
+       For style, prefer qualifiers after types, to be consistent with
+       putting ‘restrict’ after types.
+       * lib/af_alg.h (afalg_buffer, afalg_stream):
+       * lib/arcfour.h (arcfour_stream, arcfour_setkey):
+       * lib/arctwo.h (arctwo_setkey_ekb, arctwo_encrypt, arctwo_decrypt):
+       * lib/des.h (gl_des_setkey, gl_des_makekey, gl_des_ecb_crypt)
+       (gl_3des_set2keys, gl_3des_set3keys, gl_3des_makekey)
+       (gl_3des_ecb_crypt):
+       * lib/gc.h (gc_cipher_setkey, gc_cipher_setiv)
+       (gc_cipher_encrypt_inline, gc_cipher_decrypt_inline, gc_hash_clone)
+       (gc_hash_hmac_setkey, gc_hash_write, gc_hash_buffer, gc_md2)
+       (gc_md4, gc_md5, gc_sha1, gc_sha256, gc_sha512, gc_sm3)
+       (gc_hmac_md5, gc_hmac_sha1, gc_hmac_sha256, gc_hmac_sha512)
+       (gc_pbkdf2_hmac, gc_pbkdf2_sha1):
+       * lib/gl_openssl.h (GL_CRYPTO_FN (_process_bytes))
+       (GL_CRYPTO_FN (_process_block), GL_CRYPTO_FN (_finish_ctx))
+       (GL_CRYPTO_FN (_buffer), GL_CRYPTO_FN (_read_ctx)):
+       * lib/hmac.h (hmac_md5, hmac_sha1, hmac_sha256, hmac_sha512):
+       * lib/md2.h (md2_process_block, md2_process_bytes, md2_finish_ctx)
+       (md2_read_ctx, md2_buffer, md2_stream):
+       * lib/md4.h (md4_process_block, md4_process_bytes, md4_finish_ctx)
+       (md4_read_ctx, md4_buffer, md4_stream):
+       * lib/md5.h (__md5_process_block, __md5_process_bytes, __md5_finish_ctx)
+       (__md5_read_ctx, __md5_buffer, __md5_stream):
+       * lib/rijndael-alg-fst.h (rijndaelKeySetupEnc)
+       (rijndaelKeySetupDec, rijndaelEncrypt, rijndaelDecrypt):
+       * lib/rijndael-api-fst.h (rijndaelMakeKey, rijndaelCipherInit)
+       (rijndaelBlockEncrypt, rijndaelPadEncrypt, rijndaelBlockDecrypt)
+       (rijndaelPadDecrypt):
+       * lib/sha1.h (sha1_process_block, sha1_process_bytes)
+       (sha1_finish_ctx, sha1_read_ctx, sha1_buffer, sha1_stream):
+       * lib/sha256.h (sha256_process_block, sha256_process_bytes)
+       (sha256_finish_ctx, sha224_finish_ctx, sha256_read_ctx)
+       (sha224_read_ctx, sha256_buffer, sha224_buffer, sha256_stream)
+       (sha224_stream):
+       * lib/sha3.h (sha3_process_block, sha3_process_bytes)
+       (sha3_finish_ctx, sha3_read_ctx, sha3_224_buffer, sha3_256_buffer)
+       (sha3_384_buffer, sha3_512_buffer, sha3_224_stream)
+       (sha3_256_stream, sha3_384_stream, sha3_512_stream):
+       * lib/sha512.h (sha512_process_block, sha512_process_bytes)
+       (sha512_finish_ctx, sha384_finish_ctx, sha512_read_ctx)
+       (sha384_read_ctx, sha512_buffer, sha384_buffer, sha512_stream)
+       (sha384_stream):
+       * lib/sm3.h (sm3_process_block, sm3_process_bytes, sm3_finish_ctx)
+       (sm3_read_ctx, sm3_buffer, sm3_stream):
+       Add ‘restrict’ to pointer args.  All implementations changed.
+
        crypto/sha3: Don’t leak if init fails and no free
        If the init_ctx functions fail, it’s natural for callers to
        immediately fail too.  Change the init_ctx functions to not leak
diff --git a/lib/af_alg.c b/lib/af_alg.c
index 91f3df15f4..ff21f0f00a 100644
--- a/lib/af_alg.c
+++ b/lib/af_alg.c
@@ -61,8 +61,9 @@ alg_socket (char const *alg)
 }
 
 int
-afalg_buffer (const char *buffer, size_t len, const char *alg,
-              void *resblock, ssize_t hashlen)
+afalg_buffer (char const *restrict buffer, size_t len,
+              char const *restrict alg,
+              void *restrict resblock, ssize_t hashlen)
 {
   /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
      See <https://patchwork.kernel.org/patch/9308641/>.
@@ -99,8 +100,8 @@ afalg_buffer (const char *buffer, size_t len, const char 
*alg,
 }
 
 int
-afalg_stream (FILE *stream, const char *alg,
-              void *resblock, ssize_t hashlen)
+afalg_stream (FILE *restrict stream, char const *restrict alg,
+              void *restrict resblock, ssize_t hashlen)
 {
   int ofd = alg_socket (alg);
   if (ofd < 0)
diff --git a/lib/af_alg.h b/lib/af_alg.h
index 1321970f8e..6272d1ecbb 100644
--- a/lib/af_alg.h
+++ b/lib/af_alg.h
@@ -58,8 +58,8 @@ extern "C" {
    If successful, fill RESBLOCK and return 0.
    Upon failure, return a negated error number.  */
 int
-afalg_buffer (const char *buffer, size_t len, const char *alg,
-              void *resblock, ssize_t hashlen);
+afalg_buffer (char const *restrict buffer, size_t len, char const *restrict 
alg,
+              void *restrict resblock, ssize_t hashlen);
 
 /* Compute a message digest of data read from STREAM.
 
@@ -87,21 +87,21 @@ afalg_buffer (const char *buffer, size_t len, const char 
*alg,
    Unless returning 0 or -EIO, restore STREAM's file position so that
    the caller can fall back on some other method.  */
 int
-afalg_stream (FILE *stream, const char *alg,
-              void *resblock, ssize_t hashlen);
+afalg_stream (FILE *restrict stream, char const *restrict alg,
+              void *restrict resblock, ssize_t hashlen);
 
 # else
 
 static inline int
-afalg_buffer (const char *buffer, size_t len, const char *alg,
-              void *resblock, ssize_t hashlen)
+afalg_buffer (char const *restrict buffer, size_t len, char const *restrict 
alg,
+              void *restrict resblock, ssize_t hashlen)
 {
   return -EAFNOSUPPORT;
 }
 
 static inline int
-afalg_stream (FILE *stream, const char *alg,
-              void *resblock, ssize_t hashlen)
+afalg_stream (FILE *restrict stream, char const *restrict alg,
+              void *restrict resblock, ssize_t hashlen)
 {
   return -EAFNOSUPPORT;
 }
diff --git a/lib/arcfour.c b/lib/arcfour.c
index c8cfe1ec9c..5a57243db4 100644
--- a/lib/arcfour.c
+++ b/lib/arcfour.c
@@ -29,7 +29,8 @@
 #include "arcfour.h"
 
 void
-arcfour_stream (arcfour_context * context, const char *inbuf, char *outbuf,
+arcfour_stream (arcfour_context *restrict context,
+                char const *restrict inbuf, char *restrict outbuf,
                 size_t length)
 {
   uint8_t i = context->idx_i;
@@ -54,7 +55,8 @@ arcfour_stream (arcfour_context * context, const char *inbuf, 
char *outbuf,
 }
 
 void
-arcfour_setkey (arcfour_context * context, const char *key, size_t keylen)
+arcfour_setkey (arcfour_context *restrict context,
+                char const *restrict key, size_t keylen)
 {
   char *sbox = context->sbox;
 
diff --git a/lib/arcfour.h b/lib/arcfour.h
index a1c1178428..e00fc3dbac 100644
--- a/lib/arcfour.h
+++ b/lib/arcfour.h
@@ -41,14 +41,16 @@ typedef struct
    LENGTH size.  CONTEXT must be initialized with arcfour_setkey
    before this function is called. */
 extern void
-arcfour_stream (arcfour_context * context,
-                const char *inbuf, char *restrict outbuf, size_t length);
+arcfour_stream (arcfour_context *restrict context,
+                char const *restrict inbuf, char *restrict outbuf,
+                size_t length);
 
 /* Initialize CONTEXT using encryption KEY of KEYLEN bytes.  KEY
    should be 40 bits (5 bytes) or longer.  The KEY cannot be zero
    length.  */
 extern void
-arcfour_setkey (arcfour_context * context, const char *key, size_t keylen);
+arcfour_setkey (arcfour_context *restrict context,
+                char const *restrict key, size_t keylen);
 
 
 #ifdef __cplusplus
diff --git a/lib/arctwo.c b/lib/arctwo.c
index 596e8092fd..3b3d075eb7 100644
--- a/lib/arctwo.c
+++ b/lib/arctwo.c
@@ -74,8 +74,8 @@ to_uchar (char ch)
 }
 
 void
-arctwo_encrypt (arctwo_context *context, const char *inbuf,
-                char *outbuf, size_t length)
+arctwo_encrypt (arctwo_context *restrict context, char const *restrict inbuf,
+                char *restrict outbuf, size_t length)
 {
   for (; length >= ARCTWO_BLOCK_SIZE; length -= ARCTWO_BLOCK_SIZE,
          inbuf += ARCTWO_BLOCK_SIZE, outbuf += ARCTWO_BLOCK_SIZE)
@@ -128,8 +128,8 @@ arctwo_encrypt (arctwo_context *context, const char *inbuf,
 }
 
 void
-arctwo_decrypt (arctwo_context *context, const char *inbuf,
-                char *outbuf, size_t length)
+arctwo_decrypt (arctwo_context *restrict context, char const *restrict inbuf,
+                char *restrict outbuf, size_t length)
 {
   for (; length >= ARCTWO_BLOCK_SIZE; length -= ARCTWO_BLOCK_SIZE,
          inbuf += ARCTWO_BLOCK_SIZE, outbuf += ARCTWO_BLOCK_SIZE)
@@ -182,8 +182,9 @@ arctwo_decrypt (arctwo_context *context, const char *inbuf,
 }
 
 void
-arctwo_setkey_ekb (arctwo_context *context,
-                   size_t keylen, const char *key, size_t effective_keylen)
+arctwo_setkey_ekb (arctwo_context *restrict context,
+                   size_t keylen, char const *restrict key,
+                   size_t effective_keylen)
 {
   if (keylen < 40 / 8 || effective_keylen > 1024)
     return;
diff --git a/lib/arctwo.h b/lib/arctwo.h
index 4923f15af8..7ff02561f8 100644
--- a/lib/arctwo.h
+++ b/lib/arctwo.h
@@ -41,8 +41,9 @@ typedef struct
    only be of EFFECTIVE_KEYLEN bits.  Normally, you use
    EFFECTIVE_KEYLEN of 0, but see RFC 2268 for more information. */
 void
-arctwo_setkey_ekb (arctwo_context *context,
-                   size_t keylen, const char *key, size_t effective_keylen);
+arctwo_setkey_ekb (arctwo_context *restrict context,
+                   size_t keylen, char const *restrict key,
+                   size_t effective_keylen);
 
 #define arctwo_setkey(context,keylen,key) \
   arctwo_setkey_ekb (context, keylen, key, 8 * (keylen))
@@ -52,7 +53,7 @@ arctwo_setkey_ekb (arctwo_context *context,
    and must have been initialized with arctwo_setkey or
    arctwo_setkey_ekb. */
 extern void
-arctwo_encrypt (arctwo_context *context, const char *inbuf,
+arctwo_encrypt (arctwo_context *restrict context, char const *restrict inbuf,
                 char *restrict outbuf, size_t length);
 
 /* Decrypt INBUF of size LENGTH into OUTBUF.  LENGTH must be a
@@ -60,7 +61,7 @@ arctwo_encrypt (arctwo_context *context, const char *inbuf,
    and must have been initialized with arctwo_setkey or
    arctwo_setkey_ekb. */
 extern void
-arctwo_decrypt (arctwo_context *context, const char *inbuf,
+arctwo_decrypt (arctwo_context *restrict context, char const *restrict inbuf,
                 char *restrict outbuf, size_t length);
 
 
diff --git a/lib/des.c b/lib/des.c
index 0dab651c69..d8f442b62c 100644
--- a/lib/des.c
+++ b/lib/des.c
@@ -520,7 +520,7 @@ des_key_schedule (const char * _rawkey, uint32_t * subkey)
 }
 
 void
-gl_des_setkey (gl_des_ctx *ctx, const char * key)
+gl_des_setkey (gl_des_ctx *restrict ctx, char const *restrict key)
 {
   des_key_schedule (key, ctx->encrypt_subkeys);
 
@@ -532,7 +532,7 @@ gl_des_setkey (gl_des_ctx *ctx, const char * key)
 }
 
 bool
-gl_des_makekey (gl_des_ctx *ctx, const char * key, size_t keylen)
+gl_des_makekey (gl_des_ctx *ctx, char const *restrict key, size_t keylen)
 {
   if (keylen != 8)
     return false;
@@ -543,7 +543,8 @@ gl_des_makekey (gl_des_ctx *ctx, const char * key, size_t 
keylen)
 }
 
 void
-gl_des_ecb_crypt (gl_des_ctx *ctx, const char * _from, char * _to, int mode)
+gl_des_ecb_crypt (gl_des_ctx *ctx, char const *restrict _from,
+                  char *restrict _to, int mode)
 {
   const unsigned char *from = (const unsigned char *) _from;
   unsigned char *to = (unsigned char *) _to;
@@ -567,7 +568,9 @@ gl_des_ecb_crypt (gl_des_ctx *ctx, const char * _from, char 
* _to, int mode)
 }
 
 void
-gl_3des_set2keys (gl_3des_ctx *ctx, const char * key1, const char * key2)
+gl_3des_set2keys (gl_3des_ctx *restrict ctx,
+                  char const *restrict key1,
+                  char const *restrict key2)
 {
   des_key_schedule (key1, ctx->encrypt_subkeys);
   des_key_schedule (key2, &(ctx->decrypt_subkeys[32]));
@@ -589,8 +592,10 @@ gl_3des_set2keys (gl_3des_ctx *ctx, const char * key1, 
const char * key2)
 }
 
 void
-gl_3des_set3keys (gl_3des_ctx *ctx, const char * key1,
-                    const char * key2, const char * key3)
+gl_3des_set3keys (gl_3des_ctx *restrict ctx,
+                  char const *restrict key1,
+                  char const *restrict key2,
+                  char const *restrict key3)
 {
   des_key_schedule (key1, ctx->encrypt_subkeys);
   des_key_schedule (key2, &(ctx->decrypt_subkeys[32]));
@@ -610,9 +615,9 @@ gl_3des_set3keys (gl_3des_ctx *ctx, const char * key1,
 }
 
 void
-gl_3des_ecb_crypt (gl_3des_ctx *ctx,
-                   const char * _from,
-                   char * _to, int mode)
+gl_3des_ecb_crypt (gl_3des_ctx *restrict ctx,
+                   char const *restrict _from,
+                   char *restrict _to, int mode)
 {
   const unsigned char *from = (const unsigned char *) _from;
   unsigned char *to = (unsigned char *) _to;
@@ -650,7 +655,8 @@ gl_3des_ecb_crypt (gl_3des_ctx *ctx,
 }
 
 bool
-gl_3des_makekey (gl_3des_ctx *ctx, const char * key, size_t keylen)
+gl_3des_makekey (gl_3des_ctx *restrict ctx,
+                 char const *restrict  key, size_t keylen)
 {
   if (keylen != 24)
     return false;
diff --git a/lib/des.h b/lib/des.h
index c7fa99a9c1..5bea42564e 100644
--- a/lib/des.h
+++ b/lib/des.h
@@ -61,18 +61,20 @@ gl_des_is_weak_key (const char * key);
  * Does not check parity bits, but simply ignore them.  Does not check
  * for weak keys. */
 extern void
-gl_des_setkey (gl_des_ctx *ctx, const char * key);
+gl_des_setkey (gl_des_ctx *restrict ctx, char const *restrict key);
 
 /* Fill a DES context CTX with subkeys calculated from 64bit KEY, with
  * weak key checking.  Does not check parity bits, but simply ignore
  * them. */
 extern bool
-gl_des_makekey (gl_des_ctx *ctx, const char * key, size_t keylen);
+gl_des_makekey (gl_des_ctx *restrict ctx,
+                char const *restrict key, size_t keylen);
 
 /* Electronic Codebook Mode DES encryption/decryption of data
  * according to 'mode'. */
 extern void
-gl_des_ecb_crypt (gl_des_ctx *ctx, const char * from,  char * to, int mode);
+gl_des_ecb_crypt (gl_des_ctx *restrict ctx, char const *restrict from,
+                  char *restrict to, int mode);
 
 #define gl_des_ecb_encrypt(ctx, from, to)  gl_des_ecb_crypt(ctx, from, to, 0)
 #define gl_des_ecb_decrypt(ctx, from, to)  gl_des_ecb_crypt(ctx, from, to, 1)
@@ -85,9 +87,9 @@ gl_des_ecb_crypt (gl_des_ctx *ctx, const char * from,  char * 
to, int mode);
  * 64bit keys in KEY1 and KEY2.  Does not check the parity bits of the
  * keys, but simply ignore them.  Does not check for weak keys. */
 extern void
-gl_3des_set2keys (gl_3des_ctx *ctx,
-                  const char * key1,
-                  const char * key2);
+gl_3des_set2keys (gl_3des_ctx *restrict ctx,
+                  char const *restrict key1,
+                  char const *restrict key2);
 
 /*
  * Fill a Triple-DES context CTX with subkeys calculated from three
@@ -95,26 +97,26 @@ gl_3des_set2keys (gl_3des_ctx *ctx,
  * of the keys, but simply ignore them.  Does not check for weak
  * keys. */
 extern void
-gl_3des_set3keys (gl_3des_ctx *ctx,
-                  const char * key1,
-                  const char * key2,
-                  const char * key3);
+gl_3des_set3keys (gl_3des_ctx *restrict ctx,
+                  char const *restrict key1,
+                  char const *restrict key2,
+                  char const *restrict key3);
 
 /* Fill a Triple-DES context CTX with subkeys calculated from three
  * concatenated 64bit keys in KEY, with weak key checking.  Does not
  * check the parity bits of the keys, but simply ignore them. */
 extern bool
-gl_3des_makekey (gl_3des_ctx *ctx,
-                 const char * key,
+gl_3des_makekey (gl_3des_ctx *restrict ctx,
+                 char const *restrict key,
                  size_t keylen);
 
 /* Electronic Codebook Mode Triple-DES encryption/decryption of data
  * according to 'mode'.  Sometimes this mode is named 'EDE' mode
  * (Encryption-Decryption-Encryption). */
 extern void
-gl_3des_ecb_crypt (gl_3des_ctx *ctx,
-                   const char * from,
-                   char * to,
+gl_3des_ecb_crypt (gl_3des_ctx *restrict ctx,
+                   char const *restrict from,
+                   char *restrict to,
                    int mode);
 
 #define gl_3des_ecb_encrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,0)
diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c
index 9c5d093aaa..9fc830fad8 100644
--- a/lib/gc-gnulib.c
+++ b/lib/gc-gnulib.c
@@ -251,7 +251,8 @@ gc_cipher_open (Gc_cipher alg, Gc_cipher_mode mode,
 }
 
 Gc_rc
-gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
+gc_cipher_setkey (gc_cipher_handle restrict handle, size_t keylen,
+                  char const *restrict key)
 {
   _gc_cipher_ctx *ctx = handle;
 
@@ -320,7 +321,8 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, 
const char *key)
 }
 
 Gc_rc
-gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
+gc_cipher_setiv (gc_cipher_handle restrict handle, size_t ivlen,
+                 char const *restrict iv)
 {
   _gc_cipher_ctx *ctx = handle;
 
@@ -372,7 +374,8 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, 
const char *iv)
 }
 
 Gc_rc
-gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+gc_cipher_encrypt_inline (gc_cipher_handle restrict handle,
+                          size_t len, char *restrict data)
 {
   _gc_cipher_ctx *ctx = handle;
 
@@ -440,7 +443,8 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t 
len, char *data)
 }
 
 Gc_rc
-gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+gc_cipher_decrypt_inline (gc_cipher_handle restrict handle, size_t len,
+                          char *restrict data)
 {
   _gc_cipher_ctx *ctx = handle;
 
@@ -624,7 +628,8 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, 
gc_hash_handle * outhandle)
 }
 
 Gc_rc
-gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
+gc_hash_clone (gc_hash_handle restrict handle,
+               gc_hash_handle *restrict outhandle)
 {
   _gc_hash_ctx *in = handle;
   _gc_hash_ctx *out = calloc (1, sizeof (*out));
@@ -684,7 +689,8 @@ gc_hash_digest_length (Gc_hash hash)
 }
 
 void
-gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
+gc_hash_write (gc_hash_handle restrict handle,
+               size_t len, char const *restrict data)
 {
   _gc_hash_ctx *ctx = handle;
 
@@ -810,7 +816,8 @@ gc_hash_close (gc_hash_handle handle)
 }
 
 Gc_rc
-gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
+gc_hash_buffer (Gc_hash hash, const void *restrict in, size_t inlen,
+                char *restrict resbuf)
 {
   switch (hash)
     {
@@ -865,7 +872,7 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, 
char *resbuf)
 
 #if GNULIB_GC_MD2
 Gc_rc
-gc_md2 (const void *in, size_t inlen, void *resbuf)
+gc_md2 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   md2_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -874,7 +881,7 @@ gc_md2 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_MD4
 Gc_rc
-gc_md4 (const void *in, size_t inlen, void *resbuf)
+gc_md4 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   md4_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -883,7 +890,7 @@ gc_md4 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_MD5
 Gc_rc
-gc_md5 (const void *in, size_t inlen, void *resbuf)
+gc_md5 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   md5_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -892,7 +899,7 @@ gc_md5 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SHA1
 Gc_rc
-gc_sha1 (const void *in, size_t inlen, void *resbuf)
+gc_sha1 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   sha1_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -901,7 +908,7 @@ gc_sha1 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SHA256
 Gc_rc
-gc_sha256 (const void *in, size_t inlen, void *resbuf)
+gc_sha256 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   sha256_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -910,7 +917,7 @@ gc_sha256 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SHA512
 Gc_rc
-gc_sha512 (const void *in, size_t inlen, void *resbuf)
+gc_sha512 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   sha512_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -919,7 +926,7 @@ gc_sha512 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SM3
 Gc_rc
-gc_sm3 (const void *in, size_t inlen, void *resbuf)
+gc_sm3 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   sm3_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -928,8 +935,8 @@ gc_sm3 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_HMAC_MD5
 Gc_rc
-gc_hmac_md5 (const void *key, size_t keylen,
-             const void *in, size_t inlen, char *resbuf)
+gc_hmac_md5 (void const *restrict key, size_t keylen,
+             void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   hmac_md5 (key, keylen, in, inlen, resbuf);
   return GC_OK;
@@ -938,8 +945,8 @@ gc_hmac_md5 (const void *key, size_t keylen,
 
 #if GNULIB_GC_HMAC_SHA1
 Gc_rc
-gc_hmac_sha1 (const void *key, size_t keylen,
-              const void *in, size_t inlen, char *resbuf)
+gc_hmac_sha1 (void const *restrict key, size_t keylen,
+              void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   hmac_sha1 (key, keylen, in, inlen, resbuf);
   return GC_OK;
@@ -948,8 +955,8 @@ gc_hmac_sha1 (const void *key, size_t keylen,
 
 #if GNULIB_GC_HMAC_SHA256
 Gc_rc
-gc_hmac_sha256 (const void *key, size_t keylen,
-                const void *in, size_t inlen, char *resbuf)
+gc_hmac_sha256 (void const *restrict key, size_t keylen,
+                void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   hmac_sha256 (key, keylen, in, inlen, resbuf);
   return GC_OK;
@@ -958,8 +965,8 @@ gc_hmac_sha256 (const void *key, size_t keylen,
 
 #if GNULIB_GC_HMAC_SHA512
 Gc_rc
-gc_hmac_sha512 (const void *key, size_t keylen,
-                const void *in, size_t inlen, char *resbuf)
+gc_hmac_sha512 (void const *restrict key, size_t keylen,
+                void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   hmac_sha512 (key, keylen, in, inlen, resbuf);
   return GC_OK;
diff --git a/lib/gc-libgcrypt.c b/lib/gc-libgcrypt.c
index c325633d89..63bbcd5366 100644
--- a/lib/gc-libgcrypt.c
+++ b/lib/gc-libgcrypt.c
@@ -189,7 +189,8 @@ gc_cipher_open (Gc_cipher alg, Gc_cipher_mode mode,
 }
 
 Gc_rc
-gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
+gc_cipher_setkey (gc_cipher_handle restrict handle, size_t keylen,
+                  char const *restrict key)
 {
   gcry_error_t err = gcry_cipher_setkey ((gcry_cipher_hd_t) handle, key, 
keylen);
   if (gcry_err_code (err))
@@ -199,7 +200,8 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, 
const char *key)
 }
 
 Gc_rc
-gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
+gc_cipher_setiv (gc_cipher_handle restrict handle,
+                 size_t ivlen, char const *restrict iv)
 {
   gcry_error_t err = gcry_cipher_setiv ((gcry_cipher_hd_t) handle, iv, ivlen);
   if (gcry_err_code (err))
@@ -209,7 +211,8 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, 
const char *iv)
 }
 
 Gc_rc
-gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+gc_cipher_encrypt_inline (gc_cipher_handle restrict handle,
+                          size_t len, char *restrict data)
 {
   if (gcry_cipher_encrypt ((gcry_cipher_hd_t) handle,
                            data, len, NULL, len) != 0)
@@ -219,7 +222,8 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t 
len, char *data)
 }
 
 Gc_rc
-gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+gc_cipher_decrypt_inline (gc_cipher_handle restrict handle,
+                          size_t len, char *restrict data)
 {
   if (gcry_cipher_decrypt ((gcry_cipher_hd_t) handle,
                            data, len, NULL, len) != 0)
@@ -357,7 +361,8 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, 
gc_hash_handle * outhandle)
 }
 
 Gc_rc
-gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
+gc_hash_clone (gc_hash_handle restrict handle,
+               gc_hash_handle *restrict outhandle)
 {
   _gc_hash_ctx *in = handle;
   _gc_hash_ctx *out = calloc (1, sizeof (*out));
@@ -433,7 +438,8 @@ gc_hash_digest_length (Gc_hash hash)
 }
 
 void
-gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key)
+gc_hash_hmac_setkey (gc_hash_handle restrict handle,
+                     size_t len, char const *restrict key)
 {
   _gc_hash_ctx *ctx = handle;
 #if GNULIB_GC_MD2
@@ -446,7 +452,8 @@ gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, 
const char *key)
 }
 
 void
-gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
+gc_hash_write (gc_hash_handle restrict handle,
+               size_t len, char const *restrict data)
 {
   _gc_hash_ctx *ctx = handle;
 
@@ -510,7 +517,8 @@ gc_hash_close (gc_hash_handle handle)
 }
 
 Gc_rc
-gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
+gc_hash_buffer (Gc_hash hash, void const *restrict in, size_t inlen,
+                char *restrict resbuf)
 {
   int gcryalg;
 
@@ -594,7 +602,7 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, 
char *resbuf)
 
 #if GNULIB_GC_MD2
 Gc_rc
-gc_md2 (const void *in, size_t inlen, void *resbuf)
+gc_md2 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   md2_buffer (in, inlen, resbuf);
   return GC_OK;
@@ -603,7 +611,7 @@ gc_md2 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_MD4
 Gc_rc
-gc_md4 (const void *in, size_t inlen, void *resbuf)
+gc_md4 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD4);
   assert (outlen == GC_MD4_DIGEST_SIZE);
@@ -632,7 +640,7 @@ gc_md4 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_MD5
 Gc_rc
-gc_md5 (const void *in, size_t inlen, void *resbuf)
+gc_md5 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
   assert (outlen == GC_MD5_DIGEST_SIZE);
@@ -661,7 +669,7 @@ gc_md5 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SHA1
 Gc_rc
-gc_sha1 (const void *in, size_t inlen, void *resbuf)
+gc_sha1 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
   assert (outlen == GC_SHA1_DIGEST_SIZE);
@@ -690,7 +698,7 @@ gc_sha1 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SHA256
 Gc_rc
-gc_sha256 (const void *in, size_t inlen, void *resbuf)
+gc_sha256 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA256);
   assert (outlen == GC_SHA256_DIGEST_SIZE);
@@ -719,7 +727,7 @@ gc_sha256 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SHA512
 Gc_rc
-gc_sha512 (const void *in, size_t inlen, void *resbuf)
+gc_sha512 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
   size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA512);
   assert (outlen == GC_SHA512_DIGEST_SIZE);
@@ -748,7 +756,7 @@ gc_sha512 (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_SM3
 Gc_rc
-gc_sm3  (const void *in, size_t inlen, void *resbuf)
+gc_sm3 (void const *restrict in, size_t inlen, void *restrict resbuf)
 {
 # if !LIBGCRYPT_HAS_MD_SM3
   sm3_buffer (in, inlen, resbuf);
@@ -782,8 +790,8 @@ gc_sm3  (const void *in, size_t inlen, void *resbuf)
 
 #if GNULIB_GC_HMAC_MD5
 Gc_rc
-gc_hmac_md5 (const void *key, size_t keylen,
-             const void *in, size_t inlen, char *resbuf)
+gc_hmac_md5 (void const *restrict key, size_t keylen,
+             void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
   assert (hlen == GC_MD5_DIGEST_SIZE);
@@ -817,8 +825,8 @@ gc_hmac_md5 (const void *key, size_t keylen,
 
 #if GNULIB_GC_HMAC_SHA1
 Gc_rc
-gc_hmac_sha1 (const void *key, size_t keylen,
-              const void *in, size_t inlen, char *resbuf)
+gc_hmac_sha1 (void const *restrict key, size_t keylen,
+              void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
   assert (hlen == GC_SHA1_DIGEST_SIZE);
@@ -852,8 +860,8 @@ gc_hmac_sha1 (const void *key, size_t keylen,
 
 #if GNULIB_GC_HMAC_SHA256
 Gc_rc
-gc_hmac_sha256 (const void *key, size_t keylen,
-             const void *in, size_t inlen, char *resbuf)
+gc_hmac_sha256 (void const *restrict key, size_t keylen,
+                void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA256);
   assert (hlen == GC_SHA256_DIGEST_SIZE);
@@ -887,8 +895,8 @@ gc_hmac_sha256 (const void *key, size_t keylen,
 
 #if GNULIB_GC_HMAC_SHA512
 Gc_rc
-gc_hmac_sha512 (const void *key, size_t keylen,
-              const void *in, size_t inlen, char *resbuf)
+gc_hmac_sha512 (void const *restrict key, size_t keylen,
+                void const *restrict in, size_t inlen, char *restrict resbuf)
 {
   size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA512);
   assert (hlen == GC_SHA512_DIGEST_SIZE);
diff --git a/lib/gc-pbkdf2-sha1.c b/lib/gc-pbkdf2-sha1.c
index 91dfb35678..1090811f0d 100644
--- a/lib/gc-pbkdf2-sha1.c
+++ b/lib/gc-pbkdf2-sha1.c
@@ -24,10 +24,10 @@
 #include <string.h>
 
 Gc_rc
-gc_pbkdf2_sha1 (const char *P, size_t Plen,
-                const char *S, size_t Slen,
+gc_pbkdf2_sha1 (char const *restrict P, size_t Plen,
+                char const *restrict S, size_t Slen,
                 unsigned int c,
-                char *DK, size_t dkLen)
+                char *restrict DK, size_t dkLen)
 {
   return gc_pbkdf2_hmac (GC_SHA1, P, Plen, S, Slen, c, DK, dkLen);
 }
diff --git a/lib/gc-pbkdf2.c b/lib/gc-pbkdf2.c
index 2bb9d8fda4..eb97157c24 100644
--- a/lib/gc-pbkdf2.c
+++ b/lib/gc-pbkdf2.c
@@ -23,15 +23,16 @@
 #include <stdlib.h>
 #include <string.h>
 
-typedef Gc_rc (*gc_prf_func) (const void *key, size_t keylen,
-                              const void *in, size_t inlen, char *resbuf);
+typedef Gc_rc (*gc_prf_func) (void const *restrict key, size_t keylen,
+                              void const *restrict in, size_t inlen,
+                              char *restrict resbuf);
 
 static Gc_rc
 gc_pbkdf2_prf (gc_prf_func prf, size_t hLen,
-               const char *P, size_t Plen,
-               const char *S, size_t Slen,
+               char const *restrict P, size_t Plen,
+               char const *restrict S, size_t Slen,
                unsigned int c,
-               char *DK, size_t dkLen)
+               char *restrict DK, size_t dkLen)
 {
   if (c == 0)
     return GC_PKCS5_INVALID_ITERATION_COUNT;
@@ -93,9 +94,9 @@ gc_pbkdf2_prf (gc_prf_func prf, size_t hLen,
 
 Gc_rc
 gc_pbkdf2_hmac (Gc_hash hash,
-                const char *P, size_t Plen,
-                const char *S, size_t Slen,
-                unsigned int c, char *DK, size_t dkLen)
+                char const *restrict P, size_t Plen,
+                char const *restrict S, size_t Slen,
+                unsigned int c, char *restrict DK, size_t dkLen)
 {
   gc_prf_func prf;
   size_t hLen;
diff --git a/lib/gc.h b/lib/gc.h
index 612cef8f9f..d88654be72 100644
--- a/lib/gc.h
+++ b/lib/gc.h
@@ -133,27 +133,28 @@ extern Gc_rc gc_random (char *data, size_t datalen);
 /* Ciphers. */
 extern Gc_rc gc_cipher_open (Gc_cipher cipher, Gc_cipher_mode mode,
                              gc_cipher_handle *outhandle);
-extern Gc_rc gc_cipher_setkey (gc_cipher_handle handle,
-                               size_t keylen, const char *key);
-extern Gc_rc gc_cipher_setiv (gc_cipher_handle handle,
-                              size_t ivlen, const char *iv);
-extern Gc_rc gc_cipher_encrypt_inline (gc_cipher_handle handle,
-                                       size_t len, char *data);
-extern Gc_rc gc_cipher_decrypt_inline (gc_cipher_handle handle,
-                                       size_t len, char *data);
+extern Gc_rc gc_cipher_setkey (gc_cipher_handle restrict handle,
+                               size_t keylen, char const *restrict key);
+extern Gc_rc gc_cipher_setiv (gc_cipher_handle restrict handle,
+                              size_t ivlen, char const *restrict iv);
+extern Gc_rc gc_cipher_encrypt_inline (gc_cipher_handle restrict handle,
+                                       size_t len, char *restrict data);
+extern Gc_rc gc_cipher_decrypt_inline (gc_cipher_handle restrict handle,
+                                       size_t len, char *restrict data);
 extern Gc_rc gc_cipher_close (gc_cipher_handle handle);
 
 /* Hashes. */
 
 extern Gc_rc gc_hash_open (Gc_hash hash, Gc_hash_mode mode,
                            gc_hash_handle *outhandle);
-extern Gc_rc gc_hash_clone (gc_hash_handle handle, gc_hash_handle *outhandle);
+extern Gc_rc gc_hash_clone (gc_hash_handle restrict handle,
+                            gc_hash_handle *restrict outhandle);
 extern size_t gc_hash_digest_length (Gc_hash hash)
                                      _GL_ATTRIBUTE_CONST;
-extern void gc_hash_hmac_setkey (gc_hash_handle handle,
-                                 size_t len, const char *key);
-extern void gc_hash_write (gc_hash_handle handle,
-                           size_t len, const char *data);
+extern void gc_hash_hmac_setkey (gc_hash_handle restrict handle,
+                                 size_t len, char const *restrict key);
+extern void gc_hash_write (gc_hash_handle restrict handle,
+                           size_t len, char const *restrict data);
 extern const char *gc_hash_read (gc_hash_handle handle);
 extern void gc_hash_close (gc_hash_handle handle);
 
@@ -164,24 +165,25 @@ extern void gc_hash_close (gc_hash_handle handle);
    must be 16 bytes.  The return value is 0 (GC_OK) on success, or
    another Gc_rc error code. */
 extern Gc_rc
-gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out);
+gc_hash_buffer (Gc_hash hash, void const *restrict in, size_t inlen,
+                char *restrict out);
 
 /* One-call interface. */
-extern Gc_rc gc_md2 (const void *in, size_t inlen, void *resbuf);
-extern Gc_rc gc_md4 (const void *in, size_t inlen, void *resbuf);
-extern Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf);
-extern Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf);
-extern Gc_rc gc_sha256 (const void *in, size_t inlen, void *resbuf);
-extern Gc_rc gc_sha512 (const void *in, size_t inlen, void *resbuf);
-extern Gc_rc gc_sm3 (const void *in, size_t inlen, void *resbuf);
-extern Gc_rc gc_hmac_md5 (const void *key, size_t keylen,
-                          const void *in, size_t inlen, char *resbuf);
-extern Gc_rc gc_hmac_sha1 (const void *key, size_t keylen,
-                           const void *in, size_t inlen, char *resbuf);
-extern Gc_rc gc_hmac_sha256 (const void *key, size_t keylen,
-                             const void *in, size_t inlen, char *resbuf);
-extern Gc_rc gc_hmac_sha512 (const void *key, size_t keylen,
-                             const void *in, size_t inlen, char *resbuf);
+extern Gc_rc gc_md2 (void const *restrict in, size_t inlen, void *restrict 
resbuf);
+extern Gc_rc gc_md4 (void const *restrict in, size_t inlen, void *restrict 
resbuf);
+extern Gc_rc gc_md5 (void const *restrict in, size_t inlen, void *restrict 
resbuf);
+extern Gc_rc gc_sha1 (void const *restrict in, size_t inlen, void *restrict 
resbuf);
+extern Gc_rc gc_sha256 (void const *restrict in, size_t inlen, void *restrict 
resbuf);
+extern Gc_rc gc_sha512 (void const *restrict in, size_t inlen, void *restrict 
resbuf);
+extern Gc_rc gc_sm3 (void const *restrict in, size_t inlen, void *restrict 
resbuf);
+extern Gc_rc gc_hmac_md5 (void const *restrict key, size_t keylen,
+                          void const *restrict in, size_t inlen, char 
*restrict resbuf);
+extern Gc_rc gc_hmac_sha1 (void const *restrict key, size_t keylen,
+                           void const *restrict in, size_t inlen, char 
*restrict resbuf);
+extern Gc_rc gc_hmac_sha256 (void const *restrict key, size_t keylen,
+                             void const *restrict in, size_t inlen, char 
*restrict resbuf);
+extern Gc_rc gc_hmac_sha512 (void const *restrict key, size_t keylen,
+                             void const *restrict in, size_t inlen, char 
*restrict resbuf);
 
 /* Derive cryptographic keys using PKCS#5 PBKDF2 (RFC 2898) from a
    password P of length PLEN, with salt S of length SLEN, placing the
@@ -193,13 +195,13 @@ extern Gc_rc gc_hmac_sha512 (const void *key, size_t 
keylen,
    returned on success, otherwise a Gc_rc error code is returned.  */
 extern Gc_rc
 gc_pbkdf2_hmac (Gc_hash hash,
-                const char *P, size_t Plen,
-                const char *S, size_t Slen,
+                char const *restrict P, size_t Plen,
+                char const *restrict S, size_t Slen,
                 unsigned int c, char *restrict DK, size_t dkLen);
 
 extern Gc_rc
-gc_pbkdf2_sha1 (const char *P, size_t Plen,
-                const char *S, size_t Slen,
+gc_pbkdf2_sha1 (char const *restrict P, size_t Plen,
+                char const *restrict S, size_t Slen,
                 unsigned int c, char *restrict DK, size_t dkLen);
 
 /*
diff --git a/lib/gl_openssl.h b/lib/gl_openssl.h
index 06fd8f66f9..daec994f60 100644
--- a/lib/gl_openssl.h
+++ b/lib/gl_openssl.h
@@ -83,24 +83,28 @@ GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx)
 /* These were never exposed by gnulib.  */
 #if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384)
 GL_OPENSSL_INLINE void
-GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx 
*ctx)
+GL_CRYPTO_FN (_process_bytes) (void const *restrict buf, size_t len,
+                               struct _gl_ctx *restrict ctx)
 { OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); }
 
 GL_OPENSSL_INLINE void
-GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx 
*ctx)
+GL_CRYPTO_FN (_process_block) (void const *restrict buf, size_t len,
+                               struct _gl_ctx *restrict ctx)
 { GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); }
 #endif
 
 GL_OPENSSL_INLINE void *
-GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *restrict res)
+GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *restrict ctx, void *restrict res)
 { OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; }
 
 GL_OPENSSL_INLINE void *
-GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *restrict res)
+GL_CRYPTO_FN (_buffer) (char const *restrict buf, size_t len,
+                        void *restrict res)
 { return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) 
res); }
 
 GL_OPENSSL_INLINE void *
-GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
+GL_CRYPTO_FN (_read_ctx) (struct _gl_ctx const *restrict ctx,
+                          void *restrict res)
 {
   /* Assume any unprocessed bytes in ctx are not to be ignored.  */
   _gl_CTX tmp_ctx = *(_gl_CTX const *) ctx;
diff --git a/lib/hmac.h b/lib/hmac.h
index e542c3d424..fb6e06593f 100644
--- a/lib/hmac.h
+++ b/lib/hmac.h
@@ -31,32 +31,32 @@ extern "C" {
    KEYLEN bytes, writing the output to pre-allocated 16 byte minimum
    RESBUF buffer.  Return 0 on success.  */
 int
-hmac_md5 (const void *key, size_t keylen,
-          const void *buffer, size_t buflen, void *restrict resbuf);
+hmac_md5 (void const *restrict key, size_t keylen,
+          void const *restrict 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
    output to pre-allocated 20 byte minimum RESBUF buffer.  Return 0 on
    success.  */
 int
-hmac_sha1 (const void *key, size_t keylen,
-           const void *in, size_t inlen, void *restrict resbuf);
+hmac_sha1 (void const *restrict key, size_t keylen,
+           void const *restrict 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
    output to pre-allocated 32 byte minimum RESBUF buffer.  Return 0 on
    success.  */
 int
-hmac_sha256 (const void *key, size_t keylen,
-             const void *in, size_t inlen, void *restrict resbuf);
+hmac_sha256 (void const *restrict key, size_t keylen,
+             void const *restrict 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
    output to pre-allocated 64 byte minimum RESBUF buffer.  Return 0 on
    success.  */
 int
-hmac_sha512 (const void *key, size_t keylen,
-             const void *in, size_t inlen, void *restrict resbuf);
+hmac_sha512 (void const *restrict key, size_t keylen,
+             void const *restrict in, size_t inlen, void *restrict resbuf);
 
 
 #ifdef __cplusplus
diff --git a/lib/md2-stream.c b/lib/md2-stream.c
index bbdd6e62b2..cc6ddf8a27 100644
--- a/lib/md2-stream.c
+++ b/lib/md2-stream.c
@@ -39,7 +39,7 @@
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
 int
-md2_stream (FILE *stream, void *resblock)
+md2_stream (FILE *restrict stream, void *restrict resblock)
 {
   char *buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
diff --git a/lib/md2.c b/lib/md2.c
index 873c349005..ea9a1f15e4 100644
--- a/lib/md2.c
+++ b/lib/md2.c
@@ -46,7 +46,7 @@ md2_init_ctx (struct md2_ctx *ctx)
 /* Put result from CTX in first 16 bytes following RESBUF.  The result
    must be in little endian byte order.  */
 void *
-md2_read_ctx (const struct md2_ctx *ctx, void *resbuf)
+md2_read_ctx (struct md2_ctx const *restrict ctx, void *restrict resbuf)
 {
   memcpy (resbuf, ctx->X, 16);
 
@@ -56,7 +56,7 @@ md2_read_ctx (const struct md2_ctx *ctx, void *resbuf)
 /* Process the remaining bytes in the internal buffer and the usual
    prolog according to the standard and write the result to RESBUF.  */
 void *
-md2_finish_ctx (struct md2_ctx *ctx, void *resbuf)
+md2_finish_ctx (struct md2_ctx *restrict ctx, void *restrict resbuf)
 {
   /* pad the message */
   unsigned long k = 16 - ctx->curlen;
@@ -81,7 +81,7 @@ md2_finish_ctx (struct md2_ctx *ctx, void *resbuf)
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-md2_buffer (const char *buffer, size_t len, void *resblock)
+md2_buffer (char const *restrict buffer, size_t len, void *restrict resblock)
 {
   struct md2_ctx ctx;
 
@@ -96,7 +96,8 @@ md2_buffer (const char *buffer, size_t len, void *resblock)
 }
 
 void
-md2_process_bytes (const void *buffer, size_t len, struct md2_ctx *ctx)
+md2_process_bytes (void const *restrict buffer, size_t len,
+                   struct md2_ctx *restrict ctx)
 {
   const char *in = buffer;
 
@@ -177,7 +178,8 @@ md2_compress (struct md2_ctx *ctx)
 
 /* Process LEN bytes of BUFFER, accumulating context into CTX.  */
 void
-md2_process_block (const void *buffer, size_t len, struct md2_ctx *ctx)
+md2_process_block (void const *restrict buffer, size_t len,
+                   struct md2_ctx *restrict ctx)
 {
   md2_process_bytes (buffer, len, ctx);
 }
diff --git a/lib/md2.h b/lib/md2.h
index 773da7ed56..83f5acc364 100644
--- a/lib/md2.h
+++ b/lib/md2.h
@@ -43,41 +43,43 @@ extern void md2_init_ctx (struct md2_ctx *ctx);
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void md2_process_block (const void *buffer, size_t len,
-                               struct md2_ctx *ctx);
+extern void md2_process_block (void const *restrict buffer, size_t len,
+                               struct md2_ctx *restrict ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void md2_process_bytes (const void *buffer, size_t len,
-                               struct md2_ctx *ctx);
+extern void md2_process_bytes (void const *restrict buffer, size_t len,
+                               struct md2_ctx *restrict ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX
    in first 16 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 *md2_finish_ctx (struct md2_ctx *ctx, void *restrict resbuf);
+extern void *md2_finish_ctx (struct md2_ctx *restrict ctx,
+                             void *restrict resbuf);
 
 
 /* Put result from CTX in first 16 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 *md2_read_ctx (const struct md2_ctx *ctx, void *restrict resbuf);
+extern void *md2_read_ctx (struct md2_ctx const *restrict ctx,
+                           void *restrict resbuf);
 
 
 /* Compute MD2 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 *md2_buffer (const char *buffer, size_t len,
+extern void *md2_buffer (char const *restrict buffer, size_t len,
                          void *restrict resblock);
 
 
 /* Compute MD2 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
-extern int md2_stream (FILE *stream, void *resblock);
+extern int md2_stream (FILE *restrict stream, void *restrict resblock);
 
 
 # ifdef __cplusplus
diff --git a/lib/md4-stream.c b/lib/md4-stream.c
index 9b3daef2f5..602dffa2a4 100644
--- a/lib/md4-stream.c
+++ b/lib/md4-stream.c
@@ -39,7 +39,7 @@
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
 int
-md4_stream (FILE * stream, void *resblock)
+md4_stream (FILE *restrict stream, void *restrict resblock)
 {
   char *buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
diff --git a/lib/md4.c b/lib/md4.c
index 9b24b2017c..fe34886140 100644
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -66,7 +66,7 @@ set_uint32 (char *cp, uint32_t v)
 /* Put result from CTX in first 16 bytes following RESBUF.  The result
    must be in little endian byte order.  */
 void *
-md4_read_ctx (const struct md4_ctx *ctx, void *resbuf)
+md4_read_ctx (struct md4_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
   set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
@@ -80,7 +80,7 @@ md4_read_ctx (const struct md4_ctx *ctx, void *resbuf)
 /* Process the remaining bytes in the internal buffer and the usual
    prolog according to the standard and write the result to RESBUF.  */
 void *
-md4_finish_ctx (struct md4_ctx *ctx, void *resbuf)
+md4_finish_ctx (struct md4_ctx *restrict ctx, void *restrict resbuf)
 {
   /* Take yet unprocessed bytes into account.  */
   uint32_t bytes = ctx->buflen;
@@ -109,7 +109,7 @@ md4_finish_ctx (struct md4_ctx *ctx, void *resbuf)
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-md4_buffer (const char *buffer, size_t len, void *resblock)
+md4_buffer (char const *restrict buffer, size_t len, void *restrict resblock)
 {
   struct md4_ctx ctx;
 
@@ -124,7 +124,8 @@ md4_buffer (const char *buffer, size_t len, void *resblock)
 }
 
 void
-md4_process_bytes (const void *buffer, size_t len, struct md4_ctx *ctx)
+md4_process_bytes (void const *restrict buffer, size_t len,
+                   struct md4_ctx *restrict ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -207,7 +208,8 @@ md4_process_bytes (const void *buffer, size_t len, struct 
md4_ctx *ctx)
    It is assumed that LEN % 64 == 0.  */
 
 void
-md4_process_block (const void *buffer, size_t len, struct md4_ctx *ctx)
+md4_process_block (void const *restrict buffer, size_t len,
+                   struct md4_ctx *restrict ctx)
 {
   const uint32_t *words = buffer;
   size_t nwords = len / sizeof (uint32_t);
diff --git a/lib/md4.h b/lib/md4.h
index e86e008c7a..4aa7d509bc 100644
--- a/lib/md4.h
+++ b/lib/md4.h
@@ -49,41 +49,43 @@ extern void md4_init_ctx (struct md4_ctx *ctx);
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-extern void md4_process_block (const void *buffer, size_t len,
-                               struct md4_ctx *ctx);
+extern void md4_process_block (void const *restrict buffer, size_t len,
+                               struct md4_ctx *restrict ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void md4_process_bytes (const void *buffer, size_t len,
-                               struct md4_ctx *ctx);
+extern void md4_process_bytes (void const *restrict buffer, size_t len,
+                               struct md4_ctx *restrict ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX
    in first 16 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 *md4_finish_ctx (struct md4_ctx *ctx, void *restrict resbuf);
+extern void *md4_finish_ctx (struct md4_ctx *restrict ctx,
+                             void *restrict resbuf);
 
 
 /* Put result from CTX in first 16 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 *md4_read_ctx (const struct md4_ctx *ctx, void *restrict resbuf);
+extern void *md4_read_ctx (struct md4_ctx const *restrict ctx,
+                           void *restrict resbuf);
 
 
 /* Compute MD4 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 *md4_buffer (const char *buffer, size_t len,
+extern void *md4_buffer (char const *restrict buffer, size_t len,
                          void *restrict resblock);
 
 
 /* Compute MD4 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
-extern int md4_stream (FILE * stream, void *resblock);
+extern int md4_stream (FILE *restrict stream, void *restrict resblock);
 
 
 # ifdef __cplusplus
diff --git a/lib/md5.h b/lib/md5.h
index 16c6684b61..5d93b10baa 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -121,28 +121,30 @@ extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-extern void __md5_process_block (const void *buffer, size_t len,
-                                 struct md5_ctx *ctx) __THROW;
+extern void __md5_process_block (void const *restrict buffer, size_t len,
+                                 struct md5_ctx *restrict ctx) __THROW;
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void __md5_process_bytes (const void *buffer, size_t len,
-                                 struct md5_ctx *ctx) __THROW;
+extern void __md5_process_bytes (void const *restrict buffer, size_t len,
+                                 struct md5_ctx *restrict ctx) __THROW;
 
 /* Process the remaining bytes in the buffer and put result from CTX
    in first 16 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 *__md5_finish_ctx (struct md5_ctx *ctx, void *restrict resbuf)
+extern void *__md5_finish_ctx (struct md5_ctx *restrict ctx,
+                               void *restrict resbuf)
      __THROW;
 
 
 /* Put result from CTX in first 16 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 *__md5_read_ctx (const struct md5_ctx *ctx, void *restrict resbuf)
+extern void *__md5_read_ctx (struct md5_ctx const *restrict ctx,
+                             void *restrict resbuf)
      __THROW;
 
 
@@ -150,7 +152,7 @@ extern void *__md5_read_ctx (const struct md5_ctx *ctx, 
void *restrict resbuf)
    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 *__md5_buffer (const char *buffer, size_t len,
+extern void *__md5_buffer (char const *restrict buffer, size_t len,
                            void *restrict resblock) __THROW;
 
 # endif
@@ -161,7 +163,8 @@ extern void *__md5_buffer (const char *buffer, size_t len,
    The case that the last operation on STREAM was an 'ungetc' is not supported.
    The resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
-extern int __md5_stream (FILE *stream, void *resblock) __THROW;
+extern int __md5_stream (FILE *restrict stream, void *restrict resblock)
+  __THROW;
 
 
 # ifdef __cplusplus
diff --git a/lib/rijndael-alg-fst.c b/lib/rijndael-alg-fst.c
index 778641f0eb..7562892737 100644
--- a/lib/rijndael-alg-fst.c
+++ b/lib/rijndael-alg-fst.c
@@ -750,8 +750,8 @@ static const uint32_t rcon[] = {
  * @return      the number of rounds for the given cipher key size.
  */
 int
-rijndaelKeySetupEnc (uint32_t rk[ /*4*(Nr + 1) */ ],
-                     const char cipherKey[], size_t keyBits)
+rijndaelKeySetupEnc (uint32_t rk[restrict /*4*(Nr + 1) */],
+                     char const cipherKey[restrict], size_t keyBits)
 {
   size_t i = 0;
 
@@ -848,8 +848,8 @@ rijndaelKeySetupEnc (uint32_t rk[ /*4*(Nr + 1) */ ],
  * @return      the number of rounds for the given cipher key size.
  */
 int
-rijndaelKeySetupDec (uint32_t rk[ /*4*(Nr + 1) */ ],
-                     const char cipherKey[], size_t keyBits)
+rijndaelKeySetupDec (uint32_t rk[restrict /*4*(Nr + 1) */],
+                     char const cipherKey[restrict], size_t keyBits)
 {
   /* expand the cipher key: */
   size_t Nr = rijndaelKeySetupEnc (rk, cipherKey, keyBits);
@@ -910,8 +910,8 @@ rijndaelKeySetupDec (uint32_t rk[ /*4*(Nr + 1) */ ],
 }
 
 void
-rijndaelEncrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr,
-                 const char pt[16], char ct[16])
+rijndaelEncrypt (uint32_t const rk[restrict /*4*(Nr + 1) */], size_t Nr,
+                 char const pt[restrict 16], char ct[restrict 16])
 {
   uint32_t t0, t1, t2, t3;
 
@@ -1002,8 +1002,8 @@ rijndaelEncrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], 
size_t Nr,
 }
 
 void
-rijndaelDecrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr,
-                 const char ct[16], char pt[16])
+rijndaelDecrypt (uint32_t const rk[restrict /*4*(Nr + 1) */], size_t Nr,
+                 char const ct[restrict 16], char pt[restrict 16])
 {
   uint32_t t0, t1, t2, t3;
 
diff --git a/lib/rijndael-alg-fst.h b/lib/rijndael-alg-fst.h
index 1c5a2c67e8..cb48d9beca 100644
--- a/lib/rijndael-alg-fst.h
+++ b/lib/rijndael-alg-fst.h
@@ -58,14 +58,14 @@ extern "C" {
 #define RIJNDAEL_MAXKB (256/8)
 #define RIJNDAEL_MAXNR 14
 
-int rijndaelKeySetupEnc (uint32_t rk[ /*4*(Nr + 1) */ ],
-                         const char cipherKey[], size_t keyBits);
-int rijndaelKeySetupDec (uint32_t rk[ /*4*(Nr + 1) */ ],
-                         const char cipherKey[], size_t keyBits);
-void rijndaelEncrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr,
-                      const char pt[16], char ct[16]);
-void rijndaelDecrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr,
-                      const char ct[16], char pt[16]);
+int rijndaelKeySetupEnc (uint32_t rk[restrict /*4*(Nr + 1) */],
+                         char const cipherKey[restrict], size_t keyBits);
+int rijndaelKeySetupDec (uint32_t rk[restrict /*4*(Nr + 1) */],
+                         char const cipherKey[restrict], size_t keyBits);
+void rijndaelEncrypt (const uint32_t rk[restrict /*4*(Nr + 1) */], size_t Nr,
+                      char const pt[restrict 16], char ct[restrict 16]);
+void rijndaelDecrypt (const uint32_t rk[restrict /*4*(Nr + 1) */], size_t Nr,
+                      char const ct[restrict 16], char pt[restrict 16]);
 
 
 #ifdef __cplusplus
diff --git a/lib/rijndael-api-fst.c b/lib/rijndael-api-fst.c
index 9b869e1da3..8fb87a1e46 100644
--- a/lib/rijndael-api-fst.c
+++ b/lib/rijndael-api-fst.c
@@ -70,8 +70,9 @@
 #include <string.h>
 
 rijndael_rc
-rijndaelMakeKey (rijndaelKeyInstance *key, rijndael_direction direction,
-                 size_t keyLen, const char *keyMaterial)
+rijndaelMakeKey (rijndaelKeyInstance *restrict key,
+                 rijndael_direction direction,
+                 size_t keyLen, char const *restrict keyMaterial)
 {
   if (key == NULL)
     {
@@ -148,8 +149,8 @@ rijndaelMakeKey (rijndaelKeyInstance *key, 
rijndael_direction direction,
 }
 
 rijndael_rc
-rijndaelCipherInit (rijndaelCipherInstance *cipher, rijndael_mode mode,
-                    const char *IV)
+rijndaelCipherInit (rijndaelCipherInstance *restrict cipher, rijndael_mode 
mode,
+                    char const *restrict IV)
 {
   if ((mode == RIJNDAEL_MODE_ECB) || (mode == RIJNDAEL_MODE_CBC)
       || (mode == RIJNDAEL_MODE_CFB1))
@@ -201,10 +202,10 @@ rijndaelCipherInit (rijndaelCipherInstance *cipher, 
rijndael_mode mode,
 }
 
 int
-rijndaelBlockEncrypt (rijndaelCipherInstance *cipher,
-                      const rijndaelKeyInstance *key,
-                      const char *input,
-                      size_t inputLen, char *outBuffer)
+rijndaelBlockEncrypt (rijndaelCipherInstance *restrict cipher,
+                      rijndaelKeyInstance const *restrict key,
+                      char const *restrict input,
+                      size_t inputLen, char *restrict outBuffer)
 {
   if (cipher == NULL || key == NULL || key->direction == RIJNDAEL_DIR_DECRYPT)
     {
@@ -279,10 +280,10 @@ rijndaelBlockEncrypt (rijndaelCipherInstance *cipher,
 }
 
 int
-rijndaelPadEncrypt (rijndaelCipherInstance *cipher,
-                    const rijndaelKeyInstance *key,
-                    const char *input,
-                    size_t inputOctets, char *outBuffer)
+rijndaelPadEncrypt (rijndaelCipherInstance *restrict cipher,
+                    rijndaelKeyInstance const *restrict key,
+                    char const *restrict input,
+                    size_t inputOctets, char *restrict outBuffer)
 {
   if (cipher == NULL || key == NULL || key->direction == RIJNDAEL_DIR_DECRYPT)
     {
@@ -353,10 +354,10 @@ rijndaelPadEncrypt (rijndaelCipherInstance *cipher,
 }
 
 int
-rijndaelBlockDecrypt (rijndaelCipherInstance *cipher,
-                      const rijndaelKeyInstance *key,
-                      const char *input,
-                      size_t inputLen, char *outBuffer)
+rijndaelBlockDecrypt (rijndaelCipherInstance *restrict cipher,
+                      rijndaelKeyInstance const *restrict key,
+                      char const *restrict input,
+                      size_t inputLen, char *restrict outBuffer)
 {
   if (cipher == NULL
       || key == NULL
@@ -432,10 +433,10 @@ rijndaelBlockDecrypt (rijndaelCipherInstance *cipher,
 }
 
 int
-rijndaelPadDecrypt (rijndaelCipherInstance *cipher,
-                    const rijndaelKeyInstance *key,
-                    const char *input,
-                    size_t inputOctets, char *outBuffer)
+rijndaelPadDecrypt (rijndaelCipherInstance *restrict cipher,
+                    rijndaelKeyInstance const *restrict key,
+                    char const *restrict input,
+                    size_t inputOctets, char *restrict outBuffer)
 {
   if (cipher == NULL || key == NULL || key->direction == RIJNDAEL_DIR_ENCRYPT)
     {
diff --git a/lib/rijndael-api-fst.h b/lib/rijndael-api-fst.h
index cb70006a71..85af72e44f 100644
--- a/lib/rijndael-api-fst.h
+++ b/lib/rijndael-api-fst.h
@@ -140,16 +140,17 @@ typedef struct
    from KEYMATERIAL, a hex string, of KEYLEN size.  KEYLEN should be
    128, 192 or 256. Returns 0 on success, or an error code. */
 extern rijndael_rc
-rijndaelMakeKey (rijndaelKeyInstance *key, rijndael_direction direction,
-                 size_t keyLen, const char *keyMaterial);
+rijndaelMakeKey (rijndaelKeyInstance *restrict key,
+                 rijndael_direction direction,
+                 size_t keyLen, char const *restrict keyMaterial);
 
 /* Initialize cipher state CIPHER for encryption MODE (e.g.,
    RIJNDAEL_MODE_CBC) with initialization vector IV, a hex string of
    2*RIJNDAEL_MAX_IV_SIZE length.  IV may be NULL for modes that do
    not need an IV (i.e., RIJNDAEL_MODE_ECB).  */
 extern rijndael_rc
-rijndaelCipherInit (rijndaelCipherInstance *cipher,
-                    rijndael_mode mode, const char *IV);
+rijndaelCipherInit (rijndaelCipherInstance *restrict cipher,
+                    rijndael_mode mode, char const *restrict IV);
 
 /* Encrypt data in INPUT, of INPUTLEN/8 bytes length, placing the
    output in the pre-allocated OUTBUFFER which must hold at least
@@ -159,9 +160,9 @@ rijndaelCipherInit (rijndaelCipherInstance *cipher,
    calling this function.  Return the number of bits written, or a
    negative rijndael_rc error code. */
 extern int
-rijndaelBlockEncrypt (rijndaelCipherInstance *cipher,
-                      const rijndaelKeyInstance *key,
-                      const char *input, size_t inputLen,
+rijndaelBlockEncrypt (rijndaelCipherInstance *restrict cipher,
+                      const rijndaelKeyInstance *restrict key,
+                      char const *restrict input, size_t inputLen,
                       char *restrict outBuffer);
 
 /* Encrypt data in INPUT, of INPUTOCTETS bytes length, placing the
@@ -174,9 +175,9 @@ rijndaelBlockEncrypt (rijndaelCipherInstance *cipher,
    calling this function.  Return the number of bits written, or a
    negative rijndael_rc error code. */
 extern int
-rijndaelPadEncrypt (rijndaelCipherInstance *cipher,
-                    const rijndaelKeyInstance *key,
-                    const char *input, size_t inputOctets,
+rijndaelPadEncrypt (rijndaelCipherInstance *restrict cipher,
+                    const rijndaelKeyInstance *restrict key,
+                    char const *restrict input, size_t inputOctets,
                     char *restrict outBuffer);
 
 /* Decrypt data in INPUT, of INPUTLEN/8 bytes length, placing the
@@ -187,9 +188,9 @@ rijndaelPadEncrypt (rijndaelCipherInstance *cipher,
    calling this function.  Return the number of bits written, or a
    negative rijndael_rc error code. */
 extern int
-rijndaelBlockDecrypt (rijndaelCipherInstance *cipher,
-                      const rijndaelKeyInstance *key,
-                      const char *input, size_t inputLen,
+rijndaelBlockDecrypt (rijndaelCipherInstance *restrict cipher,
+                      const rijndaelKeyInstance *restrict key,
+                      char const *restrict input, size_t inputLen,
                       char *restrict outBuffer);
 
 /* Decrypt data in INPUT, of INPUTOCTETS bytes length, placing the
@@ -202,9 +203,9 @@ rijndaelBlockDecrypt (rijndaelCipherInstance *cipher,
    calling this function.  Return the number of bits written, or a
    negative rijndael_rc error code. */
 extern int
-rijndaelPadDecrypt (rijndaelCipherInstance *cipher,
-                    const rijndaelKeyInstance *key,
-                    const char *input, size_t inputOctets,
+rijndaelPadDecrypt (rijndaelCipherInstance *restrict cipher,
+                    const rijndaelKeyInstance *restrict key,
+                    char const *restrict input, size_t inputOctets,
                     char *restrict outBuffer);
 
 
diff --git a/lib/sha1-stream.c b/lib/sha1-stream.c
index 210eaa049d..b11464bc10 100644
--- a/lib/sha1-stream.c
+++ b/lib/sha1-stream.c
@@ -43,7 +43,7 @@
    resulting message digest number will be written into the 20 bytes
    beginning at RESBLOCK.  */
 int
-sha1_stream (FILE *stream, void *resblock)
+sha1_stream (FILE *restrict stream, void *restrict resblock)
 {
   switch (afalg_stream (stream, "sha1", resblock, SHA1_DIGEST_SIZE))
     {
diff --git a/lib/sha1.c b/lib/sha1.c
index f41bda875d..bb7aa2af29 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -74,7 +74,7 @@ set_uint32 (char *cp, uint32_t v)
 /* Put result from CTX in first 20 bytes following RESBUF.  The result
    must be in little endian byte order.  */
 void *
-sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
+sha1_read_ctx (struct sha1_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
   set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
@@ -89,7 +89,7 @@ sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
 /* Process the remaining bytes in the internal buffer and the usual
    prolog according to the standard and write the result to RESBUF.  */
 void *
-sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
+sha1_finish_ctx (struct sha1_ctx *restrict ctx, void *restrict resbuf)
 {
   /* Take yet unprocessed bytes into account.  */
   uint32_t bytes = ctx->buflen;
@@ -117,7 +117,7 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-sha1_buffer (const char *buffer, size_t len, void *resblock)
+sha1_buffer (char const *restrict buffer, size_t len, void *restrict resblock)
 {
   struct sha1_ctx ctx;
 
@@ -132,7 +132,8 @@ sha1_buffer (const char *buffer, size_t len, void *resblock)
 }
 
 void
-sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
+sha1_process_bytes (void const *restrict buffer, size_t len,
+                    struct sha1_ctx *restrict ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -219,7 +220,8 @@ sha1_process_bytes (const void *buffer, size_t len, struct 
sha1_ctx *ctx)
    Most of this code comes from GnuPG's cipher/sha1.c.  */
 
 void
-sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
+sha1_process_block (void const *restrict buffer, size_t len,
+                    struct sha1_ctx *restrict ctx)
 {
   const uint32_t *words = buffer;
   size_t nwords = len / sizeof (uint32_t);
diff --git a/lib/sha1.h b/lib/sha1.h
index a267d46ab4..444902cb28 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -79,34 +79,36 @@ extern void sha1_init_ctx (struct sha1_ctx *ctx);
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-extern void sha1_process_block (const void *buffer, size_t len,
-                                struct sha1_ctx *ctx);
+extern void sha1_process_block (void const *restrict buffer, size_t len,
+                                struct sha1_ctx *restrict ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void sha1_process_bytes (const void *buffer, size_t len,
-                                struct sha1_ctx *ctx);
+extern void sha1_process_bytes (void const *restrict buffer, size_t len,
+                                struct sha1_ctx *restrict ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX
    in first 20 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 *sha1_finish_ctx (struct sha1_ctx *ctx, void *restrict resbuf);
+extern void *sha1_finish_ctx (struct sha1_ctx *restrict ctx,
+                              void *restrict resbuf);
 
 
 /* Put result from CTX in first 20 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 *sha1_read_ctx (const struct sha1_ctx *ctx, void *restrict resbuf);
+extern void *sha1_read_ctx (struct sha1_ctx const *restrict ctx,
+                            void *restrict resbuf);
 
 
 /* Compute SHA1 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 *sha1_buffer (const char *buffer, size_t len,
+extern void *sha1_buffer (char const *restrict buffer, size_t len,
                           void *restrict resblock);
 
 # endif
@@ -117,7 +119,7 @@ extern void *sha1_buffer (const char *buffer, size_t len,
    The case that the last operation on STREAM was an 'ungetc' is not supported.
    The resulting message digest number will be written into the 20 bytes
    beginning at RESBLOCK.  */
-extern int sha1_stream (FILE *stream, void *resblock);
+extern int sha1_stream (FILE *restrict stream, void *restrict resblock);
 
 
 # ifdef __cplusplus
diff --git a/lib/sha256-stream.c b/lib/sha256-stream.c
index 011b36e2a8..66277664da 100644
--- a/lib/sha256-stream.c
+++ b/lib/sha256-stream.c
@@ -43,9 +43,11 @@
    The initial and finishing operations are INIT_CTX and FINISH_CTX.
    Return zero if and only if successful.  */
 static int
-shaxxx_stream (FILE *stream, char const *alg, void *resblock,
+shaxxx_stream (FILE *restrict stream, char const *restrict alg,
+               void *restrict resblock,
                ssize_t hashlen, void (*init_ctx) (struct sha256_ctx *),
-               void *(*finish_ctx) (struct sha256_ctx *, void *))
+               void *(*finish_ctx) (struct sha256_ctx *restrict,
+                                    void *restrict))
 {
   switch (afalg_stream (stream, alg, resblock, hashlen))
     {
@@ -120,14 +122,14 @@ shaxxx_stream (FILE *stream, char const *alg, void 
*resblock,
 }
 
 int
-sha256_stream (FILE *stream, void *resblock)
+sha256_stream (FILE *restrict stream, void *restrict resblock)
 {
   return shaxxx_stream (stream, "sha256", resblock, SHA256_DIGEST_SIZE,
                         sha256_init_ctx, sha256_finish_ctx);
 }
 
 int
-sha224_stream (FILE *stream, void *resblock)
+sha224_stream (FILE *restrict stream, void *restrict resblock)
 {
   return shaxxx_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE,
                         sha224_init_ctx, sha224_finish_ctx);
diff --git a/lib/sha256.c b/lib/sha256.c
index bada2d0717..115b288e46 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -94,7 +94,7 @@ set_uint32 (char *cp, uint32_t v)
 /* Put result from CTX in first 32 bytes following RESBUF.
    The result must be in little endian byte order.  */
 void *
-sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
+sha256_read_ctx (struct sha256_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
 
@@ -105,7 +105,7 @@ sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
 }
 
 void *
-sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
+sha224_read_ctx (struct sha256_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
 
@@ -144,14 +144,14 @@ sha256_conclude_ctx (struct sha256_ctx *ctx)
 }
 
 void *
-sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
+sha256_finish_ctx (struct sha256_ctx *restrict ctx, void *restrict resbuf)
 {
   sha256_conclude_ctx (ctx);
   return sha256_read_ctx (ctx, resbuf);
 }
 
 void *
-sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
+sha224_finish_ctx (struct sha256_ctx *restrict ctx, void *restrict resbuf)
 {
   sha256_conclude_ctx (ctx);
   return sha224_read_ctx (ctx, resbuf);
@@ -162,7 +162,7 @@ sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-sha256_buffer (const char *buffer, size_t len, void *resblock)
+sha256_buffer (char const *restrict buffer, size_t len, void *restrict 
resblock)
 {
   struct sha256_ctx ctx;
 
@@ -177,7 +177,7 @@ sha256_buffer (const char *buffer, size_t len, void 
*resblock)
 }
 
 void *
-sha224_buffer (const char *buffer, size_t len, void *resblock)
+sha224_buffer (char const *restrict buffer, size_t len, void *restrict 
resblock)
 {
   struct sha256_ctx ctx;
 
@@ -192,7 +192,8 @@ sha224_buffer (const char *buffer, size_t len, void 
*resblock)
 }
 
 void
-sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
+sha256_process_bytes (void const *restrict buffer, size_t len,
+                      struct sha256_ctx *restrict ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -292,7 +293,8 @@ static const uint32_t sha256_round_constants[64] = {
    Most of this code comes from GnuPG's cipher/sha1.c.  */
 
 void
-sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
+sha256_process_block (void const *restrict buffer, size_t len,
+                      struct sha256_ctx *restrict ctx)
 {
   const uint32_t *words = buffer;
   size_t nwords = len / sizeof (uint32_t);
diff --git a/lib/sha256.h b/lib/sha256.h
index db80ea5e35..867befdd5d 100644
--- a/lib/sha256.h
+++ b/lib/sha256.h
@@ -78,30 +78,32 @@ extern void sha224_init_ctx (struct sha256_ctx *ctx);
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-extern void sha256_process_block (const void *buffer, size_t len,
-                                  struct sha256_ctx *ctx);
+extern void sha256_process_block (void const *restrict buffer, size_t len,
+                                  struct sha256_ctx *restrict ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void sha256_process_bytes (const void *buffer, size_t len,
-                                  struct sha256_ctx *ctx);
+extern void sha256_process_bytes (void const *restrict buffer, size_t len,
+                                  struct sha256_ctx *restrict ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX
    in first 32 (28) 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 *sha256_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
-extern void *sha224_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
+extern void *sha256_finish_ctx (struct sha256_ctx *restrict ctx,
+                                void *restrict resbuf);
+extern void *sha224_finish_ctx (struct sha256_ctx *restrict ctx,
+                                void *restrict resbuf);
 
 
 /* Put result from CTX in first 32 (28) 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 *sha256_read_ctx (const struct sha256_ctx *ctx,
+extern void *sha256_read_ctx (struct sha256_ctx const *restrict ctx,
                               void *restrict resbuf);
-extern void *sha224_read_ctx (const struct sha256_ctx *ctx,
+extern void *sha224_read_ctx (struct sha256_ctx const *restrict ctx,
                               void *restrict resbuf);
 
 
@@ -109,9 +111,9 @@ extern void *sha224_read_ctx (const struct sha256_ctx *ctx,
    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 *sha256_buffer (const char *buffer, size_t len,
+extern void *sha256_buffer (char const *restrict buffer, size_t len,
                             void *restrict resblock);
-extern void *sha224_buffer (const char *buffer, size_t len,
+extern void *sha224_buffer (char const *restrict buffer, size_t len,
                             void *restrict resblock);
 
 # endif
@@ -122,8 +124,8 @@ extern void *sha224_buffer (const char *buffer, size_t len,
    The case that the last operation on STREAM was an 'ungetc' is not supported.
    The resulting message digest number will be written into the 32 (28) bytes
    beginning at RESBLOCK.  */
-extern int sha256_stream (FILE *stream, void *resblock);
-extern int sha224_stream (FILE *stream, void *resblock);
+extern int sha256_stream (FILE *restrict stream, void *restrict resblock);
+extern int sha224_stream (FILE *restrict stream, void *restrict resblock);
 
 
 # ifdef __cplusplus
diff --git a/lib/sha3-stream.c b/lib/sha3-stream.c
index b50e40a103..a4d6507bba 100644
--- a/lib/sha3-stream.c
+++ b/lib/sha3-stream.c
@@ -141,28 +141,28 @@ sha3_xxx_stream (FILE *stream, char const *alg, void 
*resblock,
 }
 
 int
-sha3_224_stream (FILE *stream, void *resblock)
+sha3_224_stream (FILE *restrict stream, void *restrict resblock)
 {
   return sha3_xxx_stream (stream, "sha3-224", resblock, SHA3_224_DIGEST_SIZE,
                           sha3_224_init_ctx);
 }
 
 int
-sha3_256_stream (FILE *stream, void *resblock)
+sha3_256_stream (FILE *restrict stream, void *restrict resblock)
 {
   return sha3_xxx_stream (stream, "sha3-256", resblock, SHA3_256_DIGEST_SIZE,
                           sha3_256_init_ctx);
 }
 
 int
-sha3_384_stream (FILE *stream, void *resblock)
+sha3_384_stream (FILE *restrict stream, void *restrict resblock)
 {
   return sha3_xxx_stream (stream, "sha3-384", resblock, SHA3_384_DIGEST_SIZE,
                           sha3_384_init_ctx);
 }
 
 int
-sha3_512_stream (FILE *stream, void *resblock)
+sha3_512_stream (FILE *restrict stream, void *restrict resblock)
 {
   return sha3_xxx_stream (stream, "sha3-512", resblock, SHA3_512_DIGEST_SIZE,
                           sha3_512_init_ctx);
diff --git a/lib/sha3.c b/lib/sha3.c
index dec3b94b9a..c839f9148a 100644
--- a/lib/sha3.c
+++ b/lib/sha3.c
@@ -81,7 +81,7 @@ set_uint64 (char *cp, u64 v)
 }
 
 void *
-sha3_read_ctx (const struct sha3_ctx *ctx, void *resbuf)
+sha3_read_ctx (struct sha3_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
   size_t words = ctx->digestlen / sizeof *ctx->state;
@@ -113,7 +113,7 @@ sha3_conclude_ctx (struct sha3_ctx *ctx)
 }
 
 void *
-sha3_finish_ctx (struct sha3_ctx *ctx, void *resbuf)
+sha3_finish_ctx (struct sha3_ctx *restrict ctx, void *restrict resbuf)
 {
   sha3_conclude_ctx (ctx);
   return sha3_read_ctx (ctx, resbuf);
@@ -121,7 +121,8 @@ sha3_finish_ctx (struct sha3_ctx *ctx, void *resbuf)
 
 #define DEFINE_SHA3_BUFFER(SIZE)                                        \
   void *                                                                \
-  sha3_##SIZE##_buffer (const char *buffer, size_t len, void *resblock) \
+  sha3_##SIZE##_buffer (char const *restrict buffer, size_t len,        \
+                        void *restrict resblock)                        \
   {                                                                     \
     struct sha3_ctx ctx;                                                \
     sha3_##SIZE##_init_ctx (&ctx);                                      \
@@ -135,7 +136,8 @@ DEFINE_SHA3_BUFFER (384)
 DEFINE_SHA3_BUFFER (512)
 
 bool
-sha3_process_bytes (const void *buffer, size_t len, struct sha3_ctx *ctx)
+sha3_process_bytes (void const *restrict buffer, size_t len,
+                    struct sha3_ctx *restrict ctx)
 {
   char const *buf = buffer;
 
@@ -168,7 +170,8 @@ sha3_process_bytes (const void *buffer, size_t len, struct 
sha3_ctx *ctx)
 }
 
 bool
-sha3_process_block (const void *buffer, size_t len, struct sha3_ctx *ctx)
+sha3_process_block (void const *restrict buffer, size_t len,
+                    struct sha3_ctx *restrict ctx)
 {
   u64 *a = ctx->state;
   const u64 *words = buffer;
@@ -366,7 +369,7 @@ sha3_free_ctx (struct sha3_ctx *ctx)
 }
 
 void *
-sha3_read_ctx (const struct sha3_ctx *ctx, void *resbuf)
+sha3_read_ctx (struct sha3_ctx const *restrict ctx, void *restrict resbuf)
 {
   void *result = NULL;
   int err = ENOMEM;
@@ -386,7 +389,7 @@ sha3_read_ctx (const struct sha3_ctx *ctx, void *resbuf)
 }
 
 void *
-sha3_finish_ctx (struct sha3_ctx *ctx, void *resbuf)
+sha3_finish_ctx (struct sha3_ctx *restrict ctx, void *restrict resbuf)
 {
   int result = EVP_DigestFinal_ex (ctx->evp_ctx, resbuf, NULL);
   if (result == 0)
@@ -416,7 +419,8 @@ DEFINE_SHA3_BUFFER (384)
 DEFINE_SHA3_BUFFER (512)
 
 bool
-sha3_process_bytes (const void *buffer, size_t len, struct sha3_ctx *ctx)
+sha3_process_bytes (void const *restrict buffer, size_t len,
+                    struct sha3_ctx *restrict ctx)
 {
   int result = EVP_DigestUpdate (ctx->evp_ctx, buffer, len);
   if (result == 0)
@@ -428,7 +432,8 @@ sha3_process_bytes (const void *buffer, size_t len, struct 
sha3_ctx *ctx)
 }
 
 bool
-sha3_process_block (const void *buffer, size_t len, struct sha3_ctx *ctx)
+sha3_process_block (void const *restrict buffer, size_t len,
+                    struct sha3_ctx *restrict ctx)
 {
   return sha3_process_bytes (buffer, len, ctx);
 }
diff --git a/lib/sha3.h b/lib/sha3.h
index 65d4226ac3..a44922a084 100644
--- a/lib/sha3.h
+++ b/lib/sha3.h
@@ -76,28 +76,29 @@ extern void sha3_free_ctx (struct sha3_ctx *ctx);
    starting at BUFFER.
    It is necessary that LEN is a multiple of the BLOCKLEN member of CTX!!!
    Return false if an OpenSSL function fails.  */
-extern bool sha3_process_block (const void *buffer, size_t len,
-                                struct sha3_ctx *ctx);
+extern bool sha3_process_block (void const *restrict buffer, size_t len,
+                                struct sha3_ctx *restrict ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of the BLOCKLEN member of CTX.
    Return false if an OpenSSL function fails.  */
-extern bool sha3_process_bytes (const void *buffer, size_t len,
-                                struct sha3_ctx *ctx);
+extern bool sha3_process_bytes (void const *restrict buffer, size_t len,
+                                struct sha3_ctx *restrict ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX in 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.
    Return NULL if an OpenSSL function fails.  */
-extern void *sha3_finish_ctx (struct sha3_ctx *ctx, void *restrict resbuf);
+extern void *sha3_finish_ctx (struct sha3_ctx *restrict ctx,
+                              void *restrict resbuf);
 
 /* Put result from CTX in 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.
    Return NULL if an OpenSSL function fails.  */
-extern void *sha3_read_ctx (const struct sha3_ctx *ctx,
+extern void *sha3_read_ctx (struct sha3_ctx const *restrict ctx,
                             void *restrict resbuf);
 
 /* Compute a SHA-3 message digest for LEN bytes beginning at BUFFER.
@@ -105,13 +106,13 @@ extern void *sha3_read_ctx (const struct sha3_ctx *ctx,
    output yields to the wanted ASCII representation of the message
    digest.
    Return NULL if an OpenSSL function fails.  */
-extern void *sha3_224_buffer (const char *buffer, size_t len,
+extern void *sha3_224_buffer (char const *restrict buffer, size_t len,
                               void *restrict resblock);
-extern void *sha3_256_buffer (const char *buffer, size_t len,
+extern void *sha3_256_buffer (char const *restrict buffer, size_t len,
                               void *restrict resblock);
-extern void *sha3_384_buffer (const char *buffer, size_t len,
+extern void *sha3_384_buffer (char const *restrict buffer, size_t len,
                               void *restrict resblock);
-extern void *sha3_512_buffer (const char *buffer, size_t len,
+extern void *sha3_512_buffer (char const *restrict buffer, size_t len,
                               void *restrict resblock);
 
 /* Compute SHA-3 message digest for bytes read from STREAM.  STREAM is an open
@@ -119,10 +120,10 @@ extern void *sha3_512_buffer (const char *buffer, size_t 
len,
    STREAM from its current position to its end will be read.  The case that the
    last operation on STREAM was an 'ungetc' is not supported.  The resulting
    message digest number will be written into RESBLOCK.  */
-extern int sha3_224_stream (FILE *stream, void *resblock);
-extern int sha3_256_stream (FILE *stream, void *resblock);
-extern int sha3_384_stream (FILE *stream, void *resblock);
-extern int sha3_512_stream (FILE *stream, void *resblock);
+extern int sha3_224_stream (FILE *restrict stream, void *restrict resblock);
+extern int sha3_256_stream (FILE *restrict stream, void *restrict resblock);
+extern int sha3_384_stream (FILE *restrict stream, void *restrict resblock);
+extern int sha3_512_stream (FILE *restrict stream, void *restrict resblock);
 
 # ifdef __cplusplus
 }
diff --git a/lib/sha512-stream.c b/lib/sha512-stream.c
index 75ccd349e0..a5371b4991 100644
--- a/lib/sha512-stream.c
+++ b/lib/sha512-stream.c
@@ -43,9 +43,11 @@
    The initial and finishing operations are INIT_CTX and FINISH_CTX.
    Return zero if and only if successful.  */
 static int
-shaxxx_stream (FILE *stream, char const *alg, void *resblock,
+shaxxx_stream (FILE *restrict stream, char const *restrict alg,
+               void *restrict resblock,
                ssize_t hashlen, void (*init_ctx) (struct sha512_ctx *),
-               void *(*finish_ctx) (struct sha512_ctx *, void *))
+               void *(*finish_ctx) (struct sha512_ctx *restrict,
+                                    void *restrict))
 {
   switch (afalg_stream (stream, alg, resblock, hashlen))
     {
@@ -120,14 +122,14 @@ shaxxx_stream (FILE *stream, char const *alg, void 
*resblock,
 }
 
 int
-sha512_stream (FILE *stream, void *resblock)
+sha512_stream (FILE *restrict stream, void *restrict resblock)
 {
   return shaxxx_stream (stream, "sha512", resblock, SHA512_DIGEST_SIZE,
                         sha512_init_ctx, sha512_finish_ctx);
 }
 
 int
-sha384_stream (FILE *stream, void *resblock)
+sha384_stream (FILE *restrict stream, void *restrict resblock)
 {
   return shaxxx_stream (stream, "sha384", resblock, SHA384_DIGEST_SIZE,
                         sha384_init_ctx, sha384_finish_ctx);
diff --git a/lib/sha512.c b/lib/sha512.c
index a8c6484c2e..4a213f8acc 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -94,7 +94,7 @@ set_uint64 (char *cp, u64 v)
 /* Put result from CTX in first 64 bytes following RESBUF.
    The result must be in little endian byte order.  */
 void *
-sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
+sha512_read_ctx (struct sha512_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
 
@@ -105,7 +105,7 @@ sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
 }
 
 void *
-sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
+sha384_read_ctx (struct sha512_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
 
@@ -145,14 +145,14 @@ sha512_conclude_ctx (struct sha512_ctx *ctx)
 }
 
 void *
-sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
+sha512_finish_ctx (struct sha512_ctx *restrict ctx, void *restrict resbuf)
 {
   sha512_conclude_ctx (ctx);
   return sha512_read_ctx (ctx, resbuf);
 }
 
 void *
-sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
+sha384_finish_ctx (struct sha512_ctx *restrict ctx, void *restrict resbuf)
 {
   sha512_conclude_ctx (ctx);
   return sha384_read_ctx (ctx, resbuf);
@@ -163,7 +163,7 @@ sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-sha512_buffer (const char *buffer, size_t len, void *resblock)
+sha512_buffer (char const *restrict buffer, size_t len, void *restrict 
resblock)
 {
   struct sha512_ctx ctx;
 
@@ -178,7 +178,7 @@ sha512_buffer (const char *buffer, size_t len, void 
*resblock)
 }
 
 void *
-sha384_buffer (const char *buffer, size_t len, void *resblock)
+sha384_buffer (char const *restrict buffer, size_t len, void *restrict 
resblock)
 {
   struct sha512_ctx ctx;
 
@@ -193,7 +193,8 @@ sha384_buffer (const char *buffer, size_t len, void 
*resblock)
 }
 
 void
-sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
+sha512_process_bytes (void const *restrict buffer, size_t len,
+                      struct sha512_ctx *restrict ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -317,7 +318,8 @@ static u64 const sha512_round_constants[80] = {
    Most of this code comes from GnuPG's cipher/sha1.c.  */
 
 void
-sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
+sha512_process_block (void const *restrict buffer, size_t len,
+                      struct sha512_ctx *restrict ctx)
 {
   u64 const *words = buffer;
   u64 const *endp = words + len / sizeof (u64);
diff --git a/lib/sha512.h b/lib/sha512.h
index aedd9c8e21..6b9cf58da1 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -78,22 +78,24 @@ extern void sha384_init_ctx (struct sha512_ctx *ctx);
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 128!!! */
-extern void sha512_process_block (const void *buffer, size_t len,
-                                  struct sha512_ctx *ctx);
+extern void sha512_process_block (void const *restrict buffer, size_t len,
+                                  struct sha512_ctx *restrict ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 128.  */
-extern void sha512_process_bytes (const void *buffer, size_t len,
-                                  struct sha512_ctx *ctx);
+extern void sha512_process_bytes (void const *restrict buffer, size_t len,
+                                  struct sha512_ctx *restrict ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX
    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 *restrict resbuf);
-extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *restrict resbuf);
+extern void *sha512_finish_ctx (struct sha512_ctx *restrict ctx,
+                                void *restrict resbuf);
+extern void *sha384_finish_ctx (struct sha512_ctx *restrict ctx,
+                                void *restrict resbuf);
 
 
 /* Put result from CTX in first 64 (48) bytes following RESBUF.  The result is
@@ -102,9 +104,9 @@ extern void *sha384_finish_ctx (struct sha512_ctx *ctx, 
void *restrict 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,
+extern void *sha512_read_ctx (struct sha512_ctx const *restrict ctx,
                               void *restrict resbuf);
-extern void *sha384_read_ctx (const struct sha512_ctx *ctx,
+extern void *sha384_read_ctx (struct sha512_ctx const *restrict ctx,
                               void *restrict resbuf);
 
 
@@ -112,9 +114,9 @@ extern void *sha384_read_ctx (const struct sha512_ctx *ctx,
    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,
+extern void *sha512_buffer (char const *restrict buffer, size_t len,
                             void *restrict resblock);
-extern void *sha384_buffer (const char *buffer, size_t len,
+extern void *sha384_buffer (char const *restrict buffer, size_t len,
                             void *restrict resblock);
 
 # endif
@@ -125,8 +127,8 @@ extern void *sha384_buffer (const char *buffer, size_t len,
    The case that the last operation on STREAM was an 'ungetc' is not supported.
    The resulting message digest number will be written into the 64 (48) bytes
    beginning at RESBLOCK.  */
-extern int sha512_stream (FILE *stream, void *resblock);
-extern int sha384_stream (FILE *stream, void *resblock);
+extern int sha512_stream (FILE *restrict stream, void *restrict resblock);
+extern int sha384_stream (FILE *restrict stream, void *restrict resblock);
 
 
 # ifdef __cplusplus
diff --git a/lib/sm3-stream.c b/lib/sm3-stream.c
index a81958b465..0e730e3ccb 100644
--- a/lib/sm3-stream.c
+++ b/lib/sm3-stream.c
@@ -43,7 +43,7 @@
    resulting message digest number will be written into the 32 bytes
    beginning at RESBLOCK.  */
 int
-sm3_stream (FILE *stream, void *resblock)
+sm3_stream (FILE *restrict stream, void *restrict resblock)
 {
   char *buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
diff --git a/lib/sm3.c b/lib/sm3.c
index f5fa9df713..7fd365065b 100644
--- a/lib/sm3.c
+++ b/lib/sm3.c
@@ -91,7 +91,7 @@ set_uint32 (char *cp, uint32_t v)
 /* Put result from CTX in first 32 bytes following RESBUF.  The result
    must be in little endian byte order.  */
 void *
-sm3_read_ctx (const struct sm3_ctx *ctx, void *resbuf)
+sm3_read_ctx (struct sm3_ctx const *restrict ctx, void *restrict resbuf)
 {
   char *r = resbuf;
 
@@ -130,7 +130,7 @@ sm3_conclude_ctx (struct sm3_ctx *ctx)
 }
 
 void *
-sm3_finish_ctx (struct sm3_ctx *ctx, void *resbuf)
+sm3_finish_ctx (struct sm3_ctx *restrict ctx, void *restrict resbuf)
 {
   sm3_conclude_ctx (ctx);
   return sm3_read_ctx (ctx, resbuf);
@@ -141,7 +141,7 @@ sm3_finish_ctx (struct sm3_ctx *ctx, void *resbuf)
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-sm3_buffer (const char *buffer, size_t len, void *resblock)
+sm3_buffer (char const *restrict buffer, size_t len, void *restrict resblock)
 {
   struct sm3_ctx ctx;
 
@@ -156,7 +156,8 @@ sm3_buffer (const char *buffer, size_t len, void *resblock)
 }
 
 void
-sm3_process_bytes (const void *buffer, size_t len, struct sm3_ctx *ctx)
+sm3_process_bytes (void const *restrict buffer, size_t len,
+                   struct sm3_ctx *restrict ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -258,7 +259,8 @@ static const uint32_t sm3_round_constants[64] = {
    Most of this code comes from David Madore's sha256.c.  */
 
 void
-sm3_process_block (const void *buffer, size_t len, struct sm3_ctx *ctx)
+sm3_process_block (void const *restrict buffer, size_t len,
+                   struct sm3_ctx *restrict ctx)
 {
   const uint32_t *words = buffer;
   size_t nwords = len / sizeof (uint32_t);
diff --git a/lib/sm3.h b/lib/sm3.h
index 480021eed0..5891302cb0 100644
--- a/lib/sm3.h
+++ b/lib/sm3.h
@@ -83,32 +83,34 @@ extern void sm3_init_ctx (struct sm3_ctx *ctx);
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-extern void sm3_process_block (const void *buffer, size_t len,
-                               struct sm3_ctx *ctx);
+extern void sm3_process_block (void const *restrict buffer, size_t len,
+                               struct sm3_ctx *restrict ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void sm3_process_bytes (const void *buffer, size_t len,
-                               struct sm3_ctx *ctx);
+extern void sm3_process_bytes (void const *restrict buffer, size_t len,
+                               struct sm3_ctx *restrict ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX
    in first 32 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 *sm3_finish_ctx (struct sm3_ctx *ctx, void *restrict resbuf);
+extern void *sm3_finish_ctx (struct sm3_ctx *restrict ctx,
+                             void *restrict resbuf);
 
 /* Put result from CTX in first 32 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 *sm3_read_ctx (const struct sm3_ctx *ctx, void *restrict resbuf);
+extern void *sm3_read_ctx (struct sm3_ctx const *restrict ctx,
+                           void *restrict resbuf);
 
 /* Compute SM3 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 *sm3_buffer (const char *buffer, size_t len,
+extern void *sm3_buffer (char const *restrict buffer, size_t len,
                          void *restrict resblock);
 
 # endif
@@ -116,7 +118,7 @@ extern void *sm3_buffer (const char *buffer, size_t len,
 /* Compute SM3 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 32 bytes
    beginning at RESBLOCK.  */
-extern int sm3_stream (FILE *stream, void *resblock);
+extern int sm3_stream (FILE *restrict stream, void *restrict resblock);
 
 
 # ifdef __cplusplus
-- 
2.51.0


Reply via email to