summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2020-04-06 16:49:42 +0000
committerjsing <>2020-04-06 16:49:42 +0000
commit547644e5a6d21b3e4e3a8ce5be9263d9f4de519a (patch)
tree4a8376167d21cbe7ce75f198a5b6b50f0ce85e1f /src
parent886e7b4e8496825506fcddbdd782a52e1730e168 (diff)
downloadopenbsd-547644e5a6d21b3e4e3a8ce5be9263d9f4de519a.tar.gz
openbsd-547644e5a6d21b3e4e3a8ce5be9263d9f4de519a.tar.bz2
openbsd-547644e5a6d21b3e4e3a8ce5be9263d9f4de519a.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')
-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);