summaryrefslogtreecommitdiff
path: root/toxcore/crypto_core.api.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-14 21:08:02 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-14 21:08:02 +0000
commitda739a9438bab75b1ad18cb96208069895b88d2b (patch)
tree75f1dbb6d7c08264e27a58d0b2ad97839aa414f3 /toxcore/crypto_core.api.h
parentd79b15c52daf82748040f41f93fa6e046efdeee7 (diff)
Add random_u16 function and rename the others to match.
Diffstat (limited to 'toxcore/crypto_core.api.h')
-rw-r--r--toxcore/crypto_core.api.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/toxcore/crypto_core.api.h b/toxcore/crypto_core.api.h
index cef1a52c..0ba28c0c 100644
--- a/toxcore/crypto_core.api.h
+++ b/toxcore/crypto_core.api.h
@@ -110,15 +110,34 @@ static int32_t public_key_cmp(
110 const uint8_t[CRYPTO_PUBLIC_KEY_SIZE] pk1, 110 const uint8_t[CRYPTO_PUBLIC_KEY_SIZE] pk1,
111 const uint8_t[CRYPTO_PUBLIC_KEY_SIZE] pk2); 111 const uint8_t[CRYPTO_PUBLIC_KEY_SIZE] pk2);
112 112
113namespace random {
114
115/**
116 * Return a random 16 bit integer.
117 */
118static uint16_t u16();
119
113/** 120/**
114 * Return a random 32 bit integer. 121 * Return a random 32 bit integer.
115 */ 122 */
116static uint32_t random_int(); 123static uint32_t u32();
117 124
118/** 125/**
119 * Return a random 64 bit integer. 126 * Return a random 64 bit integer.
120 */ 127 */
121static uint64_t random_64b(); 128static uint64_t u64();
129
130/**
131 * Fill the given nonce with random bytes.
132 */
133static void nonce(uint8_t[CRYPTO_NONCE_SIZE] nonce);
134
135/**
136 * Fill an array of bytes with random values.
137 */
138static void bytes(uint8_t[length] bytes);
139
140}
122 141
123/** 142/**
124 * Check if a Tox public key CRYPTO_PUBLIC_KEY_SIZE is valid or not. This 143 * Check if a Tox public key CRYPTO_PUBLIC_KEY_SIZE is valid or not. This
@@ -227,20 +246,10 @@ static void increment_nonce(uint8_t[CRYPTO_NONCE_SIZE] nonce);
227static void increment_nonce_number(uint8_t[CRYPTO_NONCE_SIZE] nonce, uint32_t host_order_num); 246static void increment_nonce_number(uint8_t[CRYPTO_NONCE_SIZE] nonce, uint32_t host_order_num);
228 247
229/** 248/**
230 * Fill the given nonce with random bytes.
231 */
232static void random_nonce(uint8_t[CRYPTO_NONCE_SIZE] nonce);
233
234/**
235 * Fill a key CRYPTO_SYMMETRIC_KEY_SIZE big with random bytes. 249 * Fill a key CRYPTO_SYMMETRIC_KEY_SIZE big with random bytes.
236 */ 250 */
237static void new_symmetric_key(uint8_t[CRYPTO_SYMMETRIC_KEY_SIZE] key); 251static void new_symmetric_key(uint8_t[CRYPTO_SYMMETRIC_KEY_SIZE] key);
238 252
239/**
240 * Fill an array of bytes with random values.
241 */
242static void random_bytes(uint8_t[length] bytes);
243
244%{ 253%{
245#endif /* CRYPTO_CORE_H */ 254#endif /* CRYPTO_CORE_H */
246%} 255%}