Exemple #1
0
void
rsa_sha256_sign(const struct rsa_private_key *key,
		struct sha256_ctx *hash,
		mpz_t s)
{
  assert(key->size >= RSA_MINIMUM_N_OCTETS);

  pkcs1_rsa_sha256_encode(s, key->size - 1, hash);

  rsa_compute_root(key, s, s);
}
Exemple #2
0
int
rsa_sha256_sign(const struct rsa_private_key *key,
		struct sha256_ctx *hash,
		mpz_t s)
{
  if (pkcs1_rsa_sha256_encode(s, key->size, hash))
    {
      rsa_compute_root(key, s, s);
      return 1;
    }
  else
    {
      mpz_set_ui(s, 0);
      return 0;
    }  
}
int
rsa_sha256_verify(const struct rsa_public_key *key,
		  struct sha256_ctx *hash,
		  const mpz_t s)
{
  int res;
  mpz_t m;

  mpz_init(m);

  res = (pkcs1_rsa_sha256_encode(m, key->size, hash)
	 &&_rsa_verify(key, m, s));
  
  mpz_clear(m);

  return res;
}