Commit 4045691d authored by Niels Möller's avatar Niels Möller

Bug fixes.

Rev: src/nettle/rsa-compat.c:1.2
parent 68f53d70
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "rsa-compat.h" #include "rsa-compat.h"
#include "bignum.h"
#include "md5.h" #include "md5.h"
int int
...@@ -75,10 +76,10 @@ R_SignFinal(R_SIGNATURE_CTX *ctx, ...@@ -75,10 +76,10 @@ R_SignFinal(R_SIGNATURE_CTX *ctx,
nettle_mpz_init_set_str_256(k.c, nettle_mpz_init_set_str_256(k.c,
MAX_RSA_MODULUS_LEN, key->coefficient); MAX_RSA_MODULUS_LEN, key->coefficient);
if (rsa_init_private_key(&k) && (k.size <= MAX_RSA_MODULUS_LEN)) if (rsa_init_private_key(&k) && (k.pub.size <= MAX_RSA_MODULUS_LEN))
{ {
*length = k->size; *length = k.pub.size;
rsa_md5_sign(&key, &ctx->hash, signature); rsa_md5_sign(&k, &ctx->hash, signature);
res = RE_SUCCESS; res = RE_SUCCESS;
} }
else else
...@@ -124,9 +125,9 @@ R_VerifyFinal(R_SIGNATURE_CTX *ctx, ...@@ -124,9 +125,9 @@ R_VerifyFinal(R_SIGNATURE_CTX *ctx,
nettle_mpz_init_set_str_256(k.n, nettle_mpz_init_set_str_256(k.n,
MAX_RSA_MODULUS_LEN, key->modulus); MAX_RSA_MODULUS_LEN, key->modulus);
nettle_mpz_init_set_str_256(k.e, nettle_mpz_init_set_str_256(k.e,
MAX_RSA_MODULUS_LEN, key->publicExponent); MAX_RSA_MODULUS_LEN, key->exponent);
if (rsa_init_private_key(&k) && (k.size == length)) if (rsa_init_public_key(&k) && (k.size == length))
res = rsa_md5_verify(&k, &ctx->hash, signature) res = rsa_md5_verify(&k, &ctx->hash, signature)
? RE_SUCCESS : RE_SIGNATURE; ? RE_SUCCESS : RE_SIGNATURE;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment