2 * Copyright 1995-2017 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
14 #include <openssl/evp.h>
15 #include <openssl/crypto.h>
16 #include <openssl/bn.h>
17 #ifndef OPENSSL_NO_MD2
18 # include <openssl/md2.h>
20 #ifndef OPENSSL_NO_RC4
21 # include <openssl/rc4.h>
23 #ifndef OPENSSL_NO_DES
24 # include <openssl/des.h>
26 #ifndef OPENSSL_NO_IDEA
27 # include <openssl/idea.h>
30 # include <openssl/blowfish.h>
33 typedef enum OPTION_choice {
34 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
35 OPT_B, OPT_D, OPT_E, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R
38 const OPTIONS version_options[] = {
39 {"help", OPT_HELP, '-', "Display this summary"},
40 {"a", OPT_A, '-', "Show all data"},
41 {"b", OPT_B, '-', "Show build date"},
42 {"d", OPT_D, '-', "Show configuration directory"},
43 {"e", OPT_E, '-', "Show engines directory"},
44 {"f", OPT_F, '-', "Show compiler flags used"},
45 {"o", OPT_O, '-', "Show some internal datatype options"},
46 {"p", OPT_P, '-', "Show target build platform"},
47 {"r", OPT_R, '-', "Show random seeding options"},
48 {"v", OPT_V, '-', "Show library version"},
52 #if defined(OPENSSL_RAND_SEED_DEVRANDOM) || defined(OPENSSL_RAND_SEED_EGD)
53 static void printlist(const char *prefix, const char **dev)
55 printf("%s (", prefix);
56 for ( ; *dev != NULL; dev++)
57 printf(" \"%s\"", *dev);
62 int version_main(int argc, char **argv)
64 int ret = 1, dirty = 0, seed = 0;
65 int cflags = 0, version = 0, date = 0, options = 0, platform = 0, dir = 0;
70 prog = opt_init(argc, argv, version_options);
71 while ((o = opt_next()) != OPT_EOF) {
75 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
78 opt_help(version_options);
106 seed = cflags = version = date = platform = dir = engdir = 1;
114 if (OpenSSL_version_num() == OPENSSL_VERSION_NUMBER)
115 printf("%s\n", OpenSSL_version(OPENSSL_VERSION));
117 printf("%s (Library: %s)\n",
118 OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
121 printf("%s\n", OpenSSL_version(OPENSSL_BUILT_ON));
123 printf("%s\n", OpenSSL_version(OPENSSL_PLATFORM));
126 printf("%s ", BN_options());
127 #ifndef OPENSSL_NO_MD2
128 printf("%s ", MD2_options());
130 #ifndef OPENSSL_NO_RC4
131 printf("%s ", RC4_options());
133 #ifndef OPENSSL_NO_DES
134 printf("%s ", DES_options());
136 #ifndef OPENSSL_NO_IDEA
137 printf("%s ", IDEA_options());
139 #ifndef OPENSSL_NO_BF
140 printf("%s ", BF_options());
145 printf("%s\n", OpenSSL_version(OPENSSL_CFLAGS));
147 printf("%s\n", OpenSSL_version(OPENSSL_DIR));
149 printf("%s\n", OpenSSL_version(OPENSSL_ENGINES_DIR));
151 printf("Seeding source:");
152 #ifdef OPENSSL_RAND_SEED_RTDSC
155 #ifdef OPENSSL_RAND_SEED_RDCPU
156 printf(" rdrand ( rdseed rdrand )");
158 #ifdef OPENSSL_RAND_SEED_LIBRANDOM
159 printf(" C-library-random");
161 #ifdef OPENSSL_RAND_SEED_GETRANDOM
162 printf(" getrandom-syscall");
164 #ifdef OPENSSL_RAND_SEED_DEVRANDOM
166 static const char *dev[] = { DEVRANDOM, NULL };
167 printlist(" random-device", dev);
170 #ifdef OPENSSL_RAND_SEED_EGD
172 static const char *dev[] = { DEVRANDOM_EGD, NULL };
173 printlist(" EGD", dev);
176 #ifdef OPENSSL_RAND_SEED_NONE
179 #ifdef OPENSSL_RAND_SEED_OS
180 printf(" os-specific");