]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Consistently use foo_func *f (rather than foo_func f) for declaring function pointer...
authorNiels Möller <nisse@lysator.liu.se>
Mon, 25 Jun 2012 20:35:51 +0000 (22:35 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 25 Jun 2012 20:35:51 +0000 (22:35 +0200)
23 files changed:
ChangeLog
bignum-next-prime.c
bignum-random-prime.c
bignum-random.c
bignum.h
cbc.c
cbc.h
ctr.c
ctr.h
dsa-keygen.c
dsa-sha1-sign.c
dsa-sha256-sign.c
dsa-sign.c
dsa.h
gcm.c
pkcs1-encrypt.c
pkcs1.h
rsa-blind.c
rsa-decrypt-tr.c
rsa-encrypt.c
rsa-keygen.c
rsa-pkcs1-sign-tr.c
rsa.h

index b77893f37379d6bfb8d14aef0ba7d69c3081944f..ad88ece9f0083c6e674f8546cb751dcb86ec1aa9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 2012-06-25  Niels Möller  <nisse@lysator.liu.se>
 
+       * bignum-next-prime.c (nettle_next_prime): Consistently use the
+       type nettle_random_func * (rather then just nettle_random_func)
+       when passing the function pointer as argument. Similar change for
+       nettle_progress_func. Should have been done for the 2.0 release,
+       but a few arguments were overlooked.
+       * bignum-random-prime.c (_nettle_generate_pocklington_prime)
+       (nettle_random_prime): Likewise.
+       * bignum-random.c (nettle_mpz_random_size, nettle_mpz_random):
+       Likewise.
+       * dsa-keygen.c (dsa_generate_keypair): Likewise.
+       * dsa-sha1-sign.c (dsa_sha1_sign_digest, dsa_sha1_sign): Likewise.
+       * dsa-sha256-sign.c (dsa_sha256_sign_digest, dsa_sha256_sign):
+       Likewise.
+       * dsa-sign.c (_dsa_sign): Likewise.
+       * pkcs1-encrypt.c (pkcs1_encrypt): Likewise.
+       * rsa-blind.c (_rsa_blind): Likewise.
+       * rsa-decrypt-tr.c (rsa_decrypt_tr): Likewise.
+       * rsa-encrypt.c (rsa_encrypt): Likewise.
+       * rsa-keygen.c (rsa_generate_keypair): Likewise.
+       * rsa-pkcs1-sign-tr.c (rsa_pkcs1_sign_tr): Likewise.
+
+       * cbc.c (cbc_encrypt, cbc_decrypt): Similarly, use the type
+       nettle_crypt_func * rather than just nettle_crypt_func.
+       * ctr.c (ctr_crypt): Likewise.
+       * gcm.c (gcm_set_key): Likewise.
+
        * testsuite/des-compat-test.c (test_main): Disable declarations of
        disabled functions and variables, to avoid warnings. No verbose
        output unless verbose flag is set.
index d3980a554be676c141f47fc7c60d4bc2bfd2582e..953f6b72f081d4bd6ab013182cb9da6abe6d09c3 100644 (file)
@@ -74,7 +74,7 @@ static const uint16_t primes[] = {
 /* NOTE: The mpz_nextprime in current GMP is unoptimized. */
 void
 nettle_next_prime(mpz_t p, mpz_t n, unsigned count, unsigned prime_limit,
-                 void *progress_ctx, nettle_progress_func progress)
+                 void *progress_ctx, nettle_progress_func *progress)
 {
   mpz_t tmp;
   TMP_DECL(moduli, unsigned, NUMBER_OF_PRIMES);
index e0454a88c3c14c0f143b57f177d253c8efaf2cc2..f172d6d85a1fcac3a4751feed484b1102932e4e4 100644 (file)
@@ -260,7 +260,7 @@ miller_rabin_pocklington(mpz_t n, mpz_t nm1, mpz_t nm1dq, mpz_t a)
 void
 _nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
                                    unsigned bits, int top_bits_set, 
-                                   void *ctx, nettle_random_func random, 
+                                   void *ctx, nettle_random_func *random, 
                                    const mpz_t p0,
                                    const mpz_t q,
                                    const mpz_t p0q)
@@ -345,8 +345,8 @@ _nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
    the variant in fips186-3). */
 void
 nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,
