summaryrefslogtreecommitdiff
path: root/toxcore/crypto_core.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/crypto_core.h')
-rw-r--r--toxcore/crypto_core.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/toxcore/crypto_core.h b/toxcore/crypto_core.h
index 6a13b22b..a862635e 100644
--- a/toxcore/crypto_core.h
+++ b/toxcore/crypto_core.h
@@ -25,6 +25,7 @@
25 25
26#include "network.h" 26#include "network.h"
27 27
28
28/* return zero if the buffer contains only zeros. */ 29/* return zero if the buffer contains only zeros. */
29uint8_t crypto_iszero(uint8_t *buffer, uint32_t blen); 30uint8_t crypto_iszero(uint8_t *buffer, uint32_t blen);
30 31
@@ -83,4 +84,34 @@ void new_symmetric_key(uint8_t *key);
83/*Gives a nonce guaranteed to be different from previous ones.*/ 84/*Gives a nonce guaranteed to be different from previous ones.*/
84void new_nonce(uint8_t *nonce); 85void new_nonce(uint8_t *nonce);
85 86
87#define MAX_CRYPTO_REQUEST_SIZE 1024
88
89#define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */
90#define CRYPTO_PACKET_HARDENING 48 /* Hardening crypto packet ID. */
91#define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */
92#define CRYPTO_PACKET_GROUP_CHAT_GET_NODES 48 /* Group chat get Nodes packet */
93#define CRYPTO_PACKET_GROUP_CHAT_SEND_NODES 49 /* Group chat send Nodes packet */
94#define CRYPTO_PACKET_GROUP_CHAT_BROADCAST 50 /* Group chat broadcast packet */
95
96/* Create a request to peer.
97 * send_public_key and send_secret_key are the pub/secret keys of the sender.
98 * recv_public_key is public key of reciever.
99 * packet must be an array of MAX_CRYPTO_REQUEST_SIZE big.
100 * Data represents the data we send with the request with length being the length of the data.
101 * request_id is the id of the request (32 = friend request, 254 = ping request).
102 *
103 * return -1 on failure.
104 * return the length of the created packet on success.
105 */
106int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t *packet, uint8_t *recv_public_key,
107 uint8_t *data, uint32_t length, uint8_t request_id);
108
109/* puts the senders public key in the request in public_key, the data from the request
110 in data if a friend or ping request was sent to us and returns the length of the data.
111 packet is the request packet and length is its length
112 return -1 if not valid request. */
113int handle_request(uint8_t *self_public_key, uint8_t *self_secret_key, uint8_t *public_key, uint8_t *data,
114 uint8_t *request_id, uint8_t *packet, uint16_t length);
115
116
86#endif 117#endif