summaryrefslogtreecommitdiff
path: root/pkcs1-rsa-sha512.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2012-06-03 22:02:59 +0200
committerNiels Möller <nisse@lysator.liu.se>2012-06-03 22:02:59 +0200
commitadad6eaac2d03fba830eb1630b5458c1ac7f1907 (patch)
treeea02b675e2cf8f3c6584f35f9f73fd0d072b3428 /pkcs1-rsa-sha512.c
parent0589865876f8c89047eaee1698071e31956b0480 (diff)
downloadnettle-adad6eaac2d03fba830eb1630b5458c1ac7f1907.tar.gz
Changes to pkcs1_signature_prefix interface.
Diffstat (limited to 'pkcs1-rsa-sha512.c')
-rw-r--r--pkcs1-rsa-sha512.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/pkcs1-rsa-sha512.c b/pkcs1-rsa-sha512.c
index df7520e5..ddf62769 100644
--- a/pkcs1-rsa-sha512.c
+++ b/pkcs1-rsa-sha512.c
@@ -60,19 +60,20 @@ sha512_prefix[] =
};
int
-pkcs1_rsa_sha512_encode(mpz_t m, unsigned size, struct sha512_ctx *hash)
+pkcs1_rsa_sha512_encode(mpz_t m, unsigned key_size, struct sha512_ctx *hash)
{
+ uint8_t *p;
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
- TMP_ALLOC(em, size);
+ TMP_ALLOC(em, key_size);
- if (pkcs1_signature_prefix(size, em,
+ p = pkcs1_signature_prefix(key_size, em,
sizeof(sha512_prefix),
sha512_prefix,
- SHA512_DIGEST_SIZE))
+ SHA512_DIGEST_SIZE);
+ if (p)
{
- sha512_digest(hash, SHA512_DIGEST_SIZE,
- em + size - SHA512_DIGEST_SIZE);
- nettle_mpz_set_str_256_u(m, size, em);
+ sha512_digest(hash, SHA512_DIGEST_SIZE, p);
+ nettle_mpz_set_str_256_u(m, key_size, em);
return 1;
}
else
@@ -80,18 +81,20 @@ 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)
+pkcs1_rsa_sha512_encode_digest(mpz_t m, unsigned key_size, const uint8_t *digest)
{
+ uint8_t *p;
TMP_DECL(em, uint8_t, NETTLE_MAX_BIGNUM_SIZE);
- TMP_ALLOC(em, size);
+ TMP_ALLOC(em, key_size);
- if (pkcs1_signature_prefix(size, em,
+ p = pkcs1_signature_prefix(key_size, em,
sizeof(sha512_prefix),
sha512_prefix,
- SHA512_DIGEST_SIZE))
+ SHA512_DIGEST_SIZE);
+ if (p)
{
- memcpy(em + size - SHA512_DIGEST_SIZE, digest, SHA512_DIGEST_SIZE);
- nettle_mpz_set_str_256_u(m, size, em);
+ memcpy(p, digest, SHA512_DIGEST_SIZE);
+ nettle_mpz_set_str_256_u(m, key_size, em);
return 1;
}
else