]> andersk Git - openssh.git/blobdiff - dh.c
- stevesk@cvs.openbsd.org 2002/12/04 04:36:47
[openssh.git] / dh.c
diff --git a/dh.c b/dh.c
index a5d6f379c6b132b2d0005be1df834998b9c4f38e..1be51953c6e2f02b545b21e12b0384e35d2352a0 100644 (file)
--- a/dh.c
+++ b/dh.c
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: dh.c,v 1.18 2001/12/27 18:22:16 markus Exp $");
+RCSID("$OpenBSD: dh.c,v 1.23 2002/11/21 22:22:50 markus Exp $");
 
 #include "xmalloc.h"
 
@@ -50,7 +50,7 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg)
        /* Ignore leading whitespace */
        if (*arg == '\0')
                arg = strdelim(&cp);
-       if (!*arg || *arg == '#')
+       if (!arg || !*arg || *arg == '#')
                return 0;
 
        /* time */
@@ -94,8 +94,8 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg)
        return (1);
 
  failclean:
-       BN_free(dhg->g);
-       BN_free(dhg->p);
+       BN_clear_free(dhg->g);
+       BN_clear_free(dhg->p);
  fail:
        error("Bad prime description in line %d", linenum);
        return (0);
@@ -122,8 +122,8 @@ choose_dh(int min, int wantbits, int max)
                linenum++;
                if (!parse_prime(linenum, line, &dhg))
                        continue;
-               BN_free(dhg.g);
-               BN_free(dhg.p);
+               BN_clear_free(dhg.g);
+               BN_clear_free(dhg.p);
 
                if (dhg.size > max || dhg.size < min)
                        continue;
@@ -152,8 +152,8 @@ choose_dh(int min, int wantbits, int max)
                if ((dhg.size > max || dhg.size < min) ||
                    dhg.size != best ||
                    linenum++ != which) {
-                       BN_free(dhg.g);
-                       BN_free(dhg.p);
+                       BN_clear_free(dhg.g);
+                       BN_clear_free(dhg.p);
                        continue;
                }
                break;
@@ -182,7 +182,7 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
        for (i = 0; i <= n; i++)
                if (BN_is_bit_set(dh_pub, i))
                        bits_set++;
-       debug("bits set: %d/%d", bits_set, BN_num_bits(dh->p));
+       debug2("bits set: %d/%d", bits_set, BN_num_bits(dh->p));
 
        /* 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))
@@ -203,7 +203,7 @@ dh_gen_key(DH *dh, int need)
                    BN_num_bits(dh->p), 2*need);
        do {
                if (dh->priv_key != NULL)
-                       BN_free(dh->priv_key);
+                       BN_clear_free(dh->priv_key);
                if ((dh->priv_key = BN_new()) == NULL)
                        fatal("dh_gen_key: BN_new failed");
                /* generate a 2*need bits random private exponent */
@@ -214,7 +214,7 @@ dh_gen_key(DH *dh, int need)
                for (i = 0; i <= BN_num_bits(dh->priv_key); i++)
                        if (BN_is_bit_set(dh->priv_key, i))
                                bits_set++;
-               debug("dh_gen_key: priv key bits set: %d/%d",
+               debug2("dh_gen_key: priv key bits set: %d/%d",
                    bits_set, BN_num_bits(dh->priv_key));
                if (tries++ > 10)
                        fatal("dh_gen_key: too many bad keys: giving up");
This page took 0.038503 seconds and 4 git commands to generate.