aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/rsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'cipher/rsa.c')
-rw-r--r--cipher/rsa.c16
1 files changed, 16 insertions, 0 deletions
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;
+}
+
/****************