tortls_internal.h 2.9 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. #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. void tor_tls_context_impl_free(struct ssl_ctx_st *);
  28. #else
  29. struct ssl_ctx_st; // XXXX replace
  30. void tor_tls_context_impl_free(struct ssl_ctx_st *);
  31. #endif
  32. #ifdef ENABLE_OPENSSL
  33. tor_tls_t *tor_tls_get_by_ssl(const struct ssl_st *ssl);
  34. int tor_tls_client_is_using_v2_ciphers(const struct ssl_st *ssl);
  35. void tor_tls_debug_state_callback(const struct ssl_st *ssl,
  36. int type, int val);
  37. void tor_tls_server_info_callback(const struct ssl_st *ssl,
  38. int type, int val);
  39. void tor_tls_allocate_tor_tls_object_ex_data_index(void);
  40. #if !defined(HAVE_SSL_SESSION_GET_MASTER_KEY)
  41. size_t SSL_SESSION_get_master_key(struct ssl_session_st *s,
  42. uint8_t *out,
  43. size_t len);
  44. #endif
  45. #ifdef TORTLS_OPENSSL_PRIVATE
  46. int always_accept_verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx);
  47. int tor_tls_classify_client_ciphers(const struct ssl_st *ssl,
  48. STACK_OF(SSL_CIPHER) *peer_ciphers);
  49. STATIC int tor_tls_session_secret_cb(struct ssl_st *ssl, void *secret,
  50. int *secret_len,
  51. STACK_OF(SSL_CIPHER) *peer_ciphers,
  52. CONST_IF_OPENSSL_1_1_API SSL_CIPHER **cipher,
  53. void *arg);
  54. STATIC int find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m,
  55. uint16_t cipher);
  56. #endif
  57. #endif
  58. #ifdef TOR_UNIT_TESTS
  59. extern int tor_tls_object_ex_data_index;
  60. extern tor_tls_context_t *server_tls_context;
  61. extern tor_tls_context_t *client_tls_context;
  62. extern uint16_t v2_cipher_list[];
  63. extern uint64_t total_bytes_written_over_tls;
  64. extern uint64_t total_bytes_written_by_tls;
  65. #endif /* defined(TOR_UNIT_TESTS) */
  66. #endif /* defined(TORTLS_INTERNAL_H) */