summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/ciphers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/openssl/ciphers.c')
-rw-r--r--src/usr.bin/openssl/ciphers.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/usr.bin/openssl/ciphers.c b/src/usr.bin/openssl/ciphers.c
index 73d9e63b6f..247929bb9e 100644
--- a/src/usr.bin/openssl/ciphers.c
+++ b/src/usr.bin/openssl/ciphers.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ciphers.c,v 1.17 2023/03/05 13:12:53 tb Exp $ */ 1/* $OpenBSD: ciphers.c,v 1.18 2023/03/06 14:32:05 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -29,65 +29,65 @@ static struct {
29 int use_supported; 29 int use_supported;
30 int verbose; 30 int verbose;
31 int version; 31 int version;
32} ciphers_config; 32} cfg;
33 33
34static const struct option ciphers_options[] = { 34static const struct option ciphers_options[] = {
35 { 35 {
36 .name = "h", 36 .name = "h",
37 .type = OPTION_FLAG, 37 .type = OPTION_FLAG,
38 .opt.flag = &ciphers_config.usage, 38 .opt.flag = &cfg.usage,
39 }, 39 },
40 { 40 {
41 .name = "?", 41 .name = "?",
42 .type = OPTION_FLAG, 42 .type = OPTION_FLAG,
43 .opt.flag = &ciphers_config.usage, 43 .opt.flag = &cfg.usage,
44 }, 44 },
45 { 45 {
46 .name = "s", 46 .name = "s",
47 .desc = "Only list ciphers that are supported by the TLS method", 47 .desc = "Only list ciphers that are supported by the TLS method",
48 .type = OPTION_FLAG, 48 .type = OPTION_FLAG,
49 .opt.flag = &ciphers_config.use_supported, 49 .opt.flag = &cfg.use_supported,
50 }, 50 },
51 { 51 {
52 .name = "tls1", 52 .name = "tls1",
53 .desc = "Use TLS protocol version 1", 53 .desc = "Use TLS protocol version 1",
54 .type = OPTION_VALUE, 54 .type = OPTION_VALUE,
55 .opt.value = &ciphers_config.version, 55 .opt.value = &cfg.version,
56 .value = TLS1_VERSION, 56 .value = TLS1_VERSION,
57 }, 57 },
58 { 58 {
59 .name = "tls1_1", 59 .name = "tls1_1",
60 .desc = "Use TLS protocol version 1.1", 60 .desc = "Use TLS protocol version 1.1",
61 .type = OPTION_VALUE, 61 .type = OPTION_VALUE,
62 .opt.value = &ciphers_config.version, 62 .opt.value = &cfg.version,
63 .value = TLS1_1_VERSION, 63 .value = TLS1_1_VERSION,
64 }, 64 },
65 { 65 {
66 .name = "tls1_2", 66 .name = "tls1_2",
67 .desc = "Use TLS protocol version 1.2", 67 .desc = "Use TLS protocol version 1.2",
68 .type = OPTION_VALUE, 68 .type = OPTION_VALUE,
69 .opt.value = &ciphers_config.version, 69 .opt.value = &cfg.version,
70 .value = TLS1_2_VERSION, 70 .value = TLS1_2_VERSION,
71 }, 71 },
72 { 72 {
73 .name = "tls1_3", 73 .name = "tls1_3",
74 .desc = "Use TLS protocol version 1.3", 74 .desc = "Use TLS protocol version 1.3",
75 .type = OPTION_VALUE, 75 .type = OPTION_VALUE,
76 .opt.value = &ciphers_config.version, 76 .opt.value = &cfg.version,
77 .value = TLS1_3_VERSION, 77 .value = TLS1_3_VERSION,
78 }, 78 },
79 { 79 {
80 .name = "v", 80 .name = "v",
81 .desc = "Provide cipher listing", 81 .desc = "Provide cipher listing",
82 .type = OPTION_VALUE, 82 .type = OPTION_VALUE,
83 .opt.value = &ciphers_config.verbose, 83 .opt.value = &cfg.verbose,
84 .value = 1, 84 .value = 1,
85 }, 85 },
86 { 86 {
87 .name = "V", 87 .name = "V",
88 .desc = "Provide cipher listing with cipher suite values", 88 .desc = "Provide cipher listing with cipher suite values",
89 .type = OPTION_VALUE, 89 .type = OPTION_VALUE,
90 .opt.value = &ciphers_config.verbose, 90 .opt.value = &cfg.verbose,
91 .value = 2, 91 .value = 2,
92 }, 92 },
93 { NULL }, 93 { NULL },
@@ -119,7 +119,7 @@ ciphers_main(int argc, char **argv)
119 exit(1); 119 exit(1);
120 } 120 }
121 121
122 memset(&ciphers_config, 0, sizeof(ciphers_config)); 122 memset(&cfg, 0, sizeof(cfg));
123 123
124 if (options_parse(argc, argv, ciphers_options, &cipherlist, 124 if (options_parse(argc, argv, ciphers_options, &cipherlist,
125 NULL) != 0) { 125 NULL) != 0) {
@@ -127,7 +127,7 @@ ciphers_main(int argc, char **argv)
127 return (1); 127 return (1);
128 } 128 }
129 129
130 if (ciphers_config.usage) { 130 if (cfg.usage) {
131 ciphers_usage(); 131 ciphers_usage();
132 return (1); 132 return (1);
133 } 133 }
@@ -135,12 +135,12 @@ ciphers_main(int argc, char **argv)
135 if ((ssl_ctx = SSL_CTX_new(TLS_method())) == NULL) 135 if ((ssl_ctx = SSL_CTX_new(TLS_method())) == NULL)
136 goto err; 136 goto err;
137 137
138 if (ciphers_config.version != 0) { 138 if (cfg.version != 0) {
139 if (!SSL_CTX_set_min_proto_version(ssl_ctx, 139 if (!SSL_CTX_set_min_proto_version(ssl_ctx,
140 ciphers_config.version)) 140 cfg.version))
141 goto err; 141 goto err;
142 if (!SSL_CTX_set_max_proto_version(ssl_ctx, 142 if (!SSL_CTX_set_max_proto_version(ssl_ctx,
143 ciphers_config.version)) 143 cfg.version))
144 goto err; 144 goto err;
145 } 145 }
146 146
@@ -152,7 +152,7 @@ ciphers_main(int argc, char **argv)
152 if ((ssl = SSL_new(ssl_ctx)) == NULL) 152 if ((ssl = SSL_new(ssl_ctx)) == NULL)
153 goto err; 153 goto err;
154 154
155 if (ciphers_config.use_supported) { 155 if (cfg.use_supported) {
156 if ((supported_ciphers = 156 if ((supported_ciphers =
157 SSL_get1_supported_ciphers(ssl)) == NULL) 157 SSL_get1_supported_ciphers(ssl)) == NULL)
158 goto err; 158 goto err;
@@ -164,12 +164,12 @@ ciphers_main(int argc, char **argv)
164 164
165 for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { 165 for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) {
166 cipher = sk_SSL_CIPHER_value(ciphers, i); 166 cipher = sk_SSL_CIPHER_value(ciphers, i);
167 if (ciphers_config.verbose == 0) { 167 if (cfg.verbose == 0) {
168 fprintf(stdout, "%s%s", (i ? ":" : ""), 168 fprintf(stdout, "%s%s", (i ? ":" : ""),
169 SSL_CIPHER_get_name(cipher)); 169 SSL_CIPHER_get_name(cipher));
170 continue; 170 continue;
171 } 171 }
172 if (ciphers_config.verbose > 1) { 172 if (cfg.verbose > 1) {
173 value = SSL_CIPHER_get_value(cipher); 173 value = SSL_CIPHER_get_value(cipher);
174 fprintf(stdout, "%-*s0x%02X,0x%02X - ", 10, "", 174 fprintf(stdout, "%-*s0x%02X,0x%02X - ", 10, "",
175 ((value >> 8) & 0xff), (value & 0xff)); 175 ((value >> 8) & 0xff), (value & 0xff));
@@ -182,7 +182,7 @@ ciphers_main(int argc, char **argv)
182 fprintf(stdout, "%s", desc); 182 fprintf(stdout, "%s", desc);
183 free(desc); 183 free(desc);
184 } 184 }
185 if (ciphers_config.verbose == 0) 185 if (cfg.verbose == 0)
186 fprintf(stdout, "\n"); 186 fprintf(stdout, "\n");
187 187
188 goto done; 188 goto done;