From: Niels Möller Date: Wed, 9 Jan 2002 15:15:39 +0000 (+0100) Subject: Updated for new md5 and rsa conventions. X-Git-Tag: nettle_1.5_release_20020131~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5d65ea3a8bdbcae95a7f8158cf5499686b99dc7;p=thirdparty%2Fnettle.git Updated for new md5 and rsa conventions. Rev: src/nettle/rsa-compat.c:1.3 --- 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;