rsa_decrypt(const struct rsa_private_key *key,
	    size_t *length, uint8_t *message,
	    const mpz_t gibberish)
{
  mpz_t m;
  int res;

  mpz_init(m);

  /* First check that input is in range. Since we don't have the
     public key available here, we need to reconstruct n. */
  mpz_mul (m, key->p, key->q);
  if (mpz_sgn (gibberish) < 0 || mpz_cmp (gibberish, m) >= 0)
    {
      mpz_clear (m);
      return 0;
    }

  rsa_compute_root(key, m, gibberish);

  res = pkcs1_decrypt (key->size, m, length, message);
  mpz_clear(m);
  return res;
}
rsa_decrypt(const struct rsa_private_key *key,
	    size_t *length, uint8_t *message,
	    const mpz_t gibberish)
{
  mpz_t m;
  int res;

  mpz_init(m);

   
  mpz_mul (m, key->p, key->q);
  if (mpz_sgn (gibberish) < 0 || mpz_cmp (gibberish, m) >= 0)
    {
      mpz_clear (m);
      return 0;
    }

  rsa_compute_root(key, m, gibberish);

  res = pkcs1_decrypt (key->size, m, length, message);
  mpz_clear(m);
  return res;
}