Debian Codegraph @

crt/s2n/tls/s2n_establish_session.c

raw symbols SCIP
1 /*
2 * Copyright 2020 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 <stdint.h>
17
18 #include "api/s2n.h"
19 #include "error/s2n_errno.h"
20 #include "stuffer/s2n_stuffer.h"
21 #include "tls/s2n_connection.h"
22 #include "tls/s2n_tls.h"
23 #include "utils/s2n_array.h"
24
25 /* Establishing a session requires reading the CLIENT_HELLO message and then generating security parameters.
26 *
27 * S2N supports resuming sessions under TLS1.2 if the client sends a session ID. The server can lookup a
28 * provided session ID in its cache. */
29 int s2n_establish_session(struct s2n_connection *conn)
30 {
31 /* Start by receiving and processing the entire CLIENT_HELLO message */
32 if (!conn->handshake.client_hello_received) {
33 POSIX_GUARD(s2n_client_hello_recv(conn));
34 conn->handshake.client_hello_received = 1;
35 }
36
37 POSIX_GUARD_RESULT(s2n_early_data_accept_or_reject(conn));
38 POSIX_GUARD(s2n_conn_set_handshake_type(conn));
39
40 if (!conn->client_hello.sslv2) {
41 /* We've selected the parameters for the handshake, update the required hashes for this connection */
42 POSIX_GUARD(s2n_conn_update_required_handshake_hashes(conn));
43 }
44
45 return 0;
46 }