diff options
author | Niels Möller <nisse@lysator.liu.se> | 2002-01-09 16:15:39 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2002-01-09 16:15:39 +0100 |
commit | d5d65ea3a8bdbcae95a7f8158cf5499686b99dc7 (patch) | |
tree | 42bd7fba97a90691bd099548e777c4079b5395b2 /rsa-compat.c | |
parent | 6e0c5d8e9872a059eaed2afd7ef22fbcfd9f545d (diff) | |
download | nettle-d5d65ea3a8bdbcae95a7f8158cf5499686b99dc7.tar.gz |
Updated for new md5 and rsa conventions.
Rev: src/nettle/rsa-compat.c:1.3
Diffstat (limited to 'rsa-compat.c')
-rw-r--r-- | rsa-compat.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/rsa-compat.c b/rsa-compat.c index 3141f0d1..6b818536 100644 --- a/rsa-compat.c +++ b/rsa-compat.c @@ -76,10 +76,18 @@ R_SignFinal(R_SIGNATURE_CTX *ctx, nettle_mpz_init_set_str_256(k.c, MAX_RSA_MODULUS_LEN, key->coefficient); - if (rsa_init_private_key(&k) && (k.pub.size <= MAX_RSA_MODULUS_LEN)) + if (rsa_prepare_private_key(&k) && (k.pub.size <= MAX_RSA_MODULUS_LEN)) { + mpz_t s; + mpz_init(s); + + rsa_md5_sign(&k, &ctx->hash, s); + nettle_mpz_get_str_256(k.pub.size, signature, s); + + mpz_clear(s); + *length = k.pub.size; - rsa_md5_sign(&k, &ctx->hash, signature); + res = RE_SUCCESS; } else @@ -126,10 +134,18 @@ R_VerifyFinal(R_SIGNATURE_CTX *ctx, MAX_RSA_MODULUS_LEN, key->modulus); nettle_mpz_init_set_str_256(k.e, MAX_RSA_MODULUS_LEN, key->exponent); + + if (rsa_prepare_public_key(&k) && (k.size == length)) + { + mpz_t s; + + nettle_mpz_init_set_str_256(s, + k.size, signature); + res = rsa_md5_verify(&k, &ctx->hash, s) + ? RE_SUCCESS : RE_SIGNATURE; - if (rsa_init_public_key(&k) && (k.size == length)) - res = rsa_md5_verify(&k, &ctx->hash, signature) - ? RE_SUCCESS : RE_SIGNATURE; + mpz_clear(s); + } else res = RE_PUBLIC_KEY; |