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 : : #pragma once 17 : : 18 : : #include <stdbool.h> 19 : : #include <stdint.h> 20 : : 21 : : #include "tls/s2n_connection.h" 22 : : 23 : : extern uint8_t s2n_unknown_protocol_version; 24 : : extern uint8_t s2n_highest_protocol_version; 25 : : 26 : : int s2n_flush(struct s2n_connection *conn, s2n_blocked_status *more); 27 : : S2N_RESULT s2n_client_hello_request_validate(struct s2n_connection *conn); 28 : : S2N_RESULT s2n_client_hello_request_recv(struct s2n_connection *conn); 29 : : int s2n_client_hello_send(struct s2n_connection *conn); 30 : : int s2n_client_hello_recv(struct s2n_connection *conn); 31 : : int s2n_establish_session(struct s2n_connection *conn); 32 : : int s2n_sslv2_client_hello_parse(struct s2n_connection *conn); 33 : : int s2n_server_hello_retry_send(struct s2n_connection *conn); 34 : : int s2n_server_hello_retry_recv(struct s2n_connection *conn); 35 : : int s2n_server_hello_write_message(struct s2n_connection *conn); 36 : : int s2n_server_hello_send(struct s2n_connection *conn); 37 : : int s2n_server_hello_recv(struct s2n_connection *conn); 38 : : int s2n_encrypted_extensions_send(struct s2n_connection *conn); 39 : : int s2n_encrypted_extensions_recv(struct s2n_connection *conn); 40 : : int s2n_next_protocol_send(struct s2n_connection *conn); 41 : : int s2n_next_protocol_recv(struct s2n_connection *conn); 42 : : int s2n_server_cert_send(struct s2n_connection *conn); 43 : : int s2n_server_cert_recv(struct s2n_connection *conn); 44 : : int s2n_server_status_send(struct s2n_connection *conn); 45 : : int s2n_server_status_recv(struct s2n_connection *conn); 46 : : int s2n_server_key_send(struct s2n_connection *conn); 47 : : int s2n_server_key_recv(struct s2n_connection *conn); 48 : : int s2n_cert_req_recv(struct s2n_connection *conn); 49 : : int s2n_cert_req_send(struct s2n_connection *conn); 50 : : int s2n_tls13_cert_req_send(struct s2n_connection *conn); 51 : : int s2n_tls13_cert_req_recv(struct s2n_connection *conn); 52 : : int s2n_server_done_send(struct s2n_connection *conn); 53 : : int s2n_server_done_recv(struct s2n_connection *conn); 54 : : int s2n_client_cert_recv(struct s2n_connection *conn); 55 : : int s2n_client_cert_send(struct s2n_connection *conn); 56 : : int s2n_client_key_send(struct s2n_connection *conn); 57 : : int s2n_client_key_recv(struct s2n_connection *conn); 58 : : int s2n_client_cert_verify_recv(struct s2n_connection *conn); 59 : : int s2n_client_cert_verify_send(struct s2n_connection *conn); 60 : : int s2n_tls13_cert_verify_recv(struct s2n_connection *conn); 61 : : int s2n_tls13_cert_verify_send(struct s2n_connection *conn); 62 : : int s2n_server_nst_send(struct s2n_connection *conn); 63 : : S2N_RESULT s2n_server_nst_write(struct s2n_connection *conn, uint32_t *lifetime_hint_in_secs, 64 : : struct s2n_blob *session_ticket); 65 : : int s2n_server_nst_recv(struct s2n_connection *conn); 66 : : S2N_RESULT s2n_tls13_server_nst_send(struct s2n_connection *conn, s2n_blocked_status *blocked); 67 : : S2N_RESULT s2n_tls13_server_nst_write(struct s2n_connection *conn, struct s2n_stuffer *output); 68 : : S2N_RESULT s2n_tls13_server_nst_recv(struct s2n_connection *conn, struct s2n_stuffer *input); 69 : : int s2n_ccs_send(struct s2n_connection *conn); 70 : : int s2n_basic_ccs_recv(struct s2n_connection *conn); 71 : : int s2n_server_ccs_recv(struct s2n_connection *conn); 72 : : int s2n_client_ccs_recv(struct s2n_connection *conn); 73 : : int s2n_client_finished_send(struct s2n_connection *conn); 74 : : int s2n_client_finished_recv(struct s2n_connection *conn); 75 : : int s2n_server_finished_send(struct s2n_connection *conn); 76 : : int s2n_server_finished_recv(struct s2n_connection *conn); 77 : : int s2n_tls13_client_finished_send(struct s2n_connection *conn); 78 : : int s2n_tls13_client_finished_recv(struct s2n_connection *conn); 79 : : int s2n_tls13_server_finished_send(struct s2n_connection *conn); 80 : : int s2n_tls13_server_finished_recv(struct s2n_connection *conn); 81 : : int s2n_end_of_early_data_send(struct s2n_connection *conn); 82 : : int s2n_end_of_early_data_recv(struct s2n_connection *conn); 83 : : int s2n_process_client_hello(struct s2n_connection *conn); 84 : : int s2n_handshake_write_header(struct s2n_stuffer *out, uint8_t message_type); 85 : : int s2n_handshake_finish_header(struct s2n_stuffer *out); 86 : : S2N_RESULT s2n_handshake_parse_header(struct s2n_stuffer *io, uint8_t *message_type, uint32_t *length); 87 : : int s2n_read_full_record(struct s2n_connection *conn, uint8_t *record_type, int *isSSLv2); 88 : : S2N_RESULT s2n_sendv_with_offset_total_size(const struct iovec *bufs, ssize_t count, 89 : : ssize_t offs, ssize_t *total_size_out); 90 : : S2N_RESULT s2n_recv_in_init(struct s2n_connection *conn, uint32_t written, uint32_t size); 91 : : 92 : : extern uint16_t mfl_code_to_length[5]; 93 : : 94 : 7372 : #define s2n_server_received_server_name(conn) ((conn)->server_name[0] != 0) 95 : : 96 : : #define s2n_server_can_send_ec_point_formats(conn) \ 97 : : ((conn)->ec_point_formats) 98 : : 99 : 9581 : #define s2n_server_can_send_ocsp(conn) ((conn)->mode == S2N_SERVER \ 100 : 4909 : && (conn)->status_type == S2N_STATUS_REQUEST_OCSP \ 101 : 4909 : && (conn)->handshake_params.our_chain_and_key \ 102 : 9581 : && (conn)->handshake_params.our_chain_and_key->ocsp_status.size > 0) 103 : : 104 : 4667 : #define s2n_server_sent_ocsp(conn) ((conn)->mode == S2N_CLIENT \ 105 : 4667 : && (conn)->status_type == S2N_STATUS_REQUEST_OCSP) 106 : : 107 : 19 : #define s2n_server_can_send_sct_list(conn) ((conn)->mode == S2N_SERVER \ 108 : 19 : && (conn)->ct_level_requested == S2N_CT_SUPPORT_REQUEST \ 109 : 19 : && (conn)->handshake_params.our_chain_and_key \ 110 : 19 : && (conn)->handshake_params.our_chain_and_key->sct_list.size > 0) 111 : : 112 : 118 : #define s2n_server_sending_nst(conn) ((conn)->config->use_tickets \ 113 : 118 : && (conn)->session_ticket_status == S2N_NEW_TICKET)