]> andersk Git - openssh.git/blobdiff - dh.c
[configure.ac] Make sure -lcrypto is before -lsocket for sco3. ok mouring@
[openssh.git] / dh.c
diff --git a/dh.c b/dh.c
index 1be51953c6e2f02b545b21e12b0384e35d2352a0..c7a3e18be82afb4bebe659ce1c9e1a8e16aa1a51 100644 (file)
--- a/dh.c
+++ b/dh.c
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: dh.c,v 1.23 2002/11/21 22:22:50 markus Exp $");
+RCSID("$OpenBSD: dh.c,v 1.26 2003/12/16 15:51:54 markus Exp $");
 
 #include "xmalloc.h"
 
@@ -112,7 +112,7 @@ choose_dh(int min, int wantbits, int max)
 
        if ((f = fopen(_PATH_DH_MODULI, "r")) == NULL &&
            (f = fopen(_PATH_DH_PRIMES, "r")) == NULL) {
-               log("WARNING: %s does not exist, using old modulus", _PATH_DH_MODULI);
+               logit("WARNING: %s does not exist, using old modulus", _PATH_DH_MODULI);
                return (dh_new_group1());
        }
 
@@ -140,7 +140,7 @@ choose_dh(int min, int wantbits, int max)
 
        if (bestcount == 0) {
                fclose(f);
-               log("WARNING: no suitable primes in %s", _PATH_DH_PRIMES);
+               logit("WARNING: no suitable primes in %s", _PATH_DH_PRIMES);
                return (NULL);
        }
 
@@ -176,7 +176,7 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
        int bits_set = 0;
 
        if (dh_pub->neg) {
-               log("invalid public DH value: negativ");
+               logit("invalid public DH value: negativ");
                return 0;
        }
        for (i = 0; i <= n; i++)
@@ -187,7 +187,7 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
        /* if g==2 and bits_set==1 then computing log_g(dh_pub) is trivial */
        if (bits_set > 1 && (BN_cmp(dh_pub, dh->p) == -1))
                return 1;
-       log("invalid public DH value (%d/%d)", bits_set, BN_num_bits(dh->p));
+       logit("invalid public DH value (%d/%d)", bits_set, BN_num_bits(dh->p));
        return 0;
 }
 
@@ -198,7 +198,7 @@ dh_gen_key(DH *dh, int need)
 
        if (dh->p == NULL)
                fatal("dh_gen_key: dh->p == NULL");
-       if (2*need >= BN_num_bits(dh->p))
+       if (need > INT_MAX / 2 || 2 * need >= BN_num_bits(dh->p))
                fatal("dh_gen_key: group too small: %d (2*need %d)",
                    BN_num_bits(dh->p), 2*need);
        do {
@@ -279,11 +279,9 @@ int
 dh_estimate(int bits)
 {
 
-       if (bits < 64)
-               return (512);   /* O(2**63) */
-       if (bits < 128)
+       if (bits <= 128)
                return (1024);  /* O(2**86) */
-       if (bits < 192)
+       if (bits <= 192)
                return (2048);  /* O(2**116) */
        return (4096);          /* O(2**156) */
 }
This page took 0.037728 seconds and 4 git commands to generate.