diff options
author | irungentoo <irungentoo@gmail.com> | 2014-06-15 10:29:13 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-06-15 10:29:13 -0400 |
commit | a38d962b040e06ebe986e59e4c53843dc5fbbfab (patch) | |
tree | 487e6892ca1b10444b98d128bddd18282c17a86b /toxcore/net_crypto.c | |
parent | 1a3d45f83dd935360036fb71530c16a06a028834 (diff) | |
parent | 4940c4c62b6014d1f0586aa6aca7bf6e4ecfcf29 (diff) |
Merge branch 'const_correctness' of https://github.com/schuetzm/ProjectTox-Core into schuetzm-const_correctness
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 78a6121c..c34c24d7 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -120,7 +120,7 @@ static int create_cookie(uint8_t *cookie, uint8_t *bytes, uint8_t *encryption_ke | |||
120 | * return -1 on failure. | 120 | * return -1 on failure. |
121 | * return 0 on success. | 121 | * return 0 on success. |
122 | */ | 122 | */ |
123 | static int open_cookie(uint8_t *bytes, uint8_t *cookie, uint8_t *encryption_key) | 123 | static int open_cookie(uint8_t *bytes, const uint8_t *cookie, const uint8_t *encryption_key) |
124 | { | 124 | { |
125 | uint8_t contents[COOKIE_CONTENTS_LENGTH]; | 125 | uint8_t contents[COOKIE_CONTENTS_LENGTH]; |
126 | int len = decrypt_data_symmetric(encryption_key, cookie, cookie + crypto_box_NONCEBYTES, | 126 | int len = decrypt_data_symmetric(encryption_key, cookie, cookie + crypto_box_NONCEBYTES, |
@@ -178,7 +178,7 @@ static int create_cookie_response(Net_Crypto *c, uint8_t *packet, uint8_t *reque | |||
178 | * return 0 on success. | 178 | * return 0 on success. |
179 | */ | 179 | */ |
180 | static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t *shared_key, uint8_t *dht_public_key, | 180 | static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t *shared_key, uint8_t *dht_public_key, |
181 | uint8_t *packet, uint16_t length) | 181 | const uint8_t *packet, uint16_t length) |
182 | { | 182 | { |
183 | if (length != COOKIE_REQUEST_LENGTH) | 183 | if (length != COOKIE_REQUEST_LENGTH) |
184 | return -1; | 184 | return -1; |
@@ -197,7 +197,7 @@ static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t | |||
197 | 197 | ||
198 | /* Handle the cookie request packet (for raw UDP) | 198 | /* Handle the cookie request packet (for raw UDP) |
199 | */ | 199 | */ |
200 | static int udp_handle_cookie_request(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 200 | static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
201 | { | 201 | { |
202 | Net_Crypto *c = object; | 202 | Net_Crypto *c = object; |
203 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; | 203 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; |
@@ -275,8 +275,8 @@ static int tcp_oob_handle_cookie_request(Net_Crypto *c, TCP_Client_Connection *T | |||
275 | * return -1 on failure. | 275 | * return -1 on failure. |
276 | * return COOKIE_LENGTH on success. | 276 | * return COOKIE_LENGTH on success. |
277 | */ | 277 | */ |
278 | static int handle_cookie_response(uint8_t *cookie, uint64_t *number, uint8_t *packet, uint32_t length, | 278 | static int handle_cookie_response(uint8_t *cookie, uint64_t *number, const uint8_t *packet, uint32_t length, |
279 | uint8_t *shared_key) | 279 | const uint8_t *shared_key) |
280 | { | 280 | { |
281 | if (length != COOKIE_RESPONSE_LENGTH) | 281 | if (length != COOKIE_RESPONSE_LENGTH) |
282 | return -1; | 282 | return -1; |
@@ -349,7 +349,7 @@ static int create_crypto_handshake(Net_Crypto *c, uint8_t *packet, uint8_t *cook | |||
349 | * return 0 on success. | 349 | * return 0 on success. |
350 | */ | 350 | */ |
351 | static int handle_crypto_handshake(Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk, | 351 | static int handle_crypto_handshake(Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk, |
352 | uint8_t *dht_public_key, uint8_t *cookie, uint8_t *packet, uint32_t length, uint8_t *expected_real_pk) | 352 | uint8_t *dht_public_key, uint8_t *cookie, const uint8_t *packet, uint32_t length, uint8_t *expected_real_pk) |
353 | { | 353 | { |
354 | if (length != HANDSHAKE_PACKET_LENGTH) | 354 | if (length != HANDSHAKE_PACKET_LENGTH) |
355 | return -1; | 355 | return -1; |
@@ -815,7 +815,7 @@ static uint16_t get_nonce_uint16(uint8_t *nonce) | |||
815 | * return -1 on failure. | 815 | * return -1 on failure. |
816 | * return length of data on success. | 816 | * return length of data on success. |
817 | */ | 817 | */ |
818 | static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint8_t *packet, uint16_t length) | 818 | static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, const uint8_t *packet, uint16_t length) |
819 | { | 819 | { |
820 | if (length <= (1 + sizeof(uint16_t) + crypto_box_MACBYTES) || length > MAX_CRYPTO_PACKET_SIZE) | 820 | if (length <= (1 + sizeof(uint16_t) + crypto_box_MACBYTES) || length > MAX_CRYPTO_PACKET_SIZE) |
821 | return -1; | 821 | return -1; |
@@ -1039,7 +1039,7 @@ static int send_kill_packet(Net_Crypto *c, int crypt_connection_id) | |||
1039 | * return -1 on failure. | 1039 | * return -1 on failure. |
1040 | * return 0 on success. | 1040 | * return 0 on success. |
1041 | */ | 1041 | */ |
1042 | static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint8_t *packet, uint16_t length) | 1042 | static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length) |
1043 | { | 1043 | { |
1044 | if (length > MAX_CRYPTO_PACKET_SIZE || length <= CRYPTO_DATA_PACKET_MIN_SIZE) | 1044 | if (length > MAX_CRYPTO_PACKET_SIZE || length <= CRYPTO_DATA_PACKET_MIN_SIZE) |
1045 | return -1; | 1045 | return -1; |
@@ -1133,7 +1133,7 @@ static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uin | |||
1133 | * return -1 on failure. | 1133 | * return -1 on failure. |
1134 | * return 0 on success. | 1134 | * return 0 on success. |
1135 | */ | 1135 | */ |
1136 | static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, uint8_t *packet, uint16_t length) | 1136 | static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length) |
1137 | { | 1137 | { |
1138 | if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) | 1138 | if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) |
1139 | return -1; | 1139 | return -1; |
@@ -1370,7 +1370,7 @@ void new_connection_handler(Net_Crypto *c, int (*new_connection_callback)(void * | |||
1370 | * return -1 on failure. | 1370 | * return -1 on failure. |
1371 | * return 0 on success. | 1371 | * return 0 on success. |
1372 | */ | 1372 | */ |
1373 | static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source, uint8_t *data, uint16_t length) | 1373 | static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source, const uint8_t *data, uint16_t length) |
1374 | { | 1374 | { |
1375 | New_Connection n_c; | 1375 | New_Connection n_c; |
1376 | n_c.cookie = malloc(COOKIE_LENGTH); | 1376 | n_c.cookie = malloc(COOKIE_LENGTH); |
@@ -2123,7 +2123,7 @@ static int crypto_id_ip_port(Net_Crypto *c, IP_Port ip_port) | |||
2123 | * Crypto data packets. | 2123 | * Crypto data packets. |
2124 | * | 2124 | * |
2125 | */ | 2125 | */ |
2126 | static int udp_handle_packet(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 2126 | static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
2127 | { | 2127 | { |
2128 | if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE) | 2128 | if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE) |
2129 | return 1; | 2129 | return 1; |