summaryrefslogtreecommitdiff
path: root/src/regress/lib
diff options
context:
space:
mode:
authorjsing <>2021-02-06 07:33:27 +0000
committerjsing <>2021-02-06 07:33:27 +0000
commit9c4ebcf34a97f2443372ea9e4a19f5ce8e9beb77 (patch)
tree22c69a77a98d917d75e292377622d33f214263e2 /src/regress/lib
parenta5e93fc7b4feac54578a8c48f8eb98244e56fad6 (diff)
downloadopenbsd-9c4ebcf34a97f2443372ea9e4a19f5ce8e9beb77.tar.gz
openbsd-9c4ebcf34a97f2443372ea9e4a19f5ce8e9beb77.tar.bz2
openbsd-9c4ebcf34a97f2443372ea9e4a19f5ce8e9beb77.zip
Test reads and writes between the client and server.
Diffstat (limited to 'src/regress/lib')
-rw-r--r--src/regress/lib/libssl/dtls/dtlstest.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/regress/lib/libssl/dtls/dtlstest.c b/src/regress/lib/libssl/dtls/dtlstest.c
index ae8075f709..cb83ced4d3 100644
--- a/src/regress/lib/libssl/dtls/dtlstest.c
+++ b/src/regress/lib/libssl/dtls/dtlstest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dtlstest.c,v 1.4 2020/10/16 17:57:20 tb Exp $ */ 1/* $OpenBSD: dtlstest.c,v 1.5 2021/02/06 07:33:27 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2020 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -284,7 +284,7 @@ static void
284dtls_info_callback(const SSL *ssl, int type, int val) 284dtls_info_callback(const SSL *ssl, int type, int val)
285{ 285{
286 /* 286 /*
287 * Squeal's ahead... remove the bbio from the info callback, so we can 287 * Squeals ahead... remove the bbio from the info callback, so we can
288 * drop specific messages. Ideally this would be an option for the SSL. 288 * drop specific messages. Ideally this would be an option for the SSL.
289 */ 289 */
290 if (ssl->wbio == ssl->bbio) 290 if (ssl->wbio == ssl->bbio)
@@ -428,6 +428,38 @@ do_accept(SSL *ssl, const char *name, int *done, short *events)
428} 428}
429 429
430static int 430static int
431do_read(SSL *ssl, const char *name, int *done, short *events)
432{
433 uint8_t buf[512];
434 int ssl_ret;
435
436 if ((ssl_ret = SSL_read(ssl, buf, sizeof(buf))) > 0) {
437 fprintf(stderr, "INFO: %s read done\n", name);
438 if (debug)
439 hexdump(buf, ssl_ret);
440 *done = 1;
441 return 1;
442 }
443
444 return ssl_error(ssl, name, "read", ssl_ret, events);
445}
446
447static int
448do_write(SSL *ssl, const char *name, int *done, short *events)
449{
450 const uint8_t buf[] = "Hello, World!\n";
451 int ssl_ret;
452
453 if ((ssl_ret = SSL_write(ssl, buf, sizeof(buf))) > 0) {
454 fprintf(stderr, "INFO: %s write done\n", name);
455 *done = 1;
456 return 1;
457 }
458
459 return ssl_error(ssl, name, "write", ssl_ret, events);
460}
461
462static int
431do_shutdown(SSL *ssl, const char *name, int *done, short *events) 463do_shutdown(SSL *ssl, const char *name, int *done, short *events)
432{ 464{
433 int ssl_ret; 465 int ssl_ret;
@@ -657,7 +689,21 @@ dtlstest(const struct dtls_test *dt)
657 goto failure; 689 goto failure;
658 } 690 }
659 691
660 /* XXX - do reads and writes. */ 692 pfd[0].events = POLLIN;
693 pfd[1].events = POLLOUT;
694
695 if (!do_client_server_loop(client, do_read, server, do_write, pfd)) {
696 fprintf(stderr, "FAIL: client read and server write I/O failed\n");
697 goto failure;
698 }
699
700 pfd[0].events = POLLOUT;
701 pfd[1].events = POLLIN;
702
703 if (!do_client_server_loop(client, do_write, server, do_read, pfd)) {
704 fprintf(stderr, "FAIL: client write and server read I/O failed\n");
705 goto failure;
706 }
661 707
662 pfd[0].events = POLLOUT; 708 pfd[0].events = POLLOUT;
663 pfd[1].events = POLLOUT; 709 pfd[1].events = POLLOUT;