diff options
author | tb <> | 2022-01-14 09:24:20 +0000 |
---|---|---|
committer | tb <> | 2022-01-14 09:24:20 +0000 |
commit | 710e9c74891f8fd58bb7ab1adee63fdd98e7f90a (patch) | |
tree | a0af04ebae30338bb80c20a50f5df79586b3ee40 /src | |
parent | 5f55a5a94d9b6b8a4e230bc45980216aab9139f8 (diff) | |
download | openbsd-710e9c74891f8fd58bb7ab1adee63fdd98e7f90a.tar.gz openbsd-710e9c74891f8fd58bb7ab1adee63fdd98e7f90a.tar.bz2 openbsd-710e9c74891f8fd58bb7ab1adee63fdd98e7f90a.zip |
Convert openssl(1) dsaparam to opaque dsa
ok inoguchi jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/dsaparam.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/usr.bin/openssl/dsaparam.c b/src/usr.bin/openssl/dsaparam.c index 3a907fe620..33bde035aa 100644 --- a/src/usr.bin/openssl/dsaparam.c +++ b/src/usr.bin/openssl/dsaparam.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsaparam.c,v 1.12 2021/11/20 18:10:48 tb Exp $ */ | 1 | /* $OpenBSD: dsaparam.c,v 1.13 2022/01/14 09:24:20 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 | * |
@@ -259,14 +259,14 @@ dsaparam_main(int argc, char **argv) | |||
259 | unsigned char *data; | 259 | unsigned char *data; |
260 | int l, len, bits_p; | 260 | int l, len, bits_p; |
261 | 261 | ||
262 | len = BN_num_bytes(dsa->p); | 262 | len = BN_num_bytes(DSA_get0_p(dsa)); |
263 | bits_p = BN_num_bits(dsa->p); | 263 | bits_p = BN_num_bits(DSA_get0_p(dsa)); |
264 | data = malloc(len + 20); | 264 | data = malloc(len + 20); |
265 | if (data == NULL) { | 265 | if (data == NULL) { |
266 | perror("malloc"); | 266 | perror("malloc"); |
267 | goto end; | 267 | goto end; |
268 | } | 268 | } |
269 | l = BN_bn2bin(dsa->p, data); | 269 | l = BN_bn2bin(DSA_get0_p(dsa), data); |
270 | printf("static unsigned char dsa%d_p[] = {", bits_p); | 270 | printf("static unsigned char dsa%d_p[] = {", bits_p); |
271 | for (i = 0; i < l; i++) { | 271 | for (i = 0; i < l; i++) { |
272 | if ((i % 12) == 0) | 272 | if ((i % 12) == 0) |
@@ -275,7 +275,7 @@ dsaparam_main(int argc, char **argv) | |||
275 | } | 275 | } |
276 | printf("\n\t};\n"); | 276 | printf("\n\t};\n"); |
277 | 277 | ||
278 | l = BN_bn2bin(dsa->q, data); | 278 | l = BN_bn2bin(DSA_get0_q(dsa), data); |
279 | printf("static unsigned char dsa%d_q[] = {", bits_p); | 279 | printf("static unsigned char dsa%d_q[] = {", bits_p); |
280 | for (i = 0; i < l; i++) { | 280 | for (i = 0; i < l; i++) { |
281 | if ((i % 12) == 0) | 281 | if ((i % 12) == 0) |
@@ -284,7 +284,7 @@ dsaparam_main(int argc, char **argv) | |||
284 | } | 284 | } |
285 | printf("\n\t};\n"); | 285 | printf("\n\t};\n"); |
286 | 286 | ||
287 | l = BN_bn2bin(dsa->g, data); | 287 | l = BN_bn2bin(DSA_get0_g(dsa), data); |
288 | printf("static unsigned char dsa%d_g[] = {", bits_p); | 288 | printf("static unsigned char dsa%d_g[] = {", bits_p); |
289 | for (i = 0; i < l; i++) { | 289 | for (i = 0; i < l; i++) { |
290 | if ((i % 12) == 0) | 290 | if ((i % 12) == 0) |
@@ -295,16 +295,18 @@ dsaparam_main(int argc, char **argv) | |||
295 | printf("\n\t};\n\n"); | 295 | printf("\n\t};\n\n"); |
296 | 296 | ||
297 | printf("DSA *get_dsa%d()\n\t{\n", bits_p); | 297 | printf("DSA *get_dsa%d()\n\t{\n", bits_p); |
298 | printf("\tBIGNUM *p = NULL, *q = NULL, *g = NULL;\n"); | ||
298 | printf("\tDSA *dsa;\n\n"); | 299 | printf("\tDSA *dsa;\n\n"); |
299 | printf("\tif ((dsa = DSA_new()) == NULL) return(NULL);\n"); | 300 | printf("\tif ((dsa = DSA_new()) == NULL) return(NULL);\n"); |
300 | printf("\tdsa->p = BN_bin2bn(dsa%d_p, sizeof(dsa%d_p), NULL);\n", | 301 | printf("\tp = BN_bin2bn(dsa%d_p, sizeof(dsa%d_p), NULL);\n", |
301 | bits_p, bits_p); | 302 | bits_p, bits_p); |
302 | printf("\tdsa->q = BN_bin2bn(dsa%d_q, sizeof(dsa%d_q), NULL);\n", | 303 | printf("\tq = BN_bin2bn(dsa%d_q, sizeof(dsa%d_q), NULL);\n", |
303 | bits_p, bits_p); | 304 | bits_p, bits_p); |
304 | printf("\tdsa->g = BN_bin2bn(dsa%d_g, sizeof(dsa%d_g), NULL);\n", | 305 | printf("\tg = BN_bin2bn(dsa%d_g, sizeof(dsa%d_g), NULL);\n", |
305 | bits_p, bits_p); | 306 | bits_p, bits_p); |
306 | printf("\tif ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))\n"); | 307 | printf("\tif (p == NULL || q == NULL || g == NULL)\n"); |
307 | printf("\t\t{ DSA_free(dsa); return(NULL); }\n"); | 308 | printf("\t\t{ BN_free(p); BN_free(q); BN_free(g); DSA_free(dsa); return(NULL); }\n"); |
309 | printf("\tDSA_set0_pqg(dsa, p, q, g);\n"); | ||
308 | printf("\treturn(dsa);\n\t}\n"); | 310 | printf("\treturn(dsa);\n\t}\n"); |
309 | } | 311 | } |
310 | if (!dsaparam_config.noout) { | 312 | if (!dsaparam_config.noout) { |