summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-01-14 09:21:54 +0000
committertb <>2022-01-14 09:21:54 +0000
commit756c62c5d110be4b1aa54ae70bc0935b5f6b4e07 (patch)
tree065ec6b83facad1e8b6009339f7a3ecdc6bf7cd6 /src
parentf52d2cee4715037e45c2b5537d5770ec104d2c04 (diff)
downloadopenbsd-756c62c5d110be4b1aa54ae70bc0935b5f6b4e07.tar.gz
openbsd-756c62c5d110be4b1aa54ae70bc0935b5f6b4e07.tar.bz2
openbsd-756c62c5d110be4b1aa54ae70bc0935b5f6b4e07.zip
Convert openssl(1) dh.c to opaque DH
ok inoguchi jsing
Diffstat (limited to 'src')
-rw-r--r--src/usr.bin/openssl/dh.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/usr.bin/openssl/dh.c b/src/usr.bin/openssl/dh.c
index 9557d15a3f..c2c5d689e1 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.12 2019/07/14 03:30:45 guenther Exp $ */ 1/* $OpenBSD: dh.c,v 1.13 2022/01/14 09:21:54 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 *
@@ -234,14 +234,14 @@ dh_main(int argc, char **argv)
234 unsigned char *data; 234 unsigned char *data;
235 int len, l, bits; 235 int len, l, bits;
236 236
237 len = BN_num_bytes(dh->p); 237 len = BN_num_bytes(DH_get0_p(dh));
238 bits = BN_num_bits(dh->p); 238 bits = BN_num_bits(DH_get0_p(dh));
239 data = malloc(len); 239 data = malloc(len);
240 if (data == NULL) { 240 if (data == NULL) {
241 perror("malloc"); 241 perror("malloc");
242 goto end; 242 goto end;
243 } 243 }
244 l = BN_bn2bin(dh->p, data); 244 l = BN_bn2bin(DH_get0_p(dh), data);
245 printf("static unsigned char dh%d_p[] = {", bits); 245 printf("static unsigned char dh%d_p[] = {", bits);
246 for (i = 0; i < l; i++) { 246 for (i = 0; i < l; i++) {
247 if ((i % 12) == 0) 247 if ((i % 12) == 0)
@@ -250,7 +250,7 @@ dh_main(int argc, char **argv)
250 } 250 }
251 printf("\n\t};\n"); 251 printf("\n\t};\n");
252 252
253 l = BN_bn2bin(dh->g, data); 253 l = BN_bn2bin(DH_get0_g(dh), data);
254 printf("static unsigned char dh%d_g[] = {", bits); 254 printf("static unsigned char dh%d_g[] = {", bits);
255 for (i = 0; i < l; i++) { 255 for (i = 0; i < l; i++) {
256 if ((i % 12) == 0) 256 if ((i % 12) == 0)
@@ -260,14 +260,16 @@ dh_main(int argc, char **argv)
260 printf("\n\t};\n\n"); 260 printf("\n\t};\n\n");
261 261
262 printf("DH *get_dh%d()\n\t{\n", bits); 262 printf("DH *get_dh%d()\n\t{\n", bits);
263 printf("\tDH *dh;\n\n"); 263 printf("\tDH *dh;\n");
264 printf("\tBIGNUM *p = NULL, *g = NULL;\n\n");
264 printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n"); 265 printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n");
265 printf("\tdh->p = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n", 266 printf("\tp = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n",
266 bits, bits); 267 bits, bits);
267 printf("\tdh->g = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n", 268 printf("\tg = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n",
268 bits, bits); 269 bits, bits);
269 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n"); 270 printf("\tif (p == NULL || g == NULL)\n");
270 printf("\t\treturn(NULL);\n"); 271 printf("\t\t{ BN_free(p); BN_free(q); DH_free(dh); return(NULL); }\n");
272 printf("\tDH_set0_pqg(dh, p, NULL, g);\n");
271 printf("\treturn(dh);\n\t}\n"); 273 printf("\treturn(dh);\n\t}\n");
272 free(data); 274 free(data);
273 } 275 }