Commit 8d38b6af authored by Simo Sorce's avatar Simo Sorce Committed by Niels Möller

Use side-channel silent pkcs1 in rsa_decrypt_tr

Signed-off-by: default avatarSimo Sorce <simo@redhat.com>
parent 72c02ff3
......@@ -37,9 +37,8 @@
#endif
#include "rsa.h"
#include "bignum.h"
#include "pkcs1.h"
#include "rsa-internal.h"
#include "gmp-glue.h"
int
rsa_decrypt_tr(const struct rsa_public_key *pub,
......@@ -48,14 +47,22 @@ rsa_decrypt_tr(const struct rsa_public_key *pub,
size_t *length, uint8_t *message,
const mpz_t gibberish)
{
mpz_t m;
TMP_GMP_DECL (m, mp_limb_t);
TMP_GMP_DECL (em, uint8_t);
int res;
mpz_init_set(m, gibberish);
TMP_GMP_ALLOC (m, mpz_size(pub->n));
TMP_GMP_ALLOC (em, key->size);
res = rsa_sec_compute_root_tr (pub, key, random_ctx, random, m,
mpz_limbs_read(gibberish),
mpz_size(gibberish));
mpn_get_base256 (em, key->size, m, mpz_size(pub->n));
res = (rsa_compute_root_tr (pub, key, random_ctx, random, m, gibberish)
&& pkcs1_decrypt (key->size, m, length, message));
res &= _pkcs1_sec_decrypt_variable (length, message, key->size, em);
mpz_clear(m);
TMP_GMP_FREE (em);
TMP_GMP_FREE (m);
return res;
}
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