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 "utils/s2n_result.h" 19 : : 20 : : /* Maximum number of valid handshakes */ 21 : : #define S2N_HANDSHAKES_COUNT 256 22 : : 23 : : #define IS_NEGOTIATED(conn) \ 24 : 3309714 : (s2n_handshake_type_check_flag(conn, NEGOTIATED)) 25 : : 26 : : #define IS_FULL_HANDSHAKE(conn) \ 27 : 7581 : (s2n_handshake_type_check_flag(conn, FULL_HANDSHAKE)) 28 : : 29 : : #define IS_RESUMPTION_HANDSHAKE(conn) \ 30 : 7554 : (!IS_FULL_HANDSHAKE(conn) && IS_NEGOTIATED(conn)) 31 : : 32 : : #define IS_CLIENT_AUTH_HANDSHAKE(conn) \ 33 : 624 : (s2n_handshake_type_check_flag(conn, CLIENT_AUTH)) 34 : : 35 : : #define IS_CLIENT_AUTH_NO_CERT(conn) \ 36 : 132 : (IS_CLIENT_AUTH_HANDSHAKE(conn) && s2n_handshake_type_check_flag(conn, NO_CLIENT_CERT)) 37 : : 38 : : #define IS_TLS12_PERFECT_FORWARD_SECRECY_HANDSHAKE(conn) \ 39 : : (s2n_handshake_type_check_tls12_flag(conn, TLS12_PERFECT_FORWARD_SECRECY)) 40 : : 41 : : #define IS_OCSP_STAPLED(conn) \ 42 : 8 : (s2n_handshake_type_check_tls12_flag(conn, OCSP_STATUS)) 43 : : 44 : : #define IS_ISSUING_NEW_SESSION_TICKET(conn) \ 45 : : (s2n_handshake_type_check_tls12_flag(conn, WITH_SESSION_TICKET)) 46 : : 47 : : #define IS_NPN_HANDSHAKE(conn) \ 48 : : (s2n_handshake_type_check_tls12_flag(conn, WITH_NPN)) 49 : : 50 : : #define IS_HELLO_RETRY_HANDSHAKE(conn) \ 51 : 94196 : (s2n_handshake_type_check_tls13_flag(conn, HELLO_RETRY_REQUEST)) 52 : : 53 : : #define IS_MIDDLEBOX_COMPAT_MODE(conn) \ 54 : : (s2n_handshake_type_check_tls13_flag(conn, MIDDLEBOX_COMPAT)) 55 : : 56 : : #define WITH_EARLY_DATA(conn) \ 57 : 6394 : (s2n_handshake_type_check_tls13_flag(conn, WITH_EARLY_DATA)) 58 : : 59 : : #define WITH_EARLY_CLIENT_CCS(conn) \ 60 : : (s2n_handshake_type_check_tls13_flag(conn, EARLY_CLIENT_CCS)) 61 : : 62 : : typedef enum { 63 : : INITIAL = 0, 64 : : NEGOTIATED = 1, 65 : : FULL_HANDSHAKE = 2, 66 : : CLIENT_AUTH = 4, 67 : : NO_CLIENT_CERT = 8, 68 : : } s2n_handshake_type_flag; 69 : : 70 : : S2N_RESULT s2n_handshake_type_set_flag(struct s2n_connection *conn, s2n_handshake_type_flag flag); 71 : : bool s2n_handshake_type_check_flag(struct s2n_connection *conn, s2n_handshake_type_flag flag); 72 : : 73 : : typedef enum { 74 : : TLS12_PERFECT_FORWARD_SECRECY = 16, 75 : : OCSP_STATUS = 32, 76 : : WITH_SESSION_TICKET = 64, 77 : : WITH_NPN = 128, 78 : : } s2n_tls12_handshake_type_flag; 79 : : 80 : : S2N_RESULT s2n_handshake_type_set_tls12_flag(struct s2n_connection *conn, s2n_tls12_handshake_type_flag flag); 81 : : S2N_RESULT s2n_handshake_type_unset_tls12_flag(struct s2n_connection *conn, s2n_tls12_handshake_type_flag flag); 82 : : bool s2n_handshake_type_check_tls12_flag(struct s2n_connection *conn, s2n_tls12_handshake_type_flag flag); 83 : : 84 : : typedef enum { 85 : : HELLO_RETRY_REQUEST = 16, 86 : : MIDDLEBOX_COMPAT = 32, 87 : : WITH_EARLY_DATA = 64, 88 : : EARLY_CLIENT_CCS = 128, 89 : : } s2n_tls13_handshake_type_flag; 90 : : 91 : : S2N_RESULT s2n_handshake_type_set_tls13_flag(struct s2n_connection *conn, s2n_tls13_handshake_type_flag flag); 92 : : bool s2n_handshake_type_check_tls13_flag(struct s2n_connection *conn, s2n_tls13_handshake_type_flag flag); 93 : : 94 : : S2N_RESULT s2n_handshake_type_reset(struct s2n_connection *conn);