summaryrefslogtreecommitdiff
path: root/pkcs1-rsa-md5.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2004-01-08 13:37:13 +0100
committerNiels Möller <nisse@lysator.liu.se>2004-01-08 13:37:13 +0100
commit21ee1904b5c46f314b862eea33d3b86fcf6c7c88 (patch)
tree87460c8b18c74f6b20f94bac8e3cc1b378a6215f /pkcs1-rsa-md5.c
parentdcd5b982b7323a3834bbf43019dd8b30df7e71e4 (diff)
downloadnettle-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 'pkcs1-rsa-md5.c')
-rw-r--r--pkcs1-rsa-md5.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pkcs1-rsa-md5.c b/pkcs1-rsa-md5.c
index c337232d..d3ccd8b0 100644
--- a/pkcs1-rsa-md5.c
+++ b/pkcs1-rsa-md5.c
@@ -38,6 +38,8 @@
#include "bignum.h"
#include "pkcs1.h"
+#include "nettle-internal.h"
+
/* From pkcs-1v2
*
* md5 OBJECT IDENTIFIER ::=
@@ -64,7 +66,8 @@ md5_prefix[] =
void
pkcs1_rsa_md5_encode(mpz_t m, unsigned length, struct md5_ctx *hash)
{
- uint8_t *em = alloca(length);
+ TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
+ TMP_ALLOC(em, length);
assert(length >= MD5_DIGEST_SIZE);
pkcs1_signature_prefix(length - MD5_DIGEST_SIZE, em,
@@ -78,7 +81,8 @@ pkcs1_rsa_md5_encode(mpz_t m, unsigned length, struct md5_ctx *hash)
void
pkcs1_rsa_md5_encode_digest(mpz_t m, unsigned length, const uint8_t *digest)
{
- uint8_t *em = alloca(length);
+ TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_BITS / 8);
+ TMP_ALLOC(em, length);
assert(length >= MD5_DIGEST_SIZE);
pkcs1_signature_prefix(length - MD5_DIGEST_SIZE, em,