summaryrefslogtreecommitdiff
path: root/pkcs1-rsa-sha1.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-sha1.c
parent0589865876f8c89047eaee1698071e31956b0480 (diff)
downloadnettle-adad6eaac2d03fba830eb1630b5458c1ac7f1907.tar.gz
Changes to pkcs1_signature_prefix interface.
Diffstat (limited to 'pkcs1-rsa-sha1.c')
-rw-r--r--pkcs1-rsa-sha1.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/pkcs1-rsa-sha1.c b/pkcs1-rsa-sha1.c
index 78143a77..427a5ade 100644
--- a/pkcs1-rsa-sha1.c
+++ b/pkcs1-rsa-sha1.c
@@ -62,18 +62,20 @@ sha1_prefix[] =
};
int
-pkcs1_rsa_sha1_encode(mpz_t m, unsigned size, struct sha1_ctx *hash)
+pkcs1_rsa_sha1_encode(mpz_t m, unsigned key_size, struct sha1_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(sha1_prefix),
sha1_prefix,
- SHA1_DIGEST_SIZE))
+ SHA1_DIGEST_SIZE);
+ if (p)
{
- sha1_digest(hash, SHA1_DIGEST_SIZE, em + size - SHA1_DIGEST_SIZE);
- nettle_mpz_set_str_256_u(m, size, em);
+ sha1_digest(hash, SHA1_DIGEST_SIZE, p);
+ nettle_mpz_set_str_256_u(m, key_size, em);
return 1;
}
else
@@ -81,18 +83,20 @@ 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)
+pkcs1_rsa_sha1_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(sha1_prefix),
sha1_prefix,
- SHA1_DIGEST_SIZE))
+ SHA1_DIGEST_SIZE);
+ if (p)
{
- memcpy(em + size - SHA1_DIGEST_SIZE, digest, SHA1_DIGEST_SIZE);
- nettle_mpz_set_str_256_u(m, size, em);
+ memcpy(p, digest, SHA1_DIGEST_SIZE);
+ nettle_mpz_set_str_256_u(m, key_size, em);
return 1;
}
else