1 | #include <machine/rtems-bsd-user-space.h> |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. |
---|
5 | * |
---|
6 | * Licensed under the OpenSSL license (the "License"). You may not use |
---|
7 | * this file except in compliance with the License. You can obtain a copy |
---|
8 | * in the file LICENSE in the source distribution or at |
---|
9 | * https://www.openssl.org/source/license.html |
---|
10 | */ |
---|
11 | |
---|
12 | #include <stdio.h> |
---|
13 | #include <stdlib.h> |
---|
14 | #include <string.h> |
---|
15 | #include "apps.h" |
---|
16 | #include "progs.h" |
---|
17 | #include <openssl/evp.h> |
---|
18 | #include <openssl/crypto.h> |
---|
19 | #include <openssl/bn.h> |
---|
20 | #ifndef OPENSSL_NO_MD2 |
---|
21 | # include <openssl/md2.h> |
---|
22 | #endif |
---|
23 | #ifndef OPENSSL_NO_RC4 |
---|
24 | # include <openssl/rc4.h> |
---|
25 | #endif |
---|
26 | #ifndef OPENSSL_NO_DES |
---|
27 | # include <openssl/des.h> |
---|
28 | #endif |
---|
29 | #ifndef OPENSSL_NO_IDEA |
---|
30 | # include <openssl/idea.h> |
---|
31 | #endif |
---|
32 | #ifndef OPENSSL_NO_BF |
---|
33 | # include <openssl/blowfish.h> |
---|
34 | #endif |
---|
35 | |
---|
36 | typedef enum OPTION_choice { |
---|
37 | OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, |
---|
38 | OPT_B, OPT_D, OPT_E, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R |
---|
39 | } OPTION_CHOICE; |
---|
40 | |
---|
41 | const OPTIONS version_options[] = { |
---|
42 | {"help", OPT_HELP, '-', "Display this summary"}, |
---|
43 | {"a", OPT_A, '-', "Show all data"}, |
---|
44 | {"b", OPT_B, '-', "Show build date"}, |
---|
45 | {"d", OPT_D, '-', "Show configuration directory"}, |
---|
46 | {"e", OPT_E, '-', "Show engines directory"}, |
---|
47 | {"f", OPT_F, '-', "Show compiler flags used"}, |
---|
48 | {"o", OPT_O, '-', "Show some internal datatype options"}, |
---|
49 | {"p", OPT_P, '-', "Show target build platform"}, |
---|
50 | {"r", OPT_R, '-', "Show random seeding options"}, |
---|
51 | {"v", OPT_V, '-', "Show library version"}, |
---|
52 | {NULL} |
---|
53 | }; |
---|
54 | |
---|
55 | #if defined(OPENSSL_RAND_SEED_DEVRANDOM) || defined(OPENSSL_RAND_SEED_EGD) |
---|
56 | static void printlist(const char *prefix, const char **dev) |
---|
57 | { |
---|
58 | printf("%s (", prefix); |
---|
59 | for ( ; *dev != NULL; dev++) |
---|
60 | printf(" \"%s\"", *dev); |
---|
61 | printf(" )"); |
---|
62 | } |
---|
63 | #endif |
---|
64 | |
---|
65 | int version_main(int argc, char **argv) |
---|
66 | { |
---|
67 | int ret = 1, dirty = 0, seed = 0; |
---|
68 | int cflags = 0, version = 0, date = 0, options = 0, platform = 0, dir = 0; |
---|
69 | int engdir = 0; |
---|
70 | char *prog; |
---|
71 | OPTION_CHOICE o; |
---|
72 | |
---|
73 | prog = opt_init(argc, argv, version_options); |
---|
74 | while ((o = opt_next()) != OPT_EOF) { |
---|
75 | switch (o) { |
---|
76 | case OPT_EOF: |
---|
77 | case OPT_ERR: |
---|
78 | opthelp: |
---|
79 | BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); |
---|
80 | goto end; |
---|
81 | case OPT_HELP: |
---|
82 | opt_help(version_options); |
---|
83 | ret = 0; |
---|
84 | goto end; |
---|
85 | case OPT_B: |
---|
86 | dirty = date = 1; |
---|
87 | break; |
---|
88 | case OPT_D: |
---|
89 | dirty = dir = 1; |
---|
90 | break; |
---|
91 | case OPT_E: |
---|
92 | dirty = engdir = 1; |
---|
93 | break; |
---|
94 | case OPT_F: |
---|
95 | dirty = cflags = 1; |
---|
96 | break; |
---|
97 | case OPT_O: |
---|
98 | dirty = options = 1; |
---|
99 | break; |
---|
100 | case OPT_P: |
---|
101 | dirty = platform = 1; |
---|
102 | break; |
---|
103 | case OPT_R: |
---|
104 | dirty = seed = 1; |
---|
105 | break; |
---|
106 | case OPT_V: |
---|
107 | dirty = version = 1; |
---|
108 | break; |
---|
109 | case OPT_A: |
---|
110 | seed = options = cflags = version = date = platform = dir = engdir |
---|
111 | = 1; |
---|
112 | break; |
---|
113 | } |
---|
114 | } |
---|
115 | if (opt_num_rest() != 0) { |
---|
116 | BIO_printf(bio_err, "Extra parameters given.\n"); |
---|
117 | goto opthelp; |
---|
118 | } |
---|
119 | if (!dirty) |
---|
120 | version = 1; |
---|
121 | |
---|
122 | if (version) { |
---|
123 | if (OpenSSL_version_num() == OPENSSL_VERSION_NUMBER) |
---|
124 | printf("%s\n", OpenSSL_version(OPENSSL_VERSION)); |
---|
125 | else |
---|
126 | printf("%s (Library: %s)\n", |
---|
127 | OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION)); |
---|
128 | } |
---|
129 | if (date) |
---|
130 | printf("%s\n", OpenSSL_version(OPENSSL_BUILT_ON)); |
---|
131 | if (platform) |
---|
132 | printf("%s\n", OpenSSL_version(OPENSSL_PLATFORM)); |
---|
133 | if (options) { |
---|
134 | printf("options: "); |
---|
135 | printf("%s ", BN_options()); |
---|
136 | #ifndef OPENSSL_NO_MD2 |
---|
137 | printf("%s ", MD2_options()); |
---|
138 | #endif |
---|
139 | #ifndef OPENSSL_NO_RC4 |
---|
140 | printf("%s ", RC4_options()); |
---|
141 | #endif |
---|
142 | #ifndef OPENSSL_NO_DES |
---|
143 | printf("%s ", DES_options()); |
---|
144 | #endif |
---|
145 | #ifndef OPENSSL_NO_IDEA |
---|
146 | printf("%s ", IDEA_options()); |
---|
147 | #endif |
---|
148 | #ifndef OPENSSL_NO_BF |
---|
149 | printf("%s ", BF_options()); |
---|
150 | #endif |
---|
151 | printf("\n"); |
---|
152 | } |
---|
153 | if (cflags) |
---|
154 | printf("%s\n", OpenSSL_version(OPENSSL_CFLAGS)); |
---|
155 | if (dir) |
---|
156 | printf("%s\n", OpenSSL_version(OPENSSL_DIR)); |
---|
157 | if (engdir) |
---|
158 | printf("%s\n", OpenSSL_version(OPENSSL_ENGINES_DIR)); |
---|
159 | if (seed) { |
---|
160 | printf("Seeding source:"); |
---|
161 | #ifdef OPENSSL_RAND_SEED_RTDSC |
---|
162 | printf(" rtdsc"); |
---|
163 | #endif |
---|
164 | #ifdef OPENSSL_RAND_SEED_RDCPU |
---|
165 | printf(" rdrand ( rdseed rdrand )"); |
---|
166 | #endif |
---|
167 | #ifdef OPENSSL_RAND_SEED_LIBRANDOM |
---|
168 | printf(" C-library-random"); |
---|
169 | #endif |
---|
170 | #ifdef OPENSSL_RAND_SEED_GETRANDOM |
---|
171 | printf(" getrandom-syscall"); |
---|
172 | #endif |
---|
173 | #ifdef OPENSSL_RAND_SEED_DEVRANDOM |
---|
174 | { |
---|
175 | static const char *dev[] = { DEVRANDOM, NULL }; |
---|
176 | printlist(" random-device", dev); |
---|
177 | } |
---|
178 | #endif |
---|
179 | #ifdef OPENSSL_RAND_SEED_EGD |
---|
180 | { |
---|
181 | static const char *dev[] = { DEVRANDOM_EGD, NULL }; |
---|
182 | printlist(" EGD", dev); |
---|
183 | } |
---|
184 | #endif |
---|
185 | #ifdef OPENSSL_RAND_SEED_NONE |
---|
186 | printf(" none"); |
---|
187 | #endif |
---|
188 | #ifdef OPENSSL_RAND_SEED_OS |
---|
189 | printf(" os-specific"); |
---|
190 | #endif |
---|
191 | printf("\n"); |
---|
192 | } |
---|
193 | ret = 0; |
---|
194 | end: |
---|
195 | return ret; |
---|
196 | } |
---|