]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
crypto: add ‘restrict’ to .h files
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 Feb 2026 23:08:59 +0000 (15:08 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 23 Feb 2026 00:18:31 +0000 (16:18 -0800)
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.

42 files changed:
ChangeLog
lib/af_alg.c
lib/af_alg.h
lib/arcfour.c
lib/arcfour.h
lib/arctwo.c
lib/arctwo.h
lib/des.c
lib/des.h
lib/gc-gnulib.c
lib/gc-libgcrypt.c
lib/gc-pbkdf2-sha1.c
lib/gc-pbkdf2.c
lib/gc.h
lib/gl_openssl.h
lib/hmac.h
lib/md2-stream.c
lib/md2.c
lib/md2.h
lib/md4-stream.c
lib/md4.c
lib/md4.h
lib/md5.h
lib/rijndael-alg-fst.c
lib/rijndael-alg-fst.h
lib/rijndael-api-fst.c
lib/rijndael-api-fst.h
lib/sha1-stream.c
lib/sha1.c
lib/sha1.h
lib/sha256-stream.c
lib/sha256.c
lib/sha256.h
lib/sha3-stream.c
lib/sha3.c
lib/sha3.h
lib/sha512-stream.c
lib/sha512.c
lib/sha512.h
lib/sm3-stream.c
lib/sm3.c
lib/sm3.h

index 9144f8a0c2eb5a8fc02a40074e9fd37052f57c56..73b0c46649a544c4ba0f4a4f536f0ff6824d708e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,55 @@
 2026-02-22  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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
index 91f3df15f4e69537268a1ff0112d8fdbeed770d4..ff21f0f00a605892f4c47ee5e11a14e1a1ce5732 100644 (file)
@@ -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)
index 1321970f8ee0d1035721eca3a317f2f5044f51f7..6272d1ecbbb17e4a3c91974762b926d0034347f3 100644 (file)
@@ -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;
 }
index c8cfe1ec9c198a21a775fdf5c835142b0f5fc310..5a57243db40e6baeba959ff220544dcd8948d6b5 100644 (file)
@@ -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;
 
index a1c11784284e69bc23d2ac2973e9dc5dbaadae32..e00fc3dbacf0145978acd737d57525250e43121b 100644 (file)
@@ -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
index 596e8092fdcedbece4c2bbd38ac9f09b348d85b3..3b3d075eb73342acc388802e49bbc2a363f476c9 100644 (file)
@@ -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;
index 4923f15af88f86f54b4d7f4afb582f038b4354ed..7ff02561f822eae9453932fc856c1907b8600215 100644 (file)
@@ -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);
 
 
index 0dab651c69c7474959a691d55d9d88bd15927959..d8f442b62cd84a6d9c365dcb14bd7d7d2effd3cd 100644 (file)
--- 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;
index c7fa99a9c16325806fa25b8e21807e948db0a86f..5bea42564e0ec502b6a08503d6e87d8c9920867d 100644 (file)
--- 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)
index 9c5d093aaaa6253d0228207402aab7ce325f0065..9fc830fad84950769674c33fd73e761c05453574 100644 (file)
@@ -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;
index c325633d890cc82f89177c3e14fbbf62295a7fb5..63bbcd53666230c68fe60f13ccf1b5aedab6c3b0 100644 (file)
@@ -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);
index 91dfb35678d2f3f35bd34392167a7e0889e12e65..1090811f0dd0f1304df501a7eee79a306b287694 100644 (file)
 #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);
 }
index 2bb9d8fda4e39c015b1caa0c27e5cd260345d4b2..eb97157c243e3f554d363b9ba4af942e0b9762cd 100644 (file)
 #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;
