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_sct_list.h" 17 : : 18 : : #include "stuffer/s2n_stuffer.h" 19 : : #include "tls/s2n_connection.h" 20 : : #include "tls/s2n_tls.h" 21 : : #include "utils/s2n_blob.h" 22 : : #include "utils/s2n_safety.h" 23 : : 24 : : static bool s2n_server_sct_list_should_send(struct s2n_connection *conn); 25 : : static int s2n_server_sct_list_send(struct s2n_connection *conn, struct s2n_stuffer *out); 26 : : static int s2n_server_sct_list_recv(struct s2n_connection *conn, struct s2n_stuffer *extension); 27 : : 28 : : const s2n_extension_type s2n_server_sct_list_extension = { 29 : : .iana_value = TLS_EXTENSION_SCT_LIST, 30 : : .is_response = true, 31 : : .send = s2n_server_sct_list_send, 32 : : .recv = s2n_server_sct_list_recv, 33 : : .should_send = s2n_server_sct_list_should_send, 34 : : .if_missing = s2n_extension_noop_if_missing, 35 : : }; 36 : : 37 : : static bool s2n_server_sct_list_should_send(struct s2n_connection *conn) 38 : 19 : { 39 [ + + ][ + + ]: 19 : return s2n_server_can_send_sct_list(conn); [ + + ][ + + ] 40 : 19 : } 41 : : 42 : : int s2n_server_sct_list_send(struct s2n_connection *conn, struct s2n_stuffer *out) 43 : 5 : { 44 [ - + ][ # # ]: 5 : POSIX_ENSURE_REF(conn); 45 : 5 : struct s2n_blob *sct_list = &conn->handshake_params.our_chain_and_key->sct_list; 46 : : 47 [ - + ][ # # ]: 5 : POSIX_ENSURE_REF(sct_list); 48 [ - + ]: 5 : POSIX_GUARD(s2n_stuffer_write(out, sct_list)); 49 : : 50 : 5 : return S2N_SUCCESS; 51 : 5 : } 52 : : 53 : : int s2n_server_sct_list_recv(struct s2n_connection *conn, struct s2n_stuffer *extension) 54 : 3 : { 55 [ # # ][ - + ]: 3 : POSIX_ENSURE_REF(conn); 56 : : 57 : 3 : struct s2n_blob sct_list = { 0 }; 58 : 3 : size_t data_available = s2n_stuffer_data_available(extension); 59 [ - + ]: 3 : POSIX_GUARD(s2n_blob_init(&sct_list, 60 : 3 : s2n_stuffer_raw_read(extension, data_available), 61 : 3 : data_available)); 62 [ - + ][ # # ]: 3 : POSIX_ENSURE_REF(sct_list.data); 63 : : 64 [ - + ]: 3 : POSIX_GUARD(s2n_dup(&sct_list, &conn->ct_response)); 65 : : 66 : 3 : return S2N_SUCCESS; 67 : 3 : }