LCOV - code coverage report
Current view: top level - tls - s2n_establish_session.c (source / functions) Hit Total Coverage
Test: unit_test_coverage.info Lines: 12 12 100.0 %
Date: 2025-08-15 07:28:39 Functions: 1 1 100.0 %
Branches: 11 12 91.7 %

           Branch data     Line data    Source code
       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                 :       7358 : {
      31                 :            :     /* Start by receiving and processing the entire CLIENT_HELLO message */
      32         [ +  + ]:       7358 :     if (!conn->handshake.client_hello_received) {
      33         [ +  + ]:       7348 :         POSIX_GUARD(s2n_client_hello_recv(conn));
      34                 :       7276 :         conn->handshake.client_hello_received = 1;
      35                 :       7276 :     }
      36                 :            : 
      37         [ +  + ]:       7286 :     POSIX_GUARD_RESULT(s2n_early_data_accept_or_reject(conn));
      38         [ +  + ]:       7282 :     POSIX_GUARD(s2n_conn_set_handshake_type(conn));
      39                 :            : 
      40         [ +  + ]:       7275 :     if (!conn->client_hello.sslv2) {
      41                 :            :         /* We've selected the parameters for the handshake, update the required hashes for this connection */
      42         [ -  + ]:       7272 :         POSIX_GUARD(s2n_conn_update_required_handshake_hashes(conn));
      43                 :       7272 :     }
      44                 :            : 
      45                 :       7275 :     return 0;
      46                 :       7275 : }

Generated by: LCOV version 1.14