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

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>
* 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.
......
......@@ -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);
......
......@@ -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)
......
......@@ -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
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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)
......
......@@ -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)))
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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)
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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);
......
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