Commit ba98962d authored by Niels Möller's avatar Niels Möller
Browse files

Consistently use foo_func *f (rather than foo_func f) for declaring function pointer arguments.

parent 0cc9526c
2012-06-25 Niels Möller <nisse@lysator.liu.se> 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 * testsuite/des-compat-test.c (test_main): Disable declarations of
disabled functions and variables, to avoid warnings. No verbose disabled functions and variables, to avoid warnings. No verbose
output unless verbose flag is set. output unless verbose flag is set.
......
...@@ -74,7 +74,7 @@ static const uint16_t primes[] = { ...@@ -74,7 +74,7 @@ static const uint16_t primes[] = {
/* NOTE: The mpz_nextprime in current GMP is unoptimized. */ /* NOTE: The mpz_nextprime in current GMP is unoptimized. */
void void
nettle_next_prime(mpz_t p, mpz_t n, unsigned count, unsigned prime_limit, 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; mpz_t tmp;
TMP_DECL(moduli, unsigned, NUMBER_OF_PRIMES); TMP_DECL(moduli, unsigned, NUMBER_OF_PRIMES);
......
...@@ -260,7 +260,7 @@ miller_rabin_pocklington(mpz_t n, mpz_t nm1, mpz_t nm1dq, mpz_t a) ...@@ -260,7 +260,7 @@ miller_rabin_pocklington(mpz_t n, mpz_t nm1, mpz_t nm1dq, mpz_t a)
void void
_nettle_generate_pocklington_prime (mpz_t p, mpz_t r, _nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
unsigned bits, int top_bits_set, 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 p0,
const mpz_t q, const mpz_t q,
const mpz_t p0q) const mpz_t p0q)
...@@ -345,8 +345,8 @@ _nettle_generate_pocklington_prime (mpz_t p, mpz_t r, ...@@ -345,8 +345,8 @@ _nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
the variant in fips186-3). */ the variant in fips186-3). */
void void
nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set, nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,
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)
{ {
assert (bits >= 3); assert (bits >= 3);
if (bits <= 10) if (bits <= 10)
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
void void
nettle_mpz_random_size(mpz_t x, nettle_mpz_random_size(mpz_t x,
void *ctx, nettle_random_func random, void *ctx, nettle_random_func *random,
unsigned bits) unsigned bits)
{ {
unsigned length = (bits + 7) / 8; unsigned length = (bits + 7) / 8;
...@@ -52,7 +52,7 @@ nettle_mpz_random_size(mpz_t x, ...@@ -52,7 +52,7 @@ nettle_mpz_random_size(mpz_t x,
/* Returns a random number x, 0 <= x < n */ /* Returns a random number x, 0 <= x < n */
void void
nettle_mpz_random(mpz_t x, nettle_mpz_random(mpz_t x,
void *ctx, nettle_random_func random, void *ctx, nettle_random_func *random,
const mpz_t n) const mpz_t n)
{ {
/* NOTE: This leaves some bias, which may be bad for DSA. A better /* NOTE: This leaves some bias, which may be bad for DSA. A better
......
...@@ -71,29 +71,29 @@ nettle_mpz_init_set_str_256_u(mpz_t x, ...@@ -71,29 +71,29 @@ nettle_mpz_init_set_str_256_u(mpz_t x,
/* Returns a uniformly distributed random number 0 <= x < 2^n */ /* Returns a uniformly distributed random number 0 <= x < 2^n */
void void
nettle_mpz_random_size(mpz_t x, nettle_mpz_random_size(mpz_t x,
void *ctx, nettle_random_func random, void *ctx, nettle_random_func *random,
unsigned bits); unsigned bits);
/* Returns a number x, almost uniformly random in the range /* Returns a number x, almost uniformly random in the range
* 0 <= x < n. */ * 0 <= x < n. */
void void
nettle_mpz_random(mpz_t x, nettle_mpz_random(mpz_t x,
void *ctx, nettle_random_func random, void *ctx, nettle_random_func *random,
const mpz_t n); const mpz_t n);
void void
nettle_next_prime(mpz_t p, mpz_t n, unsigned count, unsigned prime_limit, 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 void
nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set, nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,
void *ctx, nettle_random_func random, void *ctx, nettle_random_func *random,
void *progress_ctx, nettle_progress_func progress); void *progress_ctx, nettle_progress_func *progress);
void void
_nettle_generate_pocklington_prime (mpz_t p, mpz_t r, _nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
unsigned bits, int top_bits_set, 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 p0,
const mpz_t q, const mpz_t q,
const mpz_t p0q); const mpz_t p0q);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "nettle-internal.h" #include "nettle-internal.h"
void void
cbc_encrypt(void *ctx, nettle_crypt_func f, cbc_encrypt(void *ctx, nettle_crypt_func *f,
unsigned block_size, uint8_t *iv, unsigned block_size, uint8_t *iv,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src) const uint8_t *src)
...@@ -56,7 +56,7 @@ cbc_encrypt(void *ctx, nettle_crypt_func f, ...@@ -56,7 +56,7 @@ cbc_encrypt(void *ctx, nettle_crypt_func f,
#define CBC_BUFFER_LIMIT 512 #define CBC_BUFFER_LIMIT 512
void void
cbc_decrypt(void *ctx, nettle_crypt_func f, cbc_decrypt(void *ctx, nettle_crypt_func *f,
unsigned block_size, uint8_t *iv, unsigned block_size, uint8_t *iv,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src) const uint8_t *src)
......
...@@ -37,13 +37,13 @@ extern "C" { ...@@ -37,13 +37,13 @@ extern "C" {
#define cbc_decrypt nettle_cbc_decrypt #define cbc_decrypt nettle_cbc_decrypt
void void
cbc_encrypt(void *ctx, nettle_crypt_func f, cbc_encrypt(void *ctx, nettle_crypt_func *f,
unsigned block_size, uint8_t *iv, unsigned block_size, uint8_t *iv,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
void void
cbc_decrypt(void *ctx, nettle_crypt_func f, cbc_decrypt(void *ctx, nettle_crypt_func *f,
unsigned block_size, uint8_t *iv, unsigned block_size, uint8_t *iv,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#define NBLOCKS 4 #define NBLOCKS 4
void void
ctr_crypt(void *ctx, nettle_crypt_func f, ctr_crypt(void *ctx, nettle_crypt_func *f,
unsigned block_size, uint8_t *ctr, unsigned block_size, uint8_t *ctr,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src) const uint8_t *src)
......
...@@ -37,7 +37,7 @@ extern "C" { ...@@ -37,7 +37,7 @@ extern "C" {
#define ctr_crypt nettle_ctr_crypt #define ctr_crypt nettle_ctr_crypt
void void
ctr_crypt(void *ctx, nettle_crypt_func f, ctr_crypt(void *ctx, nettle_crypt_func *f,
unsigned block_size, uint8_t *ctr, unsigned block_size, uint8_t *ctr,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
...@@ -51,7 +51,7 @@ memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr)) ...@@ -51,7 +51,7 @@ memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))
#define CTR_CRYPT(self, f, length, dst, src) \ #define CTR_CRYPT(self, f, length, dst, src) \
(0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \ (0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \
: ctr_crypt((void *) &(self)->ctx, \ : ctr_crypt((void *) &(self)->ctx, \
(nettle_crypt_func) (f), \ (nettle_crypt_func *) (f), \
sizeof((self)->ctr), (self)->ctr, \ sizeof((self)->ctr), (self)->ctr, \
(length), (dst), (src))) (length), (dst), (src)))
......
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
int int
dsa_generate_keypair(struct dsa_public_key *pub, dsa_generate_keypair(struct dsa_public_key *pub,
struct dsa_private_key *key, 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) unsigned p_bits, unsigned q_bits)
{ {
mpz_t p0, p0q, r; mpz_t p0, p0q, r;
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
int int
dsa_sha1_sign_digest(const struct dsa_public_key *pub, dsa_sha1_sign_digest(const struct dsa_public_key *pub,
const struct dsa_private_key *key, const struct dsa_private_key *key,
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
const uint8_t *digest, const uint8_t *digest,
struct dsa_signature *signature) struct dsa_signature *signature)
{ {
...@@ -44,7 +44,7 @@ dsa_sha1_sign_digest(const struct dsa_public_key *pub, ...@@ -44,7 +44,7 @@ dsa_sha1_sign_digest(const struct dsa_public_key *pub,
int int
dsa_sha1_sign(const struct dsa_public_key *pub, dsa_sha1_sign(const struct dsa_public_key *pub,
const struct dsa_private_key *key, 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 sha1_ctx *hash,
struct dsa_signature *signature) struct dsa_signature *signature)
{ {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
int int
dsa_sha256_sign_digest(const struct dsa_public_key *pub, dsa_sha256_sign_digest(const struct dsa_public_key *pub,
const struct dsa_private_key *key, const struct dsa_private_key *key,
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
const uint8_t *digest, const uint8_t *digest,
struct dsa_signature *signature) struct dsa_signature *signature)
{ {
...@@ -43,7 +43,7 @@ dsa_sha256_sign_digest(const struct dsa_public_key *pub, ...@@ -43,7 +43,7 @@ dsa_sha256_sign_digest(const struct dsa_public_key *pub,
int int
dsa_sha256_sign(const struct dsa_public_key *pub, dsa_sha256_sign(const struct dsa_public_key *pub,
const struct dsa_private_key *key, 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 sha256_ctx *hash,
struct dsa_signature *signature) struct dsa_signature *signature)
{ {
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
int int
_dsa_sign(const struct dsa_public_key *pub, _dsa_sign(const struct dsa_public_key *pub,
const struct dsa_private_key *key, const struct dsa_private_key *key,
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
unsigned digest_size, unsigned digest_size,
const uint8_t *digest, const uint8_t *digest,
struct dsa_signature *signature) struct dsa_signature *signature)
......
...@@ -32,9 +32,6 @@ ...@@ -32,9 +32,6 @@
#include "sha.h" #include "sha.h"
/* For nettle_random_func */
#include "nettle-meta.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -152,14 +149,14 @@ dsa_signature_clear(struct dsa_signature *signature); ...@@ -152,14 +149,14 @@ dsa_signature_clear(struct dsa_signature *signature);
int int
dsa_sha1_sign(const struct dsa_public_key *pub, dsa_sha1_sign(const struct dsa_public_key *pub,
const struct dsa_private_key *key, 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 sha1_ctx *hash,
struct dsa_signature *signature); struct dsa_signature *signature);
int int
dsa_sha256_sign(const struct dsa_public_key *pub, dsa_sha256_sign(const struct dsa_public_key *pub,
const struct dsa_private_key *key, 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 sha256_ctx *hash,
struct dsa_signature *signature); struct dsa_signature *signature);
...@@ -176,13 +173,13 @@ dsa_sha256_verify(const struct dsa_public_key *key, ...@@ -176,13 +173,13 @@ dsa_sha256_verify(const struct dsa_public_key *key,
int int
dsa_sha1_sign_digest(const struct dsa_public_key *pub, dsa_sha1_sign_digest(const struct dsa_public_key *pub,
const struct dsa_private_key *key, const struct dsa_private_key *key,
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
const uint8_t *digest, const uint8_t *digest,
struct dsa_signature *signature); struct dsa_signature *signature);
int int
dsa_sha256_sign_digest(const struct dsa_public_key *pub, dsa_sha256_sign_digest(const struct dsa_public_key *pub,
const struct dsa_private_key *key, const struct dsa_private_key *key,
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
const uint8_t *digest, const uint8_t *digest,
struct dsa_signature *signature); struct dsa_signature *signature);
...@@ -202,9 +199,9 @@ int ...@@ -202,9 +199,9 @@ int
dsa_generate_keypair(struct dsa_public_key *pub, dsa_generate_keypair(struct dsa_public_key *pub,
struct dsa_private_key *key, 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); unsigned p_bits, unsigned q_bits);
/* Keys in sexp form. */ /* Keys in sexp form. */
...@@ -277,7 +274,7 @@ dsa_openssl_private_key_from_der(struct dsa_public_key *pub, ...@@ -277,7 +274,7 @@ dsa_openssl_private_key_from_der(struct dsa_public_key *pub,
int int
_dsa_sign(const struct dsa_public_key *pub, _dsa_sign(const struct dsa_public_key *pub,
const struct dsa_private_key *key, const struct dsa_private_key *key,
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
unsigned digest_size, unsigned digest_size,
const uint8_t *digest, const uint8_t *digest,
struct dsa_signature *signature); struct dsa_signature *signature);
......
...@@ -323,7 +323,7 @@ gcm_gf_mul (union gcm_block *x, const union gcm_block *table) ...@@ -323,7 +323,7 @@ gcm_gf_mul (union gcm_block *x, const union gcm_block *table)
*/ */
void void
gcm_set_key(struct gcm_key *key, 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 /* Middle element if GCM_TABLE_BITS > 0, otherwise the first
element */ element */
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
int int
pkcs1_encrypt (unsigned key_size, pkcs1_encrypt (unsigned key_size,
/* For padding */ /* For padding */
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
unsigned length, const uint8_t *message, unsigned length, const uint8_t *message,
mpz_t m) mpz_t m)
{ {
......
...@@ -62,7 +62,7 @@ pkcs1_signature_prefix(unsigned key_size, ...@@ -62,7 +62,7 @@ pkcs1_signature_prefix(unsigned key_size,
int int
pkcs1_encrypt (unsigned key_size, pkcs1_encrypt (unsigned key_size,
/* For padding */ /* For padding */
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
unsigned length, const uint8_t *message, unsigned length, const uint8_t *message,
mpz_t m); mpz_t m);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
returns the inverse (ri), for use by rsa_unblind. */ returns the inverse (ri), for use by rsa_unblind. */
void void
_rsa_blind (const struct rsa_public_key *pub, _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 c, mpz_t ri)
{ {
mpz_t r; mpz_t r;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
int int
rsa_decrypt_tr(const struct rsa_public_key *pub, rsa_decrypt_tr(const struct rsa_public_key *pub,
const struct rsa_private_key *key, 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, unsigned *length, uint8_t *message,
const mpz_t gibberish) const mpz_t gibberish)
{ {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
int int
rsa_encrypt(const struct rsa_public_key *key, rsa_encrypt(const struct rsa_public_key *key,
/* For padding */ /* For padding */
void *random_ctx, nettle_random_func random, void *random_ctx, nettle_random_func *random,
unsigned length, const uint8_t *message, unsigned length, const uint8_t *message,
mpz_t gibberish) mpz_t gibberish)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment