Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
tortls_st.h
Go to the documentation of this file.
1/* Copyright (c) 2003, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2021, The Tor Project, Inc. */
4/* See LICENSE for licensing information */
5
6#ifndef TOR_TORTLS_ST_H
7#define TOR_TORTLS_ST_H
8
9/**
10 * @file tortls_st.h
11 * @brief Structure declarations for internal TLS types.
12 *
13 * These should generally be treated as opaque outside of the
14 * lib/tls module.
15 **/
16
17#include "lib/net/socket.h"
18
19#define TOR_TLS_MAGIC 0x71571571
20
21typedef enum {
22 TOR_TLS_ST_HANDSHAKE, TOR_TLS_ST_OPEN, TOR_TLS_ST_GOTCLOSE,
23 TOR_TLS_ST_SENTCLOSE, TOR_TLS_ST_CLOSED, TOR_TLS_ST_RENEGOTIATE,
24 TOR_TLS_ST_BUFFEREVENT
25} tor_tls_state_t;
26#define tor_tls_state_bitfield_t ENUM_BF(tor_tls_state_t)
27
29 int refcnt;
30 tor_tls_context_impl_t *ctx;
31 struct tor_x509_cert_t *my_link_cert;
32 struct tor_x509_cert_t *my_id_cert;
33 struct tor_x509_cert_t *my_auth_cert;
34 crypto_pk_t *link_key;
35 crypto_pk_t *auth_key;
36};
37
38/** Holds a SSL object and its associated data. Members are only
39 * accessed from within tortls.c.
40 */
41struct tor_tls_t {
42 uint32_t magic;
43 tor_tls_context_t *context; /** A link to the context object for this tls. */
44 tor_tls_impl_t *ssl; /**< An OpenSSL SSL object or NSS PRFileDesc. */
45 tor_socket_t socket; /**< The underlying file descriptor for this TLS
46 * connection. */
47 char *address; /**< An address to log when describing this connection. */
48 tor_tls_state_bitfield_t state : 3; /**< The current SSL state,
49 * depending on which operations
50 * have completed successfully. */
51 unsigned int isServer:1; /**< True iff this is a server-side connection */
52#ifdef ENABLE_OPENSSL
53 /** Return value from tor_tls_classify_client_ciphers, or 0 if we haven't
54 * called that function yet. */
55 int8_t client_cipher_list_type;
56 size_t wantwrite_n; /**< 0 normally, >0 if we returned wantwrite last
57 * time. */
58 /** Last values retrieved from BIO_number_read()/write(); see
59 * tor_tls_get_n_raw_bytes() for usage.
60 */
61 unsigned long last_write_count;
62 unsigned long last_read_count;
63 /** Most recent error value from ERR_get_error(). */
64 unsigned long last_error;
65 /** If set, a callback to invoke whenever the client tries to renegotiate
66 * the handshake. */
67 void (*negotiated_callback)(tor_tls_t *tls, void *arg);
68 /** Argument to pass to negotiated_callback. */
69 void *callback_arg;
70#endif /* defined(ENABLE_OPENSSL) */
71#ifdef ENABLE_NSS
72 /** Last values retried from tor_get_prfiledesc_byte_counts(). */
73 uint64_t last_write_count;
74 uint64_t last_read_count;
75 long last_error;
76#endif /* defined(ENABLE_NSS) */
77};
78
79#endif /* !defined(TOR_TORTLS_ST_H) */
#define tor_socket_t
Definition: nettypes.h:36
Header for socket.c.
tor_tls_state_bitfield_t state
Definition: tortls_st.h:48
unsigned int isServer
Definition: tortls_st.h:51
char * address
Definition: tortls_st.h:47
tor_tls_impl_t * ssl
Definition: tortls_st.h:44
tor_socket_t socket
Definition: tortls_st.h:45