diff options
author | jsing <> | 2019-01-20 10:20:50 +0000 |
---|---|---|
committer | jsing <> | 2019-01-20 10:20:50 +0000 |
commit | 109c1a3cd723529ce9ea6e4db6ce37493ed83034 (patch) | |
tree | d58bd269b37847bb593eaa013fabeeefb37b38e9 | |
parent | 7edeeab42abe6a4ac98592eaeb95ef15308aa99e (diff) | |
download | openbsd-109c1a3cd723529ce9ea6e4db6ce37493ed83034.tar.gz openbsd-109c1a3cd723529ce9ea6e4db6ce37493ed83034.tar.bz2 openbsd-109c1a3cd723529ce9ea6e4db6ce37493ed83034.zip |
Update record regress to match functionality changes.
-rw-r--r-- | src/regress/lib/libssl/record/recordtest.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/src/regress/lib/libssl/record/recordtest.c b/src/regress/lib/libssl/record/recordtest.c index 2e08c34577..42bba88c1b 100644 --- a/src/regress/lib/libssl/record/recordtest.c +++ b/src/regress/lib/libssl/record/recordtest.c | |||
@@ -44,7 +44,12 @@ static uint8_t test_record_1[] = { | |||
44 | 44 | ||
45 | /* Truncated record. */ | 45 | /* Truncated record. */ |
46 | static uint8_t test_record_2[] = { | 46 | static uint8_t test_record_2[] = { |
47 | 0x17, 0x03, 0x03, 0xff, 0xff, 0x02, 0x00, 0x00, | 47 | 0x17, 0x03, 0x03, 0x41, 0x00, 0x02, 0x00, 0x00, |
48 | }; | ||
49 | |||
50 | /* Oversized and truncated record. */ | ||
51 | static uint8_t test_record_3[] = { | ||
52 | 0x17, 0x03, 0x03, 0x41, 0x01, 0x02, 0x00, 0x00, | ||
48 | }; | 53 | }; |
49 | 54 | ||
50 | static void | 55 | static void |
@@ -230,6 +235,15 @@ struct record_recv_test record_recv_tests[] = { | |||
230 | }, | 235 | }, |
231 | .want_content_type = SSL3_RT_APPLICATION_DATA, | 236 | .want_content_type = SSL3_RT_APPLICATION_DATA, |
232 | }, | 237 | }, |
238 | { | ||
239 | .read_buf = test_record_3, | ||
240 | .rt = { | ||
241 | { | ||
242 | .rw_len = sizeof(test_record_3), | ||
243 | .want_ret = TLS13_IO_FAILURE, | ||
244 | }, | ||
245 | }, | ||
246 | }, | ||
233 | }; | 247 | }; |
234 | 248 | ||
235 | #define N_RECORD_RECV_TESTS (sizeof(record_recv_tests) / sizeof(record_recv_tests[0])) | 249 | #define N_RECORD_RECV_TESTS (sizeof(record_recv_tests) / sizeof(record_recv_tests[0])) |
@@ -388,7 +402,6 @@ test_record_recv(size_t test_no, struct record_recv_test *rrt) | |||
388 | } | 402 | } |
389 | 403 | ||
390 | tls13_record_data(rec, &cbs); | 404 | tls13_record_data(rec, &cbs); |
391 | |||
392 | if (rrt->want_data == NULL) { | 405 | if (rrt->want_data == NULL) { |
393 | if (CBS_data(&cbs) != NULL || CBS_len(&cbs) != 0) { | 406 | if (CBS_data(&cbs) != NULL || CBS_len(&cbs) != 0) { |
394 | fprintf(stderr, "FAIL: Test %zu - got CBS with data, " | 407 | fprintf(stderr, "FAIL: Test %zu - got CBS with data, " |
@@ -397,7 +410,6 @@ test_record_recv(size_t test_no, struct record_recv_test *rrt) | |||
397 | } | 410 | } |
398 | goto done; | 411 | goto done; |
399 | } | 412 | } |
400 | |||
401 | if (!CBS_mem_equal(&cbs, rrt->want_data, rrt->want_len)) { | 413 | if (!CBS_mem_equal(&cbs, rrt->want_data, rrt->want_len)) { |
402 | fprintf(stderr, "FAIL: Test %zu - data mismatch\n", test_no); | 414 | fprintf(stderr, "FAIL: Test %zu - data mismatch\n", test_no); |
403 | fprintf(stderr, "Got record data:\n"); | 415 | fprintf(stderr, "Got record data:\n"); |
@@ -406,6 +418,21 @@ test_record_recv(size_t test_no, struct record_recv_test *rrt) | |||
406 | hexdump(rrt->want_data, rrt->want_len); | 418 | hexdump(rrt->want_data, rrt->want_len); |
407 | goto failure; | 419 | goto failure; |
408 | } | 420 | } |
421 | |||
422 | if (!tls13_record_header(rec, &cbs)) { | ||
423 | fprintf(stderr, "FAIL: Test %zu - fail to get record " | ||
424 | "header", test_no); | ||
425 | goto failure; | ||
426 | } | ||
427 | if (!CBS_mem_equal(&cbs, rrt->want_data, TLS13_RECORD_HEADER_LEN)) { | ||
428 | fprintf(stderr, "FAIL: Test %zu - header mismatch\n", test_no); | ||
429 | fprintf(stderr, "Got record header:\n"); | ||
430 | hexdump(CBS_data(&cbs), CBS_len(&cbs)); | ||
431 | fprintf(stderr, "Want record header:\n"); | ||
432 | hexdump(rrt->want_data, rrt->want_len); | ||
433 | goto failure; | ||
434 | } | ||
435 | |||
409 | if (!tls13_record_content(rec, &cbs)) { | 436 | if (!tls13_record_content(rec, &cbs)) { |
410 | fprintf(stderr, "FAIL: Test %zu - fail to get record " | 437 | fprintf(stderr, "FAIL: Test %zu - fail to get record " |
411 | "content", test_no); | 438 | "content", test_no); |
@@ -414,9 +441,9 @@ test_record_recv(size_t test_no, struct record_recv_test *rrt) | |||
414 | if (!CBS_mem_equal(&cbs, rrt->want_data + TLS13_RECORD_HEADER_LEN, | 441 | if (!CBS_mem_equal(&cbs, rrt->want_data + TLS13_RECORD_HEADER_LEN, |
415 | rrt->want_len - TLS13_RECORD_HEADER_LEN)) { | 442 | rrt->want_len - TLS13_RECORD_HEADER_LEN)) { |
416 | fprintf(stderr, "FAIL: Test %zu - content mismatch\n", test_no); | 443 | fprintf(stderr, "FAIL: Test %zu - content mismatch\n", test_no); |
417 | fprintf(stderr, "Got record data:\n"); | 444 | fprintf(stderr, "Got record content:\n"); |
418 | hexdump(CBS_data(&cbs), CBS_len(&cbs)); | 445 | hexdump(CBS_data(&cbs), CBS_len(&cbs)); |
419 | fprintf(stderr, "Want record data:\n"); | 446 | fprintf(stderr, "Want record content:\n"); |
420 | hexdump(rrt->want_data, rrt->want_len); | 447 | hexdump(rrt->want_data, rrt->want_len); |
421 | goto failure; | 448 | goto failure; |
422 | } | 449 | } |
@@ -452,7 +479,11 @@ test_record_send(size_t test_no, struct record_send_test *rst) | |||
452 | errx(1, "malloc"); | 479 | errx(1, "malloc"); |
453 | memcpy(data, rst->data, rst->data_len); | 480 | memcpy(data, rst->data, rst->data_len); |
454 | 481 | ||
455 | tls13_record_set_data(rec, data, rst->data_len); | 482 | if (!tls13_record_set_data(rec, data, rst->data_len)) { |
483 | fprintf(stderr, "FAIL: Test %zu - failed to set record data\n", | ||
484 | test_no); | ||
485 | goto failure; | ||
486 | } | ||
456 | data = NULL; | 487 | data = NULL; |
457 | 488 | ||
458 | for (i = 0; rst->rt[i].rw_len != 0 || rst->rt[i].want_ret != 0; i++) { | 489 | for (i = 0; rst->rt[i].rw_len != 0 || rst->rt[i].want_ret != 0; i++) { |