Check that length is properly set in `mbedtls_rsa_check_pubkey`
diff --git a/library/rsa.c b/library/rsa.c
index 8623011..ae4382b 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -1028,6 +1028,9 @@
     if( !ctx->N.p || !ctx->E.p )
         return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
 
+    if( ctx->len != mbedtls_mpi_size( &ctx->N ) )
+        return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
+
     if( ( ctx->N.p[0] & 1 ) == 0 ||
         ( ctx->E.p[0] & 1 ) == 0 )
         return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );