From 935965049d424d3bb69efb672f9f44c36e7cbcb6 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 9 Dec 1997 12:46:23 +0000 Subject: fingerprints and self signatures added --- cipher/rsa.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cipher/rsa.c') diff --git a/cipher/rsa.c b/cipher/rsa.c index a1f08457b..db82b48d7 100644 --- a/cipher/rsa.c +++ b/cipher/rsa.c @@ -157,6 +157,22 @@ rsa_generate( RSA_public_key *pk, RSA_secret_key *sk, unsigned nbits ) } +/**************** + * Test wether the secret key is valid. + * Returns: true if this is a valid key. + */ +int +rsa_check_secret_key( RSA_secret_key *sk ) +{ + int rc; + MPI temp = mpi_alloc( mpi_get_nlimbs(sk->p)*2 ); + + mpi_mul(temp, sk->p, sk->q ); + rc = mpi_cmp( temp, sk->n ); + mpi_free(temp); + return !rc; +} + /**************** -- cgit