summaryrefslogtreecommitdiff
path: root/core/net_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/net_crypto.c')
-rw-r--r--core/net_crypto.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c
index a16537e8..044845f0 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -26,12 +26,10 @@
26 26
27#include "net_crypto.h" 27#include "net_crypto.h"
28 28
29
30/* Our public and secret keys. */ 29/* Our public and secret keys. */
31uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; 30uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
32uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; 31uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
33 32
34
35typedef struct 33typedef struct
36{ 34{
37 uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* the real public key of the peer. */ 35 uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* the real public key of the peer. */
@@ -177,7 +175,6 @@ int read_cryptpacket(int crypt_connection_id, uint8_t * data)
177 return -1; 175 return -1;
178} 176}
179 177
180
181/* return 0 if data could not be put in packet queue 178/* return 0 if data could not be put in packet queue
182 return 1 if data was put into the queue */ 179 return 1 if data was put into the queue */
183int write_cryptpacket(int crypt_connection_id, uint8_t * data, uint32_t length) 180int write_cryptpacket(int crypt_connection_id, uint8_t * data, uint32_t length)
@@ -267,7 +264,6 @@ int handle_request(uint8_t * public_key, uint8_t * data, uint8_t * packet, uint1
267 } 264 }
268} 265}
269 266
270
271/* Send a crypto handshake packet containing an encrypted secret nonce and session public key 267/* Send a crypto handshake packet containing an encrypted secret nonce and session public key
272 to peer with connection_id and public_key 268 to peer with connection_id and public_key
273 the packet is encrypted with a random nonce which is sent in plain text with the packet */ 269 the packet is encrypted with a random nonce which is sent in plain text with the packet */
@@ -327,9 +323,6 @@ int handle_cryptohandshake(uint8_t * public_key, uint8_t * secret_nonce,
327 return 1; 323 return 1;
328} 324}
329 325
330
331
332
333/* get crypto connection id from public key of peer 326/* get crypto connection id from public key of peer
334 return -1 if there are no connections like we are looking for 327 return -1 if there are no connections like we are looking for
335 return id if it found it */ 328 return id if it found it */
@@ -349,7 +342,6 @@ int getcryptconnection_id(uint8_t * public_key)
349 return -1; 342 return -1;
350} 343}
351 344
352
353/* Start a secure connection with other peer who has public_key and ip_port 345/* Start a secure connection with other peer who has public_key and ip_port
354 returns -1 if failure 346 returns -1 if failure
355 returns crypt_connection_id of the initialized connection if everything went well. */ 347 returns crypt_connection_id of the initialized connection if everything went well. */
@@ -447,7 +439,6 @@ int crypto_kill(int crypt_connection_id)
447 return 1; 439 return 1;
448} 440}
449 441
450
451/* accept an incoming connection using the parameters provided by crypto_inbound 442/* accept an incoming connection using the parameters provided by crypto_inbound
452 return -1 if not successful 443 return -1 if not successful
453 returns the crypt_connection_id if successful */ 444 returns the crypt_connection_id if successful */
@@ -505,7 +496,6 @@ int is_cryptoconnected(int crypt_connection_id)
505 return 0; 496 return 0;
506} 497}
507 498
508
509/* Generate our public and private keys 499/* Generate our public and private keys
510 Only call this function the first time the program starts. */ 500 Only call this function the first time the program starts. */
511void new_keys() 501void new_keys()
@@ -681,4 +671,4 @@ void doNetCrypto()
681 handle_incomings(); 671 handle_incomings();
682 receive_crypto(); 672 receive_crypto();
683 killTimedout(); 673 killTimedout();
684} 674} \ No newline at end of file