diff options
Diffstat (limited to 'toxcore/crypto_core.c')
-rw-r--r-- | toxcore/crypto_core.c | 14 |
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 | */ | ||
75 | int 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. |