diff options
Diffstat (limited to 'src/usr.bin/openssl/rand.c')
-rw-r--r-- | src/usr.bin/openssl/rand.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/usr.bin/openssl/rand.c b/src/usr.bin/openssl/rand.c index 6ae6a8d8ee..a0f3b44664 100644 --- a/src/usr.bin/openssl/rand.c +++ b/src/usr.bin/openssl/rand.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rand.c,v 1.16 2023/03/05 13:12:53 tb Exp $ */ | 1 | /* $OpenBSD: rand.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -66,27 +66,27 @@ static struct { | |||
66 | int base64; | 66 | int base64; |
67 | int hex; | 67 | int hex; |
68 | char *outfile; | 68 | char *outfile; |
69 | } rand_config; | 69 | } cfg; |
70 | 70 | ||
71 | static const struct option rand_options[] = { | 71 | static const struct option rand_options[] = { |
72 | { | 72 | { |
73 | .name = "base64", | 73 | .name = "base64", |
74 | .desc = "Perform base64 encoding on output", | 74 | .desc = "Perform base64 encoding on output", |
75 | .type = OPTION_FLAG, | 75 | .type = OPTION_FLAG, |
76 | .opt.flag = &rand_config.base64, | 76 | .opt.flag = &cfg.base64, |
77 | }, | 77 | }, |
78 | { | 78 | { |
79 | .name = "hex", | 79 | .name = "hex", |
80 | .desc = "Hexadecimal output", | 80 | .desc = "Hexadecimal output", |
81 | .type = OPTION_FLAG, | 81 | .type = OPTION_FLAG, |
82 | .opt.flag = &rand_config.hex, | 82 | .opt.flag = &cfg.hex, |
83 | }, | 83 | }, |
84 | { | 84 | { |
85 | .name = "out", | 85 | .name = "out", |
86 | .argname = "file", | 86 | .argname = "file", |
87 | .desc = "Write to the given file instead of standard output", | 87 | .desc = "Write to the given file instead of standard output", |
88 | .type = OPTION_ARG, | 88 | .type = OPTION_ARG, |
89 | .opt.arg = &rand_config.outfile, | 89 | .opt.arg = &cfg.outfile, |
90 | }, | 90 | }, |
91 | {NULL}, | 91 | {NULL}, |
92 | }; | 92 | }; |
@@ -114,7 +114,7 @@ rand_main(int argc, char **argv) | |||
114 | exit(1); | 114 | exit(1); |
115 | } | 115 | } |
116 | 116 | ||
117 | memset(&rand_config, 0, sizeof(rand_config)); | 117 | memset(&cfg, 0, sizeof(cfg)); |
118 | 118 | ||
119 | if (options_parse(argc, argv, rand_options, &num_bytes, NULL) != 0) { | 119 | if (options_parse(argc, argv, rand_options, &num_bytes, NULL) != 0) { |
120 | rand_usage(); | 120 | rand_usage(); |
@@ -128,7 +128,7 @@ rand_main(int argc, char **argv) | |||
128 | } else | 128 | } else |
129 | badopt = 1; | 129 | badopt = 1; |
130 | 130 | ||
131 | if (rand_config.hex && rand_config.base64) | 131 | if (cfg.hex && cfg.base64) |
132 | badopt = 1; | 132 | badopt = 1; |
133 | 133 | ||
134 | if (badopt) { | 134 | if (badopt) { |
@@ -139,13 +139,13 @@ rand_main(int argc, char **argv) | |||
139 | out = BIO_new(BIO_s_file()); | 139 | out = BIO_new(BIO_s_file()); |
140 | if (out == NULL) | 140 | if (out == NULL) |
141 | goto err; | 141 | goto err; |
142 | if (rand_config.outfile != NULL) | 142 | if (cfg.outfile != NULL) |
143 | r = BIO_write_filename(out, rand_config.outfile); | 143 | r = BIO_write_filename(out, cfg.outfile); |
144 | else | 144 | else |
145 | r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); | 145 | r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); |
146 | if (r <= 0) | 146 | if (r <= 0) |
147 | goto err; | 147 | goto err; |
148 | if (rand_config.base64) { | 148 | if (cfg.base64) { |
149 | BIO *b64 = BIO_new(BIO_f_base64()); | 149 | BIO *b64 = BIO_new(BIO_f_base64()); |
150 | if (b64 == NULL) | 150 | if (b64 == NULL) |
151 | goto err; | 151 | goto err; |
@@ -160,7 +160,7 @@ rand_main(int argc, char **argv) | |||
160 | if (chunk > (int) sizeof(buf)) | 160 | if (chunk > (int) sizeof(buf)) |
161 | chunk = sizeof(buf); | 161 | chunk = sizeof(buf); |
162 | arc4random_buf(buf, chunk); | 162 | arc4random_buf(buf, chunk); |
163 | if (rand_config.hex) { | 163 | if (cfg.hex) { |
164 | for (i = 0; i < chunk; i++) | 164 | for (i = 0; i < chunk; i++) |
165 | BIO_printf(out, "%02x", buf[i]); | 165 | BIO_printf(out, "%02x", buf[i]); |
166 | } else | 166 | } else |
@@ -168,7 +168,7 @@ rand_main(int argc, char **argv) | |||
168 | num -= chunk; | 168 | num -= chunk; |
169 | } | 169 | } |
170 | 170 | ||
171 | if (rand_config.hex) | 171 | if (cfg.hex) |
172 | BIO_puts(out, "\n"); | 172 | BIO_puts(out, "\n"); |
173 | (void) BIO_flush(out); | 173 | (void) BIO_flush(out); |
174 | 174 | ||