diff options
author | irungentoo <irungentoo@gmail.com> | 2014-04-22 20:28:40 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-04-22 20:28:40 -0400 |
commit | 1bfe15ee88844bdbd43052b4026202cf924ad6ca (patch) | |
tree | a740f16199cf0a263447e2084dd8906028a7b268 /toxcore/onion.c | |
parent | c46ab5821d0fa8c604de52e15009e2b8da5d9c07 (diff) |
Decided pretty much how the handshake would work.
Started writing the code.
Astyled some files.
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r-- | toxcore/onion.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c index 8603de0a..c2ca21f8 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -112,7 +112,7 @@ int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint | |||
112 | memcpy(step2 + sizeof(IP_Port), path->public_key3, crypto_box_PUBLICKEYBYTES); | 112 | memcpy(step2 + sizeof(IP_Port), path->public_key3, crypto_box_PUBLICKEYBYTES); |
113 | 113 | ||
114 | int len = encrypt_data_symmetric(path->shared_key3, nonce, step1, sizeof(step1), | 114 | int len = encrypt_data_symmetric(path->shared_key3, nonce, step1, sizeof(step1), |
115 | step2 + sizeof(IP_Port) + crypto_box_PUBLICKEYBYTES); | 115 | step2 + sizeof(IP_Port) + crypto_box_PUBLICKEYBYTES); |
116 | 116 | ||
117 | if ((uint32_t)len != sizeof(IP_Port) + length + crypto_box_MACBYTES) | 117 | if ((uint32_t)len != sizeof(IP_Port) + length + crypto_box_MACBYTES) |
118 | return -1; | 118 | return -1; |
@@ -121,7 +121,7 @@ int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint | |||
121 | memcpy(step3, &path->ip_port2, sizeof(IP_Port)); | 121 | memcpy(step3, &path->ip_port2, sizeof(IP_Port)); |
122 | memcpy(step3 + sizeof(IP_Port), path->public_key2, crypto_box_PUBLICKEYBYTES); | 122 | memcpy(step3 + sizeof(IP_Port), path->public_key2, crypto_box_PUBLICKEYBYTES); |
123 | len = encrypt_data_symmetric(path->shared_key2, nonce, step2, sizeof(step2), | 123 | len = encrypt_data_symmetric(path->shared_key2, nonce, step2, sizeof(step2), |
124 | step3 + sizeof(IP_Port) + crypto_box_PUBLICKEYBYTES); | 124 | step3 + sizeof(IP_Port) + crypto_box_PUBLICKEYBYTES); |
125 | 125 | ||
126 | if ((uint32_t)len != sizeof(IP_Port) + SEND_BASE + length + crypto_box_MACBYTES) | 126 | if ((uint32_t)len != sizeof(IP_Port) + SEND_BASE + length + crypto_box_MACBYTES) |
127 | return -1; | 127 | return -1; |
@@ -132,7 +132,7 @@ int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint | |||
132 | memcpy(packet + 1 + crypto_box_NONCEBYTES, path->public_key1, crypto_box_PUBLICKEYBYTES); | 132 | memcpy(packet + 1 + crypto_box_NONCEBYTES, path->public_key1, crypto_box_PUBLICKEYBYTES); |
133 | 133 | ||
134 | len = encrypt_data_symmetric(path->shared_key1, nonce, step3, sizeof(step3), | 134 | len = encrypt_data_symmetric(path->shared_key1, nonce, step3, sizeof(step3), |
135 | packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES); | 135 | packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES); |
136 | 136 | ||
137 | if ((uint32_t)len != sizeof(IP_Port) + SEND_BASE * 2 + length + crypto_box_MACBYTES) | 137 | if ((uint32_t)len != sizeof(IP_Port) + SEND_BASE * 2 + length + crypto_box_MACBYTES) |
138 | return -1; | 138 | return -1; |
@@ -176,7 +176,7 @@ static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, ui | |||
176 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | 176 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; |
177 | get_shared_key(&onion->shared_keys_1, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); | 177 | get_shared_key(&onion->shared_keys_1, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); |
178 | int len = decrypt_data_symmetric(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, | 178 | int len = decrypt_data_symmetric(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, |
179 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES), plain); | 179 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES), plain); |
180 | 180 | ||
181 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)) | 181 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)) |
182 | return 1; | 182 | return 1; |
@@ -227,7 +227,7 @@ static int handle_send_1(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
227 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | 227 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; |
228 | get_shared_key(&onion->shared_keys_2, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); | 228 | get_shared_key(&onion->shared_keys_2, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); |
229 | int len = decrypt_data_symmetric(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, | 229 | int len = decrypt_data_symmetric(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, |
230 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1), plain); | 230 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1), plain); |
231 | 231 | ||
232 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1 + crypto_box_MACBYTES)) | 232 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1 + crypto_box_MACBYTES)) |
233 | return 1; | 233 | return 1; |
@@ -276,7 +276,7 @@ static int handle_send_2(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
276 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | 276 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; |
277 | get_shared_key(&onion->shared_keys_3, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); | 277 | get_shared_key(&onion->shared_keys_3, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); |
278 | int len = decrypt_data_symmetric(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, | 278 | int len = decrypt_data_symmetric(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, |
279 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2), plain); | 279 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2), plain); |
280 | 280 | ||
281 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2 + crypto_box_MACBYTES)) | 281 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2 + crypto_box_MACBYTES)) |
282 | return 1; | 282 | return 1; |