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

Catch bad private keys early on.

parent 3f76113c
Branches
Tags bugzilla-2.16.5
No related merge requests found
...@@ -70,6 +70,12 @@ rsa_private_key_prepare(struct rsa_private_key *key) ...@@ -70,6 +70,12 @@ rsa_private_key_prepare(struct rsa_private_key *key)
{ {
mpz_t n; mpz_t n;
/* A key is invalid if the sizes of q and c are smaller than
* the size of n, we rely on that property in calculations so
* fail early if that happens. */
if (mpz_size (key->q) + mpz_size (key->c) < mpz_size(key->p))
return 0;
/* The size of the product is the sum of the sizes of the factors, /* The size of the product is the sum of the sizes of the factors,
* or sometimes one less. It's possible but tricky to compute the * or sometimes one less. It's possible but tricky to compute the
* size without computing the full product. */ * size without computing the full product. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment