tor  0.4.2.0-alpha-dev
tortls_internal.h
1 /* Copyright (c) 2003, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
6 #ifndef TORTLS_INTERNAL_H
7 #define TORTLS_INTERNAL_H
8 
9 int tor_errno_to_tls_error(int e);
10 #ifdef ENABLE_OPENSSL
11 int tor_tls_get_error(tor_tls_t *tls, int r, int extra,
12  const char *doing, int severity, int domain);
13 #endif
14 MOCK_DECL(void, try_to_extract_certs_from_tls,
15  (int severity, tor_tls_t *tls,
16  tor_x509_cert_impl_t **cert_out,
17  tor_x509_cert_impl_t **id_cert_out));
18 
19 tor_tls_context_t *tor_tls_context_new(crypto_pk_t *identity,
20  unsigned int key_lifetime, unsigned flags, int is_client);
22  crypto_pk_t *identity,
23  unsigned int key_lifetime,
24  unsigned int flags,
25  int is_client);
27  crypto_pk_t *identity,
28  unsigned key_lifetime,
29  unsigned flags);
30 void tor_tls_impl_free_(tor_tls_impl_t *ssl);
31 #define tor_tls_impl_free(tls) \
32  FREE_AND_NULL(tor_tls_impl_t, tor_tls_impl_free_, (tls))
33 
34 void tor_tls_context_impl_free_(tor_tls_context_impl_t *);
35 #define tor_tls_context_impl_free(ctx) \
36  FREE_AND_NULL(tor_tls_context_impl_t, tor_tls_context_impl_free_, (ctx))
37 
38 #ifdef ENABLE_OPENSSL
39 tor_tls_t *tor_tls_get_by_ssl(const struct ssl_st *ssl);
40 int tor_tls_client_is_using_v2_ciphers(const struct ssl_st *ssl);
41 void tor_tls_debug_state_callback(const struct ssl_st *ssl,
42  int type, int val);
43 void tor_tls_server_info_callback(const struct ssl_st *ssl,
44  int type, int val);
45 void tor_tls_allocate_tor_tls_object_ex_data_index(void);
46 
47 #if !defined(HAVE_SSL_SESSION_GET_MASTER_KEY)
48 size_t SSL_SESSION_get_master_key(struct ssl_session_st *s,
49  uint8_t *out,
50  size_t len);
51 #endif
52 
53 #ifdef TORTLS_OPENSSL_PRIVATE
54 int always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx);
55 int tor_tls_classify_client_ciphers(const struct ssl_st *ssl,
56  STACK_OF(SSL_CIPHER) *peer_ciphers);
57 STATIC int tor_tls_session_secret_cb(struct ssl_st *ssl, void *secret,
58  int *secret_len,
59  STACK_OF(SSL_CIPHER) *peer_ciphers,
60  CONST_IF_OPENSSL_1_1_API SSL_CIPHER **cipher,
61  void *arg);
62 STATIC int find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m,
63  uint16_t cipher);
64 #endif /* defined(TORTLS_OPENSSL_PRIVATE) */
65 #endif /* defined(ENABLE_OPENSSL) */
66 
67 #ifdef TOR_UNIT_TESTS
68 extern int tor_tls_object_ex_data_index;
70 extern tor_tls_context_t *client_tls_context;
71 extern uint16_t v2_cipher_list[];
72 extern uint64_t total_bytes_written_over_tls;
73 extern uint64_t total_bytes_written_by_tls;
74 #endif /* defined(TOR_UNIT_TESTS) */
75 
76 #endif /* !defined(TORTLS_INTERNAL_H) */
STATIC tor_tls_context_t * server_tls_context
Definition: tortls.c:32
int tor_errno_to_tls_error(int e)
Definition: tortls.c:48
int tor_tls_context_init_certificates(tor_tls_context_t *result, crypto_pk_t *identity, unsigned key_lifetime, unsigned flags)
Definition: tortls.c:287
int tor_tls_context_init_one(tor_tls_context_t **ppcontext, crypto_pk_t *identity, unsigned int key_lifetime, unsigned int flags, int is_client)
Definition: tortls.c:249
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94