blob: 9221d6f1d3984af80d71dbe5480305778a8a31d5 [file] [log] [blame]
Adam Langleyd9e397b2015-01-22 14:27:53 -08001/* 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 Benjaminc895d6b2016-08-11 13:26:41 -040019#include <vector>
Adam Langleyd9e397b2015-01-22 14:27:53 -080020
Adam Vartanianbfcf3a72018-08-10 14:55:24 +010021#include <openssl/base.h>
22#include <openssl/x509.h>
23
24#include "test_state.h"
Adam Langleyd9e397b2015-01-22 14:27:53 -080025
26struct TestConfig {
Adam Langleye9ada862015-05-11 17:20:37 -070027 int port = 0;
28 bool is_server = false;
29 bool is_dtls = false;
David Benjaminf0c4a6c2016-08-11 13:26:41 -040030 int resume_count = 0;
Robert Sloanf6200e72017-07-10 08:09:18 -070031 std::string write_settings;
Adam Langleye9ada862015-05-11 17:20:37 -070032 bool fallback_scsv = false;
David Benjaminc895d6b2016-08-11 13:26:41 -040033 std::vector<int> signing_prefs;
Robert Sloan572a4e22017-04-17 10:52:19 -070034 std::vector<int> verify_prefs;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000035 std::vector<int> expected_peer_verify_prefs;
Robert Sloan11c28bd2018-12-17 12:09:20 -080036 std::vector<int> curves;
Adam Langleyd9e397b2015-01-22 14:27:53 -080037 std::string key_file;
38 std::string cert_file;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000039 std::string expected_server_name;
40 std::string expected_certificate_types;
Adam Langleye9ada862015-05-11 17:20:37 -070041 bool require_any_client_certificate = false;
Adam Langleyd9e397b2015-01-22 14:27:53 -080042 std::string advertise_npn;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000043 std::string expected_next_proto;
Adam Langleye9ada862015-05-11 17:20:37 -070044 bool false_start = false;
Adam Langleyd9e397b2015-01-22 14:27:53 -080045 std::string select_next_proto;
Adam Langleye9ada862015-05-11 17:20:37 -070046 bool async = false;
47 bool write_different_record_sizes = false;
48 bool cbc_record_splitting = false;
49 bool partial_write = false;
David Benjamind316cba2016-06-02 16:17:39 -040050 bool no_tls13 = false;
Adam Langleye9ada862015-05-11 17:20:37 -070051 bool no_tls12 = false;
52 bool no_tls11 = false;
53 bool no_tls1 = false;
Adam Vartanianbfcf3a72018-08-10 14:55:24 +010054 bool no_ticket = false;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000055 std::string expected_channel_id;
David Benjaminc895d6b2016-08-11 13:26:41 -040056 bool enable_channel_id = false;
Adam Langleyd9e397b2015-01-22 14:27:53 -080057 std::string send_channel_id;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000058 int expected_token_binding_param = -1;
Robert Sloan978112c2018-01-22 12:53:01 -080059 std::string send_token_binding_params;
Adam Langleye9ada862015-05-11 17:20:37 -070060 bool shim_writes_first = false;
Adam Langleyd9e397b2015-01-22 14:27:53 -080061 std::string host_name;
62 std::string advertise_alpn;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000063 std::string expected_alpn;
64 std::string expected_late_alpn;
65 std::string expected_advertised_alpn;
Adam Langleyd9e397b2015-01-22 14:27:53 -080066 std::string select_alpn;
David Benjamin4969cc92016-04-22 15:02:23 -040067 bool decline_alpn = false;
Adam Vartanianbfcf3a72018-08-10 14:55:24 +010068 bool select_empty_alpn = false;
Robert Sloan8542c082018-02-05 09:07:34 -080069 std::string quic_transport_params;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000070 std::string expected_quic_transport_params;
Adam Langleye9ada862015-05-11 17:20:37 -070071 bool expect_session_miss = false;
72 bool expect_extended_master_secret = false;
Adam Langleyd9e397b2015-01-22 14:27:53 -080073 std::string psk;
74 std::string psk_identity;
Adam Langleyd9e397b2015-01-22 14:27:53 -080075 std::string srtp_profiles;
Adam Langleye9ada862015-05-11 17:20:37 -070076 bool enable_ocsp_stapling = false;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000077 std::string expected_ocsp_response;
Adam Langleye9ada862015-05-11 17:20:37 -070078 bool enable_signed_cert_timestamps = false;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000079 std::string expected_signed_cert_timestamps;
Adam Langleye9ada862015-05-11 17:20:37 -070080 int min_version = 0;
81 int max_version = 0;
Robert Sloanf6200e72017-07-10 08:09:18 -070082 int expect_version = 0;
Adam Langleye9ada862015-05-11 17:20:37 -070083 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 Valdez909b19f2016-11-21 15:35:44 -050089 bool fail_cert_callback = false;
Adam Langleye9ada862015-05-11 17:20:37 -070090 std::string cipher;
91 bool handshake_never_done = false;
Srinivas Paladugudd42a612019-08-09 19:30:39 +000092 int export_early_keying_material = 0;
Adam Langleye9ada862015-05-11 17:20:37 -070093 int export_keying_material = 0;
94 std::string export_label;
95 std::string export_context;
96 bool use_export_context = false;
Adam Langleyf4e42722015-06-04 17:45:09 -070097 bool tls_unique = false;
Kenny Rootb8494592015-09-25 02:29:14 +000098 bool expect_ticket_renewal = false;
99 bool expect_no_session = false;
Robert Sloanb1b54b82017-11-06 13:50:02 -0800100 bool expect_ticket_supports_early_data = false;
Robert Sloan6d0d00e2017-03-27 07:13:07 -0700101 bool expect_accept_early_data = false;
102 bool expect_reject_early_data = false;
Robert Sloan29c1d2c2017-10-30 14:10:28 -0700103 bool expect_no_offer_early_data = false;
Kenny Rootb8494592015-09-25 02:29:14 +0000104 bool use_ticket_callback = false;
105 bool renew_ticket = false;
Robert Sloan69939df2017-01-09 10:53:07 -0800106 bool enable_early_data = false;
Kenny Rootb8494592015-09-25 02:29:14 +0000107 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 Rootb8494592015-09-25 02:29:14 +0000114 bool verify_fail = false;
115 bool verify_peer = false;
Robert Sloanf6200e72017-07-10 08:09:18 -0700116 bool verify_peer_if_no_obc = false;
Kenny Rootb8494592015-09-25 02:29:14 +0000117 bool expect_verify_result = false;
118 std::string signed_cert_timestamps;
Kenny Roote99801b2015-11-06 15:31:15 -0800119 int expect_total_renegotiations = 0;
120 bool renegotiate_once = false;
121 bool renegotiate_freely = false;
Adam Langleyfad63272015-11-12 12:15:39 -0800122 bool renegotiate_ignore = false;
Adam Vartanianbfcf3a72018-08-10 14:55:24 +0100123 bool forbid_renegotiation_after_handshake = false;
David Benjaminc895d6b2016-08-11 13:26:41 -0400124 int expect_peer_signature_algorithm = 0;
Adam Langley4139edb2016-01-13 15:00:54 -0800125 bool enable_all_curves = false;
David Benjaminc895d6b2016-08-11 13:26:41 -0400126 int expect_curve_id = 0;
David Benjamin4969cc92016-04-22 15:02:23 -0400127 bool use_old_client_cert_callback = false;
David Benjamind316cba2016-06-02 16:17:39 -0400128 int initial_timeout_duration_ms = 0;
Robert Sloan7d422bc2017-03-06 10:04:29 -0800129 std::string use_client_ca_list;
Srinivas Paladugudd42a612019-08-09 19:30:39 +0000130 std::string expected_client_ca_list;
David Benjaminc895d6b2016-08-11 13:26:41 -0400131 bool send_alert = false;
Steven Valdezbb1ceac2016-10-07 10:34:51 -0400132 bool peek_then_read = false;
133 bool enable_grease = false;
134 int max_cert_list = 0;
Steven Valdez909b19f2016-11-21 15:35:44 -0500135 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 Sloan8f860b12017-08-28 07:37:06 -0700141 bool retain_only_sha256_client_cert = false;
142 bool expect_sha256_client_cert = false;
Robert Sloan69939df2017-01-09 10:53:07 -0800143 bool read_with_unfinished_write = false;
Steven Valdezb0b45c62017-01-17 16:23:54 -0500144 bool expect_secure_renegotiation = false;
145 bool expect_no_secure_renegotiation = false;
146 int max_send_fragment = 0;
147 int read_size = 0;
Robert Sloan4d1ac502017-02-06 08:36:14 -0800148 bool expect_session_id = false;
149 bool expect_no_session_id = false;
Robert Sloan1c9db532017-03-13 08:03:59 -0700150 int expect_ticket_age_skew = 0;
Robert Sloan6f79a502017-04-03 09:16:40 -0700151 bool no_op_extra_handshake = false;
152 bool handshake_twice = false;
Robert Sloan572a4e22017-04-17 10:52:19 -0700153 bool allow_unknown_alpn_protos = false;
154 bool enable_ed25519 = false;
Robert Sloanb6d070c2017-07-24 08:40:01 -0700155 bool use_custom_verify_callback = false;
Robert Sloanfe7cd212017-08-07 09:03:39 -0700156 std::string expect_msg_callback;
Robert Sloancd79cde2017-12-11 09:06:12 -0800157 bool allow_false_start_without_alpn = false;
Robert Sloand9e572d2018-08-27 12:27:00 -0700158 bool ignore_tls13_downgrade = false;
159 bool expect_tls13_downgrade = false;
Robert Sloan8542c082018-02-05 09:07:34 -0800160 bool handoff = false;
Robert Sloan5cbb5c82018-04-24 11:35:46 -0700161 bool no_rsa_pss_rsae_certs = false;
Adam Vartanianbfcf3a72018-08-10 14:55:24 +0100162 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 Sloand9e572d2018-08-27 12:27:00 -0700167 bool reverify_on_resume = false;
Robert Sloan4c22c5f2019-03-01 15:53:37 -0800168 bool enforce_rsa_key_usage = false;
Adam Vartanianbfcf3a72018-08-10 14:55:24 +0100169 bool is_handshaker_supported = false;
170 bool handshaker_resume = false;
171 std::string handshaker_path;
Robert Sloanc9abfe42018-11-26 12:19:07 -0800172 bool jdk11_workaround = false;
Robert Sloan11c28bd2018-12-17 12:09:20 -0800173 bool server_preference = false;
174 bool export_traffic_secrets = false;
Robert Sloan4c22c5f2019-03-01 15:53:37 -0800175 bool key_update = false;
176 std::string delegated_credential;
Adam Vartanianbfcf3a72018-08-10 14:55:24 +0100177
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 Langleyd9e397b2015-01-22 14:27:53 -0800186};
187
Robert Sloane56da3e2017-06-26 08:26:42 -0700188bool ParseConfig(int argc, char **argv, TestConfig *out_initial,
189 TestConfig *out_resume, TestConfig *out_retry);
Adam Langleyd9e397b2015-01-22 14:27:53 -0800190
Adam Vartanianbfcf3a72018-08-10 14:55:24 +0100191bool SetTestConfig(SSL *ssl, const TestConfig *config);
192
193const TestConfig *GetTestConfig(const SSL *ssl);
194
195bool LoadCertificate(bssl::UniquePtr<X509> *out_x509,
196 bssl::UniquePtr<STACK_OF(X509)> *out_chain,
197 const std::string &file);
198
199bssl::UniquePtr<EVP_PKEY> LoadPrivateKey(const std::string &file);
Adam Langleyd9e397b2015-01-22 14:27:53 -0800200
201#endif // HEADER_TEST_CONFIG