summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2003-12-31 11:34:51 +1100
committerDarren Tucker <dtucker@zip.com.au>2003-12-31 11:34:51 +1100
commit06930c70ad47744dd96955a6a1b75df7c5eebc3b (patch)
treebbf78cf7994924547edac1d02572d8044ccc1ed9
parent3715be3cd3aab2bcf14a223c614f62c367730f67 (diff)
- djm@cvs.openbsd.org 2003/12/22 09:16:58
[moduli.c ssh-keygen.1 ssh-keygen.c] tidy up moduli generation debugging, add -v (verbose/debug) option to ssh-keygen; ok markus@
-rw-r--r--ChangeLog9
-rw-r--r--moduli.c27
-rw-r--r--ssh-keygen.114
-rw-r--r--ssh-keygen.c18
4 files changed, 55 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 0cd1a31c9..62095746d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
120031231
2 - (dtucker) OpenBSD CVS Sync
3 - djm@cvs.openbsd.org 2003/12/22 09:16:58
4 [moduli.c ssh-keygen.1 ssh-keygen.c]
5 tidy up moduli generation debugging, add -v (verbose/debug) option to
6 ssh-keygen; ok markus@
7
120031219 820031219
2 - (dtucker) [defines.h] Bug #458: Define SIZE_T_MAX as UINT_MAX if we 9 - (dtucker) [defines.h] Bug #458: Define SIZE_T_MAX as UINT_MAX if we
3 typedef size_t ourselves. 10 typedef size_t ourselves.
@@ -1616,4 +1623,4 @@
1616 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. 1623 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
1617 Report from murple@murple.net, diagnosis from dtucker@zip.com.au 1624 Report from murple@murple.net, diagnosis from dtucker@zip.com.au
1618 1625
1619$Id: ChangeLog,v 1.3152 2003/12/18 23:58:43 dtucker Exp $ 1626$Id: ChangeLog,v 1.3153 2003/12/31 00:34:51 dtucker Exp $
diff --git a/moduli.c b/moduli.c
index 371319d0f..a09073aed 100644
--- a/moduli.c
+++ b/moduli.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: moduli.c,v 1.4 2003/12/09 13:52:55 dtucker Exp $ */ 1/* $OpenBSD: moduli.c,v 1.5 2003/12/22 09:16:57 djm Exp $ */
2/* 2/*
3 * Copyright 1994 Phil Karn <karn@qualcomm.com> 3 * Copyright 1994 Phil Karn <karn@qualcomm.com>
4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com> 4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com>
@@ -72,9 +72,10 @@
72#define QTEST_JACOBI (0x08) 72#define QTEST_JACOBI (0x08)
73#define QTEST_ELLIPTIC (0x10) 73#define QTEST_ELLIPTIC (0x10)
74 74
75/* Size: decimal. 75/*
76 * Size: decimal.
76 * Specifies the number of the most significant bit (0 to M). 77 * Specifies the number of the most significant bit (0 to M).
77 ** WARNING: internally, usually 1 to N. 78 * WARNING: internally, usually 1 to N.
78 */ 79 */
79#define QSIZE_MINIMUM (511) 80#define QSIZE_MINIMUM (511)
80 81
@@ -169,7 +170,7 @@ sieve_large(u_int32_t s)
169{ 170{
170 u_int32_t r, u; 171 u_int32_t r, u;
171 172
172 debug2("sieve_large %u", s); 173 debug3("sieve_large %u", s);
173 largetries++; 174 largetries++;
174 /* r = largebase mod s */ 175 /* r = largebase mod s */
175 r = BN_mod_word(largebase, s); 176 r = BN_mod_word(largebase, s);
@@ -474,6 +475,7 @@ prime_test(FILE *in, FILE *out, u_int32_t trials,
474 debug2("%10u: known composite", count_in); 475 debug2("%10u: known composite", count_in);
475 continue; 476 continue;
476 } 477 }
478
477 /* tries */ 479 /* tries */
478 in_tries = strtoul(cp, &cp, 10); 480 in_tries = strtoul(cp, &cp, 10);
479 481
@@ -498,13 +500,20 @@ prime_test(FILE *in, FILE *out, u_int32_t trials,
498 in_size += 1; 500 in_size += 1;
499 generator_known = 0; 501 generator_known = 0;
500 break; 502 break;
501 default: 503 case QTYPE_UNSTRUCTURED:
504 case QTYPE_SAFE:
505 case QTYPE_SCHNOOR:
506 case QTYPE_STRONG:
507 case QTYPE_UNKNOWN:
502 debug2("%10u: (%u)", count_in, in_type); 508 debug2("%10u: (%u)", count_in, in_type);
503 a = p; 509 a = p;
504 BN_hex2bn(&a, cp); 510 BN_hex2bn(&a, cp);
505 /* q = (p-1) / 2 */ 511 /* q = (p-1) / 2 */
506 BN_rshift(q, p, 1); 512 BN_rshift(q, p, 1);
507 break; 513 break;
514 default:
515 debug2("Unknown prime type");
516 break;
508 } 517 }
509 518
510 /* 519 /*
@@ -524,6 +533,7 @@ prime_test(FILE *in, FILE *out, u_int32_t trials,
524 in_tries += trials; 533 in_tries += trials;
525 else 534 else
526 in_tries = trials; 535 in_tries = trials;
536
527 /* 537 /*
528 * guess unknown generator 538 * guess unknown generator
529 */ 539 */
@@ -535,9 +545,8 @@ prime_test(FILE *in, FILE *out, u_int32_t trials,
535 else { 545 else {
536 u_int32_t r = BN_mod_word(p, 10); 546 u_int32_t r = BN_mod_word(p, 10);
537 547
538 if (r == 3 || r == 7) { 548 if (r == 3 || r == 7)
539 generator_known = 5; 549 generator_known = 5;
540 }
541 } 550 }
542 } 551 }
543 /* 552 /*
@@ -569,7 +578,7 @@ prime_test(FILE *in, FILE *out, u_int32_t trials,
569 * vast majority of composite q's. 578 * vast majority of composite q's.
570 */ 579 */
571 if (BN_is_prime(q, 1, NULL, ctx, NULL) <= 0) { 580 if (BN_is_prime(q, 1, NULL, ctx, NULL) <= 0) {
572 debug2("%10u: q failed first possible prime test", 581 debug("%10u: q failed first possible prime test",
573 count_in); 582 count_in);
574 continue; 583 continue;
575 } 584 }
@@ -582,7 +591,7 @@ prime_test(FILE *in, FILE *out, u_int32_t trials,
582 * doesn't hurt to specify a high iteration count. 591 * doesn't hurt to specify a high iteration count.
583 */ 592 */
584 if (!BN_is_prime(p, trials, NULL, ctx, NULL)) { 593 if (!BN_is_prime(p, trials, NULL, ctx, NULL)) {
585 debug2("%10u: p is not prime", count_in); 594 debug("%10u: p is not prime", count_in);
586 continue; 595 continue;
587 } 596 }
588 debug("%10u: p is almost certainly prime", count_in); 597 debug("%10u: p is almost certainly prime", count_in);
diff --git a/ssh-keygen.1 b/ssh-keygen.1
index dc4bcacd0..6dd615428 100644
--- a/ssh-keygen.1
+++ b/ssh-keygen.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-keygen.1,v 1.60 2003/07/28 09:49:56 djm Exp $ 1.\" $OpenBSD: ssh-keygen.1,v 1.61 2003/12/22 09:16:58 djm Exp $
2.\" 2.\"
3.\" -*- nroff -*- 3.\" -*- nroff -*-
4.\" 4.\"
@@ -89,12 +89,14 @@
89.Op Fl g 89.Op Fl g
90.Nm ssh-keygen 90.Nm ssh-keygen
91.Fl G Ar output_file 91.Fl G Ar output_file
92.Op Fl v
92.Op Fl b Ar bits 93.Op Fl b Ar bits
93.Op Fl M Ar memory 94.Op Fl M Ar memory
94.Op Fl S Ar start_point 95.Op Fl S Ar start_point
95.Nm ssh-keygen 96.Nm ssh-keygen
96.Fl T Ar output_file 97.Fl T Ar output_file
97.Fl f Ar input_file 98.Fl f Ar input_file
99.Op Fl v
98.Op Fl a Ar num_trials 100.Op Fl a Ar num_trials
99.Op Fl W Ar generator 101.Op Fl W Ar generator
100.Sh DESCRIPTION 102.Sh DESCRIPTION
@@ -263,6 +265,16 @@ Specify desired generator when testing candidate moduli for DH-GEX.
263.It Fl U Ar reader 265.It Fl U Ar reader
264Upload an existing RSA private key into the smartcard in 266Upload an existing RSA private key into the smartcard in
265.Ar reader . 267.Ar reader .
268.It Fl v
269Verbose mode.
270Causes
271.Nm
272to print debugging messages about its progress.
273This is helpful for debugging moduli generation.
274Multiple
275.Fl v
276options increase the verbosity.
277The maximum is 3.
266.It Fl r Ar hostname 278.It Fl r Ar hostname
267Print DNS resource record with the specified 279Print DNS resource record with the specified
268.Ar hostname . 280.Ar hostname .
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 961fd43e5..1156a010a 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: ssh-keygen.c,v 1.112 2003/11/23 23:18:45 djm Exp $"); 15RCSID("$OpenBSD: ssh-keygen.c,v 1.113 2003/12/22 09:16:58 djm Exp $");
16 16
17#include <openssl/evp.h> 17#include <openssl/evp.h>
18#include <openssl/pem.h> 18#include <openssl/pem.h>
@@ -797,6 +797,7 @@ main(int ac, char **av)
797 int opt, type, fd, download = 0, memory = 0; 797 int opt, type, fd, download = 0, memory = 0;
798 int generator_wanted = 0, trials = 100; 798 int generator_wanted = 0, trials = 100;
799 int do_gen_candidates = 0, do_screen_candidates = 0; 799 int do_gen_candidates = 0, do_screen_candidates = 0;
800 int log_level = SYSLOG_LEVEL_INFO;
800 BIGNUM *start = NULL; 801 BIGNUM *start = NULL;
801 FILE *f; 802 FILE *f;
802 803
@@ -823,7 +824,7 @@ main(int ac, char **av)
823 } 824 }
824 825
825 while ((opt = getopt(ac, av, 826 while ((opt = getopt(ac, av,
826 "degiqpclBRxXyb:f:t:U:D:P:N:C:r:g:T:G:M:S:a:W:")) != -1) { 827 "degiqpclBRvxXyb:f:t:U:D:P:N:C:r:g:T:G:M:S:a:W:")) != -1) {
827 switch (opt) { 828 switch (opt) {
828 case 'b': 829 case 'b':
829 bits = atoi(optarg); 830 bits = atoi(optarg);
@@ -891,6 +892,15 @@ main(int ac, char **av)
891 case 'U': 892 case 'U':
892 reader_id = optarg; 893 reader_id = optarg;
893 break; 894 break;
895 case 'v':
896 if (log_level == SYSLOG_LEVEL_INFO)
897 log_level = SYSLOG_LEVEL_DEBUG1;
898 else {
899 if (log_level >= SYSLOG_LEVEL_DEBUG1 &&
900 log_level < SYSLOG_LEVEL_DEBUG3)
901 log_level++;
902 }
903 break;
894 case 'r': 904 case 'r':
895 resource_record_hostname = optarg; 905 resource_record_hostname = optarg;
896 break; 906 break;
@@ -932,6 +942,10 @@ main(int ac, char **av)
932 usage(); 942 usage();
933 } 943 }
934 } 944 }
945
946 /* reinit */
947 log_init(av[0], log_level, SYSLOG_FACILITY_USER, 1);
948
935 if (optind < ac) { 949 if (optind < ac) {
936 printf("Too many arguments.\n"); 950 printf("Too many arguments.\n");
937 usage(); 951 usage();