@@ -90,7 +90,7 @@ static ssize_t getrandom(void *buf, size_t buflen, unsigned int flags)
9090}
9191#endif
9292
93- static int randombytes_linux_randombytes_getrandom (void * buf , size_t n )
93+ static int linux_getrandom (void * buf , size_t n )
9494{
9595 size_t offset = 0 ;
9696 int ret ;
@@ -114,12 +114,12 @@ static int randombytes_linux_randombytes_getrandom(void *buf, size_t n)
114114#if defined(__linux__ ) && !defined(SYS_getrandom )
115115
116116#if defined(__linux__ )
117- static inline int randombytes_linux_read_entropy_ioctl (int device , int * entropy )
117+ static inline int linux_read_entropy_ioctl (int device , int * entropy )
118118{
119119 return ioctl (device , RNDGETENTCNT , entropy );
120120}
121121
122- static int randombytes_linux_read_entropy_proc (FILE * stream , int * entropy )
122+ static int linux_read_entropy_proc (FILE * stream , int * entropy )
123123{
124124 int retcode ;
125125 do {
@@ -131,7 +131,7 @@ static int randombytes_linux_read_entropy_proc(FILE *stream, int *entropy)
131131 return 0 ;
132132}
133133
134- static int randombytes_linux_wait_for_entropy (int device )
134+ static int linux_wait_for_entropy (int device )
135135{
136136 /* We will block on /dev/random, because any increase in the OS' entropy
137137 * level will unblock the request. I use poll here (as does libsodium),
@@ -144,7 +144,7 @@ static int randombytes_linux_wait_for_entropy(int device)
144144 int entropy = 0 ;
145145
146146 /* If the device has enough entropy already, we will want to return early */
147- int retcode = randombytes_linux_read_entropy_ioctl (device , & entropy );
147+ int retcode = linux_read_entropy_ioctl (device , & entropy );
148148 if (retcode != 0 && (errno == ENOTTY || errno == ENOSYS )) {
149149 /* The ioctl call on /dev/urandom has failed due to a
150150 * - ENOTTY (unsupported action), or
@@ -184,11 +184,9 @@ static int randombytes_linux_wait_for_entropy(int device)
184184 continue ;
185185 } else if (retcode == 1 ) {
186186 if (strategy == IOCTL ) {
187- retcode =
188- randombytes_linux_read_entropy_ioctl (device , & entropy );
187+ retcode = linux_read_entropy_ioctl (device , & entropy );
189188 } else if (strategy == PROC ) {
190- retcode =
191- randombytes_linux_read_entropy_proc (proc_file , & entropy );
189+ retcode = linux_read_entropy_proc (proc_file , & entropy );
192190 } else {
193191 return -1 ; /* Unreachable */
194192 }
@@ -220,7 +218,7 @@ static int randombytes_linux_wait_for_entropy(int device)
220218}
221219#endif /* defined(__linux__) */
222220
223- static int randombytes_linux_randombytes_urandom (void * buf , size_t n )
221+ static int linux_urandom (void * buf , size_t n )
224222{
225223 int fd ;
226224 do {
@@ -229,7 +227,7 @@ static int randombytes_linux_randombytes_urandom(void *buf, size_t n)
229227 if (fd == -1 )
230228 return -1 ;
231229#if defined(__linux__ )
232- if (randombytes_linux_wait_for_entropy (fd ) == -1 )
230+ if (linux_wait_for_entropy (fd ) == -1 )
233231 return -1 ;
234232#endif
235233
@@ -259,7 +257,7 @@ static int randombytes_linux_randombytes_urandom(void *buf, size_t n)
259257#include <CommonCrypto/CommonRandom.h>
260258#endif
261259#endif
262- static int randombytes_bsd_randombytes (void * buf , size_t n )
260+ static int bsd_randombytes (void * buf , size_t n )
263261{
264262#if defined(MAC_OS_X_VERSION_10_15 ) && \
265263 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15
@@ -279,16 +277,16 @@ int randombytes(uint8_t *buf, size_t n)
279277#if defined(__linux__ ) || defined(__GNU__ )
280278#if defined(USE_GLIBC )
281279 /* Use getrandom system call */
282- return randombytes_linux_randombytes_getrandom (buf , n );
280+ return linux_getrandom (buf , n );
283281#elif defined(SYS_getrandom )
284282 /* Use getrandom system call */
285- return randombytes_linux_randombytes_getrandom (buf , n );
283+ return linux_getrandom (buf , n );
286284#else
287285 /* When we have enough entropy, we can read from /dev/urandom */
288- return randombytes_linux_randombytes_urandom (buf , n );
286+ return linux_urandom (buf , n );
289287#endif
290288#elif defined(BSD )
291- return randombytes_bsd_randombytes (buf , n );
289+ return bsd_randombytes (buf , n );
292290#else
293291#error "randombytes(...) is not supported on this platform"
294292#endif
0 commit comments