summaryrefslogtreecommitdiff
path: root/dh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-01-22 23:09:22 +1100
committerDamien Miller <djm@mindrot.org>2002-01-22 23:09:22 +1100
commitda7551677b301c6fd063eb162c7d32b37723a360 (patch)
treeee731b658802d003930540958f0b7ffc5a4a12bf /dh.c
parent154dda73a858a5924c2f5684dfec3e377cc3ab5d (diff)
- markus@cvs.openbsd.org 2001/12/27 18:22:16
[auth1.c authfile.c auth-rsa.c dh.c kexdh.c kexgex.c key.c rsa.c scard.c ssh-agent.c sshconnect1.c sshd.c ssh-dss.c] call fatal() for openssl allocation failures
Diffstat (limited to 'dh.c')
-rw-r--r--dh.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/dh.c b/dh.c
index fa2508af7..a5d6f379c 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.17 2001/06/23 15:12:18 itojun Exp $"); 26RCSID("$OpenBSD: dh.c,v 1.18 2001/12/27 18:22:16 markus Exp $");
27 27
28#include "xmalloc.h" 28#include "xmalloc.h"
29 29
@@ -78,8 +78,10 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg)
78 if (cp != NULL || *prime == '\0') 78 if (cp != NULL || *prime == '\0')
79 goto fail; 79 goto fail;
80 80
81 dhg->g = BN_new(); 81 if ((dhg->g = BN_new()) == NULL)
82 dhg->p = BN_new(); 82 fatal("parse_prime: BN_new failed");
83 if ((dhg->p = BN_new()) == NULL)
84 fatal("parse_prime: BN_new failed");
83 if (BN_hex2bn(&dhg->g, gen) == 0) 85 if (BN_hex2bn(&dhg->g, gen) == 0)
84 goto failclean; 86 goto failclean;
85 87
@@ -202,8 +204,7 @@ dh_gen_key(DH *dh, int need)
202 do { 204 do {
203 if (dh->priv_key != NULL) 205 if (dh->priv_key != NULL)
204 BN_free(dh->priv_key); 206 BN_free(dh->priv_key);
205 dh->priv_key = BN_new(); 207 if ((dh->priv_key = BN_new()) == NULL)
206 if (dh->priv_key == NULL)
207 fatal("dh_gen_key: BN_new failed"); 208 fatal("dh_gen_key: BN_new failed");
208 /* generate a 2*need bits random private exponent */ 209 /* generate a 2*need bits random private exponent */
209 if (!BN_rand(dh->priv_key, 2*need, 0, 0)) 210 if (!BN_rand(dh->priv_key, 2*need, 0, 0))
@@ -225,9 +226,8 @@ dh_new_group_asc(const char *gen, const char *modulus)
225{ 226{
226 DH *dh; 227 DH *dh;
227 228
228 dh = DH_new(); 229 if ((dh = DH_new()) == NULL)
229 if (dh == NULL) 230 fatal("dh_new_group_asc: DH_new");
230 fatal("DH_new");
231 231
232 if (BN_hex2bn(&dh->p, modulus) == 0) 232 if (BN_hex2bn(&dh->p, modulus) == 0)
233 fatal("BN_hex2bn p"); 233 fatal("BN_hex2bn p");
@@ -247,9 +247,8 @@ dh_new_group(BIGNUM *gen, BIGNUM *modulus)
247{ 247{
248 DH *dh; 248 DH *dh;
249 249
250 dh = DH_new(); 250 if ((dh = DH_new()) == NULL)
251 if (dh == NULL) 251 fatal("dh_new_group: DH_new");
252 fatal("DH_new");
253 dh->p = modulus; 252 dh->p = modulus;
254 dh->g = gen; 253 dh->g = gen;
255 254