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