summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2020-04-06 16:49:43 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2020-04-06 16:49:43 +0000
commit39bd7ae6d272c86ff21faa2ca6852a05a58e3937 (patch)
treea65ac3a1390d8c6d606ee9e403c414031b1fc03f /regress
parenta8e84878f0b03ea23460f068a62cf220a40ee594 (diff)
Improve comparision with test data.
First check the client random against the zeroed value, then zero the client random in the client hello, before comparing with the golden value. This makes failures more obvious and the test code more readable.
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libssl/client/clienttest.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/regress/lib/libssl/client/clienttest.c b/regress/lib/libssl/client/clienttest.c
index b22b26eca4e..5a76e66f8c9 100644
--- a/regress/lib/libssl/client/clienttest.c
+++ b/regress/lib/libssl/client/clienttest.c
@@ -347,7 +347,6 @@ client_hello_test(int testno, struct client_hello_test *cht)
size_t client_hello_len;
char *wbuf, rbuf[1];
int ret = 1;
- size_t i;
long len;
fprintf(stderr, "Test %i - %s\n", testno, cht->desc);
@@ -402,14 +401,17 @@ client_hello_test(int testno, struct client_hello_test *cht)
}
/* We expect the client random to differ. */
- i = cht->random_start + SSL3_RANDOM_SIZE;
- if (memcmp(client_hello, wbuf, cht->random_start) != 0 ||
- memcmp(&client_hello[cht->random_start],
- &wbuf[cht->random_start], SSL3_RANDOM_SIZE) == 0 ||
- memcmp(&client_hello[i], &wbuf[i], len - i) != 0) {
+ if (memcmp(&client_hello[cht->random_start], &wbuf[cht->random_start],
+ SSL3_RANDOM_SIZE) == 0) {
+ fprintf(stderr, "FAIL: ClientHello has zeroed random\n");
+ goto failure;
+ }
+
+ memset(&wbuf[cht->random_start], 0, SSL3_RANDOM_SIZE);
+
+ if (memcmp(client_hello, wbuf, client_hello_len) != 0) {
fprintf(stderr, "FAIL: ClientHello differs:\n");
fprintf(stderr, "received:\n");
- memset(&wbuf[cht->random_start], 0, SSL3_RANDOM_SIZE);
hexdump(wbuf, len);
fprintf(stderr, "test data:\n");
hexdump(client_hello, client_hello_len);