aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libevent/arc4random.c
diff options
context:
space:
mode:
authorkikht <kikht@yandex-team.ru>2022-02-10 16:45:14 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:14 +0300
commit778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/libevent/arc4random.c
parent194cae0e8855b11be2005e1eff12c660c3ee9774 (diff)
downloadydb-778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5.tar.gz
Restoring authorship annotation for <kikht@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/libevent/arc4random.c')
-rw-r--r--contrib/libs/libevent/arc4random.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/contrib/libs/libevent/arc4random.c b/contrib/libs/libevent/arc4random.c
index e8fbd1661f..8729f6b92f 100644
--- a/contrib/libs/libevent/arc4random.c
+++ b/contrib/libs/libevent/arc4random.c
@@ -50,17 +50,17 @@
#endif
#ifndef ARC4RANDOM_NO_INCLUDES
-#include "evconfig-private.h"
-#ifdef _WIN32
+#include "evconfig-private.h"
+#ifdef _WIN32
#include <wincrypt.h>
#include <process.h>
-#include <winerror.h>
+#include <winerror.h>
#else
#include <fcntl.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/time.h>
-#ifdef EVENT__HAVE_SYS_SYSCTL_H
+#ifdef EVENT__HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#ifdef EVENT__HAVE_SYS_RANDOM_H
@@ -84,7 +84,7 @@ struct arc4_stream {
unsigned char s[256];
};
-#ifdef _WIN32
+#ifdef _WIN32
#define getpid _getpid
#define pid_t int
#endif
@@ -124,7 +124,7 @@ arc4_addrandom(const unsigned char *dat, int datlen)
rs.j = rs.i;
}
-#ifndef _WIN32
+#ifndef _WIN32
static ssize_t
read_all(int fd, unsigned char *buf, size_t count)
{
@@ -144,7 +144,7 @@ read_all(int fd, unsigned char *buf, size_t count)
}
#endif
-#ifdef _WIN32
+#ifdef _WIN32
#define TRY_SEED_WIN32
static int
arc4_seed_win32(void)
@@ -202,7 +202,7 @@ arc4_seed_getrandom(void)
#endif /* EVENT__HAVE_GETRANDOM */
#if defined(EVENT__HAVE_SYS_SYSCTL_H) && defined(EVENT__HAVE_SYSCTL)
-#if EVENT__HAVE_DECL_CTL_KERN && EVENT__HAVE_DECL_KERN_ARND
+#if EVENT__HAVE_DECL_CTL_KERN && EVENT__HAVE_DECL_KERN_ARND
#define TRY_SEED_SYSCTL_BSD
static int
arc4_seed_sysctl_bsd(void)
@@ -240,7 +240,7 @@ arc4_seed_sysctl_bsd(void)
return 0;
}
#endif
-#endif /* defined(EVENT__HAVE_SYS_SYSCTL_H) */
+#endif /* defined(EVENT__HAVE_SYS_SYSCTL_H) */
#ifdef __linux__
#define TRY_SEED_PROC_SYS_KERNEL_RANDOM_UUID
@@ -256,7 +256,7 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
unsigned char entropy[64];
int bytes, n, i, nybbles;
for (bytes = 0; bytes<ADD_ENTROPY; ) {
- fd = evutil_open_closeonexec_("/proc/sys/kernel/random/uuid", O_RDONLY, 0);
+ fd = evutil_open_closeonexec_("/proc/sys/kernel/random/uuid", O_RDONLY, 0);
if (fd < 0)
return -1;
n = read(fd, buf, sizeof(buf));
@@ -265,8 +265,8 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
return -1;
memset(entropy, 0, sizeof(entropy));
for (i=nybbles=0; i<n; ++i) {
- if (EVUTIL_ISXDIGIT_(buf[i])) {
- int nyb = evutil_hex_char_to_int_(buf[i]);
+ if (EVUTIL_ISXDIGIT_(buf[i])) {
+ int nyb = evutil_hex_char_to_int_(buf[i]);
if (nybbles & 1) {
entropy[nybbles/2] |= nyb;
} else {
@@ -286,7 +286,7 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
}
#endif
-#ifndef _WIN32
+#ifndef _WIN32
#define TRY_SEED_URANDOM
static char *arc4random_urandom_filename = NULL;
@@ -296,7 +296,7 @@ static int arc4_seed_urandom_helper_(const char *fname)
int fd;
size_t n;
- fd = evutil_open_closeonexec_(fname, O_RDONLY, 0);
+ fd = evutil_open_closeonexec_(fname, O_RDONLY, 0);
if (fd<0)
return -1;
n = read_all(fd, buf, sizeof(buf));
@@ -370,7 +370,7 @@ arc4_stir(void)
rs_initialized = 1;
}
- if (0 != arc4_seed())
+ if (0 != arc4_seed())
return -1;
/*
@@ -444,9 +444,9 @@ ARC4RANDOM_EXPORT int
arc4random_stir(void)
{
int val;
- ARC4_LOCK_();
+ ARC4_LOCK_();
val = arc4_stir();
- ARC4_UNLOCK_();
+ ARC4_UNLOCK_();
return val;
}
#endif
@@ -456,7 +456,7 @@ ARC4RANDOM_EXPORT void
arc4random_addrandom(const unsigned char *dat, int datlen)
{
int j;
- ARC4_LOCK_();
+ ARC4_LOCK_();
if (!rs_initialized)
arc4_stir();
for (j = 0; j < datlen; j += 256) {
@@ -466,7 +466,7 @@ arc4random_addrandom(const unsigned char *dat, int datlen)
* crazy like passing us all the files in /var/log. */
arc4_addrandom(dat + j, datlen - j);
}
- ARC4_UNLOCK_();
+ ARC4_UNLOCK_();
}
#endif
@@ -475,27 +475,27 @@ ARC4RANDOM_EXPORT ARC4RANDOM_UINT32
arc4random(void)
{
ARC4RANDOM_UINT32 val;
- ARC4_LOCK_();
+ ARC4_LOCK_();
arc4_count -= 4;
arc4_stir_if_needed();
val = arc4_getword();
- ARC4_UNLOCK_();
+ ARC4_UNLOCK_();
return val;
}
#endif
ARC4RANDOM_EXPORT void
-arc4random_buf(void *buf_, size_t n)
+arc4random_buf(void *buf_, size_t n)
{
- unsigned char *buf = buf_;
- ARC4_LOCK_();
+ unsigned char *buf = buf_;
+ ARC4_LOCK_();
arc4_stir_if_needed();
while (n--) {
if (--arc4_count <= 0)
arc4_stir();
buf[n] = arc4_getbyte();
}
- ARC4_UNLOCK_();
+ ARC4_UNLOCK_();
}
#ifndef ARC4RANDOM_NOUNIFORM