1 /* * Copyright (c) 2012-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
6 * \brief Header file for channeltls.c
9 #ifndef TOR_CHANNELTLS_H
10 #define TOR_CHANNELTLS_H
12 #include "core/or/or.h"
13 #include "core/or/channel.h"
15 struct ed25519_public_key_t
;
16 struct curve25519_public_key_t
;
18 #define TLS_PER_CELL_OVERHEAD 29
20 #define BASE_CHAN_TO_TLS(c) (channel_tls_from_base((c)))
21 #define TLS_CHAN_TO_BASE(c) (channel_tls_to_base((c)))
22 #define CONST_BASE_CHAN_TO_TLS(c) (channel_tls_from_base_const((c)))
23 #define CONST_TLS_CHAN_TO_BASE(c) (channel_tls_to_base_const((c)))
25 #define TLS_CHAN_MAGIC 0x8a192427U
27 #ifdef CHANNEL_OBJECT_PRIVATE
29 struct channel_tls_t
{
30 /* Base channel_t struct */
32 /* or_connection_t pointer */
33 or_connection_t
*conn
;
36 #endif /* defined(CHANNEL_OBJECT_PRIVATE) */
38 channel_t
* channel_tls_connect(const tor_addr_t
*addr
, uint16_t port
,
39 const char *id_digest
,
40 const struct ed25519_public_key_t
*ed_id
);
41 channel_listener_t
* channel_tls_get_listener(void);
42 channel_listener_t
* channel_tls_start_listener(void);
43 channel_t
* channel_tls_handle_incoming(or_connection_t
*orconn
);
47 channel_t
* channel_tls_to_base(channel_tls_t
*tlschan
);
48 channel_tls_t
* channel_tls_from_base(channel_t
*chan
);
49 const channel_t
* channel_tls_to_base_const(const channel_tls_t
*tlschan
);
50 const channel_tls_t
* channel_tls_from_base_const(const channel_t
*chan
);
52 /* Things for connection_or.c to call back into */
53 void channel_tls_handle_cell(cell_t
*cell
, or_connection_t
*conn
);
54 void channel_tls_handle_state_change_on_orconn(channel_tls_t
*chan
,
55 or_connection_t
*conn
,
57 void channel_tls_handle_var_cell(var_cell_t
*var_cell
,
58 or_connection_t
*conn
);
59 void channel_tls_update_marks(or_connection_t
*conn
);
61 /* Cleanup at shutdown */
62 void channel_tls_free_all(void);
64 extern uint64_t stats_n_authorize_cells_processed
;
65 extern uint64_t stats_n_authenticate_cells_processed
;
66 extern uint64_t stats_n_versions_cells_processed
;
67 extern uint64_t stats_n_netinfo_cells_processed
;
68 extern uint64_t stats_n_vpadding_cells_processed
;
69 extern uint64_t stats_n_certs_cells_processed
;
70 extern uint64_t stats_n_auth_challenge_cells_processed
;
72 #ifdef CHANNELTLS_PRIVATE
73 STATIC
void channel_tls_process_certs_cell(var_cell_t
*cell
,
74 channel_tls_t
*tlschan
);
75 STATIC
void channel_tls_process_auth_challenge_cell(var_cell_t
*cell
,
76 channel_tls_t
*tlschan
);
77 STATIC
void channel_tls_common_init(channel_tls_t
*tlschan
);
78 STATIC
void channel_tls_process_authenticate_cell(var_cell_t
*cell
,
79 channel_tls_t
*tlschan
);
80 #endif /* defined(CHANNELTLS_PRIVATE) */
82 #endif /* !defined(TOR_CHANNELTLS_H) */