PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pg_strong_random.c File Reference
#include "c.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
Include dependency graph for pg_strong_random.c:

Go to the source code of this file.

Functions

void pg_strong_random_init (void)
 
bool pg_strong_random (void *buf, size_t len)
 

Function Documentation

◆ pg_strong_random()

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 {
162 res = read(f, p, len);
163 if (res <= 0)
164 {
165 if (errno == EINTR)
166 continue; /* interrupted by signal, just retry */
167
168 close(f);
169 return false;
170 }
171
172 p += res;
173 len -= res;
174 }
175
176 close(f);
177 return true;
178}
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
const void size_t len
static char * buf
Definition: pg_test_fsync.c:72
#define EINTR
Definition: win32_port.h:364

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  )

Definition at line 144 of file pg_strong_random.c.

145{
146 /* No initialization needed */
147}

Referenced by fork_process().