1/* $OpenBSD: rand_lib.c,v 1.24 2024/04/10 14:53:01 beck Exp $ */
2/*
3 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <stdlib.h>
19
20#include <openssl/opensslconf.h>
21
22#include <openssl/rand.h>
23
24/*
25 * The useful functions in this file are at the bottom.
26 */
27int
28RAND_set_rand_method(const RAND_METHOD *meth)
29{
30	return 1;
31}
32LCRYPTO_ALIAS(RAND_set_rand_method);
33
34const RAND_METHOD *
35RAND_get_rand_method(void)
36{
37	return NULL;
38}
39LCRYPTO_ALIAS(RAND_get_rand_method);
40
41RAND_METHOD *
42RAND_SSLeay(void)
43{
44	return NULL;
45}
46LCRYPTO_ALIAS(RAND_SSLeay);
47
48void
49RAND_cleanup(void)
50{
51
52}
53LCRYPTO_ALIAS(RAND_cleanup);
54
55void
56RAND_seed(const void *buf, int num)
57{
58
59}
60LCRYPTO_ALIAS(RAND_seed);
61
62void
63RAND_add(const void *buf, int num, double entropy)
64{
65
66}
67LCRYPTO_ALIAS(RAND_add);
68
69int
70RAND_status(void)
71{
72	return 1;
73}
74LCRYPTO_ALIAS(RAND_status);
75
76int
77RAND_poll(void)
78{
79	return 1;
80}
81LCRYPTO_ALIAS(RAND_poll);
82
83/*
84 * Hurray. You've made it to the good parts.
85 */
86int
87RAND_bytes(unsigned char *buf, int num)
88{
89	if (num > 0)
90		arc4random_buf(buf, num);
91	return 1;
92}
93LCRYPTO_ALIAS(RAND_bytes);
94
95int
96RAND_pseudo_bytes(unsigned char *buf, int num)
97{
98	if (num > 0)
99		arc4random_buf(buf, num);
100	return 1;
101}
102LCRYPTO_ALIAS(RAND_pseudo_bytes);
103