Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/ntp/libntp/ntp_crypto_rnd.c
Show All 10 Lines | |||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#ifdef HAVE_UNISTD_H | #ifdef HAVE_UNISTD_H | ||||
# include <unistd.h> | # include <unistd.h> | ||||
#endif | #endif | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <l_stdlib.h> | #include <l_stdlib.h> | ||||
#include <ntp_random.h> | #include <ntp_random.h> | ||||
#include "safecast.h" | |||||
#ifdef USE_OPENSSL_CRYPTO_RAND | #ifdef USE_OPENSSL_CRYPTO_RAND | ||||
#include <openssl/err.h> | #include <openssl/err.h> | ||||
#include <openssl/rand.h> | #include <openssl/rand.h> | ||||
int crypto_rand_init = 0; | int crypto_rand_init = 0; | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
ntp_crypto_random_buf( | ntp_crypto_random_buf( | ||||
void *buf, | void *buf, | ||||
size_t nbytes | size_t nbytes | ||||
) | ) | ||||
{ | { | ||||
#ifdef USE_OPENSSL_CRYPTO_RAND | #ifdef USE_OPENSSL_CRYPTO_RAND | ||||
int rc; | int rc; | ||||
rc = RAND_bytes(buf, nbytes); | rc = RAND_bytes(buf, size2int_chk(nbytes)); | ||||
if (1 != rc) { | if (1 != rc) { | ||||
unsigned long err; | unsigned long err; | ||||
char *err_str; | char *err_str; | ||||
err = ERR_get_error(); | err = ERR_get_error(); | ||||
err_str = ERR_error_string(err, NULL); | err_str = ERR_error_string(err, NULL); | ||||
/* XXX: Log the error */ | /* XXX: Log the error */ | ||||
(void)&err_str; | (void)&err_str; | ||||
Show All 9 Lines |