diff options
Diffstat (limited to 'kexgexc.c')
-rw-r--r-- | kexgexc.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -1,3 +1,4 @@ | |||
1 | /* $OpenBSD: kexgexc.c,v 1.11 2006/11/06 21:25:28 markus Exp $ */ | ||
1 | /* | 2 | /* |
2 | * Copyright (c) 2000 Niels Provos. All rights reserved. | 3 | * Copyright (c) 2000 Niels Provos. All rights reserved. |
3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 4 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
@@ -24,10 +25,18 @@ | |||
24 | */ | 25 | */ |
25 | 26 | ||
26 | #include "includes.h" | 27 | #include "includes.h" |
27 | RCSID("$OpenBSD: kexgexc.c,v 1.3 2005/11/04 05:15:59 djm Exp $"); | 28 | |
29 | #include <sys/types.h> | ||
30 | |||
31 | #include <stdarg.h> | ||
32 | #include <stdio.h> | ||
33 | #include <string.h> | ||
34 | #include <signal.h> | ||
28 | 35 | ||
29 | #include "xmalloc.h" | 36 | #include "xmalloc.h" |
37 | #include "buffer.h" | ||
30 | #include "key.h" | 38 | #include "key.h" |
39 | #include "cipher.h" | ||
31 | #include "kex.h" | 40 | #include "kex.h" |
32 | #include "log.h" | 41 | #include "log.h" |
33 | #include "packet.h" | 42 | #include "packet.h" |
@@ -42,7 +51,8 @@ kexgex_client(Kex *kex) | |||
42 | BIGNUM *p = NULL, *g = NULL; | 51 | BIGNUM *p = NULL, *g = NULL; |
43 | Key *server_host_key; | 52 | Key *server_host_key; |
44 | u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; | 53 | u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; |
45 | u_int klen, kout, slen, sbloblen, hashlen; | 54 | u_int klen, slen, sbloblen, hashlen; |
55 | int kout; | ||
46 | int min, max, nbits; | 56 | int min, max, nbits; |
47 | DH *dh; | 57 | DH *dh; |
48 | 58 | ||
@@ -120,7 +130,7 @@ kexgex_client(Kex *kex) | |||
120 | if (kex->verify_host_key(server_host_key) == -1) | 130 | if (kex->verify_host_key(server_host_key) == -1) |
121 | fatal("server_host_key verification failed"); | 131 | fatal("server_host_key verification failed"); |
122 | 132 | ||
123 | /* DH paramter f, server public DH key */ | 133 | /* DH parameter f, server public DH key */ |
124 | if ((dh_server_pub = BN_new()) == NULL) | 134 | if ((dh_server_pub = BN_new()) == NULL) |
125 | fatal("dh_server_pub == NULL"); | 135 | fatal("dh_server_pub == NULL"); |
126 | packet_get_bignum2(dh_server_pub); | 136 | packet_get_bignum2(dh_server_pub); |
@@ -141,13 +151,15 @@ kexgex_client(Kex *kex) | |||
141 | 151 | ||
142 | klen = DH_size(dh); | 152 | klen = DH_size(dh); |
143 | kbuf = xmalloc(klen); | 153 | kbuf = xmalloc(klen); |
144 | kout = DH_compute_key(kbuf, dh_server_pub, dh); | 154 | if ((kout = DH_compute_key(kbuf, dh_server_pub, dh)) < 0) |
155 | fatal("DH_compute_key: failed"); | ||
145 | #ifdef DEBUG_KEXDH | 156 | #ifdef DEBUG_KEXDH |
146 | dump_digest("shared secret", kbuf, kout); | 157 | dump_digest("shared secret", kbuf, kout); |
147 | #endif | 158 | #endif |
148 | if ((shared_secret = BN_new()) == NULL) | 159 | if ((shared_secret = BN_new()) == NULL) |
149 | fatal("kexgex_client: BN_new failed"); | 160 | fatal("kexgex_client: BN_new failed"); |
150 | BN_bin2bn(kbuf, kout, shared_secret); | 161 | if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) |
162 | fatal("kexgex_client: BN_bin2bn failed"); | ||
151 | memset(kbuf, 0, klen); | 163 | memset(kbuf, 0, klen); |
152 | xfree(kbuf); | 164 | xfree(kbuf); |
153 | 165 | ||