summaryrefslogtreecommitdiff
path: root/src/regress/lib/libssl/client
diff options
context:
space:
mode:
authorjsing <>2020-04-06 16:49:42 +0000
committerjsing <>2020-04-06 16:49:42 +0000
commit8eff3ba970ca459d172046c749e4763f0dc50174 (patch)
tree4a8376167d21cbe7ce75f198a5b6b50f0ce85e1f /src/regress/lib/libssl/client
parentff51012cdb035df195da4b0adb5d561d6827be09 (diff)
downloadopenbsd-8eff3ba970ca459d172046c749e4763f0dc50174.tar.gz
openbsd-8eff3ba970ca459d172046c749e4763f0dc50174.tar.bz2
openbsd-8eff3ba970ca459d172046c749e4763f0dc50174.zip
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 'src/regress/lib/libssl/client')
-rw-r--r--src/regress/lib/libssl/client/clienttest.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/regress/lib/libssl/client/clienttest.c b/src/regress/lib/libssl/client/clienttest.c
index b22b26eca4..5a76e66f8c 100644
--- a/src/regress/lib/libssl/client/clienttest.c
+++ b/src/regress/lib/libssl/client/clienttest.c
@@ -347,7 +347,6 @@ client_hello_test(int testno, struct client_hello_test *cht)
347 size_t client_hello_len; 347 size_t client_hello_len;
348 char *wbuf, rbuf[1]; 348 char *wbuf, rbuf[1];
349 int ret = 1; 349 int ret = 1;
350 size_t i;
351 long len; 350 long len;
352 351
353 fprintf(stderr, "Test %i - %s\n", testno, cht->desc); 352 fprintf(stderr, "Test %i - %s\n", testno, cht->desc);
@@ -402,14 +401,17 @@ client_hello_test(int testno, struct client_hello_test *cht)
402 } 401 }
403 402
404 /* We expect the client random to differ. */ 403 /* We expect the client random to differ. */
405 i = cht->random_start + SSL3_RANDOM_SIZE; 404 if (memcmp(&client_hello[cht->random_start], &wbuf[cht->random_start],
406 if (memcmp(client_hello, wbuf, cht->random_start) != 0 || 405 SSL3_RANDOM_SIZE) == 0) {
407 memcmp(&client_hello[cht->random_start], 406 fprintf(stderr, "FAIL: ClientHello has zeroed random\n");
408 &wbuf[cht->random_start], SSL3_RANDOM_SIZE) == 0 || 407 goto failure;
409 memcmp(&client_hello[i], &wbuf[i], len - i) != 0) { 408 }
409
410 memset(&wbuf[cht->random_start], 0, SSL3_RANDOM_SIZE);
411
412 if (memcmp(client_hello, wbuf, client_hello_len) != 0) {
410 fprintf(stderr, "FAIL: ClientHello differs:\n"); 413 fprintf(stderr, "FAIL: ClientHello differs:\n");
411 fprintf(stderr, "received:\n"); 414 fprintf(stderr, "received:\n");
412 memset(&wbuf[cht->random_start], 0, SSL3_RANDOM_SIZE);
413 hexdump(wbuf, len); 415 hexdump(wbuf, len);
414 fprintf(stderr, "test data:\n"); 416 fprintf(stderr, "test data:\n");
415 hexdump(client_hello, client_hello_len); 417 hexdump(client_hello, client_hello_len);