summaryrefslogtreecommitdiff
path: root/moduli.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2012-07-06 13:44:19 +1000
committerDamien Miller <djm@mindrot.org>2012-07-06 13:44:19 +1000
commitdfceafe8b11a4a1f9890a37e0cd88b01eb9cc30c (patch)
treea017648b59e06bd4405c04b143780b5b10bbc6af /moduli.c
parent77eab7b0240683eea307332e1df3ff8920baf012 (diff)
- dtucker@cvs.openbsd.org 2012/07/06 00:41:59
[moduli.c ssh-keygen.1 ssh-keygen.c] Add options to specify starting line number and number of lines to process when screening moduli candidates. This allows processing of different parts of a candidate moduli file in parallel. man page help jmc@, ok djm@
Diffstat (limited to 'moduli.c')
-rw-r--r--moduli.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/moduli.c b/moduli.c
index 973ee6288..5267bb9ab 100644
--- a/moduli.c
+++ b/moduli.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: moduli.c,v 1.25 2011/10/19 00:06:10 djm Exp $ */ 1/* $OpenBSD: moduli.c,v 1.26 2012/07/06 00:41:59 dtucker 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>
@@ -140,7 +140,8 @@ static u_int32_t largebits, largememory; /* megabytes */
140static BIGNUM *largebase; 140static BIGNUM *largebase;
141 141
142int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *); 142int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *);
143int prime_test(FILE *, FILE *, u_int32_t, u_int32_t, char *); 143int prime_test(FILE *, FILE *, u_int32_t, u_int32_t, char *, unsigned long,
144 unsigned long);
144 145
145/* 146/*
146 * print moduli out in consistent form, 147 * print moduli out in consistent form,
@@ -495,14 +496,14 @@ read_checkpoint(char *cpfile)
495 */ 496 */
496int 497int
497prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted, 498prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted,
498 char *checkpoint_file) 499 char *checkpoint_file, unsigned long start_lineno, unsigned long num_lines)
499{ 500{
500 BIGNUM *q, *p, *a; 501 BIGNUM *q, *p, *a;
501 BN_CTX *ctx; 502 BN_CTX *ctx;
502 char *cp, *lp; 503 char *cp, *lp;
503 u_int32_t count_in = 0, count_out = 0, count_possible = 0; 504 u_int32_t count_in = 0, count_out = 0, count_possible = 0;
504 u_int32_t generator_known, in_tests, in_tries, in_type, in_size; 505 u_int32_t generator_known, in_tests, in_tries, in_type, in_size;
505 unsigned long last_processed = 0; 506 unsigned long last_processed = 0, end_lineno;
506 time_t time_start, time_stop; 507 time_t time_start, time_stop;
507 int res; 508 int res;
508 509
@@ -525,10 +526,17 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted,
525 526
526 if (checkpoint_file != NULL) 527 if (checkpoint_file != NULL)
527 last_processed = read_checkpoint(checkpoint_file); 528 last_processed = read_checkpoint(checkpoint_file);
529 if (start_lineno > last_processed)
530 last_processed = start_lineno;
531 if (num_lines == 0)
532 end_lineno = ULONG_MAX;
533 else
534 end_lineno = last_processed + num_lines;
535 debug2("process line %lu to line %lu", last_processed, end_lineno);
528 536
529 res = 0; 537 res = 0;
530 lp = xmalloc(QLINESIZE + 1); 538 lp = xmalloc(QLINESIZE + 1);
531 while (fgets(lp, QLINESIZE + 1, in) != NULL) { 539 while (fgets(lp, QLINESIZE + 1, in) != NULL && count_in < end_lineno) {
532 count_in++; 540 count_in++;
533 if (checkpoint_file != NULL) { 541 if (checkpoint_file != NULL) {
534 if (count_in <= last_processed) { 542 if (count_in <= last_processed) {