| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <errno.h> |
| 19 |
#include <fcntl.h> |
| 20 |
#include <stddef.h> |
| 21 |
#include <stdint.h> |
| 22 |
#include <stdio.h> |
| 23 |
#include <stdlib.h> |
| 24 |
#include <unistd.h> |
| 25 |
|
| 26 |
#include "api/s2n.h" |
| 27 |
#include "stuffer/s2n_stuffer.h" |
| 28 |
#include "tests/s2n_test.h" |
| 29 |
#include "utils/s2n_safety.h" |
| 30 |
|
| 31 |
int s2n_fuzz_test(const uint8_t *buf, size_t len) |
| 32 |
{ |
| 33 |
struct s2n_stuffer in = {0}; |
| 34 |
struct s2n_stuffer out = {0}; |
| 35 |
|
| 36 |
POSIX_GUARD(s2n_stuffer_alloc(&in, len + 1)); |
| 37 |
POSIX_GUARD(s2n_stuffer_alloc(&out, len)); |
| 38 |
POSIX_GUARD(s2n_stuffer_write_bytes(&in, buf, len)); |
| 39 |
|
| 40 |
s2n_stuffer_certificate_from_pem(&in, &out); |
| 41 |
|
| 42 |
|
| 43 |
POSIX_GUARD(s2n_stuffer_reread(&in)); |
| 44 |
POSIX_GUARD(s2n_stuffer_wipe(&out)); |
| 45 |
|
| 46 |
s2n_stuffer_dhparams_from_pem(&in, &out); |
| 47 |
|
| 48 |
POSIX_GUARD(s2n_stuffer_free(&in)); |
| 49 |
POSIX_GUARD(s2n_stuffer_free(&out)); |
| 50 |
|
| 51 |
return S2N_SUCCESS; |
| 52 |
} |
| 53 |
|
| 54 |
S2N_FUZZ_TARGET(NULL, s2n_fuzz_test, NULL) |