-/* $OpenBSD: dh.c,v 1.67 2018/09/13 02:08:33 djm Exp $ */
+/* $OpenBSD: dh.c,v 1.68 2018/09/17 15:40:14 millert Exp $ */
/*
* Copyright (c) 2000 Niels Provos. All rights reserved.
*
logit("WARNING: no suitable primes in %s", _PATH_DH_MODULI);
return (dh_new_group_fallback(max));
}
+ which = arc4random_uniform(bestcount);
linenum = 0;
- which = arc4random_uniform(bestcount);
+ bestcount = 0;
while (getline(&line, &linesize, f) != -1) {
+ linenum++;
if (!parse_prime(linenum, line, &dhg))
continue;
if ((dhg.size > max || dhg.size < min) ||
dhg.size != best ||
- linenum++ != which) {
+ bestcount++ != which) {
BN_clear_free(dhg.g);
BN_clear_free(dhg.p);
continue;
free(line);
line = NULL;
fclose(f);
- if (linenum != which+1) {
- logit("WARNING: line %d disappeared in %s, giving up",
- which, _PATH_DH_MODULI);
+ if (bestcount != which + 1) {
+ logit("WARNING: selected prime disappeared in %s, giving up",
+ _PATH_DH_MODULI);
return (dh_new_group_fallback(max));
}