@@ -7,26 +7,19 @@ Upstream-Status: Submitted [https://github.com/openssl/openssl/pull/22481]
7
7
8
8
Signed-off-by: William Lyu <
[email protected] >
9
9
---
10
- test/helpers/handshake.c | 139 +++++++++++++++++++++++++++++----------
10
+ test/helpers/handshake.c | 137 +++++++++++++++++++++++++++++----------
11
11
test/helpers/handshake.h | 70 +++++++++++++++++++-
12
12
test/ssl_test.c | 44 +++++++++++++
13
- 3 files changed, 218 insertions(+), 35 deletions(-)
13
+ 3 files changed, 217 insertions(+), 34 deletions(-)
14
14
15
15
diff --git a/test/helpers/handshake.c b/test/helpers/handshake.c
16
- index e0422469e4..ae2ad59dd4 100644
16
+ index f611b3a..5703b48 100644
17
17
--- a/test/helpers/handshake.c
18
18
+++ b/test/helpers/handshake.c
19
- @@ -1,5 +1,5 @@
20
- /*
21
- - * Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
22
- + * Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
23
- *
24
- * Licensed under the Apache License 2.0 (the "License"). You may not use
25
- * this file except in compliance with the License. You can obtain a copy
26
19
@@ -24,6 +24,102 @@
27
20
#include <netinet/sctp.h>
28
21
#endif
29
-
22
+
30
23
+ /* Shamelessly copied from test/helpers/ssl_test_ctx.c */
31
24
+ /* Maps string names to various enumeration type */
32
25
+ typedef struct {
@@ -126,10 +119,10 @@ index e0422469e4..ae2ad59dd4 100644
126
119
HANDSHAKE_RESULT *HANDSHAKE_RESULT_new(void)
127
120
{
128
121
HANDSHAKE_RESULT *ret;
129
- @@ -719 ,15 +815 ,6 @@ static void configure_handshake_ssl(SSL *server, SSL *client,
122
+ @@ -725 ,15 +821 ,6 @@ static void configure_handshake_ssl(SSL *server, SSL *client,
130
123
SSL_set_post_handshake_auth(client, 1);
131
124
}
132
-
125
+
133
126
- /* The status for each connection phase. */
134
127
- typedef enum {
135
128
- PEER_SUCCESS,
@@ -142,10 +135,10 @@ index e0422469e4..ae2ad59dd4 100644
142
135
/* An SSL object and associated read-write buffers. */
143
136
typedef struct peer_st {
144
137
SSL *ssl;
145
- @@ -1074 ,17 +1161 ,6 @@ static void do_shutdown_step(PEER *peer)
138
+ @@ -1080 ,17 +1167 ,6 @@ static void do_shutdown_step(PEER *peer)
146
139
}
147
140
}
148
-
141
+
149
142
- typedef enum {
150
143
- HANDSHAKE,
151
144
- RENEG_APPLICATION_DATA,
@@ -160,10 +153,10 @@ index e0422469e4..ae2ad59dd4 100644
160
153
static int renegotiate_op(const SSL_TEST_CTX *test_ctx)
161
154
{
162
155
switch (test_ctx->handshake_mode) {
163
- @@ -1162 ,19 +1238 ,6 @@ static void do_connect_step(const SSL_TEST_CTX *test_ctx, PEER *peer,
156
+ @@ -1168 ,19 +1244 ,6 @@ static void do_connect_step(const SSL_TEST_CTX *test_ctx, PEER *peer,
164
157
}
165
158
}
166
-
159
+
167
160
- typedef enum {
168
161
- /* Both parties succeeded. */
169
162
- HANDSHAKE_SUCCESS,
@@ -180,21 +173,21 @@ index e0422469e4..ae2ad59dd4 100644
180
173
/*
181
174
* Determine the handshake outcome.
182
175
* last_status: the status of the peer to have acted last.
183
- @@ -1539 ,6 +1602 ,10 @@ static HANDSHAKE_RESULT *do_handshake_internal(
184
-
176
+ @@ -1545 ,6 +1608 ,10 @@ static HANDSHAKE_RESULT *do_handshake_internal(
177
+
185
178
start = time(NULL);
186
-
179
+
187
180
+ save_loop_history(&(ret->history),
188
181
+ phase, status, server.status, client.status,
189
182
+ client_turn_count, client_turn);
190
183
+
191
184
/*
192
185
* Half-duplex handshake loop.
193
186
* Client and server speak to each other synchronously in the same process.
194
- @@ -1560 ,6 +1627 ,10 @@ static HANDSHAKE_RESULT *do_handshake_internal(
187
+ @@ -1566 ,6 +1633 ,10 @@ static HANDSHAKE_RESULT *do_handshake_internal(
195
188
0 /* server went last */);
196
189
}
197
-
190
+
198
191
+ save_loop_history(&(ret->history),
199
192
+ phase, status, server.status, client.status,
200
193
+ client_turn_count, client_turn);
@@ -203,7 +196,7 @@ index e0422469e4..ae2ad59dd4 100644
203
196
case HANDSHAKE_SUCCESS:
204
197
client_turn_count = 0;
205
198
diff --git a/test/helpers/handshake.h b/test/helpers/handshake.h
206
- index 78b03f9f4b..b9967c2623 100644
199
+ index 78b03f9..b9967c2 100644
207
200
--- a/test/helpers/handshake.h
208
201
+++ b/test/helpers/handshake.h
209
202
@@ -1,5 +1,5 @@
@@ -214,9 +207,9 @@ index 78b03f9f4b..b9967c2623 100644
214
207
* Licensed under the Apache License 2.0 (the "License"). You may not use
215
208
* this file except in compliance with the License. You can obtain a copy
216
209
@@ -12,6 +12,11 @@
217
-
210
+
218
211
#include "ssl_test_ctx.h"
219
-
212
+
220
213
+ #define MAX_HANDSHAKE_HISTORY_ENTRY_BIT 4
221
214
+ #define MAX_HANDSHAKE_HISTORY_ENTRY (1 << MAX_HANDSHAKE_HISTORY_ENTRY_BIT)
222
215
+ #define MAX_HANDSHAKE_HISTORY_ENTRY_IDX_MASK \
@@ -228,7 +221,7 @@ index 78b03f9f4b..b9967c2623 100644
228
221
@@ -22,6 +27,63 @@ typedef struct ctx_data_st {
229
222
char *session_ticket_app_data;
230
223
} CTX_DATA;
231
-
224
+
232
225
+ typedef enum {
233
226
+ HANDSHAKE,
234
227
+ RENEG_APPLICATION_DATA,
@@ -296,25 +289,25 @@ index 78b03f9f4b..b9967c2623 100644
296
289
+ /* handshake loop history */
297
290
+ HANDSHAKE_HISTORY history;
298
291
} HANDSHAKE_RESULT;
299
-
292
+
300
293
HANDSHAKE_RESULT *HANDSHAKE_RESULT_new(void);
301
294
@@ -95,4 +159,8 @@ int configure_handshake_ctx_for_srp(SSL_CTX *server_ctx, SSL_CTX *server2_ctx,
302
295
CTX_DATA *server2_ctx_data,
303
296
CTX_DATA *client_ctx_data);
304
-
297
+
305
298
+ const char *handshake_connect_phase_name(connect_phase_t phase);
306
299
+ const char *handshake_status_name(handshake_status_t handshake_status);
307
300
+ const char *handshake_peer_status_name(peer_status_t peer_status);
308
301
+
309
302
#endif /* OSSL_TEST_HANDSHAKE_HELPER_H */
310
303
diff --git a/test/ssl_test.c b/test/ssl_test.c
311
- index ea608518f9..9d6b093c81 100644
304
+ index ea60851..9d6b093 100644
312
305
--- a/test/ssl_test.c
313
306
+++ b/test/ssl_test.c
314
307
@@ -26,6 +26,44 @@ static OSSL_LIB_CTX *libctx = NULL;
315
308
/* Currently the section names are of the form test-<number>, e.g. test-15. */
316
309
#define MAX_TESTCASE_NAME_LENGTH 100
317
-
310
+
318
311
+ static void print_handshake_history(const HANDSHAKE_HISTORY *history)
319
312
+ {
320
313
+ size_t first_idx;
0 commit comments