summaryrefslogtreecommitdiff
path: root/toxcore/crypto_core.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-06-16 19:31:39 -0400
committerirungentoo <irungentoo@gmail.com>2014-06-16 19:31:39 -0400
commit6408c406b29d189b507cefaabe0f4a3817f8ba86 (patch)
tree7ff6a88f233d46120121c662df72dc097b4d7dba /toxcore/crypto_core.c
parent881b2d900d1998981fb6b9938ec66012d049635f (diff)
Added more input validation to add_friend functions.
Diffstat (limited to 'toxcore/crypto_core.c')
-rw-r--r--toxcore/crypto_core.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c
index 87e276e7..1799b600 100644
--- a/toxcore/crypto_core.c
+++ b/toxcore/crypto_core.c
@@ -66,6 +66,20 @@ uint64_t random_64b(void)
66 return randnum; 66 return randnum;
67} 67}
68 68
69/* Check if a Tox public key crypto_box_PUBLICKEYBYTES is valid or not.
70 * This should only be used for input validation.
71 *
72 * return 0 if it isn't.
73 * return 1 if it is.
74 */
75int public_key_valid(const uint8_t *public_key)
76{
77 if (public_key[31] >= 128) /* Last bit of key is always zero. */
78 return 0;
79
80 return 1;
81}
82
69/* Precomputes the shared key from their public_key and our secret_key. 83/* Precomputes the shared key from their public_key and our secret_key.
70 * This way we can avoid an expensive elliptic curve scalar multiply for each 84 * This way we can avoid an expensive elliptic curve scalar multiply for each
71 * encrypt/decrypt operation. 85 * encrypt/decrypt operation.