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 <s2n.h> 19 : : #include <stdint.h> 20 : : 21 : : /* This is a special value assigned to handshake_start_epoch_ns to indicate that 22 : : * it has already been sent to the application and should not be sent again. 23 : : */ 24 : 3 : #define HANDSHAKE_EVENT_SENT UINT64_C(1) << 63 25 : : 26 : : struct s2n_event_handshake { 27 : : /** 28 : : * The negotiated protocol version 29 : : * 30 : : * This will be one of the protocol version constants defined in s2n.h 31 : : */ 32 : : int protocol_version; 33 : : /* static memory */ 34 : : const char *cipher; 35 : : /* static memory */ 36 : : const char *group; 37 : : /* the amount of time inside the synchronous s2n_negotiate method */ 38 : : uint64_t handshake_time_ns; 39 : : /** 40 : : * The start of the handshake. This is not an interpretable time, and only has 41 : : * meaning in reference to handshake_end_ns. 42 : : * 43 : : * This is also used as a flag to ensure that the same event isn't emitted 44 : : * twice. After the event has been emitted this is set to HANDSHAKE_EVENT_SENT 45 : : */ 46 : : uint64_t handshake_start_ns; 47 : : uint64_t handshake_end_ns; 48 : : }; 49 : : 50 : : typedef void (*s2n_event_on_handshake_cb)(struct s2n_connection *conn, void *subscriber, struct s2n_event_handshake *event); 51 : : 52 : : S2N_API extern int s2n_config_set_subscriber(struct s2n_config *config, void *subscriber); 53 : : /** 54 : : * Set a callback to receive a handshake event. 55 : : * 56 : : * The `struct s2n_event_handshake *event` is only valid over the lifetime of the 57 : : * callbacks, and must not be reference after the callback returned. 58 : : * 59 : : * An event is not emitted if the handshake fails. 60 : : */ 61 : : S2N_API extern int s2n_config_set_handshake_event(struct s2n_config *config, s2n_event_on_handshake_cb callback);