diff options
Diffstat (limited to 'dh.c')
-rw-r--r-- | dh.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: dh.c,v 1.9 2001/03/27 17:46:49 provos Exp $"); | 26 | RCSID("$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); |