diff options
author | Marc Schütz <schuetzm@gmx.net> | 2014-06-10 18:38:43 +0200 |
---|---|---|
committer | Marc Schütz <schuetzm@gmx.net> | 2014-06-10 18:38:43 +0200 |
commit | 55d986270b3af91019dabfb2169817cd894d84fe (patch) | |
tree | 0757f88a78e51dba49aab641dc74ba0892253d96 /toxcore/crypto_core.h | |
parent | 9e028b243a8eff03518e048b25a169166441df34 (diff) |
Const correctness in toxcore/crypto_core.c
Diffstat (limited to 'toxcore/crypto_core.h')
-rw-r--r-- | toxcore/crypto_core.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/toxcore/crypto_core.h b/toxcore/crypto_core.h index 6b69f917..578bd54a 100644 --- a/toxcore/crypto_core.h +++ b/toxcore/crypto_core.h | |||
@@ -43,7 +43,7 @@ | |||
43 | /* Use this instead of memcmp; not vulnerable to timing attacks. | 43 | /* Use this instead of memcmp; not vulnerable to timing attacks. |
44 | returns 0 if both mem locations of length are equal, | 44 | returns 0 if both mem locations of length are equal, |
45 | return -1 if they are not. */ | 45 | return -1 if they are not. */ |
46 | int crypto_cmp(uint8_t *mem1, uint8_t *mem2, uint32_t length); | 46 | int crypto_cmp(const uint8_t *mem1, const uint8_t *mem2, uint32_t length); |
47 | 47 | ||
48 | /* return a random number. | 48 | /* return a random number. |
49 | * | 49 | * |
@@ -60,8 +60,8 @@ uint64_t random_64b(void); | |||
60 | * return -1 if there was a problem. | 60 | * return -1 if there was a problem. |
61 | * return length of encrypted data if everything was fine. | 61 | * return length of encrypted data if everything was fine. |
62 | */ | 62 | */ |
63 | int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce, | 63 | int encrypt_data(const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *nonce, |
64 | uint8_t *plain, uint32_t length, uint8_t *encrypted); | 64 | const uint8_t *plain, uint32_t length, uint8_t *encrypted); |
65 | 65 | ||
66 | 66 | ||
67 | /* Decrypts encrypted of length length to plain of length length - 16 using the | 67 | /* Decrypts encrypted of length length to plain of length length - 16 using the |
@@ -70,13 +70,13 @@ int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce, | |||
70 | * return -1 if there was a problem (decryption failed). | 70 | * return -1 if there was a problem (decryption failed). |
71 | * return length of plain data if everything was fine. | 71 | * return length of plain data if everything was fine. |
72 | */ | 72 | */ |
73 | int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce, | 73 | int decrypt_data(const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *nonce, |
74 | uint8_t *encrypted, uint32_t length, uint8_t *plain); | 74 | const uint8_t *encrypted, uint32_t length, uint8_t *plain); |
75 | 75 | ||
76 | /* Fast encrypt/decrypt operations. Use if this is not a one-time communication. | 76 | /* Fast encrypt/decrypt operations. Use if this is not a one-time communication. |
77 | encrypt_precompute does the shared-key generation once so it does not have | 77 | encrypt_precompute does the shared-key generation once so it does not have |
78 | to be preformed on every encrypt/decrypt. */ | 78 | to be preformed on every encrypt/decrypt. */ |
79 | void encrypt_precompute(uint8_t *public_key, uint8_t *secret_key, uint8_t *enc_key); | 79 | void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, uint8_t *enc_key); |
80 | 80 | ||
81 | /* Encrypts plain of length length to encrypted of length + 16 using a | 81 | /* Encrypts plain of length length to encrypted of length + 16 using a |
82 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. | 82 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. |
@@ -84,7 +84,7 @@ void encrypt_precompute(uint8_t *public_key, uint8_t *secret_key, uint8_t *enc_k | |||
84 | * return -1 if there was a problem. | 84 | * return -1 if there was a problem. |
85 | * return length of encrypted data if everything was fine. | 85 | * return length of encrypted data if everything was fine. |
86 | */ | 86 | */ |
87 | int encrypt_data_symmetric(uint8_t *secret_key, uint8_t *nonce, uint8_t *plain, uint32_t length, uint8_t *encrypted); | 87 | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, uint8_t *encrypted); |
88 | 88 | ||
89 | /* Decrypts encrypted of length length to plain of length length - 16 using a | 89 | /* Decrypts encrypted of length length to plain of length length - 16 using a |
90 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. | 90 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. |
@@ -92,7 +92,7 @@ int encrypt_data_symmetric(uint8_t *secret_key, uint8_t *nonce, uint8_t *plain, | |||
92 | * return -1 if there was a problem (decryption failed). | 92 | * return -1 if there was a problem (decryption failed). |
93 | * return length of plain data if everything was fine. | 93 | * return length of plain data if everything was fine. |
94 | */ | 94 | */ |
95 | int decrypt_data_symmetric(uint8_t *secret_key, uint8_t *nonce, uint8_t *encrypted, uint32_t length, uint8_t *plain); | 95 | int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length, uint8_t *plain); |
96 | 96 | ||
97 | /* Increment the given nonce by 1. */ | 97 | /* Increment the given nonce by 1. */ |
98 | void increment_nonce(uint8_t *nonce); | 98 | void increment_nonce(uint8_t *nonce); |
@@ -128,15 +128,15 @@ void new_nonce(uint8_t *nonce); | |||
128 | * return -1 on failure. | 128 | * return -1 on failure. |
129 | * return the length of the created packet on success. | 129 | * return the length of the created packet on success. |
130 | */ | 130 | */ |
131 | int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t *packet, uint8_t *recv_public_key, | 131 | int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet, const uint8_t *recv_public_key, |
132 | uint8_t *data, uint32_t length, uint8_t request_id); | 132 | const uint8_t *data, uint32_t length, uint8_t request_id); |
133 | 133 | ||
134 | /* puts the senders public key in the request in public_key, the data from the request | 134 | /* puts the senders public key in the request in public_key, the data from the request |
135 | in data if a friend or ping request was sent to us and returns the length of the data. | 135 | in data if a friend or ping request was sent to us and returns the length of the data. |
136 | packet is the request packet and length is its length | 136 | packet is the request packet and length is its length |
137 | return -1 if not valid request. */ | 137 | return -1 if not valid request. */ |
138 | int handle_request(uint8_t *self_public_key, uint8_t *self_secret_key, uint8_t *public_key, uint8_t *data, | 138 | int handle_request(const uint8_t *self_public_key, const uint8_t *self_secret_key, uint8_t *public_key, uint8_t *data, |
139 | uint8_t *request_id, uint8_t *packet, uint16_t length); | 139 | uint8_t *request_id, const uint8_t *packet, uint16_t length); |
140 | 140 | ||
141 | 141 | ||
142 | #endif | 142 | #endif |