NativeClient: use get_random_bytes directly instead of the wrapper
This commit is contained in:
parent
681176e187
commit
7a667edbd0
@ -4,7 +4,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __native_client__
|
||||
# include <nacl/nacl_random.h>
|
||||
# include <irt.h>
|
||||
|
||||
# include "utils.h"
|
||||
# include "randombytes.h"
|
||||
@ -13,11 +13,23 @@
|
||||
static void
|
||||
randombytes_nativeclient_buf(void * const buf, const size_t size)
|
||||
{
|
||||
size_t readnb;
|
||||
unsigned char *buf_ = (unsigned char *) buf;
|
||||
struct nacl_irt_random rand_intf;
|
||||
size_t readnb = (size_t) 0U;
|
||||
size_t toread = size;
|
||||
|
||||
if (nacl_secure_random(buf, size, &readnb) != 0 || readnb != size) {
|
||||
if (nacl_interface_query(NACL_IRT_RANDOM_v0_1, &rand_intf,
|
||||
sizeof rand_intf) != sizeof rand_intf) {
|
||||
abort();
|
||||
}
|
||||
while (toread > (size_t) 0U) {
|
||||
if (rand_intf.get_random_bytes(buf_, size, &readnb) != 0 ||
|
||||
readnb > size) {
|
||||
abort();
|
||||
}
|
||||
toread -= readnb;
|
||||
buf_ += readnb;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
|
Loading…
Reference in New Issue
Block a user