2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include <openssl/crypto.h>
12 #include "internal/dso_conf.h"
15 #include "internal/thread_once.h"
17 static char *seed_sources = NULL;
18 static CRYPTO_ONCE init_info = CRYPTO_ONCE_STATIC_INIT;
20 DEFINE_RUN_ONCE_STATIC(init_info_strings)
23 static char seeds[512] = "";
25 #define add_seeds_string(str) \
27 if (seeds[0] != '\0') \
28 OPENSSL_strlcat(seeds, " ", sizeof(seeds)); \
29 OPENSSL_strlcat(seeds, str, sizeof(seeds)); \
31 #define add_seeds_stringlist(label, strlist) \
33 add_seeds_string(label "("); \
35 const char *dev[] = strlist; \
38 for (; *dev != NULL; dev++) { \
40 OPENSSL_strlcat(seeds, " ", sizeof(seeds)); \
42 OPENSSL_strlcat(seeds, *dev, sizeof(seeds)); \
45 OPENSSL_strlcat(seeds, ")", sizeof(seeds)); \
48 #ifdef OPENSSL_RAND_SEED_NONE
49 add_seeds_string("none");
51 #ifdef OPENSSL_RAND_SEED_RTDSC
52 add_seeds_string("stdsc");
54 #ifdef OPENSSL_RAND_SEED_RDCPU
55 add_seeds_string("rdrand ( rdseed rdrand )");
57 #ifdef OPENSSL_RAND_SEED_LIBRANDOM
58 add_seeds_string("C-library-random");
60 #ifdef OPENSSL_RAND_SEED_GETRANDOM
61 add_seeds_string("getrandom-syscall");
63 #ifdef OPENSSL_RAND_SEED_DEVRANDOM
64 add_seeds_stringlist("random-device", { DEVRANDOM, NULL });
66 #ifdef OPENSSL_RAND_SEED_EGD
67 add_seeds_stringlist("EGD", { DEVRANDOM_EGD, NULL });
69 #ifdef OPENSSL_RAND_SEED_OS
70 add_seeds_string("os-specific");
77 const char *OPENSSL_info(int t)
80 * We don't care about the result. Worst case scenario, the strings
81 * won't be initialised, i.e. remain NULL, which means that the info
82 * isn't available anyway...
84 (void)RUN_ONCE(&init_info, init_info_strings);
87 case OPENSSL_INFO_CONFIG_DIR:
89 case OPENSSL_INFO_ENGINES_DIR:
91 case OPENSSL_INFO_MODULES_DIR:
93 case OPENSSL_INFO_DSO_EXTENSION:
95 case OPENSSL_INFO_DIR_FILENAME_SEPARATOR:
100 #else /* Assume POSIX */
103 case OPENSSL_INFO_LIST_SEPARATOR:
105 static const char list_sep[] = { LIST_SEPARATOR_CHAR, '\0' };
108 case OPENSSL_INFO_SEED_SOURCE: