Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 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 | |
| 15 | #ifndef HEADER_TEST_CONFIG |
| 16 | #define HEADER_TEST_CONFIG |
| 17 | |
| 18 | #include <string> |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 19 | #include <vector> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 20 | |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 21 | #include <openssl/base.h> |
| 22 | #include <openssl/x509.h> |
| 23 | |
| 24 | #include "test_state.h" |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 25 | |
| 26 | struct TestConfig { |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 27 | int port = 0; |
| 28 | bool is_server = false; |
| 29 | bool is_dtls = false; |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 30 | int resume_count = 0; |
Robert Sloan | f6200e7 | 2017-07-10 08:09:18 -0700 | [diff] [blame] | 31 | std::string write_settings; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 32 | bool fallback_scsv = false; |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 33 | std::vector<int> signing_prefs; |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 34 | std::vector<int> verify_prefs; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 35 | std::vector<int> expected_peer_verify_prefs; |
Robert Sloan | 11c28bd | 2018-12-17 12:09:20 -0800 | [diff] [blame] | 36 | std::vector<int> curves; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 37 | std::string key_file; |
| 38 | std::string cert_file; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 39 | std::string expected_server_name; |
| 40 | std::string expected_certificate_types; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 41 | bool require_any_client_certificate = false; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 42 | std::string advertise_npn; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 43 | std::string expected_next_proto; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 44 | bool false_start = false; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 45 | std::string select_next_proto; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 46 | bool async = false; |
| 47 | bool write_different_record_sizes = false; |
| 48 | bool cbc_record_splitting = false; |
| 49 | bool partial_write = false; |
David Benjamin | d316cba | 2016-06-02 16:17:39 -0400 | [diff] [blame] | 50 | bool no_tls13 = false; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 51 | bool no_tls12 = false; |
| 52 | bool no_tls11 = false; |
| 53 | bool no_tls1 = false; |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 54 | bool no_ticket = false; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 55 | std::string expected_channel_id; |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 56 | bool enable_channel_id = false; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 57 | std::string send_channel_id; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 58 | int expected_token_binding_param = -1; |
Robert Sloan | 978112c | 2018-01-22 12:53:01 -0800 | [diff] [blame] | 59 | std::string send_token_binding_params; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 60 | bool shim_writes_first = false; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 61 | std::string host_name; |
| 62 | std::string advertise_alpn; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 63 | std::string expected_alpn; |
| 64 | std::string expected_late_alpn; |
| 65 | std::string expected_advertised_alpn; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 66 | std::string select_alpn; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 67 | bool decline_alpn = false; |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 68 | bool select_empty_alpn = false; |
Robert Sloan | 8542c08 | 2018-02-05 09:07:34 -0800 | [diff] [blame] | 69 | std::string quic_transport_params; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 70 | std::string expected_quic_transport_params; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 71 | bool expect_session_miss = false; |
| 72 | bool expect_extended_master_secret = false; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 73 | std::string psk; |
| 74 | std::string psk_identity; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 75 | std::string srtp_profiles; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 76 | bool enable_ocsp_stapling = false; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 77 | std::string expected_ocsp_response; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 78 | bool enable_signed_cert_timestamps = false; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 79 | std::string expected_signed_cert_timestamps; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 80 | int min_version = 0; |
| 81 | int max_version = 0; |
Robert Sloan | f6200e7 | 2017-07-10 08:09:18 -0700 | [diff] [blame] | 82 | int expect_version = 0; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 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; |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 89 | bool fail_cert_callback = false; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 90 | std::string cipher; |
| 91 | bool handshake_never_done = false; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 92 | int export_early_keying_material = 0; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 93 | int export_keying_material = 0; |
| 94 | std::string export_label; |
| 95 | std::string export_context; |
| 96 | bool use_export_context = false; |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 97 | bool tls_unique = false; |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 98 | bool expect_ticket_renewal = false; |
| 99 | bool expect_no_session = false; |
Robert Sloan | b1b54b8 | 2017-11-06 13:50:02 -0800 | [diff] [blame] | 100 | bool expect_ticket_supports_early_data = false; |
Robert Sloan | 6d0d00e | 2017-03-27 07:13:07 -0700 | [diff] [blame] | 101 | bool expect_accept_early_data = false; |
| 102 | bool expect_reject_early_data = false; |
Robert Sloan | 29c1d2c | 2017-10-30 14:10:28 -0700 | [diff] [blame] | 103 | bool expect_no_offer_early_data = false; |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 104 | bool use_ticket_callback = false; |
| 105 | bool renew_ticket = false; |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame] | 106 | bool enable_early_data = false; |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 107 | bool enable_client_custom_extension = false; |
| 108 | bool enable_server_custom_extension = false; |
| 109 | bool custom_extension_skip = false; |
| 110 | bool custom_extension_fail_add = false; |
| 111 | std::string ocsp_response; |
| 112 | bool check_close_notify = false; |
| 113 | bool shim_shuts_down = false; |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 114 | bool verify_fail = false; |
| 115 | bool verify_peer = false; |
Robert Sloan | f6200e7 | 2017-07-10 08:09:18 -0700 | [diff] [blame] | 116 | bool verify_peer_if_no_obc = false; |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 117 | bool expect_verify_result = false; |
| 118 | std::string signed_cert_timestamps; |
Kenny Root | e99801b | 2015-11-06 15:31:15 -0800 | [diff] [blame] | 119 | int expect_total_renegotiations = 0; |
| 120 | bool renegotiate_once = false; |
| 121 | bool renegotiate_freely = false; |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 122 | bool renegotiate_ignore = false; |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 123 | bool forbid_renegotiation_after_handshake = false; |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 124 | int expect_peer_signature_algorithm = 0; |
Adam Langley | 4139edb | 2016-01-13 15:00:54 -0800 | [diff] [blame] | 125 | bool enable_all_curves = false; |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 126 | int expect_curve_id = 0; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 127 | bool use_old_client_cert_callback = false; |
David Benjamin | d316cba | 2016-06-02 16:17:39 -0400 | [diff] [blame] | 128 | int initial_timeout_duration_ms = 0; |
Robert Sloan | 7d422bc | 2017-03-06 10:04:29 -0800 | [diff] [blame] | 129 | std::string use_client_ca_list; |
Srinivas Paladugu | dd42a61 | 2019-08-09 19:30:39 +0000 | [diff] [blame^] | 130 | std::string expected_client_ca_list; |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 131 | bool send_alert = false; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 132 | bool peek_then_read = false; |
| 133 | bool enable_grease = false; |
| 134 | int max_cert_list = 0; |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 135 | std::string ticket_key; |
| 136 | bool use_exporter_between_reads = false; |
| 137 | int expect_cipher_aes = 0; |
| 138 | int expect_cipher_no_aes = 0; |
| 139 | std::string expect_peer_cert_file; |
| 140 | int resumption_delay = 0; |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 141 | bool retain_only_sha256_client_cert = false; |
| 142 | bool expect_sha256_client_cert = false; |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame] | 143 | bool read_with_unfinished_write = false; |
Steven Valdez | b0b45c6 | 2017-01-17 16:23:54 -0500 | [diff] [blame] | 144 | bool expect_secure_renegotiation = false; |
| 145 | bool expect_no_secure_renegotiation = false; |
| 146 | int max_send_fragment = 0; |
| 147 | int read_size = 0; |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame] | 148 | bool expect_session_id = false; |
| 149 | bool expect_no_session_id = false; |
Robert Sloan | 1c9db53 | 2017-03-13 08:03:59 -0700 | [diff] [blame] | 150 | int expect_ticket_age_skew = 0; |
Robert Sloan | 6f79a50 | 2017-04-03 09:16:40 -0700 | [diff] [blame] | 151 | bool no_op_extra_handshake = false; |
| 152 | bool handshake_twice = false; |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 153 | bool allow_unknown_alpn_protos = false; |
| 154 | bool enable_ed25519 = false; |
Robert Sloan | b6d070c | 2017-07-24 08:40:01 -0700 | [diff] [blame] | 155 | bool use_custom_verify_callback = false; |
Robert Sloan | fe7cd21 | 2017-08-07 09:03:39 -0700 | [diff] [blame] | 156 | std::string expect_msg_callback; |
Robert Sloan | cd79cde | 2017-12-11 09:06:12 -0800 | [diff] [blame] | 157 | bool allow_false_start_without_alpn = false; |
Robert Sloan | d9e572d | 2018-08-27 12:27:00 -0700 | [diff] [blame] | 158 | bool ignore_tls13_downgrade = false; |
| 159 | bool expect_tls13_downgrade = false; |
Robert Sloan | 8542c08 | 2018-02-05 09:07:34 -0800 | [diff] [blame] | 160 | bool handoff = false; |
Robert Sloan | 5cbb5c8 | 2018-04-24 11:35:46 -0700 | [diff] [blame] | 161 | bool no_rsa_pss_rsae_certs = false; |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 162 | bool use_ocsp_callback = false; |
| 163 | bool set_ocsp_in_callback = false; |
| 164 | bool decline_ocsp_callback = false; |
| 165 | bool fail_ocsp_callback = false; |
| 166 | bool install_cert_compression_algs = false; |
Robert Sloan | d9e572d | 2018-08-27 12:27:00 -0700 | [diff] [blame] | 167 | bool reverify_on_resume = false; |
Robert Sloan | 4c22c5f | 2019-03-01 15:53:37 -0800 | [diff] [blame] | 168 | bool enforce_rsa_key_usage = false; |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 169 | bool is_handshaker_supported = false; |
| 170 | bool handshaker_resume = false; |
| 171 | std::string handshaker_path; |
Robert Sloan | c9abfe4 | 2018-11-26 12:19:07 -0800 | [diff] [blame] | 172 | bool jdk11_workaround = false; |
Robert Sloan | 11c28bd | 2018-12-17 12:09:20 -0800 | [diff] [blame] | 173 | bool server_preference = false; |
| 174 | bool export_traffic_secrets = false; |
Robert Sloan | 4c22c5f | 2019-03-01 15:53:37 -0800 | [diff] [blame] | 175 | bool key_update = false; |
| 176 | std::string delegated_credential; |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 177 | |
| 178 | int argc; |
| 179 | char **argv; |
| 180 | |
| 181 | bssl::UniquePtr<SSL_CTX> SetupCtx(SSL_CTX *old_ctx) const; |
| 182 | |
| 183 | bssl::UniquePtr<SSL> NewSSL(SSL_CTX *ssl_ctx, SSL_SESSION *session, |
| 184 | bool is_resume, |
| 185 | std::unique_ptr<TestState> test_state) const; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 186 | }; |
| 187 | |
Robert Sloan | e56da3e | 2017-06-26 08:26:42 -0700 | [diff] [blame] | 188 | bool ParseConfig(int argc, char **argv, TestConfig *out_initial, |
| 189 | TestConfig *out_resume, TestConfig *out_retry); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 190 | |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 191 | bool SetTestConfig(SSL *ssl, const TestConfig *config); |
| 192 | |
| 193 | const TestConfig *GetTestConfig(const SSL *ssl); |
| 194 | |
| 195 | bool LoadCertificate(bssl::UniquePtr<X509> *out_x509, |
| 196 | bssl::UniquePtr<STACK_OF(X509)> *out_chain, |
| 197 | const std::string &file); |
| 198 | |
| 199 | bssl::UniquePtr<EVP_PKEY> LoadPrivateKey(const std::string &file); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 200 | |
| 201 | #endif // HEADER_TEST_CONFIG |