1 /* $OpenBSD: rand_lib.c,v 1.21 2023/07/07 12:01:32 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 */ 27 int 28 RAND_set_rand_method(const RAND_METHOD *meth) 29 { 30 return 1; 31 } 32 LCRYPTO_ALIAS(RAND_set_rand_method); 33 34 const RAND_METHOD * 35 RAND_get_rand_method(void) 36 { 37 return NULL; 38 } 39 LCRYPTO_ALIAS(RAND_get_rand_method); 40 41 RAND_METHOD * 42 RAND_SSLeay(void) 43 { 44 return NULL; 45 } 46 LCRYPTO_ALIAS(RAND_SSLeay); 47 48 #ifndef OPENSSL_NO_ENGINE 49 int 50 RAND_set_rand_engine(ENGINE *engine) 51 { 52 return 1; 53 } 54 LCRYPTO_ALIAS(RAND_set_rand_engine); 55 #endif 56 57 void 58 RAND_cleanup(void) 59 { 60 61 } 62 LCRYPTO_ALIAS(RAND_cleanup); 63 64 void 65 RAND_seed(const void *buf, int num) 66 { 67 68 } 69 LCRYPTO_ALIAS(RAND_seed); 70 71 void 72 RAND_add(const void *buf, int num, double entropy) 73 { 74 75 } 76 LCRYPTO_ALIAS(RAND_add); 77 78 int 79 RAND_status(void) 80 { 81 return 1; 82 } 83 LCRYPTO_ALIAS(RAND_status); 84 85 int 86 RAND_poll(void) 87 { 88 return 1; 89 } 90 LCRYPTO_ALIAS(RAND_poll); 91 92 /* 93 * Hurray. You've made it to the good parts. 94 */ 95 int 96 RAND_bytes(unsigned char *buf, int num) 97 { 98 if (num > 0) 99 arc4random_buf(buf, num); 100 return 1; 101 } 102 LCRYPTO_ALIAS(RAND_bytes); 103 104 int 105 RAND_pseudo_bytes(unsigned char *buf, int num) 106 { 107 if (num > 0) 108 arc4random_buf(buf, num); 109 return 1; 110 } 111 LCRYPTO_ALIAS(RAND_pseudo_bytes); 112