tortls_internal.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. int tor_errno_to_tls_error(int e);
  8. #ifdef ENABLE_OPENSSL
  9. int tor_tls_get_error(tor_tls_t *tls, int r, int extra,
  10. const char *doing, int severity, int domain);
  11. #endif
  12. MOCK_DECL(void, try_to_extract_certs_from_tls,
  13. (int severity, tor_tls_t *tls,
  14. tor_x509_cert_impl_t **cert_out,
  15. tor_x509_cert_impl_t **id_cert_out));
  16. tor_tls_context_t *tor_tls_context_new(crypto_pk_t *identity,
  17. unsigned int key_lifetime, unsigned flags, int is_client);
  18. int tor_tls_context_init_one(tor_tls_context_t **ppcontext,
  19. crypto_pk_t *identity,
  20. unsigned int key_lifetime,
  21. unsigned int flags,
  22. int is_client);
  23. int tor_tls_context_init_certificates(tor_tls_context_t *result,
  24. crypto_pk_t *identity,
  25. unsigned key_lifetime,
  26. unsigned flags);
  27. void tor_tls_impl_free_(tor_tls_impl_t *ssl);
  28. #define tor_tls_impl_free(tls) \
  29. FREE_AND_NULL(tor_tls_impl_t, tor_tls_impl_free_, (tls))
  30. void tor_tls_context_impl_free_(tor_tls_context_impl_t *);
  31. #define tor_tls_context_impl_free(ctx) \
  32. FREE_AND_NULL(tor_tls_context_impl_t, tor_tls_context_impl_free_, (ctx))
  33. #ifdef ENABLE_OPENSSL
  34. tor_tls_t *tor_tls_get_by_ssl(const struct ssl_st *ssl);
  35. int tor_tls_client_is_using_v2_ciphers(const struct ssl_st *ssl);
  36. void tor_tls_debug_state_callback(const struct ssl_st *ssl,
  37. int type, int val);
  38. void tor_tls_server_info_callback(const struct ssl_st *ssl,
  39. int type, int val);
  40. void tor_tls_allocate_tor_tls_object_ex_data_index(void);
  41. #if !defined(HAVE_SSL_SESSION_GET_MASTER_KEY)
  42. size_t SSL_SESSION_get_master_key(struct ssl_session_st *s,
  43. uint8_t *out,
  44. size_t len);
  45. #endif
  46. #ifdef TORTLS_OPENSSL_PRIVATE
  47. int always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx);
  48. int tor_tls_classify_client_ciphers(const struct ssl_st *ssl,
  49. STACK_OF(SSL_CIPHER) *peer_ciphers);
  50. STATIC int tor_tls_session_secret_cb(struct ssl_st *ssl, void *secret,
  51. int *secret_len,
  52. STACK_OF(SSL_CIPHER) *peer_ciphers,
  53. CONST_IF_OPENSSL_1_1_API SSL_CIPHER **cipher,
  54. void *arg);
  55. STATIC int find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m,
  56. uint16_t cipher);
  57. #endif
  58. #endif
  59. #ifdef TOR_UNIT_TESTS
  60. extern int tor_tls_object_ex_data_index;
  61. extern tor_tls_context_t *server_tls_context;
  62. extern tor_tls_context_t *client_tls_context;
  63. extern uint16_t v2_cipher_list[];
  64. extern uint64_t total_bytes_written_over_tls;
  65. extern uint64_t total_bytes_written_by_tls;
  66. #endif /* defined(TOR_UNIT_TESTS) */
  67. #endif /* defined(TORTLS_INTERNAL_H) */