tortls_internal.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright (c) 2003, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. #ifndef TORTLS_INTERNAL_H
  6. #define TORTLS_INTERNAL_H
  7. #ifdef ENABLE_OPENSSL
  8. struct ssl_st;
  9. struct ssl_ctx_st;
  10. struct ssl_session_st;
  11. #endif
  12. int tor_errno_to_tls_error(int e);
  13. int tor_tls_get_error(tor_tls_t *tls, int r, int extra,
  14. const char *doing, int severity, int domain);
  15. MOCK_DECL(void, try_to_extract_certs_from_tls,
  16. (int severity, tor_tls_t *tls,
  17. tor_x509_cert_impl_t **cert_out,
  18. tor_x509_cert_impl_t **id_cert_out));
  19. tor_tls_context_t *tor_tls_context_new(crypto_pk_t *identity,
  20. unsigned int key_lifetime, unsigned flags, int is_client);
  21. int tor_tls_context_init_one(tor_tls_context_t **ppcontext,
  22. crypto_pk_t *identity,
  23. unsigned int key_lifetime,
  24. unsigned int flags,
  25. int is_client);
  26. #ifdef ENABLE_OPENSSL
  27. tor_tls_t *tor_tls_get_by_ssl(const struct ssl_st *ssl);
  28. int tor_tls_client_is_using_v2_ciphers(const struct ssl_st *ssl);
  29. void tor_tls_debug_state_callback(const struct ssl_st *ssl,
  30. int type, int val);
  31. void tor_tls_server_info_callback(const struct ssl_st *ssl,
  32. int type, int val);
  33. void tor_tls_allocate_tor_tls_object_ex_data_index(void);
  34. #if !defined(HAVE_SSL_SESSION_GET_MASTER_KEY)
  35. size_t SSL_SESSION_get_master_key(struct ssl_session_st *s,
  36. uint8_t *out,
  37. size_t len);
  38. #endif
  39. #ifdef TORTLS_OPENSSL_PRIVATE
  40. int always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx);
  41. int tor_tls_classify_client_ciphers(const struct ssl_st *ssl,
  42. STACK_OF(SSL_CIPHER) *peer_ciphers);
  43. STATIC int tor_tls_session_secret_cb(struct ssl_st *ssl, void *secret,
  44. int *secret_len,
  45. STACK_OF(SSL_CIPHER) *peer_ciphers,
  46. CONST_IF_OPENSSL_1_1_API SSL_CIPHER **cipher,
  47. void *arg);
  48. STATIC int find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m,
  49. uint16_t cipher);
  50. #endif
  51. #endif
  52. #ifdef TOR_UNIT_TESTS
  53. extern int tor_tls_object_ex_data_index;
  54. extern tor_tls_context_t *server_tls_context;
  55. extern tor_tls_context_t *client_tls_context;
  56. extern uint16_t v2_cipher_list[];
  57. extern uint64_t total_bytes_written_over_tls;
  58. extern uint64_t total_bytes_written_by_tls;
  59. #endif /* defined(TOR_UNIT_TESTS) */
  60. #endif /* defined(TORTLS_INTERNAL_H) */