test_config.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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> expect_peer_verify_prefs;
  31. std::vector<int> curves;
  32. std::string key_file;
  33. std::string cert_file;
  34. std::string expect_server_name;
  35. std::string expect_certificate_types;
  36. bool require_any_client_certificate = false;
  37. std::string advertise_npn;
  38. std::string expect_next_proto;
  39. bool false_start = false;
  40. std::string select_next_proto;
  41. bool async = false;
  42. bool write_different_record_sizes = false;
  43. bool cbc_record_splitting = false;
  44. bool partial_write = false;
  45. bool no_tls13 = false;
  46. bool no_tls12 = false;
  47. bool no_tls11 = false;
  48. bool no_tls1 = false;
  49. bool no_ticket = false;
  50. std::string expect_channel_id;
  51. bool enable_channel_id = false;
  52. std::string send_channel_id;
  53. int expect_token_binding_param = -1;
  54. std::string send_token_binding_params;
  55. bool shim_writes_first = false;
  56. std::string host_name;
  57. std::string advertise_alpn;
  58. std::string expect_alpn;
  59. std::string expect_late_alpn;
  60. std::string expect_advertised_alpn;
  61. std::string select_alpn;
  62. bool decline_alpn = false;
  63. bool select_empty_alpn = false;
  64. std::string quic_transport_params;
  65. std::string expect_quic_transport_params;
  66. bool expect_session_miss = false;
  67. bool expect_extended_master_secret = false;
  68. std::string psk;
  69. std::string psk_identity;
  70. std::string srtp_profiles;
  71. bool enable_ocsp_stapling = false;
  72. std::string expect_ocsp_response;
  73. bool enable_signed_cert_timestamps = false;
  74. std::string expect_signed_cert_timestamps;
  75. int min_version = 0;
  76. int max_version = 0;
  77. int expect_version = 0;
  78. int mtu = 0;
  79. bool implicit_handshake = false;
  80. bool use_early_callback = false;
  81. bool fail_early_callback = false;
  82. bool install_ddos_callback = false;
  83. bool fail_ddos_callback = false;
  84. bool fail_cert_callback = false;
  85. std::string cipher;
  86. bool handshake_never_done = false;
  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. bool enable_client_custom_extension = false;
  102. bool enable_server_custom_extension = false;
  103. bool custom_extension_skip = false;
  104. bool custom_extension_fail_add = false;
  105. std::string ocsp_response;
  106. bool check_close_notify = false;
  107. bool shim_shuts_down = false;
  108. bool verify_fail = false;
  109. bool verify_peer = false;
  110. bool verify_peer_if_no_obc = false;
  111. bool expect_verify_result = false;
  112. std::string signed_cert_timestamps;
  113. int expect_total_renegotiations = 0;
  114. bool renegotiate_once = false;
  115. bool renegotiate_freely = false;
  116. bool renegotiate_ignore = false;
  117. bool forbid_renegotiation_after_handshake = false;
  118. int expect_peer_signature_algorithm = 0;
  119. bool enable_all_curves = false;
  120. int expect_curve_id = 0;
  121. bool use_old_client_cert_callback = false;
  122. int initial_timeout_duration_ms = 0;
  123. std::string use_client_ca_list;
  124. std::string expect_client_ca_list;
  125. bool send_alert = false;
  126. bool peek_then_read = false;
  127. bool enable_grease = false;
  128. int max_cert_list = 0;
  129. std::string ticket_key;
  130. bool use_exporter_between_reads = false;
  131. int expect_cipher_aes = 0;
  132. int expect_cipher_no_aes = 0;
  133. std::string expect_peer_cert_file;
  134. int resumption_delay = 0;
  135. bool retain_only_sha256_client_cert = false;
  136. bool expect_sha256_client_cert = false;
  137. bool read_with_unfinished_write = false;
  138. bool expect_secure_renegotiation = false;
  139. bool expect_no_secure_renegotiation = false;
  140. int max_send_fragment = 0;
  141. int read_size = 0;
  142. bool expect_session_id = false;
  143. bool expect_no_session_id = false;
  144. int expect_ticket_age_skew = 0;
  145. bool no_op_extra_handshake = false;
  146. bool handshake_twice = false;
  147. bool allow_unknown_alpn_protos = false;
  148. bool enable_ed25519 = false;
  149. bool use_custom_verify_callback = false;
  150. std::string expect_msg_callback;
  151. bool allow_false_start_without_alpn = false;
  152. bool ignore_tls13_downgrade = false;
  153. bool expect_tls13_downgrade = false;
  154. bool handoff = false;
  155. bool no_rsa_pss_rsae_certs = false;
  156. bool use_ocsp_callback = false;
  157. bool set_ocsp_in_callback = false;
  158. bool decline_ocsp_callback = false;
  159. bool fail_ocsp_callback = false;
  160. bool install_cert_compression_algs = false;
  161. bool reverify_on_resume = false;
  162. bool enforce_rsa_key_usage = false;
  163. bool is_handshaker_supported = false;
  164. bool handshaker_resume = false;
  165. std::string handshaker_path;
  166. bool jdk11_workaround = false;
  167. bool server_preference = false;
  168. bool export_traffic_secrets = false;
  169. bool key_update = false;
  170. bool expect_delegated_credential_used = false;
  171. std::string delegated_credential;
  172. std::string expect_early_data_reason;
  173. bool enable_pq_experiment_signal = false;
  174. bool expect_pq_experiment_signal = false;
  175. int argc;
  176. char **argv;
  177. bssl::UniquePtr<SSL_CTX> SetupCtx(SSL_CTX *old_ctx) const;
  178. bssl::UniquePtr<SSL> NewSSL(SSL_CTX *ssl_ctx, SSL_SESSION *session,
  179. bool is_resume,
  180. std::unique_ptr<TestState> test_state) const;
  181. };
  182. bool ParseConfig(int argc, char **argv, TestConfig *out_initial,
  183. TestConfig *out_resume, TestConfig *out_retry);
  184. bool SetTestConfig(SSL *ssl, const TestConfig *config);
  185. const TestConfig *GetTestConfig(const SSL *ssl);
  186. bool LoadCertificate(bssl::UniquePtr<X509> *out_x509,
  187. bssl::UniquePtr<STACK_OF(X509)> *out_chain,
  188. const std::string &file);
  189. bssl::UniquePtr<EVP_PKEY> LoadPrivateKey(const std::string &file);
  190. #endif // HEADER_TEST_CONFIG