• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
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> expected_peer_verify_prefs;
36   std::vector<int> curves;
37   std::string key_file;
38   std::string cert_file;
39   std::string expected_server_name;
40   std::string expected_certificate_types;
41   bool require_any_client_certificate = false;
42   std::string advertise_npn;
43   std::string expected_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 expected_channel_id;
56   bool enable_channel_id = false;
57   std::string send_channel_id;
58   int expected_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 expected_alpn;
64   std::string expected_late_alpn;
65   std::string expected_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 expected_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 expected_ocsp_response;
78   bool enable_signed_cert_timestamps = false;
79   std::string expected_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_early_keying_material = 0;
93   int export_keying_material = 0;
94   std::string export_label;
95   std::string export_context;
96   bool use_export_context = false;
97   bool tls_unique = false;
98   bool expect_ticket_renewal = false;
99   bool expect_no_session = false;
100   bool expect_ticket_supports_early_data = false;
101   bool expect_accept_early_data = false;
102   bool expect_reject_early_data = false;
103   bool expect_no_offer_early_data = false;
104   bool use_ticket_callback = false;
105   bool renew_ticket = false;
106   bool enable_early_data = false;
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;
114   bool verify_fail = false;
115   bool verify_peer = false;
116   bool verify_peer_if_no_obc = false;
117   bool expect_verify_result = false;
118   std::string signed_cert_timestamps;
119   int expect_total_renegotiations = 0;
120   bool renegotiate_once = false;
121   bool renegotiate_freely = false;
122   bool renegotiate_ignore = false;
123   bool forbid_renegotiation_after_handshake = false;
124   int expect_peer_signature_algorithm = 0;
125   bool enable_all_curves = false;
126   int expect_curve_id = 0;
127   bool use_old_client_cert_callback = false;
128   int initial_timeout_duration_ms = 0;
129   std::string use_client_ca_list;
130   std::string expected_client_ca_list;
131   bool send_alert = false;
132   bool peek_then_read = false;
133   bool enable_grease = false;
134   int max_cert_list = 0;
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;
141   bool retain_only_sha256_client_cert = false;
142   bool expect_sha256_client_cert = false;
143   bool read_with_unfinished_write = false;
144   bool expect_secure_renegotiation = false;
145   bool expect_no_secure_renegotiation = false;
146   int max_send_fragment = 0;
147   int read_size = 0;
148   bool expect_session_id = false;
149   bool expect_no_session_id = false;
150   int expect_ticket_age_skew = 0;
151   bool no_op_extra_handshake = false;
152   bool handshake_twice = false;
153   bool allow_unknown_alpn_protos = false;
154   bool enable_ed25519 = false;
155   bool use_custom_verify_callback = false;
156   std::string expect_msg_callback;
157   bool allow_false_start_without_alpn = false;
158   bool ignore_tls13_downgrade = false;
159   bool expect_tls13_downgrade = false;
160   bool handoff = false;
161   bool no_rsa_pss_rsae_certs = false;
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;
167   bool reverify_on_resume = false;
168   bool enforce_rsa_key_usage = false;
169   bool is_handshaker_supported = false;
170   bool handshaker_resume = false;
171   std::string handshaker_path;
172   bool jdk11_workaround = false;
173   bool server_preference = false;
174   bool export_traffic_secrets = false;
175   bool key_update = false;
176   std::string delegated_credential;
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;
186 };
187 
188 bool ParseConfig(int argc, char **argv, TestConfig *out_initial,
189                  TestConfig *out_resume, TestConfig *out_retry);
190 
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);
200 
201 #endif  // HEADER_TEST_CONFIG
202