Debian Codegraph @

crt/s2n/tests/testlib/s2n_extension_test_utils.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 #include "testlib/s2n_testlib.h"
17 #include "tls/s2n_connection.h"
18 #include "utils/s2n_bitmap.h"
19
20 const s2n_parsed_extension EMPTY_PARSED_EXTENSIONS[S2N_PARSED_EXTENSIONS_COUNT] = { 0 };
21
22 int s2n_connection_allow_all_response_extensions(struct s2n_connection *conn)
23 {
24 POSIX_CHECKED_MEMSET(&conn->extension_requests_received, 0xFF, S2N_SUPPORTED_EXTENSIONS_BITFIELD_LEN);
25 POSIX_CHECKED_MEMSET(&conn->extension_requests_sent, 0xFF, S2N_SUPPORTED_EXTENSIONS_BITFIELD_LEN);
26 return S2N_SUCCESS;
27 }
28
29 int s2n_connection_mark_extension_received(struct s2n_connection *conn, uint16_t iana_value)
30 {
31 s2n_extension_type_id extension_id = s2n_unsupported_extension;
32 POSIX_GUARD(s2n_extension_supported_iana_value_to_id(iana_value, &extension_id));
33 S2N_CBIT_SET(conn->extension_requests_received, extension_id);
34 S2N_CBIT_SET(conn->extension_responses_received, extension_id);
35 return S2N_SUCCESS;
36 }
37
38 int s2n_connection_allow_response_extension(struct s2n_connection *conn, uint16_t iana_value)
39 {
40 s2n_extension_type_id extension_id = s2n_unsupported_extension;
41 POSIX_GUARD(s2n_extension_supported_iana_value_to_id(iana_value, &extension_id));
42 S2N_CBIT_SET(conn->extension_requests_sent, extension_id);
43 S2N_CBIT_SET(conn->extension_requests_received, extension_id);
44 return S2N_SUCCESS;
45 }