diff options
author | jsing <> | 2021-10-23 13:12:45 +0000 |
---|---|---|
committer | jsing <> | 2021-10-23 13:12:45 +0000 |
commit | 95e856754f2f3f9efb0f717095a5fbf17ffb2c72 (patch) | |
tree | c1536523ca697f446db4e57e690618070ed928be | |
parent | d2039e7348559d4183f5d055e691e70e1dadf349 (diff) | |
download | openbsd-95e856754f2f3f9efb0f717095a5fbf17ffb2c72.tar.gz openbsd-95e856754f2f3f9efb0f717095a5fbf17ffb2c72.tar.bz2 openbsd-95e856754f2f3f9efb0f717095a5fbf17ffb2c72.zip |
Revise regress test for tls13_buffer rename.
-rw-r--r-- | src/regress/lib/libssl/buffer/buffertest.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/regress/lib/libssl/buffer/buffertest.c b/src/regress/lib/libssl/buffer/buffertest.c index e627865e35..80b3b98d68 100644 --- a/src/regress/lib/libssl/buffer/buffertest.c +++ b/src/regress/lib/libssl/buffer/buffertest.c | |||
@@ -15,9 +15,11 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <err.h> | 17 | #include <err.h> |
18 | #include <stdio.h> | ||
19 | #include <stdlib.h> | ||
18 | #include <string.h> | 20 | #include <string.h> |
19 | 21 | ||
20 | #include "tls13_internal.h" | 22 | #include "tls_internal.h" |
21 | 23 | ||
22 | uint8_t testdata[] = { | 24 | uint8_t testdata[] = { |
23 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | 25 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
@@ -37,13 +39,13 @@ read_cb(void *buf, size_t buflen, void *cb_arg) | |||
37 | ssize_t n; | 39 | ssize_t n; |
38 | 40 | ||
39 | if (rs->offset > rs->len) | 41 | if (rs->offset > rs->len) |
40 | return TLS13_IO_EOF; | 42 | return TLS_IO_EOF; |
41 | 43 | ||
42 | if ((size_t)(n = buflen) > (rs->len - rs->offset)) | 44 | if ((size_t)(n = buflen) > (rs->len - rs->offset)) |
43 | n = rs->len - rs->offset; | 45 | n = rs->len - rs->offset; |
44 | 46 | ||
45 | if (n == 0) | 47 | if (n == 0) |
46 | return TLS13_IO_WANT_POLLIN; | 48 | return TLS_IO_WANT_POLLIN; |
47 | 49 | ||
48 | memcpy(buf, &rs->buf[rs->offset], n); | 50 | memcpy(buf, &rs->buf[rs->offset], n); |
49 | rs->offset += n; | 51 | rs->offset += n; |
@@ -61,7 +63,7 @@ struct extend_test extend_tests[] = { | |||
61 | { | 63 | { |
62 | .extend_len = 4, | 64 | .extend_len = 4, |
63 | .read_len = 0, | 65 | .read_len = 0, |
64 | .want_ret = TLS13_IO_WANT_POLLIN, | 66 | .want_ret = TLS_IO_WANT_POLLIN, |
65 | }, | 67 | }, |
66 | { | 68 | { |
67 | .extend_len = 4, | 69 | .extend_len = 4, |
@@ -71,12 +73,12 @@ struct extend_test extend_tests[] = { | |||
71 | { | 73 | { |
72 | .extend_len = 12, | 74 | .extend_len = 12, |
73 | .read_len = 8, | 75 | .read_len = 8, |
74 | .want_ret = TLS13_IO_WANT_POLLIN, | 76 | .want_ret = TLS_IO_WANT_POLLIN, |
75 | }, | 77 | }, |
76 | { | 78 | { |
77 | .extend_len = 12, | 79 | .extend_len = 12, |
78 | .read_len = 10, | 80 | .read_len = 10, |
79 | .want_ret = TLS13_IO_WANT_POLLIN, | 81 | .want_ret = TLS_IO_WANT_POLLIN, |
80 | }, | 82 | }, |
81 | { | 83 | { |
82 | .extend_len = 12, | 84 | .extend_len = 12, |
@@ -91,7 +93,7 @@ struct extend_test extend_tests[] = { | |||
91 | { | 93 | { |
92 | .extend_len = 20, | 94 | .extend_len = 20, |
93 | .read_len = 1, | 95 | .read_len = 1, |
94 | .want_ret = TLS13_IO_EOF, | 96 | .want_ret = TLS_IO_EOF, |
95 | }, | 97 | }, |
96 | }; | 98 | }; |
97 | 99 | ||
@@ -100,7 +102,7 @@ struct extend_test extend_tests[] = { | |||
100 | int | 102 | int |
101 | main(int argc, char **argv) | 103 | main(int argc, char **argv) |
102 | { | 104 | { |
103 | struct tls13_buffer *buf; | 105 | struct tls_buffer *buf; |
104 | struct extend_test *et; | 106 | struct extend_test *et; |
105 | struct read_state rs; | 107 | struct read_state rs; |
106 | uint8_t *data; | 108 | uint8_t *data; |
@@ -111,21 +113,21 @@ main(int argc, char **argv) | |||
111 | rs.buf = testdata; | 113 | rs.buf = testdata; |
112 | rs.offset = 0; | 114 | rs.offset = 0; |
113 | 115 | ||
114 | if ((buf = tls13_buffer_new(0)) == NULL) | 116 | if ((buf = tls_buffer_new(0)) == NULL) |
115 | errx(1, "tls13_buffer_new"); | 117 | errx(1, "tls_buffer_new"); |
116 | 118 | ||
117 | for (i = 0; i < N_EXTEND_TESTS; i++) { | 119 | for (i = 0; i < N_EXTEND_TESTS; i++) { |
118 | et = &extend_tests[i]; | 120 | et = &extend_tests[i]; |
119 | rs.len = et->read_len; | 121 | rs.len = et->read_len; |
120 | 122 | ||
121 | ret = tls13_buffer_extend(buf, et->extend_len, read_cb, &rs); | 123 | ret = tls_buffer_extend(buf, et->extend_len, read_cb, &rs); |
122 | if (ret != extend_tests[i].want_ret) { | 124 | if (ret != extend_tests[i].want_ret) { |
123 | fprintf(stderr, "FAIL: Test %zi - extend returned %zi, " | 125 | fprintf(stderr, "FAIL: Test %zi - extend returned %zi, " |
124 | "want %zi\n", i, ret, et->want_ret); | 126 | "want %zi\n", i, ret, et->want_ret); |
125 | return 1; | 127 | return 1; |
126 | } | 128 | } |
127 | 129 | ||
128 | tls13_buffer_cbs(buf, &cbs); | 130 | tls_buffer_cbs(buf, &cbs); |
129 | 131 | ||
130 | if (!CBS_mem_equal(&cbs, testdata, CBS_len(&cbs))) { | 132 | if (!CBS_mem_equal(&cbs, testdata, CBS_len(&cbs))) { |
131 | fprintf(stderr, "FAIL: Test %zi - extend buffer " | 133 | fprintf(stderr, "FAIL: Test %zi - extend buffer " |
@@ -134,12 +136,12 @@ main(int argc, char **argv) | |||
134 | } | 136 | } |
135 | } | 137 | } |
136 | 138 | ||
137 | if (!tls13_buffer_finish(buf, &data, &data_len)) { | 139 | if (!tls_buffer_finish(buf, &data, &data_len)) { |
138 | fprintf(stderr, "FAIL: failed to finish\n"); | 140 | fprintf(stderr, "FAIL: failed to finish\n"); |
139 | return 1; | 141 | return 1; |
140 | } | 142 | } |
141 | 143 | ||
142 | tls13_buffer_free(buf); | 144 | tls_buffer_free(buf); |
143 | 145 | ||
144 | if (data_len != sizeof(testdata)) { | 146 | if (data_len != sizeof(testdata)) { |
145 | fprintf(stderr, "FAIL: got data length %zu, want %zu\n", | 147 | fprintf(stderr, "FAIL: got data length %zu, want %zu\n", |