-                   void *random_ctx, nettle_random_func random,
-                   void *progress_ctx, nettle_progress_func progress)
+                   void *random_ctx, nettle_random_func *random,
+                   void *progress_ctx, nettle_progress_func *progress)
 {
   assert (bits >= 3);
   if (bits <= 10)
index 6b745d88bbae7be72e57af649b4773a252133aa2..d1174d9d036cf2b90097c187306c5b74144db029 100644 (file)
@@ -34,7 +34,7 @@
 
 void
 nettle_mpz_random_size(mpz_t x,
-                      void *ctx, nettle_random_func random,
+                      void *ctx, nettle_random_func *random,
                       unsigned bits)
 {
   unsigned length = (bits + 7) / 8;
@@ -52,7 +52,7 @@ nettle_mpz_random_size(mpz_t x,
 /* Returns a random number x, 0 <= x < n */
 void
 nettle_mpz_random(mpz_t x,
-                 void *ctx, nettle_random_func random,
+                 void *ctx, nettle_random_func *random,
                  const mpz_t n)
 {
   /* NOTE: This leaves some bias, which may be bad for DSA. A better
index d9e06e2ea60915d20c65352d79e57ec61bfba6c2..f1dad7e156cb958394e6e2bee07e0a183f8ac9cd 100644 (file)
--- a/bignum.h
+++ b/bignum.h
@@ -71,29 +71,29 @@ nettle_mpz_init_set_str_256_u(mpz_t x,
 /* Returns a uniformly distributed random number 0 <= x < 2^n */
 void
 nettle_mpz_random_size(mpz_t x,
-                      void *ctx, nettle_random_func random,
+                      void *ctx, nettle_random_func *random,
                       unsigned bits);
 
 /* Returns a number x, almost uniformly random in the range
  * 0 <= x < n. */
 void
 nettle_mpz_random(mpz_t x, 
-                 void *ctx, nettle_random_func random,
+                 void *ctx, nettle_random_func *random,
                  const mpz_t n);
 
 void
 nettle_next_prime(mpz_t p, mpz_t n, unsigned count, unsigned prime_limit,
-                 void *progress_ctx, nettle_progress_func progress);
+                 void *progress_ctx, nettle_progress_func *progress);
 
 void
 nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,
-                   void *ctx, nettle_random_func random,
-                   void *progress_ctx, nettle_progress_func progress);
+                   void *ctx, nettle_random_func *random,
+                   void *progress_ctx, nettle_progress_func *progress);
 
 void
 _nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
                                    unsigned bits, int top_bits_set, 
-                                   void *ctx, nettle_random_func random, 
+                                   void *ctx, nettle_random_func *random, 
                                    const mpz_t p0,
                                    const mpz_t q,
                                    const mpz_t p0q);
diff --git a/cbc.c b/cbc.c
index 6e09c9bd0099ff2f5f85d570bf5fda7bd9ac574f..4eb9a19b540b81912a2925012a24f07aa4836448 100644 (file)
--- a/cbc.c
+++ b/cbc.c
@@ -37,7 +37,7 @@
 #include "nettle-internal.h"
 
 void
