Fix fuzz_pubkey failure on valid RSA keys
On a valid RSA public key, mbedtls_rsa_export should succeed if you ask for the public fields, but fail if you ask for private fields. The code was expecting to succeed when asking for private fields, so failed on every valid RSA public key.
This commit is contained in:
parent
a08e699afc
commit
8d36696e1f
1 changed files with 4 additions and 1 deletions
|
@ -21,7 +21,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||||
mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
|
mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
|
||||||
|
|
||||||
rsa = mbedtls_pk_rsa( pk );
|
rsa = mbedtls_pk_rsa( pk );
|
||||||
if ( mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E ) != 0 ) {
|
if ( mbedtls_rsa_export( rsa, &N, NULL, NULL, NULL, &E ) != 0 ) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
if ( mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E ) != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if ( mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) {
|
if ( mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) {
|
||||||
|
|
Loading…
Reference in a new issue