diff options
author | Darren Tucker <dtucker@zip.com.au> | 2003-12-31 11:34:51 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2003-12-31 11:34:51 +1100 |
commit | 06930c70ad47744dd96955a6a1b75df7c5eebc3b (patch) | |
tree | bbf78cf7994924547edac1d02572d8044ccc1ed9 /moduli.c | |
parent | 3715be3cd3aab2bcf14a223c614f62c367730f67 (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@
Diffstat (limited to 'moduli.c')
-rw-r--r-- | moduli.c | 27 |
1 files changed, 18 insertions, 9 deletions
@@ -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); |