summaryrefslogtreecommitdiff
path: root/core/net_crypto.h
diff options
context:
space:
mode:
authorKonstantin Kowalski <kostyakow42@gmail.com>2013-07-26 23:07:25 -0400
committerKonstantin Kowalski <kostyakow42@gmail.com>2013-07-26 23:07:25 -0400
commit241aca98bdc8106221ee7d7dbcea9f2fa17f24bc (patch)
tree15c324c865eb8c61c17dc442009f33b24505714d /core/net_crypto.h
parent1b4ea2e1aeb874e872a2c767326633450de12d20 (diff)
A *lot* of style changes.
Diffstat (limited to 'core/net_crypto.h')
-rw-r--r--core/net_crypto.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/core/net_crypto.h b/core/net_crypto.h
index b5bab17a..d4fe1313 100644
--- a/core/net_crypto.h
+++ b/core/net_crypto.h
@@ -40,29 +40,29 @@ extern uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
40 public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce 40 public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce
41 return -1 if there was a problem. 41 return -1 if there was a problem.
42 return length of encrypted data if everything was fine. */ 42 return length of encrypted data if everything was fine. */
43int encrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce, 43int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
44 uint8_t * plain, uint32_t length, uint8_t * encrypted); 44 uint8_t *plain, uint32_t length, uint8_t *encrypted);
45 45
46 46
47/* decrypts encrypted of length length to plain of length length - 16 using the 47/* decrypts encrypted of length length to plain of length length - 16 using the
48 public key(32 bytes) of the sender, the secret key of the receiver and a 24 byte nonce 48 public key(32 bytes) of the sender, the secret key of the receiver and a 24 byte nonce
49 return -1 if there was a problem(decryption failed) 49 return -1 if there was a problem(decryption failed)
50 return length of plain data if everything was fine. */ 50 return length of plain data if everything was fine. */
51int decrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce, 51int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
52 uint8_t * encrypted, uint32_t length, uint8_t * plain); 52 uint8_t *encrypted, uint32_t length, uint8_t *plain);
53 53
54 54
55/* fill the given nonce with random bytes. */ 55/* fill the given nonce with random bytes. */
56void random_nonce(uint8_t * nonce); 56void random_nonce(uint8_t *nonce);
57 57
58/* return 0 if there is no received data in the buffer 58/* return 0 if there is no received data in the buffer
59 return -1 if the packet was discarded. 59 return -1 if the packet was discarded.
60 return length of received data if successful */ 60 return length of received data if successful */
61int read_cryptpacket(int crypt_connection_id, uint8_t * data); 61int read_cryptpacket(int crypt_connection_id, uint8_t *data);
62 62
63/* return 0 if data could not be put in packet queue 63/* return 0 if data could not be put in packet queue
64 return 1 if data was put into the queue */ 64 return 1 if data was put into the queue */
65int write_cryptpacket(int crypt_connection_id, uint8_t * data, uint32_t length); 65int write_cryptpacket(int crypt_connection_id, uint8_t *data, uint32_t length);
66 66
67/* create a request to peer with public_key. 67/* create a request to peer with public_key.
68 packet must be an array of MAX_DATA_SIZE big. 68 packet must be an array of MAX_DATA_SIZE big.
@@ -70,18 +70,18 @@ int write_cryptpacket(int crypt_connection_id, uint8_t * data, uint32_t length);
70 request_id is the id of the request (32 = friend request, 254 = ping request) 70 request_id is the id of the request (32 = friend request, 254 = ping request)
71 returns -1 on failure 71 returns -1 on failure
72 returns the length of the created packet on success */ 72 returns the length of the created packet on success */
73int create_request(uint8_t * packet, uint8_t * public_key, uint8_t * data, uint32_t length, uint8_t request_id); 73int create_request(uint8_t *packet, uint8_t * public_key, uint8_t *data, uint32_t length, uint8_t request_id);
74 74
75/* puts the senders public key in the request in public_key, the data from the request 75/* puts the senders public key in the request in public_key, the data from the request
76 in data if a friend or ping request was sent to us and returns the length of the data. 76 in data if a friend or ping request was sent to us and returns the length of the data.
77 packet is the request packet and length is its length 77 packet is the request packet and length is its length
78 return -1 if not valid request. */ 78 return -1 if not valid request. */
79int handle_request(uint8_t * public_key, uint8_t * data, uint8_t * packet, uint16_t length); 79int handle_request(uint8_t *public_key, uint8_t *data, uint8_t *packet, uint16_t length);
80 80
81/* Start a secure connection with other peer who has public_key and ip_port 81/* Start a secure connection with other peer who has public_key and ip_port
82 returns -1 if failure 82 returns -1 if failure
83 returns crypt_connection_id of the initialized connection if everything went well. */ 83 returns crypt_connection_id of the initialized connection if everything went well. */
84int crypto_connect(uint8_t * public_key, IP_Port ip_port); 84int crypto_connect(uint8_t *public_key, IP_Port ip_port);
85 85
86/* kill a crypto connection 86/* kill a crypto connection
87 return 0 if killed successfully 87 return 0 if killed successfully
@@ -95,12 +95,12 @@ int crypto_kill(int crypt_connection_id);
95 and the session public key for the connection in session_key 95 and the session public key for the connection in session_key
96 to accept it see: accept_crypto_inbound(...) 96 to accept it see: accept_crypto_inbound(...)
97 to refuse it just call kill_connection(...) on the connection id */ 97 to refuse it just call kill_connection(...) on the connection id */
98int crypto_inbound(uint8_t * public_key, uint8_t * secret_nonce, uint8_t * session_key); 98int crypto_inbound(uint8_t *public_key, uint8_t * secret_nonce, uint8_t *session_key);
99 99
100/* accept an incoming connection using the parameters provided by crypto_inbound 100/* accept an incoming connection using the parameters provided by crypto_inbound
101 return -1 if not successful 101 return -1 if not successful
102 returns the crypt_connection_id if successful */ 102 returns the crypt_connection_id if successful */
103int accept_crypto_inbound(int connection_id, uint8_t * public_key, uint8_t * secret_nonce, uint8_t * session_key); 103int accept_crypto_inbound(int connection_id, uint8_t *public_key, uint8_t * secret_nonce, uint8_t *session_key);
104 104
105/* return 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet 105/* return 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet
106 (we have received a handshake but no empty data packet), 3 if the connection is established. 106 (we have received a handshake but no empty data packet), 3 if the connection is established.