#include #include ">

PostgreSQL Source Code: src/port/pg_strong_random.c File Reference (original) (raw)

#include "[c.h](c%5F8h%5Fsource.html)"
#include <fcntl.h>
#include <[unistd.h](unistd%5F8h%5Fsource.html)>
#include <[sys/time.h](time%5F8h%5Fsource.html)>

Go to the source code of this file.

bool pg_strong_random ( void * buf,
size_t len
)

Definition at line 150 of file pg_strong_random.c.

151{

152 int f;

153 char *p = buf;

154 ssize_t res;

155

156 f = open("/dev/urandom", O_RDONLY, 0);

157 if (f == -1)

158 return false;

159

160 while (len)

161 {

163 if (res <= 0)

164 {

165 if (errno == EINTR)

166 continue;

167

169 return false;

170 }

171

172 p += res;

173 len -= res;

174 }

175

177 return true;

178}

References buf, close, EINTR, len, and read.

Referenced by build_client_first_message(), build_server_first_message(), CheckMD5Auth(), gen_random_uuid(), generate_uuidv7(), init_sess_key(), InitControlFile(), pad_eme_pkcs1_v15(), PerformRadiusTransaction(), pg_be_scram_build_secret(), pg_fe_scram_build_secret(), pg_random_bytes(), pgp_s2k_fill(), PostgresMain(), px_gen_salt(), set_random_seed(), and write_prefix().

pg_strong_random_init()

void pg_strong_random_init ( void )