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

Use size_t for bignums, rsa and dsa.

parent 64bb6b36
......@@ -52,11 +52,11 @@ rsa_public_key_clear(struct rsa_public_key *key)
/* Computes the size, in octets, of a the modulo. Returns 0 if the
* modulo is too small to be useful. */
unsigned
size_t
_rsa_check_size(mpz_t n)
{
/* Round upwards */
unsigned size = (mpz_sizeinbase(n, 2) + 7) / 8;
size_t size = (mpz_sizeinbase(n, 2) + 7) / 8;
if (size < RSA_MINIMUM_N_OCTETS)
return 0;
......
......@@ -95,7 +95,7 @@ struct rsa_public_key
{
/* Size of the modulo, in octets. This is also the size of all
* signatures that are created or verified with this key. */
unsigned size;
size_t size;
/* Modulo */
mpz_t n;
......@@ -106,7 +106,7 @@ struct rsa_public_key
struct rsa_private_key
{
unsigned size;
size_t size;
/* d is filled in by the key generation function; otherwise it's
* completely unused. */
......@@ -174,18 +174,18 @@ rsa_private_key_prepare(struct rsa_private_key *key);
/* PKCS#1 style signatures */
int
rsa_pkcs1_sign(const struct rsa_private_key *key,
unsigned length, const uint8_t *digest_info,
size_t 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,
unsigned length, const uint8_t *digest_info,
size_t length, const uint8_t *digest_info,
mpz_t s);
int
rsa_pkcs1_verify(const struct rsa_public_key *key,
unsigned length, const uint8_t *digest_info,
size_t length, const uint8_t *digest_info,
const mpz_t signature);
int
......@@ -281,7 +281,7 @@ int
rsa_encrypt(const struct rsa_public_key *key,
/* For padding */
void *random_ctx, nettle_random_func *random,
unsigned length, const uint8_t *cleartext,
size_t length, const uint8_t *cleartext,
mpz_t cipher);
/* Message must point to a buffer of size *LENGTH. KEY->size is enough
......@@ -291,7 +291,7 @@ rsa_encrypt(const struct rsa_public_key *key,
* didn't fit. */
int
rsa_decrypt(const struct rsa_private_key *key,
unsigned *length, uint8_t *cleartext,
size_t *length, uint8_t *cleartext,
const mpz_t ciphertext);
/* Timing-resistant version, using randomized RSA blinding. */
......@@ -299,7 +299,7 @@ int
rsa_decrypt_tr(const struct rsa_public_key *pub,
const struct rsa_private_key *key,
void *random_ctx, nettle_random_func *random,
unsigned *length, uint8_t *message,
size_t *length, uint8_t *message,
const mpz_t gibberish);
/* Compute x, the e:th root of m. Calling it with x == m is allowed. */
......@@ -364,7 +364,7 @@ int
rsa_keypair_from_sexp(struct rsa_public_key *pub,
struct rsa_private_key *priv,
unsigned limit,
unsigned length, const uint8_t *expr);
size_t length, const uint8_t *expr);
/* Keys in PKCS#1 format. */
......@@ -402,7 +402,7 @@ _rsa_verify(const struct rsa_public_key *key,
const mpz_t m,
const mpz_t s);
unsigned
size_t
_rsa_check_size(mpz_t n);
void
......
......@@ -78,7 +78,7 @@ int
dsa_sha1_keypair_from_sexp(struct dsa_public_key *pub,
struct dsa_private_key *priv,
unsigned p_max_bits,
unsigned length, const uint8_t *expr)
size_t length, const uint8_t *expr)
{
struct sexp_iterator i;
......@@ -92,7 +92,7 @@ int
dsa_sha256_keypair_from_sexp(struct dsa_public_key *pub,
struct dsa_private_key *priv,
unsigned p_max_bits,
unsigned length, const uint8_t *expr)
size_t length, const uint8_t *expr)
{
struct sexp_iterator i;
......
......@@ -89,7 +89,7 @@ int
rsa_keypair_from_sexp(struct rsa_public_key *pub,
struct rsa_private_key *priv,
unsigned limit,
unsigned length, const uint8_t *expr)
size_t length, const uint8_t *expr)
{
struct sexp_iterator i;
static const uint8_t * const names[3]
......
......@@ -12,10 +12,10 @@ test_main(void)
/* FIXME: How is this spelled? */
const uint8_t *msg = "Squemish ossifrage";
unsigned msg_length;
size_t msg_length;
uint8_t *decrypted;
unsigned decrypted_length;
size_t decrypted_length;
uint8_t after;
mpz_t gibberish;
......@@ -30,7 +30,7 @@ test_main(void)
msg_length = strlen(msg);
if (verbose)
fprintf(stderr, "msg: `%s', length = %d\n", msg, msg_length);
fprintf(stderr, "msg: `%s', length = %d\n", msg, (int) msg_length);
ASSERT(rsa_encrypt(&pub,
&lfib, (nettle_random_func *) knuth_lfib_random,
......
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