2 * Copyright (c) 2018 Todd C. Miller <Todd.Miller@sudo.ws>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 * Sponsored in part by the Defense Advanced Research Projects
17 * Agency (DARPA) and Air Force Research Laboratory, Air Force
18 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
24 #include <stdlib.h> /* For arc4random() on systems that have it */
27 * All libc replacements are prefixed with "sudo_" to avoid namespace issues.
30 #ifndef HAVE_ARC4RANDOM
31 /* Note: not exported by libutil. */
32 uint32_t sudo_arc4random(void);
34 # define arc4random() sudo_arc4random()
35 #endif /* ARC4RANDOM */
37 #ifndef HAVE_ARC4RANDOM_UNIFORM
38 __dso_public uint32_t sudo_arc4random_uniform(uint32_t upper_bound);
39 # undef arc4random_uniform
40 # define arc4random_uniform(_a) sudo_arc4random_uniform((_a))
41 #endif /* ARC4RANDOM_UNIFORM */
43 #ifndef HAVE_GETENTROPY
44 /* Note: not exported by libutil. */
45 int sudo_getentropy(void *buf, size_t buflen);
47 # define getentropy(_a, _b) sudo_getentropy((_a), (_b))
48 #endif /* HAVE_GETENTROPY */
50 #endif /* SUDO_RAND_H */