mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 12:25:39 +01:00
Merge pull request #2999 from catenacyber/fuzzrsa
Checks mbedtls_rsa_export return in fuzz targets
This commit is contained in:
commit
36ce88be1e
@ -1,4 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "mbedtls/pk.h"
|
#include "mbedtls/pk.h"
|
||||||
|
|
||||||
//4 Kb should be enough for every bug ;-)
|
//4 Kb should be enough for every bug ;-)
|
||||||
@ -29,8 +30,12 @@ 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 );
|
||||||
mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E );
|
if ( mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E ) != 0 ) {
|
||||||
mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP );
|
abort();
|
||||||
|
}
|
||||||
|
if ( mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) != 0 ) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
|
mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
|
||||||
mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
|
mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "mbedtls/pk.h"
|
#include "mbedtls/pk.h"
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||||
@ -20,8 +21,12 @@ 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 );
|
||||||
ret = mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E );
|
if ( mbedtls_rsa_export( rsa, &N, &P, &Q, &D, &E ) != 0 ) {
|
||||||
ret = mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP );
|
abort();
|
||||||
|
}
|
||||||
|
if ( mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
|
mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
|
||||||
mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
|
mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
|
||||||
|
Loading…
Reference in New Issue
Block a user