Debian Codegraph @

crt/s2n/tests/fuzz/LD_PRELOAD/s2n_server_fuzz_test_overrides.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 #define _GNU_SOURCE
17 #include <dlfcn.h>
18 #include <openssl/rsa.h>
19 #include <time.h>
20
21 #include "error/s2n_errno.h"
22 #include "tls/s2n_connection.h"
23 #include "utils/s2n_safety.h"
24
25 time_t time (time_t *__timer)
26 {
27 /* Always assume the time is zero when fuzzing the server, this is to ensure that Fuzz tests are deterministic and
28 * don't depend on the time the test was run.
29 */
30 return 0;
31 }
32
33
34 int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
35 const unsigned char *sigbuf, unsigned int siglen, RSA *rsa)
36 {
37 /* Always assume that the RSA_verify function passes */
38 return 1;
39 }
40
41 bool s2n_constant_time_equals(const uint8_t *a, const uint8_t *b, uint32_t len)
42 {
43 /* Allow all signatures checked with s2n_constant_time_equals to always pass verification even if they are invalid
44 * in order to aid code coverage with server fuzz test.
45 */
46 return 1;
47 }
48
49 int s2n_rsa_client_key_recv(struct s2n_connection *conn, struct s2n_blob *shared_key)
50 {
51 /* Perform the original function */
52 typedef int (*orig_s2n_rsa_client_key_recv_func_type)(struct s2n_connection *conn, struct s2n_blob *shared_key);
53 orig_s2n_rsa_client_key_recv_func_type orig_s2n_rsa_client_key_recv;
54 orig_s2n_rsa_client_key_recv = (orig_s2n_rsa_client_key_recv_func_type) dlsym(RTLD_NEXT, "s2n_rsa_client_key_recv");
55 int original_return_code = orig_s2n_rsa_client_key_recv(conn, shared_key);
56
57 /* Then, overwrite the RSA Failed flag to false before returning, this will help fuzzing code coverage. */
58 conn->handshake.rsa_failed = 0;
59
60 return original_return_code;
61 }
62