Skip to content
Snippets Groups Projects
Commit 8d38b6af authored by Simo Sorce's avatar Simo Sorce Committed by Niels Möller
Browse files

Use side-channel silent pkcs1 in rsa_decrypt_tr


Signed-off-by: default avatarSimo Sorce <simo@redhat.com>
parent 72c02ff3
No related branches found
No related tags found
No related merge requests found
...@@ -37,9 +37,8 @@ ...@@ -37,9 +37,8 @@
#endif #endif
#include "rsa.h" #include "rsa.h"
#include "rsa-internal.h"
#include "bignum.h" #include "gmp-glue.h"
#include "pkcs1.h"
int int
rsa_decrypt_tr(const struct rsa_public_key *pub, rsa_decrypt_tr(const struct rsa_public_key *pub,
...@@ -48,14 +47,22 @@ 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, size_t *length, uint8_t *message,
const mpz_t gibberish) const mpz_t gibberish)
{ {
mpz_t m; TMP_GMP_DECL (m, mp_limb_t);
TMP_GMP_DECL (em, uint8_t);
int res; 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) res &= _pkcs1_sec_decrypt_variable (length, message, key->size, em);
&& pkcs1_decrypt (key->size, m, length, message));
mpz_clear(m); TMP_GMP_FREE (em);
TMP_GMP_FREE (m);
return res; return res;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment