Tor 0.4.9.0-alpha-dev
tortls_internal.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/**
7 * @file tortls_internal.h
8 * @brief Declare internal functions for lib/tls
9 **/
10
11#ifndef TORTLS_INTERNAL_H
12#define TORTLS_INTERNAL_H
13
14#include "lib/tls/x509.h"
15
16int tor_errno_to_tls_error(int e);
17#ifdef ENABLE_OPENSSL
18int tor_tls_get_error(tor_tls_t *tls, int r, int extra,
19 const char *doing, int severity, int domain);
20#endif
21MOCK_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));
25
27 unsigned int key_lifetime, unsigned flags, int is_client);
29 crypto_pk_t *identity,
30 unsigned int key_lifetime,
31 unsigned int flags,
32 int is_client);
34 crypto_pk_t *identity,
35 unsigned key_lifetime,
36 unsigned flags);
37void 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))
40
41void 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))
44
45#ifdef ENABLE_OPENSSL
46tor_tls_t *tor_tls_get_by_ssl(const struct ssl_st *ssl);
47int tor_tls_client_is_using_v2_ciphers(const struct ssl_st *ssl);
48void tor_tls_debug_state_callback(const struct ssl_st *ssl,
49 int type, int val);
50void tor_tls_server_info_callback(const struct ssl_st *ssl,
51 int type, int val);
52void tor_tls_allocate_tor_tls_object_ex_data_index(void);
53
54#if !defined(HAVE_SSL_SESSION_GET_MASTER_KEY)
55size_t SSL_SESSION_get_master_key(struct ssl_session_st *s,
56 uint8_t *out,
57 size_t len);
58#endif
59
60#ifdef TORTLS_OPENSSL_PRIVATE
61int always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx);
62int tor_tls_classify_client_ciphers(const struct ssl_st *ssl,
63 STACK_OF(SSL_CIPHER) *peer_ciphers);
64STATIC 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);
69STATIC 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) */
73
74#ifdef TOR_UNIT_TESTS
75extern int tor_tls_object_ex_data_index;
77extern tor_tls_context_t *client_tls_context;
78extern uint16_t v2_cipher_list[];
79extern uint64_t total_bytes_written_over_tls;
80extern uint64_t total_bytes_written_by_tls;
81#endif /* defined(TOR_UNIT_TESTS) */
82
83#endif /* !defined(TORTLS_INTERNAL_H) */
#define STATIC
Definition: testsupport.h:32
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127
STATIC tor_tls_context_t * server_tls_context
Definition: tortls.c:37
int tor_errno_to_tls_error(int e)
Definition: tortls.c:53
int tor_tls_context_init_certificates(tor_tls_context_t *result, crypto_pk_t *identity, unsigned key_lifetime, unsigned flags)
Definition: tortls.c:292
tor_tls_context_t * tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime, unsigned flags, int is_client)
Definition: tortls_nss.c:182
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:254
Headers for tortls.c.