summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/arc4random/getentropy_hpux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/arc4random/getentropy_hpux.c')
-rw-r--r--src/lib/libcrypto/arc4random/getentropy_hpux.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/src/lib/libcrypto/arc4random/getentropy_hpux.c b/src/lib/libcrypto/arc4random/getentropy_hpux.c
index 3ae6a6aa42..7208aa44c4 100644
--- a/src/lib/libcrypto/arc4random/getentropy_hpux.c
+++ b/src/lib/libcrypto/arc4random/getentropy_hpux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getentropy_hpux.c,v 1.5 2016/08/07 03:27:21 tb Exp $ */ 1/* $OpenBSD: getentropy_hpux.c,v 1.6 2018/11/20 08:04:28 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> 4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@@ -64,7 +64,6 @@
64 64
65int getentropy(void *buf, size_t len); 65int getentropy(void *buf, size_t len);
66 66
67static int gotdata(char *buf, size_t len);
68static int getentropy_urandom(void *buf, size_t len, const char *path, 67static int getentropy_urandom(void *buf, size_t len, const char *path,
69 int devfscheck); 68 int devfscheck);
70static int getentropy_fallback(void *buf, size_t len); 69static int getentropy_fallback(void *buf, size_t len);
@@ -122,22 +121,6 @@ getentropy(void *buf, size_t len)
122 return (ret); 121 return (ret);
123} 122}
124 123
125/*
126 * Basic sanity checking; wish we could do better.
127 */
128static int
129gotdata(char *buf, size_t len)
130{
131 char any_set = 0;
132 size_t i;
133
134 for (i = 0; i < len; ++i)
135 any_set |= buf[i];
136 if (any_set == 0)
137 return (-1);
138 return (0);
139}
140
141static int 124static int
142getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) 125getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck)
143{ 126{
@@ -183,10 +166,8 @@ start:
183 i += ret; 166 i += ret;
184 } 167 }
185 close(fd); 168 close(fd);
186 if (gotdata(buf, len) == 0) { 169 errno = save_errno;
187 errno = save_errno; 170 return (0); /* satisfied */
188 return (0); /* satisfied */
189 }
190nodevrandom: 171nodevrandom:
191 errno = EIO; 172 errno = EIO;
192 return (-1); 173 return (-1);
@@ -410,10 +391,6 @@ getentropy_fallback(void *buf, size_t len)
410 } 391 }
411 explicit_bzero(&ctx, sizeof ctx); 392 explicit_bzero(&ctx, sizeof ctx);
412 explicit_bzero(results, sizeof results); 393 explicit_bzero(results, sizeof results);
413 if (gotdata(buf, len) == 0) { 394 errno = save_errno;
414 errno = save_errno; 395 return (0); /* satisfied */
415 return (0); /* satisfied */
416 }
417 errno = EIO;
418 return (-1);
419} 396}