summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/dh.c
diff options
context:
space:
mode:
authortb <>2025-01-19 10:24:17 +0000
committertb <>2025-01-19 10:24:17 +0000
commit554fa5724d58481f6d98cf1f31538602c83777e3 (patch)
treec9aaf8dfef4c4e6a68d7d8444e4bfbbd8df24f13 /src/usr.bin/openssl/dh.c
parent74c210a1e6252560bd02d5adadd7034dc48d1483 (diff)
downloadopenbsd-554fa5724d58481f6d98cf1f31538602c83777e3.tar.gz
openbsd-554fa5724d58481f6d98cf1f31538602c83777e3.tar.bz2
openbsd-554fa5724d58481f6d98cf1f31538602c83777e3.zip
Remove -C option from "apps"
As far as I can tell, this way of generating "C code" was only used to add stuff to pretty regress and even prettier speed "app" and otherwise it just served to make the library maintainer's lives even more miserable. ok jsing
Diffstat (limited to 'src/usr.bin/openssl/dh.c')
-rw-r--r--src/usr.bin/openssl/dh.c54
1 files changed, 2 insertions, 52 deletions
diff --git a/src/usr.bin/openssl/dh.c b/src/usr.bin/openssl/dh.c
index a4c02235f2..d7c7d2db91 100644
--- a/src/usr.bin/openssl/dh.c
+++ b/src/usr.bin/openssl/dh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh.c,v 1.15 2023/03/06 14:32:05 tb Exp $ */ 1/* $OpenBSD: dh.c,v 1.16 2025/01/19 10:24:17 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -75,7 +75,6 @@
75#include <openssl/x509.h> 75#include <openssl/x509.h>
76 76
77static struct { 77static struct {
78 int C;
79 int check; 78 int check;
80 char *infile; 79 char *infile;
81 int informat; 80 int informat;
@@ -87,12 +86,6 @@ static struct {
87 86
88static const struct option dh_options[] = { 87static const struct option dh_options[] = {
89 { 88 {
90 .name = "C",
91 .desc = "Convert DH parameters into C code",
92 .type = OPTION_FLAG,
93 .opt.flag = &cfg.C,
94 },
95 {
96 .name = "check", 89 .name = "check",
97 .desc = "Check the DH parameters", 90 .desc = "Check the DH parameters",
98 .type = OPTION_FLAG, 91 .type = OPTION_FLAG,
@@ -145,7 +138,7 @@ static void
145dh_usage(void) 138dh_usage(void)
146{ 139{
147 fprintf(stderr, 140 fprintf(stderr,
148 "usage: dh [-C] [-check] [-in file] [-inform format]\n" 141 "usage: dh [-check] [-in file] [-inform format]\n"
149 " [-noout] [-out file] [-outform format] [-text]\n\n"); 142 " [-noout] [-out file] [-outform format] [-text]\n\n");
150 options_usage(dh_options); 143 options_usage(dh_options);
151} 144}
@@ -228,49 +221,6 @@ dh_main(int argc, char **argv)
228 if (i == 0) 221 if (i == 0)
229 printf("DH parameters appear to be ok.\n"); 222 printf("DH parameters appear to be ok.\n");
230 } 223 }
231 if (cfg.C) {
232 unsigned char *data;
233 int len, l, bits;
234
235 len = BN_num_bytes(DH_get0_p(dh));
236 bits = BN_num_bits(DH_get0_p(dh));
237 data = malloc(len);
238 if (data == NULL) {
239 perror("malloc");
240 goto end;
241 }
242 l = BN_bn2bin(DH_get0_p(dh), data);
243 printf("static unsigned char dh%d_p[] = {", bits);
244 for (i = 0; i < l; i++) {
245 if ((i % 12) == 0)
246 printf("\n\t");
247 printf("0x%02X, ", data[i]);
248 }
249 printf("\n\t};\n");
250
251 l = BN_bn2bin(DH_get0_g(dh), data);
252 printf("static unsigned char dh%d_g[] = {", bits);
253 for (i = 0; i < l; i++) {
254 if ((i % 12) == 0)
255 printf("\n\t");
256 printf("0x%02X, ", data[i]);
257 }
258 printf("\n\t};\n\n");
259
260 printf("DH *get_dh%d()\n\t{\n", bits);
261 printf("\tDH *dh;\n");
262 printf("\tBIGNUM *p = NULL, *g = NULL;\n\n");
263 printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n");
264 printf("\tp = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n",
265 bits, bits);
266 printf("\tg = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n",
267 bits, bits);
268 printf("\tif (p == NULL || g == NULL)\n");
269 printf("\t\t{ BN_free(p); BN_free(q); DH_free(dh); return(NULL); }\n");
270 printf("\tDH_set0_pqg(dh, p, NULL, g);\n");
271 printf("\treturn(dh);\n\t}\n");
272 free(data);
273 }
274 if (!cfg.noout) { 224 if (!cfg.noout) {
275 if (cfg.outformat == FORMAT_ASN1) 225 if (cfg.outformat == FORMAT_ASN1)
276 i = i2d_DHparams_bio(out, dh); 226 i = i2d_DHparams_bio(out, dh);