version 1.2.2.4, 2001/05/07 21:09:29 |
version 1.2.2.5, 2001/09/27 00:15:42 |
|
|
#include "log.h" |
#include "log.h" |
#include "misc.h" |
#include "misc.h" |
|
|
int |
static int |
parse_prime(int linenum, char *line, struct dhgroup *dhg) |
parse_prime(int linenum, char *line, struct dhgroup *dhg) |
{ |
{ |
char *cp, *arg; |
char *cp, *arg; |
|
|
choose_dh(int min, int wantbits, int max) |
choose_dh(int min, int wantbits, int max) |
{ |
{ |
FILE *f; |
FILE *f; |
char line[1024]; |
char line[2048]; |
int best, bestcount, which; |
int best, bestcount, which; |
int linenum; |
int linenum; |
struct dhgroup dhg; |
struct dhgroup dhg; |
|
|
f = fopen(_PATH_DH_PRIMES, "r"); |
if ((f = fopen(_PATH_DH_MODULI, "r")) == NULL && |
if (!f) { |
(f = fopen(_PATH_DH_PRIMES, "r")) == NULL) { |
log("WARNING: %s does not exist, using old prime", _PATH_DH_PRIMES); |
log("WARNING: %s does not exist, using old modulus", _PATH_DH_MODULI); |
return (dh_new_group1()); |
return (dh_new_group1()); |
} |
} |
|
|
|
|
if (dhg.size == best) |
if (dhg.size == best) |
bestcount++; |
bestcount++; |
} |
} |
fclose (f); |
rewind(f); |
|
|
if (bestcount == 0) { |
if (bestcount == 0) { |
|
fclose(f); |
log("WARNING: no suitable primes in %s", _PATH_DH_PRIMES); |
log("WARNING: no suitable primes in %s", _PATH_DH_PRIMES); |
return (NULL); |
return (NULL); |
} |
|
|
|
f = fopen(_PATH_DH_PRIMES, "r"); |
|
if (!f) { |
|
fatal("WARNING: %s disappeared, giving up", _PATH_DH_PRIMES); |
|
} |
} |
|
|
linenum = 0; |
linenum = 0; |