Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

191 рядки
6.4 KiB

  1. /* Copyright (c) 2014, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #ifndef HEADER_TEST_CONFIG
  15. #define HEADER_TEST_CONFIG
  16. #include <string>
  17. #include <vector>
  18. #include <openssl/base.h>
  19. #include <openssl/x509.h>
  20. #include "test_state.h"
  21. struct TestConfig {
  22. int port = 0;
  23. bool is_server = false;
  24. bool is_dtls = false;
  25. int resume_count = 0;
  26. std::string write_settings;
  27. bool fallback_scsv = false;
  28. std::vector<int> signing_prefs;
  29. std::vector<int> verify_prefs;
  30. std::vector<int> expected_peer_verify_prefs;
  31. std::string key_file;
  32. std::string cert_file;
  33. std::string expected_server_name;
  34. std::string expected_certificate_types;
  35. bool require_any_client_certificate = false;
  36. std::string advertise_npn;
  37. std::string expected_next_proto;
  38. bool false_start = false;
  39. std::string select_next_proto;
  40. bool async = false;
  41. bool write_different_record_sizes = false;
  42. bool cbc_record_splitting = false;
  43. bool partial_write = false;
  44. bool no_tls13 = false;
  45. bool no_tls12 = false;
  46. bool no_tls11 = false;
  47. bool no_tls1 = false;
  48. bool no_ticket = false;
  49. std::string expected_channel_id;
  50. bool enable_channel_id = false;
  51. std::string send_channel_id;
  52. int expected_token_binding_param = -1;
  53. std::string send_token_binding_params;
  54. bool shim_writes_first = false;
  55. std::string host_name;
  56. std::string advertise_alpn;
  57. std::string expected_alpn;
  58. std::string expected_late_alpn;
  59. std::string expected_advertised_alpn;
  60. std::string select_alpn;
  61. bool decline_alpn = false;
  62. bool select_empty_alpn = false;
  63. std::string quic_transport_params;
  64. std::string expected_quic_transport_params;
  65. bool expect_session_miss = false;
  66. bool expect_extended_master_secret = false;
  67. std::string psk;
  68. std::string psk_identity;
  69. std::string srtp_profiles;
  70. bool enable_ocsp_stapling = false;
  71. std::string expected_ocsp_response;
  72. bool enable_signed_cert_timestamps = false;
  73. std::string expected_signed_cert_timestamps;
  74. int min_version = 0;
  75. int max_version = 0;
  76. int expect_version = 0;
  77. int mtu = 0;
  78. bool implicit_handshake = false;
  79. bool use_early_callback = false;
  80. bool fail_early_callback = false;
  81. bool install_ddos_callback = false;
  82. bool fail_ddos_callback = false;
  83. bool fail_cert_callback = false;
  84. std::string cipher;
  85. bool handshake_never_done = false;
  86. int export_early_keying_material = 0;
  87. int export_keying_material = 0;
  88. std::string export_label;
  89. std::string export_context;
  90. bool use_export_context = false;
  91. bool tls_unique = false;
  92. bool expect_ticket_renewal = false;
  93. bool expect_no_session = false;
  94. bool expect_ticket_supports_early_data = false;
  95. bool expect_accept_early_data = false;
  96. bool expect_reject_early_data = false;
  97. bool expect_no_offer_early_data = false;
  98. bool use_ticket_callback = false;
  99. bool renew_ticket = false;
  100. bool enable_early_data = false;
  101. int tls13_variant = 0;
  102. bool enable_client_custom_extension = false;
  103. bool enable_server_custom_extension = false;
  104. bool custom_extension_skip = false;
  105. bool custom_extension_fail_add = false;
  106. std::string ocsp_response;
  107. bool check_close_notify = false;
  108. bool shim_shuts_down = false;
  109. bool verify_fail = false;
  110. bool verify_peer = false;
  111. bool verify_peer_if_no_obc = false;
  112. bool expect_verify_result = false;
  113. std::string signed_cert_timestamps;
  114. int expect_total_renegotiations = 0;
  115. bool renegotiate_once = false;
  116. bool renegotiate_freely = false;
  117. bool renegotiate_ignore = false;
  118. bool forbid_renegotiation_after_handshake = false;
  119. int expect_peer_signature_algorithm = 0;
  120. bool p384_only = false;
  121. bool enable_all_curves = false;
  122. int expect_curve_id = 0;
  123. bool use_old_client_cert_callback = false;
  124. int initial_timeout_duration_ms = 0;
  125. std::string use_client_ca_list;
  126. std::string expected_client_ca_list;
  127. bool send_alert = false;
  128. bool peek_then_read = false;
  129. bool enable_grease = false;
  130. int max_cert_list = 0;
  131. std::string ticket_key;
  132. bool use_exporter_between_reads = false;
  133. int expect_cipher_aes = 0;
  134. int expect_cipher_no_aes = 0;
  135. std::string expect_peer_cert_file;
  136. int resumption_delay = 0;
  137. bool retain_only_sha256_client_cert = false;
  138. bool expect_sha256_client_cert = false;
  139. bool read_with_unfinished_write = false;
  140. bool expect_secure_renegotiation = false;
  141. bool expect_no_secure_renegotiation = false;
  142. int max_send_fragment = 0;
  143. int read_size = 0;
  144. bool expect_session_id = false;
  145. bool expect_no_session_id = false;
  146. int expect_ticket_age_skew = 0;
  147. bool no_op_extra_handshake = false;
  148. bool handshake_twice = false;
  149. bool allow_unknown_alpn_protos = false;
  150. bool enable_ed25519 = false;
  151. bool use_custom_verify_callback = false;
  152. std::string expect_msg_callback;
  153. bool allow_false_start_without_alpn = false;
  154. bool expect_draft_downgrade = false;
  155. int dummy_pq_padding_len = 0;
  156. bool handoff = false;
  157. bool expect_dummy_pq_padding = false;
  158. bool no_rsa_pss_rsae_certs = false;
  159. bool use_ocsp_callback = false;
  160. bool set_ocsp_in_callback = false;
  161. bool decline_ocsp_callback = false;
  162. bool fail_ocsp_callback = false;
  163. bool install_cert_compression_algs = false;
  164. bssl::UniquePtr<SSL_CTX> SetupCtx(SSL_CTX *old_ctx) const;
  165. bssl::UniquePtr<SSL> NewSSL(SSL_CTX *ssl_ctx, SSL_SESSION *session,
  166. bool is_resume,
  167. std::unique_ptr<TestState> test_state) const;
  168. };
  169. bool ParseConfig(int argc, char **argv, TestConfig *out_initial,
  170. TestConfig *out_resume, TestConfig *out_retry);
  171. bool SetTestConfig(SSL *ssl, const TestConfig *config);
  172. const TestConfig *GetTestConfig(const SSL *ssl);
  173. bool LoadCertificate(bssl::UniquePtr<X509> *out_x509,
  174. bssl::UniquePtr<STACK_OF(X509)> *out_chain,
  175. const std::string &file);
  176. bssl::UniquePtr<EVP_PKEY> LoadPrivateKey(const std::string &file);
  177. #endif // HEADER_TEST_CONFIG