summaryrefslogtreecommitdiff
path: root/auto_tests/onion_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/onion_test.c')
-rw-r--r--auto_tests/onion_test.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c
index cd060b1f..b8145cc2 100644
--- a/auto_tests/onion_test.c
+++ b/auto_tests/onion_test.c
@@ -80,7 +80,7 @@ static int handle_test_3(void *object, IP_Port source, uint8_t *packet, uint32_t
80 80
81 uint8_t plain[1 + crypto_hash_sha256_BYTES]; 81 uint8_t plain[1 + crypto_hash_sha256_BYTES];
82 //print_client_id(packet, length); 82 //print_client_id(packet, length);
83 int len = decrypt_data(test_3_pub_key, onion->dht->c->self_secret_key, packet + 1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH, 83 int len = decrypt_data(test_3_pub_key, onion->dht->self_secret_key, packet + 1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH,
84 packet + 1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + crypto_box_NONCEBYTES, 84 packet + 1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + crypto_box_NONCEBYTES,
85 1 + crypto_hash_sha256_BYTES + crypto_box_MACBYTES, plain); 85 1 + crypto_hash_sha256_BYTES + crypto_box_MACBYTES, plain);
86 86
@@ -111,7 +111,7 @@ static int handle_test_4(void *object, IP_Port source, uint8_t *packet, uint32_t
111 if (memcmp(nonce, packet + 1, crypto_box_NONCEBYTES) != 0) 111 if (memcmp(nonce, packet + 1, crypto_box_NONCEBYTES) != 0)
112 return 1; 112 return 1;
113 113
114 int len = decrypt_data(packet + 1 + crypto_box_NONCEBYTES, onion->dht->c->self_secret_key, packet + 1, 114 int len = decrypt_data(packet + 1 + crypto_box_NONCEBYTES, onion->dht->self_secret_key, packet + 1,
115 packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, sizeof("Install gentoo") + crypto_box_MACBYTES, plain); 115 packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, sizeof("Install gentoo") + crypto_box_MACBYTES, plain);
116 116
117 if (len == -1) 117 if (len == -1)
@@ -129,8 +129,8 @@ START_TEST(test_basic)
129 IP ip; 129 IP ip;
130 ip_init(&ip, 1); 130 ip_init(&ip, 1);
131 ip.ip6.uint8[15] = 1; 131 ip.ip6.uint8[15] = 1;
132 Onion *onion1 = new_onion(new_DHT(new_net_crypto(new_networking(ip, 34567)))); 132 Onion *onion1 = new_onion(new_DHT(new_networking(ip, 34567)));
133 Onion *onion2 = new_onion(new_DHT(new_net_crypto(new_networking(ip, 34568)))); 133 Onion *onion2 = new_onion(new_DHT(new_networking(ip, 34568)));
134 ck_assert_msg((onion1 != NULL) && (onion2 != NULL), "Onion failed initializing."); 134 ck_assert_msg((onion1 != NULL) && (onion2 != NULL), "Onion failed initializing.");
135 networking_registerhandler(onion2->net, 'I', &handle_test_1, onion2); 135 networking_registerhandler(onion2->net, 'I', &handle_test_1, onion2);
136 136
@@ -177,9 +177,9 @@ START_TEST(test_basic)
177 uint8_t zeroes[64] = {0}; 177 uint8_t zeroes[64] = {0};
178 randombytes(sb_data, sizeof(sb_data)); 178 randombytes(sb_data, sizeof(sb_data));
179 memcpy(test_3_pub_key, nodes[3].client_id, crypto_box_PUBLICKEYBYTES); 179 memcpy(test_3_pub_key, nodes[3].client_id, crypto_box_PUBLICKEYBYTES);
180 ret = send_announce_request(onion1->net, &path, nodes[3], onion1->dht->c->self_public_key, 180 ret = send_announce_request(onion1->net, &path, nodes[3], onion1->dht->self_public_key,
181 onion1->dht->c->self_secret_key, 181 onion1->dht->self_secret_key,
182 zeroes, onion1->dht->c->self_public_key, onion1->dht->c->self_public_key, sb_data); 182 zeroes, onion1->dht->self_public_key, onion1->dht->self_public_key, sb_data);
183 ck_assert_msg(ret == 0, "Failed to create/send onion announce_request packet."); 183 ck_assert_msg(ret == 0, "Failed to create/send onion announce_request packet.");
184 handled_test_3 = 0; 184 handled_test_3 = 0;
185 185
@@ -193,10 +193,10 @@ START_TEST(test_basic)
193 memcpy(onion2_a->entries[1].public_key, onion2->dht->self_public_key, crypto_box_PUBLICKEYBYTES); 193 memcpy(onion2_a->entries[1].public_key, onion2->dht->self_public_key, crypto_box_PUBLICKEYBYTES);
194 onion2_a->entries[1].time = unix_time(); 194 onion2_a->entries[1].time = unix_time();
195 networking_registerhandler(onion1->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_test_4, onion1); 195 networking_registerhandler(onion1->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_test_4, onion1);
196 send_announce_request(onion1->net, &path, nodes[3], onion1->dht->c->self_public_key, onion1->dht->c->self_secret_key, 196 send_announce_request(onion1->net, &path, nodes[3], onion1->dht->self_public_key, onion1->dht->self_secret_key,
197 test_3_ping_id, onion1->dht->c->self_public_key, onion1->dht->c->self_public_key, sb_data); 197 test_3_ping_id, onion1->dht->self_public_key, onion1->dht->self_public_key, sb_data);
198 198
199 while (memcmp(onion2_a->entries[ONION_ANNOUNCE_MAX_ENTRIES - 2].public_key, onion1->dht->c->self_public_key, 199 while (memcmp(onion2_a->entries[ONION_ANNOUNCE_MAX_ENTRIES - 2].public_key, onion1->dht->self_public_key,
200 crypto_box_PUBLICKEYBYTES) != 0) { 200 crypto_box_PUBLICKEYBYTES) != 0) {
201 do_onion(onion1); 201 do_onion(onion1);
202 do_onion(onion2); 202 do_onion(onion2);
@@ -204,12 +204,12 @@ START_TEST(test_basic)
204 } 204 }
205 205
206 c_sleep(1000); 206 c_sleep(1000);
207 Onion *onion3 = new_onion(new_DHT(new_net_crypto(new_networking(ip, 34569)))); 207 Onion *onion3 = new_onion(new_DHT(new_networking(ip, 34569)));
208 ck_assert_msg((onion3 != NULL), "Onion failed initializing."); 208 ck_assert_msg((onion3 != NULL), "Onion failed initializing.");
209 209
210 new_nonce(nonce); 210 new_nonce(nonce);
211 ret = send_data_request(onion3->net, &path, nodes[3].ip_port, onion1->dht->c->self_public_key, 211 ret = send_data_request(onion3->net, &path, nodes[3].ip_port, onion1->dht->self_public_key,
212 onion1->dht->c->self_public_key, 212 onion1->dht->self_public_key,
213 nonce, (uint8_t *)"Install gentoo", sizeof("Install gentoo")); 213 nonce, (uint8_t *)"Install gentoo", sizeof("Install gentoo"));
214 ck_assert_msg(ret == 0, "Failed to create/send onion data_request packet."); 214 ck_assert_msg(ret == 0, "Failed to create/send onion data_request packet.");
215 handled_test_4 = 0; 215 handled_test_4 = 0;
@@ -234,10 +234,10 @@ Onions *new_onions(uint16_t port)
234 ip_init(&ip, 1); 234 ip_init(&ip, 1);
235 ip.ip6.uint8[15] = 1; 235 ip.ip6.uint8[15] = 1;
236 Onions *on = malloc(sizeof(Onions)); 236 Onions *on = malloc(sizeof(Onions));
237 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, port))); 237 DHT *dht = new_DHT(new_networking(ip, port));
238 on->onion = new_onion(dht); 238 on->onion = new_onion(dht);
239 on->onion_a = new_onion_announce(dht); 239 on->onion_a = new_onion_announce(dht);
240 on->onion_c = new_onion_client(dht); 240 on->onion_c = new_onion_client(new_net_crypto(dht));
241 241
242 if (on->onion && on->onion_a && on->onion_c) 242 if (on->onion && on->onion_a && on->onion_c)
243 return on; 243 return on;
@@ -298,8 +298,8 @@ START_TEST(test_announce)
298 c_sleep(50); 298 c_sleep(50);
299 } 299 }
300 300
301 onion_addfriend(onions[7]->onion_c, onions[37]->onion->dht->c->self_public_key); 301 onion_addfriend(onions[7]->onion_c, onions[37]->onion_c->c->self_public_key);
302 int frnum = onion_addfriend(onions[37]->onion_c, onions[7]->onion->dht->c->self_public_key); 302 int frnum = onion_addfriend(onions[37]->onion_c, onions[7]->onion_c->c->self_public_key);
303 303
304 int ok = -1; 304 int ok = -1;
305 305