x25519: demand RNG is successful

This commit is contained in:
Jason A. Donenfeld 2019-02-05 00:49:18 +01:00
parent fc63aa7c17
commit e4277c2dfd
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}