summaryrefslogtreecommitdiff
path: root/dh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2007-10-26 14:25:55 +1000
committerDamien Miller <djm@mindrot.org>2007-10-26 14:25:55 +1000
commit603077ab4c2446d19784e84590ae13c58f9d5032 (patch)
tree19939ad659c005f15244f3cd81178ff744bd5a4c /dh.c
parent4c7728c651254eb05a8c3ffbcc25632b7c80e722 (diff)
- ray@cvs.openbsd.org 2007/09/27 00:15:57
[dh.c] Don't return -1 on error in dh_pub_is_valid(), since it evaluates to true. Also fix a typo. Initial diff from Matthew Dempsky, input from djm. OK djm, markus.
Diffstat (limited to 'dh.c')
-rw-r--r--dh.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/dh.c b/dh.c
index 78e230b9f..66858104c 100644
--- a/dh.c
+++ b/dh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh.c,v 1.44 2006/11/07 13:02:07 markus Exp $ */ 1/* $OpenBSD: dh.c,v 1.45 2007/09/27 00:15:57 ray Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * 4 *
@@ -185,7 +185,7 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
185 BIGNUM *tmp; 185 BIGNUM *tmp;
186 186
187 if (dh_pub->neg) { 187 if (dh_pub->neg) {
188 logit("invalid public DH value: negativ"); 188 logit("invalid public DH value: negative");
189 return 0; 189 return 0;
190 } 190 }
191 if (BN_cmp(dh_pub, BN_value_one()) != 1) { /* pub_exp <= 1 */ 191 if (BN_cmp(dh_pub, BN_value_one()) != 1) { /* pub_exp <= 1 */
@@ -193,8 +193,10 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
193 return 0; 193 return 0;
194 } 194 }
195 195
196 if ((tmp = BN_new()) == NULL) 196 if ((tmp = BN_new()) == NULL) {
197 return (-1); 197 error("%s: BN_new failed", __func__);
198 return 0;
199 }
198 if (!BN_sub(tmp, dh->p, BN_value_one()) || 200 if (!BN_sub(tmp, dh->p, BN_value_one()) ||
199 BN_cmp(dh_pub, tmp) != -1) { /* pub_exp > p-2 */ 201 BN_cmp(dh_pub, tmp) != -1) { /* pub_exp > p-2 */
200 BN_clear_free(tmp); 202 BN_clear_free(tmp);