diff options
| author | jsing <> | 2017-05-07 01:56:24 +0000 |
|---|---|---|
| committer | jsing <> | 2017-05-07 01:56:24 +0000 |
| commit | 007ab3adf03f0dcd75a0963efec051cfca5bd86a (patch) | |
| tree | d55f2b85d294e65ddf3b567877fbd4fc1f937f8f | |
| parent | c681e1baa558dc17e9801e5c27aabc8cec41fd49 (diff) | |
| download | openbsd-007ab3adf03f0dcd75a0963efec051cfca5bd86a.tar.gz openbsd-007ab3adf03f0dcd75a0963efec051cfca5bd86a.tar.bz2 openbsd-007ab3adf03f0dcd75a0963efec051cfca5bd86a.zip | |
An an initial sequencing/ordering test for libtls.
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libtls/tls/tlstest.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/regress/lib/libtls/tls/tlstest.c b/src/regress/lib/libtls/tls/tlstest.c index 948425a675..1f75232dd9 100644 --- a/src/regress/lib/libtls/tls/tlstest.c +++ b/src/regress/lib/libtls/tls/tlstest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tlstest.c,v 1.5 2017/05/06 22:46:58 jsing Exp $ */ | 1 | /* $OpenBSD: tlstest.c,v 1.6 2017/05/07 01:56:24 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -350,6 +350,65 @@ do_tls_tests(void) | |||
| 350 | return (failure); | 350 | return (failure); |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | static int | ||
| 354 | do_tls_ordering_tests(void) | ||
| 355 | { | ||
| 356 | struct tls *client = NULL, *server = NULL, *server_cctx = NULL; | ||
| 357 | struct tls_config *client_cfg, *server_cfg; | ||
| 358 | int failure = 0; | ||
| 359 | |||
| 360 | circular_init(); | ||
| 361 | |||
| 362 | if ((client = tls_client()) == NULL) | ||
| 363 | errx(1, "failed to create tls client"); | ||
| 364 | if ((client_cfg = tls_config_new()) == NULL) | ||
| 365 | errx(1, "failed to create tls client config"); | ||
| 366 | tls_config_insecure_noverifyname(client_cfg); | ||
| 367 | if (tls_config_set_ca_file(client_cfg, cafile) == -1) | ||
| 368 | errx(1, "failed to set ca: %s", tls_config_error(client_cfg)); | ||
| 369 | |||
| 370 | if ((server = tls_server()) == NULL) | ||
| 371 | errx(1, "failed to create tls server"); | ||
| 372 | if ((server_cfg = tls_config_new()) == NULL) | ||
| 373 | errx(1, "failed to create tls server config"); | ||
| 374 | if (tls_config_set_keypair_file(server_cfg, certfile, keyfile) == -1) | ||
| 375 | errx(1, "failed to set keypair: %s", | ||
| 376 | tls_config_error(server_cfg)); | ||
| 377 | |||
| 378 | if (tls_configure(client, client_cfg) == -1) | ||
| 379 | errx(1, "failed to configure client: %s", tls_error(client)); | ||
| 380 | if (tls_configure(server, server_cfg) == -1) | ||
| 381 | errx(1, "failed to configure server: %s", tls_error(server)); | ||
| 382 | |||
| 383 | tls_config_free(client_cfg); | ||
| 384 | tls_config_free(server_cfg); | ||
| 385 | |||
| 386 | if (tls_accept_cbs(server, &server_cctx, server_read, server_write, | ||
| 387 | NULL) == -1) | ||
| 388 | errx(1, "failed to accept: %s", tls_error(server)); | ||
| 389 | |||
| 390 | if (tls_connect_cbs(client, client_read, client_write, NULL, | ||
| 391 | "test") == -1) | ||
| 392 | errx(1, "failed to connect: %s", tls_error(client)); | ||
| 393 | |||
| 394 | if (do_client_server_handshake("ordering", client, server_cctx) != 0) { | ||
| 395 | failure = 1; | ||
| 396 | goto done; | ||
| 397 | } | ||
| 398 | |||
| 399 | if (do_client_server_close("ordering", client, server_cctx) != 0) { | ||
| 400 | failure = 1; | ||
| 401 | goto done; | ||
| 402 | } | ||
| 403 | |||
| 404 | done: | ||
| 405 | tls_free(client); | ||
| 406 | tls_free(server); | ||
| 407 | tls_free(server_cctx); | ||
| 408 | |||
| 409 | return (failure); | ||
| 410 | } | ||
| 411 | |||
| 353 | int | 412 | int |
| 354 | main(int argc, char **argv) | 413 | main(int argc, char **argv) |
| 355 | { | 414 | { |
| @@ -369,6 +428,7 @@ main(int argc, char **argv) | |||
| 369 | errx(1, "failed to initialise tls"); | 428 | errx(1, "failed to initialise tls"); |
| 370 | 429 | ||
| 371 | failure |= do_tls_tests(); | 430 | failure |= do_tls_tests(); |
| 431 | failure |= do_tls_ordering_tests(); | ||
| 372 | 432 | ||
| 373 | return (failure); | 433 | return (failure); |
| 374 | } | 434 | } |
