diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-12-19 02:47:42 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-12-22 10:26:59 +0000 |
commit | ce29c8e7ec91d95167b2dea3aee9fd1ae1aac254 (patch) | |
tree | a288df55c44e8edf816e6abbde19a70faef73394 /toxcore/net_crypto.h | |
parent | 7122d2e862e028a730478d88cd61557fbed16ebf (diff) |
Wrap all sodium/nacl functions in crypto_core.c.
Diffstat (limited to 'toxcore/net_crypto.h')
-rw-r--r-- | toxcore/net_crypto.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index b27a05e7..81885338 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h | |||
@@ -49,7 +49,7 @@ | |||
49 | /* Maximum total size of packets that net_crypto sends. */ | 49 | /* Maximum total size of packets that net_crypto sends. */ |
50 | #define MAX_CRYPTO_PACKET_SIZE 1400 | 50 | #define MAX_CRYPTO_PACKET_SIZE 1400 |
51 | 51 | ||
52 | #define CRYPTO_DATA_PACKET_MIN_SIZE (1 + sizeof(uint16_t) + (sizeof(uint32_t) + sizeof(uint32_t)) + crypto_box_MACBYTES) | 52 | #define CRYPTO_DATA_PACKET_MIN_SIZE (1 + sizeof(uint16_t) + (sizeof(uint32_t) + sizeof(uint32_t)) + CRYPTO_MAC_SIZE) |
53 | 53 | ||
54 | /* Max size of data in packets */ | 54 | /* Max size of data in packets */ |
55 | #define MAX_CRYPTO_DATA_SIZE (MAX_CRYPTO_PACKET_SIZE - CRYPTO_DATA_PACKET_MIN_SIZE) | 55 | #define MAX_CRYPTO_DATA_SIZE (MAX_CRYPTO_PACKET_SIZE - CRYPTO_DATA_PACKET_MIN_SIZE) |
@@ -102,20 +102,20 @@ typedef struct { | |||
102 | } Packets_Array; | 102 | } Packets_Array; |
103 | 103 | ||
104 | typedef struct { | 104 | typedef struct { |
105 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */ | 105 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The real public key of the peer. */ |
106 | uint8_t recv_nonce[crypto_box_NONCEBYTES]; /* Nonce of received packets. */ | 106 | uint8_t recv_nonce[CRYPTO_NONCE_SIZE]; /* Nonce of received packets. */ |
107 | uint8_t sent_nonce[crypto_box_NONCEBYTES]; /* Nonce of sent packets. */ | 107 | uint8_t sent_nonce[CRYPTO_NONCE_SIZE]; /* Nonce of sent packets. */ |
108 | uint8_t sessionpublic_key[crypto_box_PUBLICKEYBYTES]; /* Our public key for this session. */ | 108 | uint8_t sessionpublic_key[CRYPTO_PUBLIC_KEY_SIZE]; /* Our public key for this session. */ |
109 | uint8_t sessionsecret_key[crypto_box_SECRETKEYBYTES]; /* Our private key for this session. */ | 109 | uint8_t sessionsecret_key[CRYPTO_SECRET_KEY_SIZE]; /* Our private key for this session. */ |
110 | uint8_t peersessionpublic_key[crypto_box_PUBLICKEYBYTES]; /* The public key of the peer. */ | 110 | uint8_t peersessionpublic_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The public key of the peer. */ |
111 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; /* The precomputed shared key from encrypt_precompute. */ | 111 | uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; /* The precomputed shared key from encrypt_precompute. */ |
112 | uint8_t status; /* 0 if no connection, 1 we are sending cookie request packets, | 112 | uint8_t status; /* 0 if no connection, 1 we are sending cookie request packets, |
113 | * 2 if we are sending handshake packets | 113 | * 2 if we are sending handshake packets |
114 | * 3 if connection is not confirmed yet (we have received a handshake but no data packets yet), | 114 | * 3 if connection is not confirmed yet (we have received a handshake but no data packets yet), |
115 | * 4 if the connection is established. | 115 | * 4 if the connection is established. |
116 | */ | 116 | */ |
117 | uint64_t cookie_request_number; /* number used in the cookie request packets for this connection */ | 117 | uint64_t cookie_request_number; /* number used in the cookie request packets for this connection */ |
118 | uint8_t dht_public_key[crypto_box_PUBLICKEYBYTES]; /* The dht public key of the peer */ | 118 | uint8_t dht_public_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The dht public key of the peer */ |
119 | 119 | ||
120 | uint8_t *temp_packet; /* Where the cookie request/handshake packet is stored while it is being sent. */ | 120 | uint8_t *temp_packet; /* Where the cookie request/handshake packet is stored while it is being sent. */ |
121 | uint16_t temp_packet_length; | 121 | uint16_t temp_packet_length; |
@@ -182,10 +182,10 @@ typedef struct { | |||
182 | 182 | ||
183 | typedef struct { | 183 | typedef struct { |
184 | IP_Port source; | 184 | IP_Port source; |
185 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */ | 185 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The real public key of the peer. */ |
186 | uint8_t dht_public_key[crypto_box_PUBLICKEYBYTES]; /* The dht public key of the peer. */ | 186 | uint8_t dht_public_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The dht public key of the peer. */ |
187 | uint8_t recv_nonce[crypto_box_NONCEBYTES]; /* Nonce of received packets. */ | 187 | uint8_t recv_nonce[CRYPTO_NONCE_SIZE]; /* Nonce of received packets. */ |
188 | uint8_t peersessionpublic_key[crypto_box_PUBLICKEYBYTES]; /* The public key of the peer. */ | 188 | uint8_t peersessionpublic_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The public key of the peer. */ |
189 | uint8_t *cookie; | 189 | uint8_t *cookie; |
190 | uint8_t cookie_length; | 190 | uint8_t cookie_length; |
191 | } New_Connection; | 191 | } New_Connection; |
@@ -205,11 +205,11 @@ typedef struct { | |||
205 | uint32_t crypto_connections_length; /* Length of connections array. */ | 205 | uint32_t crypto_connections_length; /* Length of connections array. */ |
206 | 206 | ||
207 | /* Our public and secret keys. */ | 207 | /* Our public and secret keys. */ |
208 | uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; | 208 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
209 | uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; | 209 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
210 | 210 | ||
211 | /* The secret key used for cookies */ | 211 | /* The secret key used for cookies */ |
212 | uint8_t secret_symmetric_key[crypto_box_KEYBYTES]; | 212 | uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE]; |
213 | 213 | ||
214 | int (*new_connection_callback)(void *object, New_Connection *n_c); | 214 | int (*new_connection_callback)(void *object, New_Connection *n_c); |
215 | void *new_connection_callback_object; | 215 | void *new_connection_callback_object; |
@@ -400,12 +400,12 @@ unsigned int crypto_connection_status(const Net_Crypto *c, int crypt_connection_ | |||
400 | void new_keys(Net_Crypto *c); | 400 | void new_keys(Net_Crypto *c); |
401 | 401 | ||
402 | /* Save the public and private keys to the keys array. | 402 | /* Save the public and private keys to the keys array. |
403 | * Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES. | 403 | * Length must be CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE. |
404 | */ | 404 | */ |
405 | void save_keys(const Net_Crypto *c, uint8_t *keys); | 405 | void save_keys(const Net_Crypto *c, uint8_t *keys); |
406 | 406 | ||
407 | /* Load the secret key. | 407 | /* Load the secret key. |
408 | * Length must be crypto_box_SECRETKEYBYTES. | 408 | * Length must be CRYPTO_SECRET_KEY_SIZE. |
409 | */ | 409 | */ |
410 | void load_secret_key(Net_Crypto *c, const uint8_t *sk); | 410 | void load_secret_key(Net_Crypto *c, const uint8_t *sk); |
411 | 411 | ||