2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (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
15 #include <openssl/evp.h>
16 #include <openssl/crypto.h>
17 #include <openssl/bn.h>
18 #ifndef OPENSSL_NO_MD2
19 # include <openssl/md2.h>
21 #ifndef OPENSSL_NO_RC4
22 # include <openssl/rc4.h>
24 #ifndef OPENSSL_NO_DES
25 # include <openssl/des.h>
27 #ifndef OPENSSL_NO_IDEA
28 # include <openssl/idea.h>
31 # include <openssl/blowfish.h>
34 typedef enum OPTION_choice {
35 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
36 OPT_B, OPT_D, OPT_E, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R
39 const OPTIONS version_options[] = {
40 {"help", OPT_HELP, '-', "Display this summary"},
41 {"a", OPT_A, '-', "Show all data"},
42 {"b", OPT_B, '-', "Show build date"},
43 {"d", OPT_D, '-', "Show configuration directory"},
44 {"e", OPT_E, '-', "Show engines directory"},
45 {"f", OPT_F, '-', "Show compiler flags used"},
46 {"o", OPT_O, '-', "Show some internal datatype options"},
47 {"p", OPT_P, '-', "Show target build platform"},
48 {"r", OPT_R, '-', "Show random seeding options"},
49 {"v", OPT_V, '-', "Show library version"},
53 #if defined(OPENSSL_RAND_SEED_DEVRANDOM) || defined(OPENSSL_RAND_SEED_EGD)
54 static void printlist(const char *prefix, const char **dev)
56 printf("%s (", prefix);
57 for ( ; *dev != NULL; dev++)
58 printf(" \"%s\"", *dev);
63 int version_main(int argc, char **argv)
65 int ret = 1, dirty = 0, seed = 0;
66 int cflags = 0, version = 0, date = 0, options = 0, platform = 0, dir = 0;
71 prog = opt_init(argc, argv, version_options);
72 while ((o = opt_next()) != OPT_EOF) {
77 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
80 opt_help(version_options);
108 seed = options = cflags = version = date = platform = dir = engdir
113 if (opt_num_rest() != 0) {
114 BIO_printf(bio_err, "Extra parameters given.\n");
121 if (OpenSSL_version_num() == OPENSSL_VERSION_NUMBER)
122 printf("%s\n", OpenSSL_version(OPENSSL_VERSION));
124 printf("%s (Library: %s)\n",
125 OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
128 printf("%s\n", OpenSSL_version(OPENSSL_BUILT_ON));
130 printf("%s\n", OpenSSL_version(OPENSSL_PLATFORM));
133 printf("%s ", BN_options());
134 #ifndef OPENSSL_NO_MD2
135 printf("%s ", MD2_options());
137 #ifndef OPENSSL_NO_RC4
138 printf("%s ", RC4_options());
140 #ifndef OPENSSL_NO_DES
141 printf("%s ", DES_options());
143 #ifndef OPENSSL_NO_IDEA
144 printf("%s ", IDEA_options());
146 #ifndef OPENSSL_NO_BF
147 printf("%s ", BF_options());
152 printf("%s\n", OpenSSL_version(OPENSSL_CFLAGS));
154 printf("%s\n", OpenSSL_version(OPENSSL_DIR));
156 printf("%s\n", OpenSSL_version(OPENSSL_ENGINES_DIR));
158 printf("Seeding source:");
159 #ifdef OPENSSL_RAND_SEED_RTDSC
162 #ifdef OPENSSL_RAND_SEED_RDCPU
163 printf(" rdrand ( rdseed rdrand )");
165 #ifdef OPENSSL_RAND_SEED_LIBRANDOM
166 printf(" C-library-random");
168 #ifdef OPENSSL_RAND_SEED_GETRANDOM
169 printf(" getrandom-syscall");
171 #ifdef OPENSSL_RAND_SEED_DEVRANDOM
173 static const char *dev[] = { DEVRANDOM, NULL };
174 printlist(" random-device", dev);
177 #ifdef OPENSSL_RAND_SEED_EGD
179 static const char *dev[] = { DEVRANDOM_EGD, NULL };
180 printlist(" EGD", dev);
183 #ifdef OPENSSL_RAND_SEED_NONE
186 #ifdef OPENSSL_RAND_SEED_OS
187 printf(" os-specific");