diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-14 21:08:02 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-14 21:08:02 +0000 |
commit | da739a9438bab75b1ad18cb96208069895b88d2b (patch) | |
tree | 75f1dbb6d7c08264e27a58d0b2ad97839aa414f3 /toxcore/crypto_core.api.h | |
parent | d79b15c52daf82748040f41f93fa6e046efdeee7 (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.h | 33 |
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 | ||
113 | namespace random { | ||
114 | |||
115 | /** | ||
116 | * Return a random 16 bit integer. | ||
117 | */ | ||
118 | static uint16_t u16(); | ||
119 | |||
113 | /** | 120 | /** |
114 | * Return a random 32 bit integer. | 121 | * Return a random 32 bit integer. |
115 | */ | 122 | */ |
116 | static uint32_t random_int(); | 123 | static uint32_t u32(); |
117 | 124 | ||
118 | /** | 125 | /** |
119 | * Return a random 64 bit integer. | 126 | * Return a random 64 bit integer. |
120 | */ | 127 | */ |
121 | static uint64_t random_64b(); | 128 | static uint64_t u64(); |
129 | |||
130 | /** | ||
131 | * Fill the given nonce with random bytes. | ||
132 | */ | ||
133 | static void nonce(uint8_t[CRYPTO_NONCE_SIZE] nonce); | ||
134 | |||
135 | /** | ||
136 | * Fill an array of bytes with random values. | ||
137 | */ | ||
138 | static 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); | |||
227 | static void increment_nonce_number(uint8_t[CRYPTO_NONCE_SIZE] nonce, uint32_t host_order_num); | 246 | static 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 | */ | ||
232 | static 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 | */ |
237 | static void new_symmetric_key(uint8_t[CRYPTO_SYMMETRIC_KEY_SIZE] key); | 251 | static void new_symmetric_key(uint8_t[CRYPTO_SYMMETRIC_KEY_SIZE] key); |
238 | 252 | ||
239 | /** | ||
240 | * Fill an array of bytes with random values. | ||
241 | */ | ||
242 | static void random_bytes(uint8_t[length] bytes); | ||
243 | |||
244 | %{ | 253 | %{ |
245 | #endif /* CRYPTO_CORE_H */ | 254 | #endif /* CRYPTO_CORE_H */ |
246 | %} | 255 | %} |