mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
util: add function to generate random bytes
Add a function to fill a buffer with random bytes which uses a better PRNG than random(). Use arc4random() if it's available on the system. Fall back to reading from /dev/urandom, which should be available on all currently supported systems.
This commit is contained in:
3
util.h
3
util.h
@@ -144,4 +144,7 @@ extern int UTI_CreateDirAndParents(const char *path, mode_t mode, uid_t uid, gid
|
||||
permissions and its uid/gid must match the specified values. */
|
||||
extern int UTI_CheckDirPermissions(const char *path, mode_t perm, uid_t uid, gid_t gid);
|
||||
|
||||
/* Fill buffer with random bytes */
|
||||
extern void UTI_GetRandomBytes(void *buf, unsigned int len);
|
||||
|
||||
#endif /* GOT_UTIL_H */
|
||||
|
||||
Reference in New Issue
Block a user