]> andersk Git - openssh.git/blobdiff - dh.c
- ian@cvs.openbsd.org 2008/06/12 23:24:58
[openssh.git] / dh.c
diff --git a/dh.c b/dh.c
index ff31ca9918cafb17ec3174e189b15dd29d7f8e0c..0908fcf113798fdb61cc570ff80c90c430158e49 100644 (file)
--- a/dh.c
+++ b/dh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh.c,v 1.37 2006/07/18 22:27:55 stevesk 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 <sys/param.h>
+
 #include <openssl/bn.h>
 #include <openssl/dh.h>
 
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include "dh.h"
 #include "pathnames.h"
 #include "log.h"
@@ -146,7 +153,7 @@ choose_dh(int min, int wantbits, int max)
        }
 
        linenum = 0;
-       which = arc4random() % bestcount;
+       which = arc4random_uniform(bestcount);
        while (fgets(line, sizeof(line), f)) {
                if (!parse_prime(linenum, line, &dhg))
                        continue;
@@ -178,7 +185,7 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
        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 */
@@ -186,8 +193,10 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
                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);
This page took 0.033477 seconds and 4 git commands to generate.