2 * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
12 #include "internal/nelem.h"
13 #include "ssltestlib.h"
17 #ifdef OPENSSL_SYS_UNIX
20 static ossl_inline
void ossl_sleep(unsigned int millis
) {
21 usleep(millis
* 1000);
26 static ossl_inline
void ossl_sleep(unsigned int millis
) {
30 /* Fallback to a busy wait */
31 static ossl_inline
void ossl_sleep(unsigned int millis
) {
32 struct timeval start
, now
;
33 unsigned int elapsedms
;
35 gettimeofday(&start
, NULL
);
37 gettimeofday(&now
, NULL
);
38 elapsedms
= (((now
.tv_sec
- start
.tv_sec
) * 1000000)
39 + now
.tv_usec
- start
.tv_usec
) / 1000;
40 } while (elapsedms
< millis
);
44 static int tls_dump_new(BIO
*bi
);
45 static int tls_dump_free(BIO
*a
);
46 static int tls_dump_read(BIO
*b
, char *out
, int outl
);
47 static int tls_dump_write(BIO
*b
, const char *in
, int inl
);
48 static long tls_dump_ctrl(BIO
*b
, int cmd
, long num
, void *ptr
);
49 static int tls_dump_gets(BIO
*bp
, char *buf
, int size
);
50 static int tls_dump_puts(BIO
*bp
, const char *str
);
52 /* Choose a sufficiently large type likely to be unused for this custom BIO */
53 #define BIO_TYPE_TLS_DUMP_FILTER (0x80 | BIO_TYPE_FILTER)
54 #define BIO_TYPE_MEMPACKET_TEST 0x81
56 static BIO_METHOD
*method_tls_dump
= NULL
;
57 static BIO_METHOD
*meth_mem
= NULL
;
59 /* Note: Not thread safe! */
60 const BIO_METHOD
*bio_f_tls_dump_filter(void)
62 if (method_tls_dump
== NULL
) {
63 method_tls_dump
= BIO_meth_new(BIO_TYPE_TLS_DUMP_FILTER
,
65 if ( method_tls_dump
== NULL
66 || !BIO_meth_set_write(method_tls_dump
, tls_dump_write
)
67 || !BIO_meth_set_read(method_tls_dump
, tls_dump_read
)
68 || !BIO_meth_set_puts(method_tls_dump
, tls_dump_puts
)
69 || !BIO_meth_set_gets(method_tls_dump
, tls_dump_gets
)
70 || !BIO_meth_set_ctrl(method_tls_dump
, tls_dump_ctrl
)
71 || !BIO_meth_set_create(method_tls_dump
, tls_dump_new
)
72 || !BIO_meth_set_destroy(method_tls_dump
, tls_dump_free
))
75 return method_tls_dump
;
78 void bio_f_tls_dump_filter_free(void)
80 BIO_meth_free(method_tls_dump
);
83 static int tls_dump_new(BIO
*bio
)
89 static int tls_dump_free(BIO
*bio
)
96 static void copy_flags(BIO
*bio
)
99 BIO
*next
= BIO_next(bio
);
101 flags
= BIO_test_flags(next
, BIO_FLAGS_SHOULD_RETRY
| BIO_FLAGS_RWS
);
102 BIO_clear_flags(bio
, BIO_FLAGS_SHOULD_RETRY
| BIO_FLAGS_RWS
);
103 BIO_set_flags(bio
, flags
);
106 #define RECORD_CONTENT_TYPE 0
107 #define RECORD_VERSION_HI 1
108 #define RECORD_VERSION_LO 2
109 #define RECORD_EPOCH_HI 3
110 #define RECORD_EPOCH_LO 4
111 #define RECORD_SEQUENCE_START 5
112 #define RECORD_SEQUENCE_END 10
113 #define RECORD_LEN_HI 11
114 #define RECORD_LEN_LO 12
118 #define MSG_LEN_MID 2
122 #define MSG_FRAG_OFF_HI 6
123 #define MSG_FRAG_OFF_MID 7
124 #define MSG_FRAG_OFF_LO 8
125 #define MSG_FRAG_LEN_HI 9
126 #define MSG_FRAG_LEN_MID 10
127 #define MSG_FRAG_LEN_LO 11
130 static void dump_data(const char *data
, int len
)
132 int rem
, i
, content
, reclen
, msglen
, fragoff
, fraglen
, epoch
;
135 printf("---- START OF PACKET ----\n");
138 rec
= (unsigned char *)data
;
143 printf("*---- START OF RECORD ----\n");
144 if (rem
< DTLS1_RT_HEADER_LENGTH
) {
145 printf("*---- RECORD TRUNCATED ----\n");
148 content
= rec
[RECORD_CONTENT_TYPE
];
149 printf("** Record Content-type: %d\n", content
);
150 printf("** Record Version: %02x%02x\n",
151 rec
[RECORD_VERSION_HI
], rec
[RECORD_VERSION_LO
]);
152 epoch
= (rec
[RECORD_EPOCH_HI
] << 8) | rec
[RECORD_EPOCH_LO
];
153 printf("** Record Epoch: %d\n", epoch
);
154 printf("** Record Sequence: ");
155 for (i
= RECORD_SEQUENCE_START
; i
<= RECORD_SEQUENCE_END
; i
++)
156 printf("%02x", rec
[i
]);
157 reclen
= (rec
[RECORD_LEN_HI
] << 8) | rec
[RECORD_LEN_LO
];
158 printf("\n** Record Length: %d\n", reclen
);
160 /* Now look at message */
161 rec
+= DTLS1_RT_HEADER_LENGTH
;
162 rem
-= DTLS1_RT_HEADER_LENGTH
;
163 if (content
== SSL3_RT_HANDSHAKE
) {
164 printf("**---- START OF HANDSHAKE MESSAGE FRAGMENT ----\n");
166 printf("**---- HANDSHAKE MESSAGE FRAGMENT ENCRYPTED ----\n");
167 } else if (rem
< DTLS1_HM_HEADER_LENGTH
168 || reclen
< DTLS1_HM_HEADER_LENGTH
) {
169 printf("**---- HANDSHAKE MESSAGE FRAGMENT TRUNCATED ----\n");
171 printf("*** Message Type: %d\n", rec
[MSG_TYPE
]);
172 msglen
= (rec
[MSG_LEN_HI
] << 16) | (rec
[MSG_LEN_MID
] << 8)
174 printf("*** Message Length: %d\n", msglen
);
175 printf("*** Message sequence: %d\n",
176 (rec
[MSG_SEQ_HI
] << 8) | rec
[MSG_SEQ_LO
]);
177 fragoff
= (rec
[MSG_FRAG_OFF_HI
] << 16)
178 | (rec
[MSG_FRAG_OFF_MID
] << 8)
179 | rec
[MSG_FRAG_OFF_LO
];
180 printf("*** Message Fragment offset: %d\n", fragoff
);
181 fraglen
= (rec
[MSG_FRAG_LEN_HI
] << 16)
182 | (rec
[MSG_FRAG_LEN_MID
] << 8)
183 | rec
[MSG_FRAG_LEN_LO
];
184 printf("*** Message Fragment len: %d\n", fraglen
);
185 if (fragoff
+ fraglen
> msglen
)
186 printf("***---- HANDSHAKE MESSAGE FRAGMENT INVALID ----\n");
187 else if (reclen
< fraglen
)
188 printf("**---- HANDSHAKE MESSAGE FRAGMENT TRUNCATED ----\n");
190 printf("**---- END OF HANDSHAKE MESSAGE FRAGMENT ----\n");
194 printf("*---- RECORD TRUNCATED ----\n");
199 printf("*---- END OF RECORD ----\n");
202 printf("---- END OF PACKET ----\n\n");
206 static int tls_dump_read(BIO
*bio
, char *out
, int outl
)
209 BIO
*next
= BIO_next(bio
);
211 ret
= BIO_read(next
, out
, outl
);
221 static int tls_dump_write(BIO
*bio
, const char *in
, int inl
)
224 BIO
*next
= BIO_next(bio
);
226 ret
= BIO_write(next
, in
, inl
);
232 static long tls_dump_ctrl(BIO
*bio
, int cmd
, long num
, void *ptr
)
235 BIO
*next
= BIO_next(bio
);
245 ret
= BIO_ctrl(next
, cmd
, num
, ptr
);
251 static int tls_dump_gets(BIO
*bio
, char *buf
, int size
)
253 /* We don't support this - not needed anyway */
257 static int tls_dump_puts(BIO
*bio
, const char *str
)
259 return tls_dump_write(bio
, str
, strlen(str
));
263 struct mempacket_st
{
270 static void mempacket_free(MEMPACKET
*pkt
)
272 if (pkt
->data
!= NULL
)
273 OPENSSL_free(pkt
->data
);
277 typedef struct mempacket_test_ctx_st
{
278 STACK_OF(MEMPACKET
) *pkts
;
280 unsigned int currrec
;
281 unsigned int currpkt
;
282 unsigned int lastpkt
;
283 unsigned int injected
;
284 unsigned int noinject
;
285 unsigned int dropepoch
;
288 } MEMPACKET_TEST_CTX
;
290 static int mempacket_test_new(BIO
*bi
);
291 static int mempacket_test_free(BIO
*a
);
292 static int mempacket_test_read(BIO
*b
, char *out
, int outl
);
293 static int mempacket_test_write(BIO
*b
, const char *in
, int inl
);
294 static long mempacket_test_ctrl(BIO
*b
, int cmd
, long num
, void *ptr
);
295 static int mempacket_test_gets(BIO
*bp
, char *buf
, int size
);
296 static int mempacket_test_puts(BIO
*bp
, const char *str
);
298 const BIO_METHOD
*bio_s_mempacket_test(void)
300 if (meth_mem
== NULL
) {
301 if (!TEST_ptr(meth_mem
= BIO_meth_new(BIO_TYPE_MEMPACKET_TEST
,
303 || !TEST_true(BIO_meth_set_write(meth_mem
, mempacket_test_write
))
304 || !TEST_true(BIO_meth_set_read(meth_mem
, mempacket_test_read
))
305 || !TEST_true(BIO_meth_set_puts(meth_mem
, mempacket_test_puts
))
306 || !TEST_true(BIO_meth_set_gets(meth_mem
, mempacket_test_gets
))
307 || !TEST_true(BIO_meth_set_ctrl(meth_mem
, mempacket_test_ctrl
))
308 || !TEST_true(BIO_meth_set_create(meth_mem
, mempacket_test_new
))
309 || !TEST_true(BIO_meth_set_destroy(meth_mem
, mempacket_test_free
)))
315 void bio_s_mempacket_test_free(void)
317 BIO_meth_free(meth_mem
);
320 static int mempacket_test_new(BIO
*bio
)
322 MEMPACKET_TEST_CTX
*ctx
;
324 if (!TEST_ptr(ctx
= OPENSSL_zalloc(sizeof(*ctx
))))
326 if (!TEST_ptr(ctx
->pkts
= sk_MEMPACKET_new_null())) {
332 BIO_set_init(bio
, 1);
333 BIO_set_data(bio
, ctx
);
337 static int mempacket_test_free(BIO
*bio
)
339 MEMPACKET_TEST_CTX
*ctx
= BIO_get_data(bio
);
341 sk_MEMPACKET_pop_free(ctx
->pkts
, mempacket_free
);
343 BIO_set_data(bio
, NULL
);
344 BIO_set_init(bio
, 0);
348 /* Record Header values */
351 #define RECORD_SEQUENCE 10
352 #define RECORD_LEN_HI 11
353 #define RECORD_LEN_LO 12
355 #define STANDARD_PACKET 0
357 static int mempacket_test_read(BIO
*bio
, char *out
, int outl
)
359 MEMPACKET_TEST_CTX
*ctx
= BIO_get_data(bio
);
363 unsigned int seq
, offset
, len
, epoch
;
365 BIO_clear_retry_flags(bio
);
366 thispkt
= sk_MEMPACKET_value(ctx
->pkts
, 0);
367 if (thispkt
== NULL
|| thispkt
->num
!= ctx
->currpkt
) {
368 /* Probably run out of data */
369 BIO_set_retry_read(bio
);
372 (void)sk_MEMPACKET_shift(ctx
->pkts
);
375 if (outl
> thispkt
->len
)
378 if (thispkt
->type
!= INJECT_PACKET_IGNORE_REC_SEQ
379 && (ctx
->injected
|| ctx
->droprec
>= 0)) {
381 * Overwrite the record sequence number. We strictly number them in
382 * the order received. Since we are actually a reliable transport
383 * we know that there won't be any re-ordering. We overwrite to deal
384 * with any packets that have been injected
386 for (rem
= thispkt
->len
, rec
= thispkt
->data
; rem
> 0; rem
-= len
) {
387 if (rem
< DTLS1_RT_HEADER_LENGTH
)
389 epoch
= (rec
[EPOCH_HI
] << 8) | rec
[EPOCH_LO
];
390 if (epoch
!= ctx
->epoch
) {
397 rec
[RECORD_SEQUENCE
- offset
] = seq
& 0xFF;
402 len
= ((rec
[RECORD_LEN_HI
] << 8) | rec
[RECORD_LEN_LO
])
403 + DTLS1_RT_HEADER_LENGTH
;
406 if (ctx
->droprec
== (int)ctx
->currrec
&& ctx
->dropepoch
== epoch
) {
408 memmove(rec
, rec
+ len
, rem
- len
);
412 BIO_set_retry_read(bio
);
421 memcpy(out
, thispkt
->data
, outl
);
422 mempacket_free(thispkt
);
426 int mempacket_test_inject(BIO
*bio
, const char *in
, int inl
, int pktnum
,
429 MEMPACKET_TEST_CTX
*ctx
= BIO_get_data(bio
);
430 MEMPACKET
*thispkt
= NULL
, *looppkt
, *nextpkt
, *allpkts
[3];
431 int i
, duprec
= ctx
->duprec
> 0;
432 const unsigned char *inu
= (const unsigned char *)in
;
433 size_t len
= ((inu
[RECORD_LEN_HI
] << 8) | inu
[RECORD_LEN_LO
])
434 + DTLS1_RT_HEADER_LENGTH
;
439 if ((size_t)inl
< len
)
442 if ((size_t)inl
== len
)
445 /* We don't support arbitrary injection when duplicating records */
446 if (duprec
&& pktnum
!= -1)
449 /* We only allow injection before we've started writing any data */
458 for (i
= 0; i
< (duprec
? 3 : 1); i
++) {
459 if (!TEST_ptr(allpkts
[i
] = OPENSSL_malloc(sizeof(*thispkt
))))
461 thispkt
= allpkts
[i
];
463 if (!TEST_ptr(thispkt
->data
= OPENSSL_malloc(inl
)))
466 * If we are duplicating the packet, we duplicate it three times. The
467 * first two times we drop the first record if there are more than one.
468 * In this way we know that libssl will not be able to make progress
469 * until it receives the last packet, and hence will be forced to
470 * buffer these records.
472 if (duprec
&& i
!= 2) {
473 memcpy(thispkt
->data
, in
+ len
, inl
- len
);
474 thispkt
->len
= inl
- len
;
476 memcpy(thispkt
->data
, in
, inl
);
479 thispkt
->num
= (pktnum
>= 0) ? (unsigned int)pktnum
: ctx
->lastpkt
+ i
;
480 thispkt
->type
= type
;
483 for(i
= 0; (looppkt
= sk_MEMPACKET_value(ctx
->pkts
, i
)) != NULL
; i
++) {
484 /* Check if we found the right place to insert this packet */
485 if (looppkt
->num
> thispkt
->num
) {
486 if (sk_MEMPACKET_insert(ctx
->pkts
, thispkt
, i
) == 0)
488 /* If we're doing up front injection then we're done */
492 * We need to do some accounting on lastpkt. We increment it first,
493 * but it might now equal the value of injected packets, so we need
499 nextpkt
= sk_MEMPACKET_value(ctx
->pkts
, i
);
500 if (nextpkt
!= NULL
&& nextpkt
->num
== ctx
->lastpkt
)
505 } else if (looppkt
->num
== thispkt
->num
) {
506 if (!ctx
->noinject
) {
507 /* We injected two packets with the same packet number! */
515 * We didn't find any packets with a packet number equal to or greater than
516 * this one, so we just add it onto the end
518 for (i
= 0; i
< (duprec
? 3 : 1); i
++) {
519 thispkt
= allpkts
[i
];
520 if (!sk_MEMPACKET_push(ctx
->pkts
, thispkt
))
530 for (i
= 0; i
< (ctx
->duprec
> 0 ? 3 : 1); i
++)
531 mempacket_free(allpkts
[i
]);
535 static int mempacket_test_write(BIO
*bio
, const char *in
, int inl
)
537 return mempacket_test_inject(bio
, in
, inl
, -1, STANDARD_PACKET
);
540 static long mempacket_test_ctrl(BIO
*bio
, int cmd
, long num
, void *ptr
)
543 MEMPACKET_TEST_CTX
*ctx
= BIO_get_data(bio
);
548 ret
= (long)(sk_MEMPACKET_num(ctx
->pkts
) == 0);
550 case BIO_CTRL_GET_CLOSE
:
551 ret
= BIO_get_shutdown(bio
);
553 case BIO_CTRL_SET_CLOSE
:
554 BIO_set_shutdown(bio
, (int)num
);
556 case BIO_CTRL_WPENDING
:
559 case BIO_CTRL_PENDING
:
560 thispkt
= sk_MEMPACKET_value(ctx
->pkts
, 0);
569 case MEMPACKET_CTRL_SET_DROP_EPOCH
:
570 ctx
->dropepoch
= (unsigned int)num
;
572 case MEMPACKET_CTRL_SET_DROP_REC
:
573 ctx
->droprec
= (int)num
;
575 case MEMPACKET_CTRL_GET_DROP_REC
:
578 case MEMPACKET_CTRL_SET_DUPLICATE_REC
:
579 ctx
->duprec
= (int)num
;
592 static int mempacket_test_gets(BIO
*bio
, char *buf
, int size
)
594 /* We don't support this - not needed anyway */
598 static int mempacket_test_puts(BIO
*bio
, const char *str
)
600 return mempacket_test_write(bio
, str
, strlen(str
));
603 int create_ssl_ctx_pair(const SSL_METHOD
*sm
, const SSL_METHOD
*cm
,
604 int min_proto_version
, int max_proto_version
,
605 SSL_CTX
**sctx
, SSL_CTX
**cctx
, char *certfile
,
608 SSL_CTX
*serverctx
= NULL
;
609 SSL_CTX
*clientctx
= NULL
;
611 if (!TEST_ptr(serverctx
= SSL_CTX_new(sm
))
612 || (cctx
!= NULL
&& !TEST_ptr(clientctx
= SSL_CTX_new(cm
))))
615 if ((min_proto_version
> 0
616 && !TEST_true(SSL_CTX_set_min_proto_version(serverctx
,
618 || (max_proto_version
> 0
619 && !TEST_true(SSL_CTX_set_max_proto_version(serverctx
,
620 max_proto_version
))))
622 if (clientctx
!= NULL
623 && ((min_proto_version
> 0
624 && !TEST_true(SSL_CTX_set_min_proto_version(clientctx
,
626 || (max_proto_version
> 0
627 && !TEST_true(SSL_CTX_set_max_proto_version(clientctx
,
628 max_proto_version
)))))
631 if (certfile
!= NULL
&& privkeyfile
!= NULL
) {
632 if (!TEST_int_eq(SSL_CTX_use_certificate_file(serverctx
, certfile
,
633 SSL_FILETYPE_PEM
), 1)
634 || !TEST_int_eq(SSL_CTX_use_PrivateKey_file(serverctx
,
636 SSL_FILETYPE_PEM
), 1)
637 || !TEST_int_eq(SSL_CTX_check_private_key(serverctx
), 1))
641 #ifndef OPENSSL_NO_DH
642 SSL_CTX_set_dh_auto(serverctx
, 1);
651 SSL_CTX_free(serverctx
);
652 SSL_CTX_free(clientctx
);
656 #define MAXLOOPS 1000000
659 * NOTE: Transfers control of the BIOs - this function will free them on error
661 int create_ssl_objects(SSL_CTX
*serverctx
, SSL_CTX
*clientctx
, SSL
**sssl
,
662 SSL
**cssl
, BIO
*s_to_c_fbio
, BIO
*c_to_s_fbio
)
664 SSL
*serverssl
= NULL
, *clientssl
= NULL
;
665 BIO
*s_to_c_bio
= NULL
, *c_to_s_bio
= NULL
;
669 else if (!TEST_ptr(serverssl
= SSL_new(serverctx
)))
673 else if (!TEST_ptr(clientssl
= SSL_new(clientctx
)))
676 if (SSL_is_dtls(clientssl
)) {
677 if (!TEST_ptr(s_to_c_bio
= BIO_new(bio_s_mempacket_test()))
678 || !TEST_ptr(c_to_s_bio
= BIO_new(bio_s_mempacket_test())))
681 if (!TEST_ptr(s_to_c_bio
= BIO_new(BIO_s_mem()))
682 || !TEST_ptr(c_to_s_bio
= BIO_new(BIO_s_mem())))
686 if (s_to_c_fbio
!= NULL
687 && !TEST_ptr(s_to_c_bio
= BIO_push(s_to_c_fbio
, s_to_c_bio
)))
689 if (c_to_s_fbio
!= NULL
690 && !TEST_ptr(c_to_s_bio
= BIO_push(c_to_s_fbio
, c_to_s_bio
)))
693 /* Set Non-blocking IO behaviour */
694 BIO_set_mem_eof_return(s_to_c_bio
, -1);
695 BIO_set_mem_eof_return(c_to_s_bio
, -1);
697 /* Up ref these as we are passing them to two SSL objects */
698 SSL_set_bio(serverssl
, c_to_s_bio
, s_to_c_bio
);
699 BIO_up_ref(s_to_c_bio
);
700 BIO_up_ref(c_to_s_bio
);
701 SSL_set_bio(clientssl
, s_to_c_bio
, c_to_s_bio
);
709 BIO_free(s_to_c_bio
);
710 BIO_free(c_to_s_bio
);
711 BIO_free(s_to_c_fbio
);
712 BIO_free(c_to_s_fbio
);
718 * Create an SSL connection, but does not ready any post-handshake
719 * NewSessionTicket messages.
721 int create_bare_ssl_connection(SSL
*serverssl
, SSL
*clientssl
, int want
)
723 int retc
= -1, rets
= -1, err
, abortctr
= 0;
724 int clienterr
= 0, servererr
= 0;
725 int isdtls
= SSL_is_dtls(serverssl
);
728 err
= SSL_ERROR_WANT_WRITE
;
729 while (!clienterr
&& retc
<= 0 && err
== SSL_ERROR_WANT_WRITE
) {
730 retc
= SSL_connect(clientssl
);
732 err
= SSL_get_error(clientssl
, retc
);
735 if (!clienterr
&& retc
<= 0 && err
!= SSL_ERROR_WANT_READ
) {
736 TEST_info("SSL_connect() failed %d, %d", retc
, err
);
739 if (want
!= SSL_ERROR_NONE
&& err
== want
)
742 err
= SSL_ERROR_WANT_WRITE
;
743 while (!servererr
&& rets
<= 0 && err
== SSL_ERROR_WANT_WRITE
) {
744 rets
= SSL_accept(serverssl
);
746 err
= SSL_get_error(serverssl
, rets
);
749 if (!servererr
&& rets
<= 0
750 && err
!= SSL_ERROR_WANT_READ
751 && err
!= SSL_ERROR_WANT_X509_LOOKUP
) {
752 TEST_info("SSL_accept() failed %d, %d", rets
, err
);
755 if (want
!= SSL_ERROR_NONE
&& err
== want
)
757 if (clienterr
&& servererr
)
760 if (rets
> 0 && retc
<= 0)
761 DTLSv1_handle_timeout(serverssl
);
762 if (retc
> 0 && rets
<= 0)
763 DTLSv1_handle_timeout(clientssl
);
765 if (++abortctr
== MAXLOOPS
) {
766 TEST_info("No progress made");
769 if (isdtls
&& abortctr
<= 50 && (abortctr
% 10) == 0) {
771 * It looks like we're just spinning. Pause for a short period to
772 * give the DTLS timer a chance to do something. We only do this for
773 * the first few times to prevent hangs.
777 } while (retc
<=0 || rets
<= 0);
783 * Create an SSL connection including any post handshake NewSessionTicket
786 int create_ssl_connection(SSL
*serverssl
, SSL
*clientssl
, int want
)
792 if (!create_bare_ssl_connection(serverssl
, clientssl
, want
))
796 * We attempt to read some data on the client side which we expect to fail.
797 * This will ensure we have received the NewSessionTicket in TLSv1.3 where
798 * appropriate. We do this twice because there are 2 NewSesionTickets.
800 for (i
= 0; i
< 2; i
++) {
801 if (SSL_read_ex(clientssl
, &buf
, sizeof(buf
), &readbytes
) > 0) {
802 if (!TEST_ulong_eq(readbytes
, 0))
804 } else if (!TEST_int_eq(SSL_get_error(clientssl
, 0),
805 SSL_ERROR_WANT_READ
)) {
813 void shutdown_ssl_connection(SSL
*serverssl
, SSL
*clientssl
)
815 SSL_shutdown(clientssl
);
816 SSL_shutdown(serverssl
);