summaryrefslogtreecommitdiff
path: root/pkcs1-rsa-sha1.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2013-12-15 19:13:37 +0100
committerNiels Möller <nisse@lysator.liu.se>2013-12-15 19:14:18 +0100
commit53bcd6b4118c0cd9f2a95debc5897da9a3bb1381 (patch)
tree293e181213c439f46ceb7b569cfe300d347b2dc1 /pkcs1-rsa-sha1.c
parent6c0f9c0fa041efccfab4f5ec6603afffa8f6dd8e (diff)
downloadnettle-53bcd6b4118c0cd9f2a95debc5897da9a3bb1381.tar.gz
Define and use new TMP_GMP_ALLOC macro.
Diffstat (limited to 'pkcs1-rsa-sha1.c')
-rw-r--r--pkcs1-rsa-sha1.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/pkcs1-rsa-sha1.c b/pkcs1-rsa-sha1.c
index 781d75d9..c46b1b82 100644
--- a/pkcs1-rsa-sha1.c
+++ b/pkcs1-rsa-sha1.c
@@ -36,7 +36,7 @@
#include "bignum.h"
#include "pkcs1.h"
-#include "nettle-internal.h"
+#include "gmp-glue.h"
/* From pkcs-1v2
*
@@ -65,8 +65,9 @@ int
pkcs1_rsa_sha1_encode(mpz_t m, size_t key_size, struct sha1_ctx *hash)
{
uint8_t *p;
- TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
- TMP_ALLOC(em, key_size);
+ TMP_GMP_DECL(em, uint8_t);
+
+ TMP_GMP_ALLOC(em, key_size);
p = _pkcs1_signature_prefix(key_size, em,
sizeof(sha1_prefix),
@@ -76,18 +77,23 @@ pkcs1_rsa_sha1_encode(mpz_t m, size_t key_size, struct sha1_ctx *hash)
{
sha1_digest(hash, SHA1_DIGEST_SIZE, p);
nettle_mpz_set_str_256_u(m, key_size, em);
+ TMP_GMP_FREE(em);
return 1;
}
else
- return 0;
+ {
+ TMP_GMP_FREE(em);
+ return 0;
+ }
}
int
pkcs1_rsa_sha1_encode_digest(mpz_t m, size_t key_size, const uint8_t *digest)
{
uint8_t *p;
- TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
- TMP_ALLOC(em, key_size);
+ TMP_GMP_DECL(em, uint8_t);
+
+ TMP_GMP_ALLOC(em, key_size);
p = _pkcs1_signature_prefix(key_size, em,
sizeof(sha1_prefix),
@@ -97,8 +103,12 @@ pkcs1_rsa_sha1_encode_digest(mpz_t m, size_t key_size, const uint8_t *digest)
{
memcpy(p, digest, SHA1_DIGEST_SIZE);
nettle_mpz_set_str_256_u(m, key_size, em);
+ TMP_GMP_FREE(em);
return 1;
}
else
- return 0;
+ {
+ TMP_GMP_FREE(em);
+ return 0;
+ }
}