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 */
7 * @file tortls_internal.h
8 * @brief Declare internal functions for lib/tls
11 #ifndef TORTLS_INTERNAL_H
12 #define TORTLS_INTERNAL_H
14 #include "lib/tls/x509.h"
16 int tor_errno_to_tls_error(int e
);
18 int tor_tls_get_error(tor_tls_t
*tls
, int r
, int extra
,
19 const char *doing
, int severity
, int domain
);
21 MOCK_DECL(void, try_to_extract_certs_from_tls
,
22 (int severity
, tor_tls_t
*tls
,
23 tor_x509_cert_impl_t
**cert_out
,
24 tor_x509_cert_impl_t
**id_cert_out
));
26 tor_tls_context_t
*tor_tls_context_new(crypto_pk_t
*identity
,
27 unsigned int key_lifetime
, unsigned flags
, int is_client
);
28 int tor_tls_context_init_one(tor_tls_context_t
**ppcontext
,
29 crypto_pk_t
*identity
,
30 unsigned int key_lifetime
,
33 int tor_tls_context_init_certificates(tor_tls_context_t
*result
,
34 crypto_pk_t
*identity
,
35 unsigned key_lifetime
,
37 void tor_tls_impl_free_(tor_tls_impl_t
*ssl
);
38 #define tor_tls_impl_free(tls) \
39 FREE_AND_NULL(tor_tls_impl_t, tor_tls_impl_free_, (tls))
41 void tor_tls_context_impl_free_(tor_tls_context_impl_t
*);
42 #define tor_tls_context_impl_free(ctx) \
43 FREE_AND_NULL(tor_tls_context_impl_t, tor_tls_context_impl_free_, (ctx))
46 tor_tls_t
*tor_tls_get_by_ssl(const struct ssl_st
*ssl
);
47 int tor_tls_client_is_using_v2_ciphers(const struct ssl_st
*ssl
);
48 void tor_tls_debug_state_callback(const struct ssl_st
*ssl
,
50 void tor_tls_server_info_callback(const struct ssl_st
*ssl
,
52 void tor_tls_allocate_tor_tls_object_ex_data_index(void);
54 #if !defined(HAVE_SSL_SESSION_GET_MASTER_KEY)
55 size_t SSL_SESSION_get_master_key(struct ssl_session_st
*s
,
60 #ifdef TORTLS_OPENSSL_PRIVATE
61 int always_accept_verify_cb(int preverify_ok
, X509_STORE_CTX
*x509_ctx
);
62 int tor_tls_classify_client_ciphers(const struct ssl_st
*ssl
,
63 STACK_OF(SSL_CIPHER
) *peer_ciphers
);
64 STATIC
int tor_tls_session_secret_cb(struct ssl_st
*ssl
, void *secret
,
66 STACK_OF(SSL_CIPHER
) *peer_ciphers
,
67 CONST_IF_OPENSSL_1_1_API SSL_CIPHER
**cipher
,
69 STATIC
int find_cipher_by_id(const SSL
*ssl
, const SSL_METHOD
*m
,
71 #endif /* defined(TORTLS_OPENSSL_PRIVATE) */
72 #endif /* defined(ENABLE_OPENSSL) */
75 extern int tor_tls_object_ex_data_index
;
76 extern tor_tls_context_t
*server_tls_context
;
77 extern tor_tls_context_t
*client_tls_context
;
78 extern uint16_t v2_cipher_list
[];
79 extern uint64_t total_bytes_written_over_tls
;
80 extern uint64_t total_bytes_written_by_tls
;
81 #endif /* defined(TOR_UNIT_TESTS) */
83 #endif /* !defined(TORTLS_INTERNAL_H) */