summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornia <nia@NetBSD.org>2020-05-06 16:17:36 +0000
committernia <nia@NetBSD.org>2020-05-06 16:17:36 +0000
commit18600f94adb544da70dfd00813ef836047425e78 (patch)
tree367cfd222dab97cb0c2cd5e7d491f369c5ea87c5 /include
parent1d0cb7ad709bd23c7ce008f09ff403fcdbaf39c6 (diff)
Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.
Posted to tech-userlevel@ a week ago and reviewed by riastradh@. GETENTROPY(3) Library Functions Manual GETENTROPY(3) NAME getentropy - fill a buffer with high quality random data LIBRARY Standard C Library (libc, -lc) SYNOPSIS #include <unistd.h> int getentropy(void *buf, size_t buflen); DESCRIPTION The getentropy() function fills a buffer with high quality random data, suitable for seeding cryptographically secure psuedorandom number generators. getentropy() is only intended for seeding random number generators and is not intended for use by regular code which simply needs secure random data. For this purpose, please use arc4random(3). The maximum value for buflen is 256 bytes. IMPLEMENTATION NOTES getentropy() reads from the sysctl(7) variable kern.arandom. RETURN VALUES The getentropy() function returns 0 on success, and -1 if an error occurred. ERRORS getentropy() will succeed unless: [EFAULT] The buf argument points to an invalid memory address. [EIO] Too many bytes were requested. SEE ALSO arc4random(3), rnd(4) STANDARDS The getentropy() function is non-standard. HISTORY The getentropy() function first appeared in OpenBSD 5.6, then in FreeBSD 12.0, and NetBSD 10.
Diffstat (limited to 'include')
-rw-r--r--include/unistd.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/unistd.h b/include/unistd.h
index f3b518c4afa..d4987646637 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: unistd.h,v 1.156 2020/03/31 16:50:31 kamil Exp $ */
+/* $NetBSD: unistd.h,v 1.157 2020/05/06 16:17:36 nia Exp $ */
/*-
* Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -338,6 +338,7 @@ int fchroot(int);
int fdiscard(int, off_t, off_t);
int fsync_range(int, int, off_t, off_t);
int getdomainname(char *, size_t);
+int getentropy(void *, size_t);
int getgrouplist(const char *, gid_t, gid_t *, int *);
int getgroupmembership(const char *, gid_t, gid_t *, int, int *);
mode_t getmode(const void *, mode_t);