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_session_ticket.h" 17 : : 18 : : #include "stuffer/s2n_stuffer.h" 19 : : #include "tls/s2n_connection.h" 20 : : #include "tls/s2n_tls.h" 21 : : #include "tls/s2n_tls_parameters.h" 22 : : 23 : : static bool s2n_session_ticket_should_send(struct s2n_connection *conn); 24 : : static int s2n_session_ticket_recv(struct s2n_connection *conn, struct s2n_stuffer *extension); 25 : : 26 : : const s2n_extension_type s2n_server_session_ticket_extension = { 27 : : .iana_value = TLS_EXTENSION_SESSION_TICKET, 28 : : .is_response = true, 29 : : .send = s2n_extension_send_noop, 30 : : .recv = s2n_session_ticket_recv, 31 : : .should_send = s2n_session_ticket_should_send, 32 : : .if_missing = s2n_extension_noop_if_missing, 33 : : }; 34 : : 35 : : static bool s2n_session_ticket_should_send(struct s2n_connection *conn) 36 : 59 : { 37 [ + + ][ + + ]: 59 : return s2n_server_sending_nst(conn) && s2n_connection_get_protocol_version(conn) < S2N_TLS13 [ + + ] 38 [ + - ]: 59 : && !conn->config->ticket_forward_secrecy; 39 : 59 : } 40 : : 41 : : static int s2n_session_ticket_recv(struct s2n_connection *conn, struct s2n_stuffer *extension) 42 : 19 : { 43 : : /* Read nothing. The extension just needs to exist. */ 44 [ - + ][ # # ]: 19 : POSIX_ENSURE_REF(conn); 45 : 19 : conn->session_ticket_status = S2N_NEW_TICKET; 46 : 19 : return S2N_SUCCESS; 47 : 19 : } 48 : : 49 : : /* Old-style extension functions -- remove after extensions refactor is complete */ 50 : : 51 : : int s2n_recv_server_session_ticket_ext(struct s2n_connection *conn, struct s2n_stuffer *extension) 52 : 0 : { 53 : 0 : return s2n_extension_recv(&s2n_server_session_ticket_extension, conn, extension); 54 : 0 : }