summaryrefslogtreecommitdiff
path: root/auto_tests/TCP_test.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2016-01-30 16:30:28 -0500
committerirungentoo <irungentoo@gmail.com>2016-01-30 16:30:28 -0500
commitccfa6c6a4fcd80171e9f64bb04205d3939ed8ffd (patch)
tree065896349a6d6aa9aa6a2240aa746daf38d4545c /auto_tests/TCP_test.c
parent61f8e65c0157049ac26bf9b081ba6842d7defdeb (diff)
parent23b0c9cdedae01b09055a0476823e225680d3930 (diff)
Merge branch 'kpp-code_review'
Diffstat (limited to 'auto_tests/TCP_test.c')
-rw-r--r--auto_tests/TCP_test.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index 0cf063f1..ba1d5232 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -117,7 +117,7 @@ START_TEST(test_basic)
117 increment_nonce(f_nonce_r); 117 increment_nonce(f_nonce_r);
118 ck_assert_msg(packet_resp_plain[0] == 1, "wrong packet id %u", packet_resp_plain[0]); 118 ck_assert_msg(packet_resp_plain[0] == 1, "wrong packet id %u", packet_resp_plain[0]);
119 ck_assert_msg(packet_resp_plain[1] == 0, "connection not refused %u", packet_resp_plain[1]); 119 ck_assert_msg(packet_resp_plain[1] == 0, "connection not refused %u", packet_resp_plain[1]);
120 ck_assert_msg(memcmp(packet_resp_plain + 2, f_public_key, crypto_box_PUBLICKEYBYTES) == 0, "key in packet wrong"); 120 ck_assert_msg(public_key_cmp(packet_resp_plain + 2, f_public_key) == 0, "key in packet wrong");
121 kill_TCP_server(tcp_s); 121 kill_TCP_server(tcp_s);
122} 122}
123END_TEST 123END_TEST
@@ -235,12 +235,12 @@ START_TEST(test_some)
235 ck_assert_msg(len == 1 + 1 + crypto_box_PUBLICKEYBYTES, "wrong len %u", len); 235 ck_assert_msg(len == 1 + 1 + crypto_box_PUBLICKEYBYTES, "wrong len %u", len);
236 ck_assert_msg(data[0] == 1, "wrong packet id %u", data[0]); 236 ck_assert_msg(data[0] == 1, "wrong packet id %u", data[0]);
237 ck_assert_msg(data[1] == 16, "connection not refused %u", data[1]); 237 ck_assert_msg(data[1] == 16, "connection not refused %u", data[1]);
238 ck_assert_msg(memcmp(data + 2, con3->public_key, crypto_box_PUBLICKEYBYTES) == 0, "key in packet wrong"); 238 ck_assert_msg(public_key_cmp(data + 2, con3->public_key) == 0, "key in packet wrong");
239 len = read_packet_sec_TCP(con3, data, 2 + 1 + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES); 239 len = read_packet_sec_TCP(con3, data, 2 + 1 + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES);
240 ck_assert_msg(len == 1 + 1 + crypto_box_PUBLICKEYBYTES, "wrong len %u", len); 240 ck_assert_msg(len == 1 + 1 + crypto_box_PUBLICKEYBYTES, "wrong len %u", len);
241 ck_assert_msg(data[0] == 1, "wrong packet id %u", data[0]); 241 ck_assert_msg(data[0] == 1, "wrong packet id %u", data[0]);
242 ck_assert_msg(data[1] == 16, "connection not refused %u", data[1]); 242 ck_assert_msg(data[1] == 16, "connection not refused %u", data[1]);
243 ck_assert_msg(memcmp(data + 2, con1->public_key, crypto_box_PUBLICKEYBYTES) == 0, "key in packet wrong"); 243 ck_assert_msg(public_key_cmp(data + 2, con1->public_key) == 0, "key in packet wrong");
244 244
245 uint8_t test_packet[512] = {16, 17, 16, 86, 99, 127, 255, 189, 78}; 245 uint8_t test_packet[512] = {16, 17, 16, 86, 99, 127, 255, 189, 78};
246 write_packet_TCP_secure_connection(con3, test_packet, sizeof(test_packet)); 246 write_packet_TCP_secure_connection(con3, test_packet, sizeof(test_packet));
@@ -363,7 +363,7 @@ static int oob_data_callback(void *object, const uint8_t *public_key, const uint
363 if (length != 5) 363 if (length != 5)
364 return 1; 364 return 1;
365 365
366 if (memcmp(public_key, oob_pubkey, crypto_box_PUBLICKEYBYTES) != 0) 366 if (public_key_cmp(public_key, oob_pubkey) != 0)
367 return 1; 367 return 1;
368 368
369 if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) { 369 if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) {
@@ -447,7 +447,7 @@ START_TEST(test_client)
447 do_TCP_connection(conn2); 447 do_TCP_connection(conn2);
448 ck_assert_msg(oob_data_callback_good == 1, "oob callback not called"); 448 ck_assert_msg(oob_data_callback_good == 1, "oob callback not called");
449 ck_assert_msg(response_callback_good == 1, "response callback not called"); 449 ck_assert_msg(response_callback_good == 1, "response callback not called");
450 ck_assert_msg(memcmp(response_callback_public_key, f2_public_key, crypto_box_PUBLICKEYBYTES) == 0, "wrong public key"); 450 ck_assert_msg(public_key_cmp(response_callback_public_key, f2_public_key) == 0, "wrong public key");
451 ck_assert_msg(status_callback_good == 1, "status callback not called"); 451 ck_assert_msg(status_callback_good == 1, "status callback not called");
452 ck_assert_msg(status_callback_status == 2, "wrong status"); 452 ck_assert_msg(status_callback_status == 2, "wrong status");
453 ck_assert_msg(status_callback_connection_id == response_callback_connection_id, "connection ids not equal"); 453 ck_assert_msg(status_callback_connection_id == response_callback_connection_id, "connection ids not equal");
@@ -538,17 +538,17 @@ START_TEST(test_tcp_connection)
538 uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; 538 uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
539 crypto_box_keypair(self_public_key, self_secret_key); 539 crypto_box_keypair(self_public_key, self_secret_key);
540 TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL); 540 TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
541 ck_assert_msg(memcmp(tcp_s->public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key"); 541 ck_assert_msg(public_key_cmp(tcp_s->public_key, self_public_key) == 0, "Wrong public key");
542 542
543 TCP_Proxy_Info proxy_info; 543 TCP_Proxy_Info proxy_info;
544 proxy_info.proxy_type = TCP_PROXY_NONE; 544 proxy_info.proxy_type = TCP_PROXY_NONE;
545 crypto_box_keypair(self_public_key, self_secret_key); 545 crypto_box_keypair(self_public_key, self_secret_key);
546 TCP_Connections *tc_1 = new_tcp_connections(self_secret_key, &proxy_info); 546 TCP_Connections *tc_1 = new_tcp_connections(self_secret_key, &proxy_info);
547 ck_assert_msg(memcmp(tc_1->self_public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key"); 547 ck_assert_msg(public_key_cmp(tc_1->self_public_key, self_public_key) == 0, "Wrong public key");
548 548
549 crypto_box_keypair(self_public_key, self_secret_key); 549 crypto_box_keypair(self_public_key, self_secret_key);
550 TCP_Connections *tc_2 = new_tcp_connections(self_secret_key, &proxy_info); 550 TCP_Connections *tc_2 = new_tcp_connections(self_secret_key, &proxy_info);
551 ck_assert_msg(memcmp(tc_2->self_public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key"); 551 ck_assert_msg(public_key_cmp(tc_2->self_public_key, self_public_key) == 0, "Wrong public key");
552 552
553 IP_Port ip_port_tcp_s; 553 IP_Port ip_port_tcp_s;
554 554
@@ -641,17 +641,17 @@ START_TEST(test_tcp_connection2)
641 uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; 641 uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
642 crypto_box_keypair(self_public_key, self_secret_key); 642 crypto_box_keypair(self_public_key, self_secret_key);
643 TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL); 643 TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
644 ck_assert_msg(memcmp(tcp_s->public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key"); 644 ck_assert_msg(public_key_cmp(tcp_s->public_key, self_public_key) == 0, "Wrong public key");
645 645
646 TCP_Proxy_Info proxy_info; 646 TCP_Proxy_Info proxy_info;
647 proxy_info.proxy_type = TCP_PROXY_NONE; 647 proxy_info.proxy_type = TCP_PROXY_NONE;
648 crypto_box_keypair(self_public_key, self_secret_key); 648 crypto_box_keypair(self_public_key, self_secret_key);
649 TCP_Connections *tc_1 = new_tcp_connections(self_secret_key, &proxy_info); 649 TCP_Connections *tc_1 = new_tcp_connections(self_secret_key, &proxy_info);
650 ck_assert_msg(memcmp(tc_1->self_public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key"); 650 ck_assert_msg(public_key_cmp(tc_1->self_public_key, self_public_key) == 0, "Wrong public key");
651 651
652 crypto_box_keypair(self_public_key, self_secret_key); 652 crypto_box_keypair(self_public_key, self_secret_key);
653 TCP_Connections *tc_2 = new_tcp_connections(self_secret_key, &proxy_info); 653 TCP_Connections *tc_2 = new_tcp_connections(self_secret_key, &proxy_info);
654 ck_assert_msg(memcmp(tc_2->self_public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key"); 654 ck_assert_msg(public_key_cmp(tc_2->self_public_key, self_public_key) == 0, "Wrong public key");
655 655
656 IP_Port ip_port_tcp_s; 656 IP_Port ip_port_tcp_s;
657 657