rand_extra.c
Go to the documentation of this file.
1 /* Copyright (c) 2017, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #include <openssl/rand.h>
16 
17 #include <limits.h>
18 
19 
20 void RAND_seed(const void *buf, int num) {
21  // OpenSSH calls |RAND_seed| before jailing on the assumption that any needed
22  // file descriptors etc will be opened.
23  uint8_t unused;
24  RAND_bytes(&unused, sizeof(unused));
25 }
26 
27 int RAND_load_file(const char *path, long num) {
28  if (num < 0) { // read the "whole file"
29  return 1;
30  } else if (num <= INT_MAX) {
31  return (int) num;
32  } else {
33  return INT_MAX;
34  }
35 }
36 
37 const char *RAND_file_name(char *buf, size_t num) { return NULL; }
38 
39 void RAND_add(const void *buf, int num, double entropy) {}
40 
41 int RAND_egd(const char *path) {
42  return 255;
43 }
44 
45 int RAND_poll(void) {
46  return 1;
47 }
48 
49 int RAND_status(void) {
50  return 1;
51 }
52 
53 static const struct rand_meth_st kSSLeayMethod = {
54  RAND_seed,
55  RAND_bytes,
57  RAND_add,
60 };
61 
63  return (RAND_METHOD*) &kSSLeayMethod;
64 }
65 
67  return RAND_SSLeay();
68 }
69 
70 const RAND_METHOD *RAND_get_rand_method(void) { return RAND_SSLeay(); }
71 
72 int RAND_set_rand_method(const RAND_METHOD *method) { return 1; }
73 
74 void RAND_cleanup(void) {}
RAND_pseudo_bytes
#define RAND_pseudo_bytes
Definition: boringssl_prefix_symbols.h:2069
RAND_bytes
#define RAND_bytes
Definition: boringssl_prefix_symbols.h:2060
RAND_get_rand_method
const RAND_METHOD * RAND_get_rand_method(void)
Definition: rand_extra.c:70
RAND_cleanup
void RAND_cleanup(void)
Definition: rand_extra.c:74
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
RAND_seed
void RAND_seed(const void *buf, int num)
Definition: rand_extra.c:20
check_documentation.path
path
Definition: check_documentation.py:57
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
rand_meth_st
Definition: rand.h:88
RAND_OpenSSL
RAND_METHOD * RAND_OpenSSL(void)
Definition: rand_extra.c:66
RAND_load_file
int RAND_load_file(const char *path, long num)
Definition: rand_extra.c:27
RAND_status
int RAND_status(void)
Definition: rand_extra.c:49
RAND_set_rand_method
int RAND_set_rand_method(const RAND_METHOD *method)
Definition: rand_extra.c:72
RAND_add
void RAND_add(const void *buf, int num, double entropy)
Definition: rand_extra.c:39
RAND_egd
int RAND_egd(const char *path)
Definition: rand_extra.c:41
rand.h
xds_manager.num
num
Definition: xds_manager.py:56
RAND_poll
int RAND_poll(void)
Definition: rand_extra.c:45
kSSLeayMethod
static const struct rand_meth_st kSSLeayMethod
Definition: rand_extra.c:53
method
NSString * method
Definition: ProtoMethod.h:28
RAND_SSLeay
RAND_METHOD * RAND_SSLeay(void)
Definition: rand_extra.c:62
RAND_file_name
const char * RAND_file_name(char *buf, size_t num)
Definition: rand_extra.c:37


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:50