diff options
author | tb <> | 2022-01-14 09:22:50 +0000 |
---|---|---|
committer | tb <> | 2022-01-14 09:22:50 +0000 |
commit | fbdb94d83accecb345785ef71d006a0da53102bc (patch) | |
tree | d066999a60d5beade1d7668ef5d1fcea62dc1037 /src | |
parent | 756c62c5d110be4b1aa54ae70bc0935b5f6b4e07 (diff) | |
download | openbsd-fbdb94d83accecb345785ef71d006a0da53102bc.tar.gz openbsd-fbdb94d83accecb345785ef71d006a0da53102bc.tar.bz2 openbsd-fbdb94d83accecb345785ef71d006a0da53102bc.zip |
Convert openssl(1) dhparam to opaque DH
ok inoguchi jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/dhparam.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/usr.bin/openssl/dhparam.c b/src/usr.bin/openssl/dhparam.c index 55263274b6..da9075f5be 100644 --- a/src/usr.bin/openssl/dhparam.c +++ b/src/usr.bin/openssl/dhparam.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dhparam.c,v 1.13 2021/11/20 18:10:48 tb Exp $ */ | 1 | /* $OpenBSD: dhparam.c,v 1.14 2022/01/14 09:22:50 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 | * |
@@ -411,8 +411,8 @@ dhparam_main(int argc, char **argv) | |||
411 | unsigned char *data; | 411 | unsigned char *data; |
412 | int len, l, bits; | 412 | int len, l, bits; |
413 | 413 | ||
414 | len = BN_num_bytes(dh->p); | 414 | len = BN_num_bytes(DH_get0_p(dh)); |
415 | bits = BN_num_bits(dh->p); | 415 | bits = BN_num_bits(DH_get0_p(dh)); |
416 | data = malloc(len); | 416 | data = malloc(len); |
417 | if (data == NULL) { | 417 | if (data == NULL) { |
418 | perror("malloc"); | 418 | perror("malloc"); |
@@ -423,7 +423,7 @@ dhparam_main(int argc, char **argv) | |||
423 | "#endif\n"); | 423 | "#endif\n"); |
424 | printf("DH *get_dh%d()\n\t{\n", bits); | 424 | printf("DH *get_dh%d()\n\t{\n", bits); |
425 | 425 | ||
426 | l = BN_bn2bin(dh->p, data); | 426 | l = BN_bn2bin(DH_get0_p(dh), data); |
427 | printf("\tstatic unsigned char dh%d_p[] = {", bits); | 427 | printf("\tstatic unsigned char dh%d_p[] = {", bits); |
428 | for (i = 0; i < l; i++) { | 428 | for (i = 0; i < l; i++) { |
429 | if ((i % 12) == 0) | 429 | if ((i % 12) == 0) |
@@ -432,7 +432,7 @@ dhparam_main(int argc, char **argv) | |||
432 | } | 432 | } |
433 | printf("\n\t\t};\n"); | 433 | printf("\n\t\t};\n"); |
434 | 434 | ||
435 | l = BN_bn2bin(dh->g, data); | 435 | l = BN_bn2bin(DH_get0_g(dh), data); |
436 | printf("\tstatic unsigned char dh%d_g[] = {", bits); | 436 | printf("\tstatic unsigned char dh%d_g[] = {", bits); |
437 | for (i = 0; i < l; i++) { | 437 | for (i = 0; i < l; i++) { |
438 | if ((i % 12) == 0) | 438 | if ((i % 12) == 0) |
@@ -441,16 +441,18 @@ dhparam_main(int argc, char **argv) | |||
441 | } | 441 | } |
442 | printf("\n\t\t};\n"); | 442 | printf("\n\t\t};\n"); |
443 | 443 | ||
444 | printf("\tDH *dh;\n\n"); | 444 | printf("\tDH *dh;\n"); |
445 | printf("\tBIGNUM *p = NULL, *g = NULL;\n\n"); | ||
445 | printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n"); | 446 | printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n"); |
446 | printf("\tdh->p = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n", | 447 | printf("\tp = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n", |
447 | bits, bits); | 448 | bits, bits); |
448 | printf("\tdh->g = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n", | 449 | printf("\tg = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n", |
449 | bits, bits); | 450 | bits, bits); |
450 | printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n"); | 451 | printf("\tif (p == NULL || g == NULL)\n"); |
451 | printf("\t\t{ DH_free(dh); return(NULL); }\n"); | 452 | printf("\t\t{ BN_free(p); BN_free(g); DH_free(dh); return(NULL); }\n"); |
452 | if (dh->length) | 453 | printf("\tDH_set0_pqg(dh, p, NULL, g);\n"); |
453 | printf("\tdh->length = %ld;\n", dh->length); | 454 | if (DH_get_length(dh) > 0) |
455 | printf("\tDH_set_length(dh, %ld);\n", DH_get_length(dh)); | ||
454 | printf("\treturn(dh);\n\t}\n"); | 456 | printf("\treturn(dh);\n\t}\n"); |
455 | free(data); | 457 | free(data); |
456 | } | 458 | } |