mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 22:55:39 +01:00
Using custom time
This commit is contained in:
parent
dbc0db9449
commit
08633825c0
@ -25,14 +25,14 @@ target_link_libraries(fuzz_privkey ${libs})
|
||||
add_executable(fuzz_pubkey fuzz_pubkey.c onefile.c)
|
||||
target_link_libraries(fuzz_pubkey ${libs})
|
||||
|
||||
add_executable(fuzz_client fuzz_client.c onefile.c)
|
||||
add_executable(fuzz_client fuzz_client.c common.c onefile.c)
|
||||
target_link_libraries(fuzz_client ${libs})
|
||||
|
||||
add_executable(fuzz_server fuzz_server.c onefile.c)
|
||||
add_executable(fuzz_server fuzz_server.c common.c onefile.c)
|
||||
target_link_libraries(fuzz_server ${libs})
|
||||
|
||||
add_executable(fuzz_dtlsclient fuzz_dtlsclient.c onefile.c)
|
||||
add_executable(fuzz_dtlsclient fuzz_dtlsclient.c common.c onefile.c)
|
||||
target_link_libraries(fuzz_dtlsclient ${libs})
|
||||
|
||||
add_executable(fuzz_dtlsserver fuzz_dtlsserver.c onefile.c)
|
||||
add_executable(fuzz_dtlsserver fuzz_dtlsserver.c common.c onefile.c)
|
||||
target_link_libraries(fuzz_dtlsserver ${libs})
|
||||
|
14
tests/fuzz/common.c
Normal file
14
tests/fuzz/common.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include "common.h"
|
||||
|
||||
mbedtls_time_t dummy_constant_time( mbedtls_time_t* time ) {
|
||||
(void) time;
|
||||
return 0x5af2a056;
|
||||
}
|
||||
|
||||
void dummy_init() {
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||
mbedtls_platform_set_time( dummy_constant_time );
|
||||
#else
|
||||
fprintf(stderr, "Warning: fuzzing without constant time\n");
|
||||
#endif
|
||||
}
|
4
tests/fuzz/common.h
Normal file
4
tests/fuzz/common.h
Normal file
@ -0,0 +1,4 @@
|
||||
#include "mbedtls/platform_time.h"
|
||||
|
||||
mbedtls_time_t dummy_constant_time( mbedtls_time_t* time );
|
||||
void dummy_init();
|
@ -2,6 +2,7 @@
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
@ -90,7 +91,6 @@ static int dummy_entropy( void *data, unsigned char *output, size_t len )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
int ret;
|
||||
size_t len;
|
||||
@ -114,6 +114,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
alpn_list[1] = "fuzzalpn";
|
||||
alpn_list[2] = NULL;
|
||||
|
||||
dummy_init();
|
||||
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
#include "mbedtls/entropy.h"
|
||||
@ -113,6 +114,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
mbedtls_test_cas_pem_len ) != 0)
|
||||
return 1;
|
||||
#endif
|
||||
dummy_init();
|
||||
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
#include "mbedtls/entropy.h"
|
||||
@ -120,6 +121,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
mbedtls_test_srv_key_len, NULL, 0 ) != 0)
|
||||
return 1;
|
||||
#endif
|
||||
dummy_init();
|
||||
|
||||
initialized = 1;
|
||||
}
|
||||
mbedtls_ssl_init( &ssl );
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/ssl_ticket.h"
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
@ -131,6 +132,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
alpn_list[1] = "fuzzalpn";
|
||||
alpn_list[2] = NULL;
|
||||
|
||||
dummy_init();
|
||||
|
||||
initialized = 1;
|
||||
}
|
||||
mbedtls_ssl_init( &ssl );
|
||||
|
Loading…
Reference in New Issue
Block a user