- Added test coverage for X509parse
- Fixed segfault in rsa_check_privkey() and rsa_check_pubkey() and added test
diff --git a/library/rsa.c b/library/rsa.c
index 525908a..94dbe4e 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -133,6 +133,9 @@
*/
int rsa_check_pubkey( rsa_context *ctx )
{
+ if( !ctx->N.p || !ctx->E.p )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
if( ( ctx->N.p[0] & 1 ) == 0 ||
( ctx->E.p[0] & 1 ) == 0 )
return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
@@ -159,6 +162,9 @@
if( ( ret = rsa_check_pubkey( ctx ) ) != 0 )
return( ret );
+ if( !ctx->P.p || !ctx->Q.p || !ctx->D.p )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
mpi_init( &PQ, &DE, &P1, &Q1, &H, &I, &G, NULL );
MPI_CHK( mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) );