-cbc_encrypt(void *ctx, nettle_crypt_func f,
+cbc_encrypt(void *ctx, nettle_crypt_func *f,
            unsigned block_size, uint8_t *iv,
            unsigned length, uint8_t *dst,
            const uint8_t *src)
@@ -56,7 +56,7 @@ cbc_encrypt(void *ctx, nettle_crypt_func f,
 #define CBC_BUFFER_LIMIT 512
 
 void
-cbc_decrypt(void *ctx, nettle_crypt_func f,
+cbc_decrypt(void *ctx, nettle_crypt_func *f,
            unsigned block_size, uint8_t *iv,
            unsigned length, uint8_t *dst,
            const uint8_t *src)
diff --git a/cbc.h b/cbc.h
index b100ab166a43df6c4432269f5f722a5c9f2d5937..8c1a7c03406ba54e9efb36eacd413adf233367c0 100644 (file)
--- a/cbc.h
+++ b/cbc.h
@@ -37,13 +37,13 @@ extern "C" {
 #define cbc_decrypt nettle_cbc_decrypt
 
 void
-cbc_encrypt(void *ctx, nettle_crypt_func f,
+cbc_encrypt(void *ctx, nettle_crypt_func *f,
            unsigned block_size, uint8_t *iv,
            unsigned length, uint8_t *dst,
            const uint8_t *src);
 
 void
-cbc_decrypt(void *ctx, nettle_crypt_func f,
+cbc_decrypt(void *ctx, nettle_crypt_func *f,
            unsigned block_size, uint8_t *iv,
            unsigned length, uint8_t *dst,
            const uint8_t *src);
diff --git a/ctr.c b/ctr.c
index 4d60eff7f9466b3ac6ffb73d5811c6cc1598e003..db13f7c5c567601fe177b3ecd8bfe61d69a7fe07 100644 (file)
--- a/ctr.c
+++ b/ctr.c
@@ -40,7 +40,7 @@
 #define NBLOCKS 4
 
 void
-ctr_crypt(void *ctx, nettle_crypt_func f,
+ctr_crypt(void *ctx, nettle_crypt_func *f,
          unsigned block_size, uint8_t *ctr,
          unsigned length, uint8_t *dst,
          const uint8_t *src)
diff --git a/ctr.h b/ctr.h
index ebd2a28f3337ff175cbdba2b408fdc164d79c962..3420abef38df09f9cb33a09c7a6333a9270b928e 100644 (file)
--- a/ctr.h
+++ b/ctr.h
@@ -37,7 +37,7 @@ extern "C" {
 #define ctr_crypt nettle_ctr_crypt
 
 void
-ctr_crypt(void *ctx, nettle_crypt_func f,
+ctr_crypt(void *ctx, nettle_crypt_func *f,
          unsigned block_size, uint8_t *ctr,
          unsigned length, uint8_t *dst,
          const uint8_t *src);
@@ -51,7 +51,7 @@ memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))
 #define CTR_CRYPT(self, f, length, dst, src)           \
 (0 ? ((f)(&(self)->ctx, 0, NULL, NULL))                        \
    : ctr_crypt((void *) &(self)->ctx,                  \
-               (nettle_crypt_func) (f),                        \
+               (nettle_crypt_func *) (f),              \
               sizeof((self)->ctr), (self)->ctr,        \
                (length), (dst), (src)))
 
index 757f175337c52848a52b6017af95806bbd7b3834..84cea545ae012330ffafe47e701c3aec0e430137 100644 (file)
@@ -42,8 +42,8 @@
 int
 dsa_generate_keypair(struct dsa_public_key *pub,
                     struct dsa_private_key *key,
-                    void *random_ctx, nettle_random_func random,
-                    void *progress_ctx, nettle_progress_func progress,
+                    void *random_ctx, nettle_random_func *random,
+                    void *progress_ctx, nettle_progress_func *progress,
                     unsigned p_bits, unsigned q_bits)
 {
   mpz_t p0, p0q, r;
index 264a89c11bf2852694b224091fbd0c0b2be83b2e..821702e8f6efc5b8f073e93000c3ef0f1434a6b2 100644 (file)
@@ -32,7 +32,7 @@
 int
 dsa_sha1_sign_digest(const struct dsa_public_key *pub,
                     const struct dsa_private_key *key,
-                    void *random_ctx, nettle_random_func random,
+                    void *random_ctx, nettle_random_func *random,
                     const uint8_t *digest,
                     struct dsa_signature *signature)
 {
@@ -44,7 +44,7 @@ dsa_sha1_sign_digest(const struct dsa_public_key *pub,
 int
 dsa_sha1_sign(const struct dsa_public_key *pub,
              const struct dsa_private_key *key,
-             void *random_ctx, nettle_random_func random,
+             void *random_ctx, nettle_random_func *random,
              struct sha1_ctx *hash,
              struct dsa_signature *signature)
 {
index f8569f9fb1d371eb2f24f35237a289569e6e17c2..020d146b8e3a32f177371a8718ac112a78a369fd 100644 (file)
@@ -32,7 +32,7 @@
 int
 dsa_sha256_sign_digest(const struct dsa_public_key *pub,
                       const struct dsa_private_key *key,
-                      void *random_ctx, nettle_random_func random,
+                      void *random_ctx, nettle_random_func *random,
                       const uint8_t *digest,
                       struct dsa_signature *signature)
 {
@@ -43,7 +43,7 @@ dsa_sha256_sign_digest(const struct dsa_public_key *pub,
 int
 dsa_sha256_sign(const struct dsa_public_key *pub,
                const struct dsa_private_key *key,
-               void *random_ctx, nettle_random_func random,
+               void *random_ctx, nettle_random_func *random,
                struct sha256_ctx *hash,
                struct dsa_signature *signature)
 {
index 8c7058ce25c71fc9c559dc808f88f66575402594..18eeca34aeecc3b128614f2de5855c5aabd06c03 100644 (file)
@@ -38,7 +38,7 @@
 int
 _dsa_sign(const struct dsa_public_key *pub,
          const struct dsa_private_key *key,
-         void *random_ctx, nettle_random_func random,
+         void *random_ctx, nettle_random_func *random,
          unsigned digest_size,
          const uint8_t *digest,
          struct dsa_signature *signature)
diff --git a/dsa.h b/dsa.h
index cb103d6344cc4ebc5ff80bf62593a92f06168921..7143d1ff68fac6ee23edb2fb2752eb7799415d14 100644 (file)
--- a/dsa.h
+++ b/dsa.h
@@ -32,9 +32,6 @@
 
 #include "sha.h"
 
-/* For nettle_random_func */
-#include "nettle-meta.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -152,14 +149,14 @@ dsa_signature_clear(struct dsa_signature *signature);
 int
 dsa_sha1_sign(const struct dsa_public_key *pub,
              const struct dsa_private_key *key,
-             void *random_ctx, nettle_random_func random,
+             void *random_ctx, nettle_random_func *random,
              struct sha1_ctx *hash,
              struct dsa_signature *signature);
 
 int
 dsa_sha256_sign(const struct dsa_public_key *pub,
                const struct dsa_private_key *key,
-               void *random_ctx, nettle_random_func random,
+               void *random_ctx, nettle_random_func *random,
                struct sha256_ctx *hash,
                struct dsa_signature *signature);
 
@@ -176,13 +173,13 @@ dsa_sha256_verify(const struct dsa_public_key *key,
 int
 dsa_sha1_sign_digest(const struct dsa_public_key *pub,
                     const struct dsa_private_key *key,
-                    void *random_ctx, nettle_random_func random,
+                    void *random_ctx, nettle_random_func *random,
                     const uint8_t *digest,
                     struct dsa_signature *signature);
 int
 dsa_sha256_sign_digest(const struct dsa_public_key *pub,
                       const struct dsa_private_key *key,
-                      void *random_ctx, nettle_random_func random,
+                      void *random_ctx, nettle_random_func *random,
                       const uint8_t *digest,
                       struct dsa_signature *signature);
 
@@ -202,9 +199,9 @@ int
 dsa_generate_keypair(struct dsa_public_key *pub,
                     struct dsa_private_key *key,
 
-                    void *random_ctx, nettle_random_func random,
+                    void *random_ctx, nettle_random_func *random,
 
-                    void *progress_ctx, nettle_progress_func progress,
+                    void *progress_ctx, nettle_progress_func *progress,
                     unsigned p_bits, unsigned q_bits);
 
 /* Keys in sexp form. */
@@ -277,7 +274,7 @@ dsa_openssl_private_key_from_der(struct dsa_public_key *pub,
 int
 _dsa_sign(const struct dsa_public_key *pub,
          const struct dsa_private_key *key,
-         void *random_ctx, nettle_random_func random,
+         void *random_ctx, nettle_random_func *random,
          unsigned digest_size,
          const uint8_t *digest,
          struct dsa_signature *signature);
diff --git a/gcm.c b/gcm.c
index 7b2e6057591993f25166ad16e87638426a62b7c7..7829aff0ea9644d0c038fb4554f7289b2dcc76bf 100644 (file)
--- a/gcm.c
+++ b/gcm.c
@@ -323,7 +323,7 @@ gcm_gf_mul (union gcm_block *x, const union gcm_block *table)
  */
 void
 gcm_set_key(struct gcm_key *key,
-           void *cipher, nettle_crypt_func f)
+           void *cipher, nettle_crypt_func *f)
 {
   /* Middle element if GCM_TABLE_BITS > 0, otherwise the first
      element */
index 10f4f9a307891d4c7dac8f619e62da511735493e..403bf69607881c20a7f6645161fe2a7582833530 100644 (file)
@@ -39,7 +39,7 @@
 int
 pkcs1_encrypt (unsigned key_size,
               /* For padding */
-              void *random_ctx, nettle_random_func random,
+              void *random_ctx, nettle_random_func *random,
               unsigned length, const uint8_t *message,
               mpz_t m)
 {
diff --git a/pkcs1.h b/pkcs1.h
index 27219554ce1535bee82274f7cee25d87d61bc90a..d6e60539cf89910b4d912a0a8f849123a013c3cf 100644 (file)
--- a/pkcs1.h
+++ b/pkcs1.h
@@ -62,7 +62,7 @@ pkcs1_signature_prefix(unsigned key_size,
 int
 pkcs1_encrypt (unsigned key_size,
               /* For padding */
-              void *random_ctx, nettle_random_func random,
+              void *random_ctx, nettle_random_func *random,
               unsigned length, const uint8_t *message,
               mpz_t m);
 
index eb5d0088806206c41af9520298a16dfa69ded6b6..96ed81ff91ba4cb5ee01b8acff5965c975c4c24d 100644 (file)
@@ -35,7 +35,7 @@
    returns the inverse (ri), for use by rsa_unblind. */
 void
 _rsa_blind (const struct rsa_public_key *pub,
-           void *random_ctx, nettle_random_func random,
+           void *random_ctx, nettle_random_func *random,
            mpz_t c, mpz_t ri)
 {
   mpz_t r;
index 1e21e985bf75bd46300d0f593aefa0ee94349c57..0ef5211220f1d2d3bd08f062ee5d23e2a7cc4842 100644 (file)
@@ -36,7 +36,7 @@
 int
 rsa_decrypt_tr(const struct rsa_public_key *pub,
               const struct rsa_private_key *key,
-              void *random_ctx, nettle_random_func random,
+              void *random_ctx, nettle_random_func *random,
               unsigned *length, uint8_t *message,
               const mpz_t gibberish)
 {
index 2e1df1d8d9ce1e54d951478687b2f4238d1509e4..877de7c976cc6a9dbebecdda6ab443413e29561a 100644 (file)
@@ -34,7 +34,7 @@
 int
 rsa_encrypt(const struct rsa_public_key *key,
            /* For padding */
-           void *random_ctx, nettle_random_func random,
+           void *random_ctx, nettle_random_func *random,
            unsigned length, const uint8_t *message,
            mpz_t gibberish)
 {
index b67aab85a01ed2248d616444806f57220cf11f08..8ca947f275eb1fb4573f13b90ae54063f2a5638e 100644 (file)
@@ -45,8 +45,8 @@
 int
 rsa_generate_keypair(struct rsa_public_key *pub,
                     struct rsa_private_key *key,
-                    void *random_ctx, nettle_random_func random,
-                    void *progress_ctx, nettle_progress_func progress,
+                    void *random_ctx, nettle_random_func *random,
+                    void *progress_ctx, nettle_progress_func *progress,
                     unsigned n_size,
                     unsigned e_size)
 {
index 672b902b0c8e671698c20c173cc1b7af49a76ba6..90c412c3e092d06b5c76450a493778bb47016f51 100644 (file)
@@ -34,7 +34,7 @@
 int
 rsa_pkcs1_sign_tr(const struct rsa_public_key *pub,
                  const struct rsa_private_key *key,
-                 void *random_ctx, nettle_random_func random,
+                 void *random_ctx, nettle_random_func *random,
                  unsigned length, const uint8_t *digest_info,
                  mpz_t s)
 {
diff --git a/rsa.h b/rsa.h
index 9857b67c21f933bcbe5edd45143c909c1cd095da..eaeba8a351f8aefd9c0aed8d8da2d6b0fba6b7bd 100644 (file)
--- a/rsa.h
+++ b/rsa.h
@@ -179,7 +179,7 @@ rsa_pkcs1_sign(const struct rsa_private_key *key,
 int
 rsa_pkcs1_sign_tr(const struct rsa_public_key *pub,
                  const struct rsa_private_key *key,
-                 void *random_ctx, nettle_random_func random,
+                 void *random_ctx, nettle_random_func *random,
                  unsigned length, const uint8_t *digest_info,
                  mpz_t s);
 int
@@ -406,7 +406,7 @@ _rsa_check_size(mpz_t n);
 
 void
 _rsa_blind (const struct rsa_public_key *pub,
-           void *random_ctx, nettle_random_func random,
+           void *random_ctx, nettle_random_func *random,
            mpz_t c, mpz_t ri);
 void
 _rsa_unblind (const struct rsa_public_key *pub, mpz_t c, const mpz_t ri);