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.
/* 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);
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)
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)
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;
/* 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
/* 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);
#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)
#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)
#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);
#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)
#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);
#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)))
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;
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_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_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(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)
{
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)
#include "sha.h"
-/* For nettle_random_func */
-#include "nettle-meta.h"
-
#ifdef __cplusplus
extern "C" {
#endif
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);
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);
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. */
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);
*/
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 */
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)
{
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);
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;
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)
{
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)
{
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)
{
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
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
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);