diff options
Diffstat (limited to 'toxcore/crypto_core.c')
-rw-r--r-- | toxcore/crypto_core.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c index 0b1971e7..6e92f5b6 100644 --- a/toxcore/crypto_core.c +++ b/toxcore/crypto_core.c | |||
@@ -50,6 +50,22 @@ int crypto_cmp(uint8_t *mem1, uint8_t *mem2, uint32_t length) | |||
50 | return (1 & ((check - 1) >> 8)) - 1; | 50 | return (1 & ((check - 1) >> 8)) - 1; |
51 | } | 51 | } |
52 | 52 | ||
53 | /* return a random number. | ||
54 | */ | ||
55 | uint32_t random_int(void) | ||
56 | { | ||
57 | uint32_t randnum; | ||
58 | randombytes((uint8_t *)&randnum , sizeof(randnum)); | ||
59 | return randnum; | ||
60 | } | ||
61 | |||
62 | uint64_t random_64b(void) | ||
63 | { | ||
64 | uint64_t randnum; | ||
65 | randombytes((uint8_t *)&randnum, sizeof(randnum)); | ||
66 | return randnum; | ||
67 | } | ||
68 | |||
53 | /* Precomputes the shared key from their public_key and our secret_key. | 69 | /* Precomputes the shared key from their public_key and our secret_key. |
54 | * This way we can avoid an expensive elliptic curve scalar multiply for each | 70 | * This way we can avoid an expensive elliptic curve scalar multiply for each |
55 | * encrypt/decrypt operation. | 71 | * encrypt/decrypt operation. |