blob: f208800ab8a329f3104107fcf7757977925728a5 [file] [log] [blame] [view]
Philippe Antoinecd6cd812019-06-06 09:22:27 +02001What is it?
Philippe Antoine81496272019-06-04 14:47:58 +02002------
3
4This directory contains fuzz targets.
5Fuzz targets are simple codes using the library.
6They are used with a so-called fuzz driver, which will generate inputs, try to process them with the fuzz target, and alert in case of an unwanted behavior (such as a buffer overflow for instance).
7
8These targets were meant to be used with oss-fuzz but can be used in other contexts.
9
10This code was contributed by Philippe Antoine ( Catena cyber ).
11
Philippe Antoinecd6cd812019-06-06 09:22:27 +020012How to run?
Philippe Antoine81496272019-06-04 14:47:58 +020013------
14
Philippe Antoinecd6cd812019-06-06 09:22:27 +020015To run the fuzz targets like oss-fuzz:
Philippe Antoine81496272019-06-04 14:47:58 +020016```
17git clone https://github.com/google/oss-fuzz
18cd oss-fuzz
19python infra/helper.py build_image mbedtls
20python infra/helper.py build_fuzzers --sanitizer address mbedtls
21python infra/helper.py run_fuzzer mbedtls fuzz_client
22```
Philippe Antoinecd6cd812019-06-06 09:22:27 +020023You can use `undefined` sanitizer as well as `address` sanitizer.
24And you can run any of the fuzz targets like `fuzz_client`.
Philippe Antoine81496272019-06-04 14:47:58 +020025
Philippe Antoinecd6cd812019-06-06 09:22:27 +020026To run the fuzz targets without oss-fuzz, you first need to install one libFuzzingEngine (libFuzzer for instance).
27Then you need to compile the code with the compiler flags of the wished sanitizer.
Philippe Antoine81496272019-06-04 14:47:58 +020028```
29perl scripts/config.pl set MBEDTLS_PLATFORM_TIME_ALT
30mkdir build
31cd build
32cmake ..
33make
34```
Philippe Antoinecd6cd812019-06-06 09:22:27 +020035Finally, you can run the targets like `./test/fuzz/fuzz_client`.