index 612cef8f9f9e1a633e855d2ea8fd3b2708e8f6e0..d88654be726bc7abf9d5fec13adad47259131b4f 100644 (file)
--- 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);
 
 /*
index 06fd8f66f9b400755359cd0241c7689fff8446a3..daec994f607e0b4d133352fd5b5d9537ef3c074c 100644 (file)
@@ -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;
index e542c3d4244c36cf59498f7c141b0a1829cede1b..fb6e06593f368d0f5b52ad7b8137de0ea4cec5ba 100644 (file)
@@ -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
index bbdd6e62b25c5df540a525e140dca055245fd5d8..cc6ddf8a27aacad8e551a3642f207bf9edc585ae 100644 (file)
@@ -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)
index 873c349005047a46835dc5c3273941764976cc44..ea9a1f15e43e347e9dfedc59162eb8dfe51b7d03 100644 (file)
--- 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);
 }
index 773da7ed56f102b76de83eefac2cb3a424055c37..83f5acc3647c64e6b43e0f964940718ad5587516 100644 (file)
--- 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
index 9b3daef2f5f98b42fce863b1c9d90bda4d1f1da7..602dffa2a4397f61e0ff48513863f78d50883eee 100644 (file)
@@ -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)
index 9b24b2017c0f9a1417ad84278422156a97cb6b4f..fe34886140756c20db3e7dcd2ad15676ff55047b 100644 (file)
--- 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);
index e86e008c7a4d3fb5d0dc0d56c1e0da076bc12d2c..4aa7d509bc8433e764e00fa44ca01da42332cfd2 100644 (file)
--- 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
index 16c6684b61b933158a10072761e20235fd161aa5..5d93b10baa63894b91ed717a8fb7e1fa70635c9e 100644 (file)
--- 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
index 778641f0eb878a37a194ab782583394541433954..7562892737374866c7431b961117ad3865e9c533 100644 (file)
@@ -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;
 
index 1c5a2c67e8c4be29afbf36fef5c23c26cd7039c5..cb48d9becaf7f98de5b4441ad0ffa0e5d6cab439 100644 (file)
@@ -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
index 9b869e1da30ad4ce0c1e822613f6d4b460f38595..8fb87a1e465a735c0e7ec72de05441f0c3292485 100644 (file)
@@ -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)
     {
index cb70006a7105f678b28d9f370f83841a02c4ba1c..85af72e44fc15ef4e1f3a8782d97f916dc0c5751 100644 (file)
@@ -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);
 
 
index 210eaa049de62b5ede2280639883c31ef5074f73..b11464bc10753f6bc828e188625e1a4c8463f7d6 100644 (file)
@@ -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))
     {
index f41bda875dbda81c8089cdb08635bf1f861d1627..bb7aa2af29346be204233be3361ce0dff4995f24 100644 (file)
@@ -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);
index a267d46ab4cbf83b3ccd401f347116f9501eaabe..444902cb28e181e7f4cd2f16da20d418f77091fb 100644 (file)
@@ -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
index 011b36e2a83172a5106e4c778f377f77c44a39b9..66277664da08b69bdbc7190b5584dd7eee8cfec0 100644 (file)
    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);
index bada2d07171700102f15297b6b5ba480aada6f48..115b288e467e2a31806f036cefec3f8659389ca3 100644 (file)
@@ -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);
index db80ea5e3570afdfbe1fa450ec4e17336417d763..867befdd5d38ac3749842c0ded22faa6644a0906 100644 (file)
@@ -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
index b50e40a103af4a2c040a9fcafe2e2ec82659eb49..a4d6507bba792cfd6995a79f28e319cda00d81d0 100644 (file)
@@ -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);
index dec3b94b9a41c935cfc692ce7266000e901695d2..c839f9148a85ddeb61de05c98d17eb6b6e6ccda6 100644 (file)
@@ -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);
 }
index 65d4226ac3ff99fa423e05ce3ddb12bb64fef9f1..a44922a084372d3d41d5a206984fa967f335f557 100644 (file)
@@ -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
 }
index 75ccd349e04c70e0a43ed739ac13e67dd0307253..a5371b4991f1b26ab2495f26c0b4ab1dbea74344 100644 (file)
    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);
index a8c6484c2eda3522afe5ef02173225cf9449ee0f..4a213f8accc54ef82e458985a023cc4dfb4d6b9a 100644 (file)
@@ -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);
index aedd9c8e210f9c4554058385fd76925c090a5b65..6b9cf58da11c20c5b51ca4a0407dfa8af3dd5895 100644 (file)
@@ -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
index a81958b465537a1a6a80f31450a2790e3b8bfcbc..0e730e3ccba7c147990f982db3eed68d92d9bbbe 100644 (file)
@@ -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)
index f5fa9df713294a53c5db9eda84f7a0c8ba640e4a..7fd365065b6ea052d5bdb35de4ae99de64d657ae 100644 (file)
--- 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);
index 480021eed07271f67826719533100c454c107707..5891302cb0102ae5115a82236ca7cd6c137768fb 100644 (file)
--- 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