Merge branch 'tor-gitlab/mr/583' into maint-0.4.7
[tor.git] / src / lib / tls / tortls_internal.h
bloba4c6b87cac98628b5f7d5aa29ccf7e26c505a40f
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 */
6 /**
7 * @file tortls_internal.h
8 * @brief Declare internal functions for lib/tls
9 **/
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);
17 #ifdef ENABLE_OPENSSL
18 int tor_tls_get_error(tor_tls_t *tls, int r, int extra,
19 const char *doing, int severity, int domain);
20 #endif
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,
31 unsigned int flags,
32 int is_client);
33 int tor_tls_context_init_certificates(tor_tls_context_t *result,
34 crypto_pk_t *identity,
35 unsigned key_lifetime,
36 unsigned flags);
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))
45 #ifdef ENABLE_OPENSSL
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,
49 int type, int val);
50 void tor_tls_server_info_callback(const struct ssl_st *ssl,
51 int type, int val);
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,
56 uint8_t *out,
57 size_t len);
58 #endif
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,
65 int *secret_len,
66 STACK_OF(SSL_CIPHER) *peer_ciphers,
67 CONST_IF_OPENSSL_1_1_API SSL_CIPHER **cipher,
68 void *arg);
69 STATIC int find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m,
70 uint16_t cipher);
71 #endif /* defined(TORTLS_OPENSSL_PRIVATE) */
72 #endif /* defined(ENABLE_OPENSSL) */
74 #ifdef TOR_UNIT_TESTS
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) */