int
rsa_public_key_prepare(struct rsa_public_key *key)
{
  key->size = _rsa_check_size(key->n);
  
  return (key->size > 0);
}
Ejemplo n.º 2
0
int
rsa_private_key_prepare(struct rsa_private_key *key)
{
  mpz_t n;
  
  /* 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
   * size without computing the full product. */

  mpz_init(n);
  mpz_mul(n, key->p, key->q);

  key->size = _rsa_check_size(n);

  mpz_clear(n);
  
  return (key->size > 0);
}