tortls_internal.h (2434B)
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 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 22 tor_tls_context_t *tor_tls_context_new(crypto_pk_t *identity, 23 unsigned int key_lifetime, unsigned flags, int is_client); 24 int tor_tls_context_init_one(tor_tls_context_t **ppcontext, 25 crypto_pk_t *identity, 26 unsigned int key_lifetime, 27 unsigned int flags, 28 int is_client); 29 int tor_tls_context_init_certificates(tor_tls_context_t *result, 30 crypto_pk_t *identity, 31 unsigned key_lifetime, 32 unsigned flags); 33 void tor_tls_impl_free_(tor_tls_impl_t *ssl); 34 #define tor_tls_impl_free(tls) \ 35 FREE_AND_NULL(tor_tls_impl_t, tor_tls_impl_free_, (tls)) 36 37 void tor_tls_context_impl_free_(tor_tls_context_impl_t *); 38 #define tor_tls_context_impl_free(ctx) \ 39 FREE_AND_NULL(tor_tls_context_impl_t, tor_tls_context_impl_free_, (ctx)) 40 41 #ifdef ENABLE_OPENSSL 42 tor_tls_t *tor_tls_get_by_ssl(const struct ssl_st *ssl); 43 void tor_tls_debug_state_callback(const struct ssl_st *ssl, 44 int type, int val); 45 void tor_tls_server_info_callback(const struct ssl_st *ssl, 46 int type, int val); 47 void tor_tls_allocate_tor_tls_object_ex_data_index(void); 48 49 #ifdef TORTLS_OPENSSL_PRIVATE 50 int always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx); 51 #endif /* defined(TORTLS_OPENSSL_PRIVATE) */ 52 #endif /* defined(ENABLE_OPENSSL) */ 53 54 #ifdef TOR_UNIT_TESTS 55 extern int tor_tls_object_ex_data_index; 56 extern tor_tls_context_t *server_tls_context; 57 extern tor_tls_context_t *client_tls_context; 58 extern uint16_t v2_cipher_list[]; 59 extern uint64_t total_bytes_written_over_tls; 60 extern uint64_t total_bytes_written_by_tls; 61 #endif /* defined(TOR_UNIT_TESTS) */ 62 63 #endif /* !defined(TORTLS_INTERNAL_H) */