diff options
author | Niels Möller <nisse@lysator.liu.se> | 2004-01-08 13:37:13 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2004-01-08 13:37:13 +0100 |
commit | 21ee1904b5c46f314b862eea33d3b86fcf6c7c88 (patch) | |
tree | 87460c8b18c74f6b20f94bac8e3cc1b378a6215f /rsa-encrypt.c | |
parent | dcd5b982b7323a3834bbf43019dd8b30df7e71e4 (diff) | |
download | nettle-21ee1904b5c46f314b862eea33d3b86fcf6c7c88.tar.gz |
(TMP_DECL, TMP_ALLOC): New macros. When alloca is unavailable, they
work by allocating a fix amount of stack and imposing a hard limit on
what can be allocated. Updated all users of alloca.
Rev: src/nettle/bignum-random.c:1.4
Rev: src/nettle/cbc.c:1.8
Rev: src/nettle/dsa-keygen.c:1.7
Rev: src/nettle/hmac.c:1.6
Rev: src/nettle/pkcs1-rsa-md5.c:1.3
Rev: src/nettle/pkcs1-rsa-sha1.c:1.3
Rev: src/nettle/rsa-decrypt.c:1.5
Rev: src/nettle/rsa-encrypt.c:1.8
Rev: src/nettle/sexp.c:1.15
Diffstat (limited to 'rsa-encrypt.c')
-rw-r--r-- | rsa-encrypt.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/rsa-encrypt.c b/rsa-encrypt.c index ecc6760b..fab5f82b 100644 --- a/rsa-encrypt.c +++ b/rsa-encrypt.c @@ -36,6 +36,7 @@ #include "rsa.h" #include "bignum.h" +#include "nettle-internal.h" int rsa_encrypt(const struct rsa_public_key *key, @@ -44,7 +45,7 @@ rsa_encrypt(const struct rsa_public_key *key, unsigned length, const uint8_t *message, mpz_t gibbberish) { - uint8_t *em; + TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8); unsigned padding; unsigned i; @@ -64,7 +65,7 @@ rsa_encrypt(const struct rsa_public_key *key, padding = key->size - length - 3; assert(padding >= 8); - em = alloca(key->size - 1); + TMP_ALLOC(em, key->size - 1); em[0] = 2; random(random_ctx, padding, em + 1); |