aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/Crypto/x25519.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 00:49:18 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 00:49:48 +0100
commitf7a31ca7bb0106ce5df02aaa4a04bc044563ce0e (patch)
treeb05413076e49bca4ba1b2f0dd68cfb7edc8fa4c7 /WireGuard/WireGuard/Crypto/x25519.c
parentConfig: Add template for macOS key (diff)
downloadwireguard-apple-f7a31ca7bb0106ce5df02aaa4a04bc044563ce0e.tar.xz
wireguard-apple-f7a31ca7bb0106ce5df02aaa4a04bc044563ce0e.zip
x25519: demand RNG is successful
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/Crypto/x25519.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/Crypto/x25519.c b/WireGuard/WireGuard/Crypto/x25519.c
index e0ff4824..b77da0b0 100644
--- a/WireGuard/WireGuard/Crypto/x25519.c
+++ b/WireGuard/WireGuard/Crypto/x25519.c
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <string.h>
+#include <assert.h>
#include <CommonCrypto/CommonRandom.h>
#include "x25519.h"
@@ -171,7 +172,7 @@ void curve25519_derive_public_key(uint8_t public_key[32], const uint8_t private_
void curve25519_generate_private_key(uint8_t private_key[32])
{
- CCRandomGenerateBytes(private_key, 32);
+ assert(CCRandomGenerateBytes(private_key, 32) == kCCSuccess);
private_key[31] = (private_key[31] & 127) | 64;
private_key[0] &= 248;
}