summaryrefslogtreecommitdiff
path: root/dh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-03-30 10:47:43 +1000
committerDamien Miller <djm@mindrot.org>2001-03-30 10:47:43 +1000
commit23e526e27199f3ae079ee302581221b49d3e6772 (patch)
tree87e24bd2f05cde74cba6db2765f4aa67921bc88d /dh.c
parent2557bfc5d712cd3422921253be60be2fbb88a4f7 (diff)
- OpenBSD CVS Sync
- provos@cvs.openbsd.org 2001/03/28 22:04:57 [dh.c] more sanity checking on primes file
Diffstat (limited to 'dh.c')
-rw-r--r--dh.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/dh.c b/dh.c
index 5f441ee1c..636758fa8 100644
--- a/dh.c
+++ b/dh.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: dh.c,v 1.9 2001/03/27 17:46:49 provos Exp $"); 26RCSID("$OpenBSD: dh.c,v 1.10 2001/03/28 22:04:57 provos Exp $");
27 27
28#include "xmalloc.h" 28#include "xmalloc.h"
29 29
@@ -79,18 +79,21 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg)
79 goto fail; 79 goto fail;
80 80
81 dhg->g = BN_new(); 81 dhg->g = BN_new();
82 if (BN_hex2bn(&dhg->g, gen) < 0) {
83 BN_free(dhg->g);
84 goto fail;
85 }
86 dhg->p = BN_new(); 82 dhg->p = BN_new();
87 if (BN_hex2bn(&dhg->p, prime) < 0) { 83 if (BN_hex2bn(&dhg->g, gen) < 0)
88 BN_free(dhg->g); 84 goto failclean;
89 BN_free(dhg->p); 85
90 goto fail; 86 if (BN_hex2bn(&dhg->p, prime) < 0)
91 } 87 goto failclean;
88
89 if (BN_num_bits(dhg->p) != dhg->size)
90 goto failclean;
92 91
93 return (1); 92 return (1);
93
94 failclean:
95 BN_free(dhg->g);
96 BN_free(dhg->p);
94 fail: 97 fail:
95 error("Bad prime description in line %d", linenum); 98 error("Bad prime description in line %d", linenum);
96 return (0); 99 return (0);