Debian Codegraph @

crt/s2n/tls/extensions/s2n_server_server_name.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 "tls/extensions/s2n_server_server_name.h"
17
18 #include "stuffer/s2n_stuffer.h"
19 #include "tls/s2n_connection.h"
20
21 static bool s2n_server_name_should_send(struct s2n_connection *conn);
22 static int s2n_server_name_send(struct s2n_connection *conn, struct s2n_stuffer *out);
23 static int s2n_server_name_recv(struct s2n_connection *conn, struct s2n_stuffer *extension);
24
25 const s2n_extension_type s2n_server_server_name_extension = {
26 .iana_value = TLS_EXTENSION_SERVER_NAME,
27 .is_response = true,
28 .send = s2n_server_name_send,
29 .recv = s2n_server_name_recv,
30 .should_send = s2n_server_name_should_send,
31 .if_missing = s2n_extension_noop_if_missing,
32 };
33
34 static bool s2n_server_name_should_send(struct s2n_connection *conn)
35 {
36 return conn && conn->server_name_used && !IS_RESUMPTION_HANDSHAKE(conn);
37 }
38
39 static int s2n_server_name_send(struct s2n_connection *conn, struct s2n_stuffer *out)
40 {
41 /* Write nothing. The extension just needs to exist. */
42 return S2N_SUCCESS;
43 }
44
45 static int s2n_server_name_recv(struct s2n_connection *conn, struct s2n_stuffer *extension)
46 {
47 POSIX_ENSURE_REF(conn);
48 /* Read nothing. The extension just needs to exist. */
49 conn->server_name_used = 1;
50 return S2N_SUCCESS;
51 }