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