LCOV - code coverage report
Current view: top level - tls/extensions - s2n_server_server_name.c (source / functions) Hit Total Coverage
Test: unit_test_coverage.info Lines: 11 11 100.0 %
Date: 2025-08-14 07:26:07 Functions: 3 3 100.0 %
Branches: 8 12 66.7 %

           Branch data     Line data    Source code
       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                 :        107 : {
      36 [ +  + ][ +  + ]:        107 :     return conn && conn->server_name_used && !IS_RESUMPTION_HANDSHAKE(conn);
         [ +  - ][ +  + ]
      37                 :        107 : }
      38                 :            : 
      39                 :            : static int s2n_server_name_send(struct s2n_connection *conn, struct s2n_stuffer *out)
      40                 :         77 : {
      41                 :            :     /* Write nothing. The extension just needs to exist. */
      42                 :         77 :     return S2N_SUCCESS;
      43                 :         77 : }
      44                 :            : 
      45                 :            : static int s2n_server_name_recv(struct s2n_connection *conn, struct s2n_stuffer *extension)
      46                 :         54 : {
      47 [ -  + ][ #  # ]:         54 :     POSIX_ENSURE_REF(conn);
      48                 :            :     /* Read nothing. The extension just needs to exist. */
      49                 :         54 :     conn->server_name_used = 1;
      50                 :         54 :     return S2N_SUCCESS;
      51                 :         54 : }

Generated by: LCOV version 1.14