xref: /openbsd-src/lib/libcrypto/rand/rand_lib.c (revision c3d6a26af7455bccce87985ff78ef0efc39b65e1)
1 /* $OpenBSD: rand_lib.c,v 1.17 2014/06/12 15:49:30 deraadt 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 #include "cryptlib.h"
18 #include <openssl/rand.h>
19 
20 #include <stdlib.h>
21 
22 /*
23  * The useful functions in this file are at the bottom.
24  */
25 int
26 RAND_set_rand_method(const RAND_METHOD *meth)
27 {
28 	return 1;
29 }
30 
31 const RAND_METHOD *
32 RAND_get_rand_method(void)
33 {
34 	return NULL;
35 }
36 
37 RAND_METHOD *
38 RAND_SSLeay(void)
39 {
40 	return NULL;
41 }
42 
43 #ifndef OPENSSL_NO_ENGINE
44 int
45 RAND_set_rand_engine(ENGINE *engine)
46 {
47 	return 1;
48 }
49 #endif
50 
51 void
52 RAND_cleanup(void)
53 {
54 
55 }
56 
57 void
58 RAND_seed(const void *buf, int num)
59 {
60 
61 }
62 
63 void
64 RAND_add(const void *buf, int num, double entropy)
65 {
66 
67 }
68 
69 int
70 RAND_status(void)
71 {
72 	return 1;
73 }
74 
75 int
76 RAND_poll(void)
77 {
78 	return 1;
79 }
80 
81 /*
82  * Hurray. You've made it to the good parts.
83  */
84 int
85 RAND_bytes(unsigned char *buf, int num)
86 {
87 	if (num > 0)
88 		arc4random_buf(buf, num);
89 	return 1;
90 }
91 
92 int
93 RAND_pseudo_bytes(unsigned char *buf, int num)
94 {
95 	if (num > 0)
96 		arc4random_buf(buf, num);
97 	return 1;
98 }
99