X-Git-Url: http://andersk.mit.edu/gitweb/gssapi-openssh.git/blobdiff_plain/e9a17296ccbb7bb4f9a0affffe58d2240768a7d4..HEAD:/openssh/dh.c diff --git a/openssh/dh.c b/openssh/dh.c index 33187e0..fa2508a 100644 --- a/openssh/dh.c +++ b/openssh/dh.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: dh.c,v 1.21 2002/03/06 00:23:27 markus Exp $"); +RCSID("$OpenBSD: dh.c,v 1.17 2001/06/23 15:12:18 itojun Exp $"); #include "xmalloc.h" @@ -78,10 +78,8 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg) if (cp != NULL || *prime == '\0') goto fail; - if ((dhg->g = BN_new()) == NULL) - fatal("parse_prime: BN_new failed"); - if ((dhg->p = BN_new()) == NULL) - fatal("parse_prime: BN_new failed"); + dhg->g = BN_new(); + dhg->p = BN_new(); if (BN_hex2bn(&dhg->g, gen) == 0) goto failclean; @@ -94,8 +92,8 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg) return (1); failclean: - BN_clear_free(dhg->g); - BN_clear_free(dhg->p); + BN_free(dhg->g); + BN_free(dhg->p); fail: error("Bad prime description in line %d", linenum); return (0); @@ -122,8 +120,8 @@ choose_dh(int min, int wantbits, int max) linenum++; if (!parse_prime(linenum, line, &dhg)) continue; - BN_clear_free(dhg.g); - BN_clear_free(dhg.p); + BN_free(dhg.g); + BN_free(dhg.p); if (dhg.size > max || dhg.size < min) continue; @@ -152,8 +150,8 @@ choose_dh(int min, int wantbits, int max) if ((dhg.size > max || dhg.size < min) || dhg.size != best || linenum++ != which) { - BN_clear_free(dhg.g); - BN_clear_free(dhg.p); + BN_free(dhg.g); + BN_free(dhg.p); continue; } break; @@ -203,8 +201,9 @@ dh_gen_key(DH *dh, int need) BN_num_bits(dh->p), 2*need); do { if (dh->priv_key != NULL) - BN_clear_free(dh->priv_key); - if ((dh->priv_key = BN_new()) == NULL) + BN_free(dh->priv_key); + dh->priv_key = BN_new(); + if (dh->priv_key == NULL) fatal("dh_gen_key: BN_new failed"); /* generate a 2*need bits random private exponent */ if (!BN_rand(dh->priv_key, 2*need, 0, 0)) @@ -226,8 +225,9 @@ dh_new_group_asc(const char *gen, const char *modulus) { DH *dh; - if ((dh = DH_new()) == NULL) - fatal("dh_new_group_asc: DH_new"); + dh = DH_new(); + if (dh == NULL) + fatal("DH_new"); if (BN_hex2bn(&dh->p, modulus) == 0) fatal("BN_hex2bn p"); @@ -247,8 +247,9 @@ dh_new_group(BIGNUM *gen, BIGNUM *modulus) { DH *dh; - if ((dh = DH_new()) == NULL) - fatal("dh_new_group: DH_new"); + dh = DH_new(); + if (dh == NULL) + fatal("DH_new"); dh->p = modulus; dh->g = gen;