Debian Codegraph @

crt/s2n/tests/fuzz/s2n_stuffer_pem_fuzz_test.c

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 /* Target Functions: s2n_stuffer_pem_read_encapsulation_line s2n_stuffer_pem_read_contents */
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 /* Reset in and out buffers */
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)