-/* $OpenBSD: dh.c,v 1.36 2006/05/04 14:55:23 djm Exp $ */
+/* $OpenBSD: dh.c,v 1.46 2008/04/13 00:22:17 djm Exp $ */
/*
* Copyright (c) 2000 Niels Provos. All rights reserved.
*
#include "includes.h"
-#include "xmalloc.h"
+#include <sys/param.h>
#include <openssl/bn.h>
#include <openssl/dh.h>
-#include <openssl/evp.h>
-#include "buffer.h"
-#include "cipher.h"
-#include "kex.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "dh.h"
#include "pathnames.h"
#include "log.h"
}
linenum = 0;
- which = arc4random() % bestcount;
+ which = arc4random_uniform(bestcount);
while (fgets(line, sizeof(line), f)) {
if (!parse_prime(linenum, line, &dhg))
continue;
BIGNUM *tmp;
if (dh_pub->neg) {
- logit("invalid public DH value: negativ");
+ logit("invalid public DH value: negative");
return 0;
}
if (BN_cmp(dh_pub, BN_value_one()) != 1) { /* pub_exp <= 1 */
return 0;
}
- if ((tmp = BN_new()) == NULL)
- return (-1);
+ if ((tmp = BN_new()) == NULL) {
+ error("%s: BN_new failed", __func__);
+ return 0;
+ }
if (!BN_sub(tmp, dh->p, BN_value_one()) ||
BN_cmp(dh_pub, tmp) != -1) { /* pub_exp > p-2 */
BN_clear_free(tmp);