Commit 77b0bf6a authored by Niels Möller's avatar Niels Möller

New constant NETTLE_MAX_BIGNUM_SIZE.

parent 8c4130e4
2012-04-23 Niels Möller <nisse@lysator.liu.se>
* nettle-internal.h (NETTLE_MAX_BIGNUM_SIZE): New constant. Based
on NETTLE_MAX_BIGNUM_BITS, rounded upwards. Replaced all uses of
NETTLE_MAX_BIGNUM_BITS.
2012-04-19 Niels Möller <nisse@lysator.liu.se>
* list-obj-sizes.awk: Use decimal rather than hexadecimal output.
......
......@@ -38,7 +38,7 @@ nettle_mpz_random_size(mpz_t x,
unsigned bits)
{
unsigned length = (bits + 7) / 8;
TMP_DECL(data, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(data, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(data, length);
random(ctx, length, data);
......
......@@ -45,6 +45,7 @@ do { if (size > (sizeof(name) / sizeof(name[0]))) abort(); } while (0)
/* Arbitrary limits which apply to systems that don't have alloca */
#define NETTLE_MAX_BIGNUM_BITS 10000
#define NETTLE_MAX_BIGNUM_SIZE ((NETTLE_MAX_BIGNUM_BITS + 7)/8)
#define NETTLE_MAX_HASH_BLOCK_SIZE 128
#define NETTLE_MAX_HASH_DIGEST_SIZE 64
#define NETTLE_MAX_SEXP_ASSOC 17
......
......@@ -38,11 +38,11 @@ pkcs1_decrypt (unsigned key_size,
const mpz_t m,
unsigned *length, uint8_t *message)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
uint8_t *terminator;
unsigned padding;
unsigned message_length;
TMP_ALLOC(em, key_size);
nettle_mpz_get_str_256(key_size, em, m);
......
......@@ -64,7 +64,7 @@ md5_prefix[] =
int
pkcs1_rsa_md5_encode(mpz_t m, unsigned size, struct md5_ctx *hash)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......@@ -83,7 +83,7 @@ pkcs1_rsa_md5_encode(mpz_t m, unsigned size, struct md5_ctx *hash)
int
pkcs1_rsa_md5_encode_digest(mpz_t m, unsigned size, const uint8_t *digest)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......
......@@ -64,7 +64,7 @@ sha1_prefix[] =
int
pkcs1_rsa_sha1_encode(mpz_t m, unsigned size, struct sha1_ctx *hash)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......@@ -83,7 +83,7 @@ pkcs1_rsa_sha1_encode(mpz_t m, unsigned size, struct sha1_ctx *hash)
int
pkcs1_rsa_sha1_encode_digest(mpz_t m, unsigned size, const uint8_t *digest)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......
......@@ -62,7 +62,7 @@ sha256_prefix[] =
int
pkcs1_rsa_sha256_encode(mpz_t m, unsigned size, struct sha256_ctx *hash)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......@@ -81,7 +81,7 @@ pkcs1_rsa_sha256_encode(mpz_t m, unsigned size, struct sha256_ctx *hash)
int
pkcs1_rsa_sha256_encode_digest(mpz_t m, unsigned size, const uint8_t *digest)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......
......@@ -62,7 +62,7 @@ sha512_prefix[] =
int
pkcs1_rsa_sha512_encode(mpz_t m, unsigned size, struct sha512_ctx *hash)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......@@ -82,7 +82,7 @@ pkcs1_rsa_sha512_encode(mpz_t m, unsigned size, struct sha512_ctx *hash)
int
pkcs1_rsa_sha512_encode_digest(mpz_t m, unsigned size, const uint8_t *digest)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
TMP_ALLOC(em, size);
if (pkcs1_signature_prefix(size, em,
......
......@@ -43,7 +43,7 @@ rsa_encrypt(const struct rsa_public_key *key,
unsigned length, const uint8_t *message,
mpz_t gibbberish)
{
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
unsigned padding;
unsigned i;
......
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