os: auth: move GenerateRandomData() and make it static

Only used in mitauth.c, so we can move it there and make it static.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-03-10 13:53:58 +01:00
parent e89006d015
commit e536c2035c
3 changed files with 14 additions and 17 deletions

View File

@ -297,17 +297,3 @@ GenerateAuthorization(unsigned name_length,
} }
return -1; return -1;
} }
void
GenerateRandomData(int len, char *buf)
{
#ifdef HAVE_ARC4RANDOM_BUF
arc4random_buf(buf, len);
#else
int fd;
fd = open("/dev/urandom", O_RDONLY);
read(fd, buf, len);
close(fd);
#endif
}

View File

@ -132,6 +132,20 @@ MitRemoveCookie(unsigned short data_length, const char *data)
static char cookie[16]; /* 128 bits */ static char cookie[16]; /* 128 bits */
static void
GenerateRandomData(int len, char *buf)
{
#ifdef HAVE_ARC4RANDOM_BUF
arc4random_buf(buf, len);
#else
int fd;
fd = open("/dev/urandom", O_RDONLY);
read(fd, buf, len);
close(fd);
#endif
}
XID XID
MitGenerateCookie(unsigned data_length, MitGenerateCookie(unsigned data_length,
const char *data, const char *data,

View File

@ -134,9 +134,6 @@ extern Bool NewOutputPending;
/* in access.c */ /* in access.c */
extern Bool ComputeLocalClient(ClientPtr client); extern Bool ComputeLocalClient(ClientPtr client);
/* in auth.c */
extern void GenerateRandomData(int len, char *buf);
/* OsTimer functions */ /* OsTimer functions */
void TimerInit(void); void TimerInit(void);
Bool TimerForce(OsTimerPtr timer); Bool TimerForce(OsTimerPtr timer);