summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-05 10:31:29 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-05 23:09:28 +0000
commit8739f7fccb7cafc54ca0f5fa074c9a740f7048ba (patch)
tree88e9f53fa6e734cd8095487d1896c56f844c782c /toxcore/net_crypto.c
parent64d0297acc7d6a1697683052e15cc76383312c38 (diff)
Make tox.c unambiguously parseable.
Rules: 1. Constants are uppercase names: THE_CONSTANT. 2. SUE[1] types start with an uppercase letter and have at least one lowercase letter in it: The_Type, THE_Type. 3. Function types end in "_cb": tox_friend_connection_cb. 4. Variable and function names are all lowercase: the_function. This makes it easier for humans reading the code to determine what an identifier means. I'm not convinced by the enum type name change, but I don't know a better rule. Currently, a lot of enum types are spelled like constants, which is confusing. [1] struct/union/enum
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index 5eea7a50..bfdbbe30 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -224,7 +224,7 @@ static int create_cookie_request(const Net_Crypto *c, uint8_t *packet, uint8_t *
224 memcpy(plain + CRYPTO_PUBLIC_KEY_SIZE, padding, CRYPTO_PUBLIC_KEY_SIZE); 224 memcpy(plain + CRYPTO_PUBLIC_KEY_SIZE, padding, CRYPTO_PUBLIC_KEY_SIZE);
225 memcpy(plain + (CRYPTO_PUBLIC_KEY_SIZE * 2), &number, sizeof(uint64_t)); 225 memcpy(plain + (CRYPTO_PUBLIC_KEY_SIZE * 2), &number, sizeof(uint64_t));
226 226
227 DHT_get_shared_key_sent(c->dht, shared_key, dht_public_key); 227 dht_get_shared_key_sent(c->dht, shared_key, dht_public_key);
228 uint8_t nonce[CRYPTO_NONCE_SIZE]; 228 uint8_t nonce[CRYPTO_NONCE_SIZE];
229 random_nonce(nonce); 229 random_nonce(nonce);
230 packet[0] = NET_PACKET_COOKIE_REQUEST; 230 packet[0] = NET_PACKET_COOKIE_REQUEST;
@@ -335,7 +335,7 @@ static int handle_cookie_request(const Net_Crypto *c, uint8_t *request_plain, ui
335 } 335 }
336 336
337 memcpy(dht_public_key, packet + 1, CRYPTO_PUBLIC_KEY_SIZE); 337 memcpy(dht_public_key, packet + 1, CRYPTO_PUBLIC_KEY_SIZE);
338 DHT_get_shared_key_sent(c->dht, shared_key, dht_public_key); 338 dht_get_shared_key_sent(c->dht, shared_key, dht_public_key);
339 int len = decrypt_data_symmetric(shared_key, packet + 1 + CRYPTO_PUBLIC_KEY_SIZE, 339 int len = decrypt_data_symmetric(shared_key, packet + 1 + CRYPTO_PUBLIC_KEY_SIZE,
340 packet + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE, COOKIE_REQUEST_PLAIN_LENGTH + CRYPTO_MAC_SIZE, 340 packet + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE, COOKIE_REQUEST_PLAIN_LENGTH + CRYPTO_MAC_SIZE,
341 request_plain); 341 request_plain);