summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kex.h4
-rw-r--r--kexgen.c67
-rw-r--r--kexgex.c18
-rw-r--r--kexgexc.c29
-rw-r--r--kexgexs.c25
5 files changed, 80 insertions, 63 deletions
diff --git a/kex.h b/kex.h
index 44e6d1972..6d446d1cc 100644
--- a/kex.h
+++ b/kex.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.h,v 1.106 2019/01/21 10:40:11 djm Exp $ */ 1/* $OpenBSD: kex.h,v 1.107 2019/01/23 00:30:41 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -229,7 +229,7 @@ int kex_dh_keygen(struct kex *);
229int kex_dh_compute_key(struct kex *, BIGNUM *, struct sshbuf *); 229int kex_dh_compute_key(struct kex *, BIGNUM *, struct sshbuf *);
230 230
231int kexgex_hash(int, const struct sshbuf *, const struct sshbuf *, 231int kexgex_hash(int, const struct sshbuf *, const struct sshbuf *,
232 const u_char *, size_t, const u_char *, size_t, const u_char *, size_t, 232 const struct sshbuf *, const struct sshbuf *, const struct sshbuf *,
233 int, int, int, 233 int, int, int,
234 const BIGNUM *, const BIGNUM *, const BIGNUM *, 234 const BIGNUM *, const BIGNUM *, const BIGNUM *,
235 const BIGNUM *, const u_char *, size_t, 235 const BIGNUM *, const u_char *, size_t,
diff --git a/kexgen.c b/kexgen.c
index 91c960fe6..bb0cb5c1b 100644
--- a/kexgen.c
+++ b/kexgen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgen.c,v 1.1 2019/01/21 11:22:00 djm Exp $ */ 1/* $OpenBSD: kexgen.c,v 1.2 2019/01/23 00:30:41 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2019 Markus Friedl. All rights reserved. 3 * Copyright (c) 2019 Markus Friedl. All rights reserved.
4 * 4 *
@@ -48,9 +48,9 @@ kex_gen_hash(
48 int hash_alg, 48 int hash_alg,
49 const struct sshbuf *client_version, 49 const struct sshbuf *client_version,
50 const struct sshbuf *server_version, 50 const struct sshbuf *server_version,
51 const u_char *ckexinit, size_t ckexinitlen, 51 const struct sshbuf *client_kexinit,
52 const u_char *skexinit, size_t skexinitlen, 52 const struct sshbuf *server_kexinit,
53 const u_char *serverhostkeyblob, size_t sbloblen, 53 const struct sshbuf *server_host_key_blob,
54 const struct sshbuf *client_pub, 54 const struct sshbuf *client_pub,
55 const struct sshbuf *server_pub, 55 const struct sshbuf *server_pub,
56 const struct sshbuf *shared_secret, 56 const struct sshbuf *shared_secret,
@@ -66,13 +66,13 @@ kex_gen_hash(
66 if ((r = sshbuf_put_stringb(b, client_version)) != 0 || 66 if ((r = sshbuf_put_stringb(b, client_version)) != 0 ||
67 (r = sshbuf_put_stringb(b, server_version)) != 0 || 67 (r = sshbuf_put_stringb(b, server_version)) != 0 ||
68 /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */ 68 /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */
69 (r = sshbuf_put_u32(b, ckexinitlen+1)) != 0 || 69 (r = sshbuf_put_u32(b, sshbuf_len(client_kexinit) + 1)) != 0 ||
70 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 || 70 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
71 (r = sshbuf_put(b, ckexinit, ckexinitlen)) != 0 || 71 (r = sshbuf_putb(b, client_kexinit)) != 0 ||
72 (r = sshbuf_put_u32(b, skexinitlen+1)) != 0 || 72 (r = sshbuf_put_u32(b, sshbuf_len(server_kexinit) + 1)) != 0 ||
73 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 || 73 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
74 (r = sshbuf_put(b, skexinit, skexinitlen)) != 0 || 74 (r = sshbuf_putb(b, server_kexinit)) != 0 ||
75 (r = sshbuf_put_string(b, serverhostkeyblob, sbloblen)) != 0 || 75 (r = sshbuf_put_stringb(b, server_host_key_blob)) != 0 ||
76 (r = sshbuf_put_stringb(b, client_pub)) != 0 || 76 (r = sshbuf_put_stringb(b, client_pub)) != 0 ||
77 (r = sshbuf_put_stringb(b, server_pub)) != 0 || 77 (r = sshbuf_put_stringb(b, server_pub)) != 0 ||
78 (r = sshbuf_putb(b, shared_secret)) != 0) { 78 (r = sshbuf_putb(b, shared_secret)) != 0) {
@@ -139,16 +139,21 @@ input_kex_gen_reply(int type, u_int32_t seq, struct ssh *ssh)
139 struct sshkey *server_host_key = NULL; 139 struct sshkey *server_host_key = NULL;
140 struct sshbuf *shared_secret = NULL; 140 struct sshbuf *shared_secret = NULL;
141 struct sshbuf *server_blob = NULL; 141 struct sshbuf *server_blob = NULL;
142 u_char *server_host_key_blob = NULL, *signature = NULL; 142 struct sshbuf *tmp = NULL, *server_host_key_blob = NULL;
143 u_char *signature = NULL;
143 u_char hash[SSH_DIGEST_MAX_LENGTH]; 144 u_char hash[SSH_DIGEST_MAX_LENGTH];
144 size_t slen, sbloblen, hashlen; 145 size_t slen, hashlen;
145 int r; 146 int r;
146 147
147 /* hostkey */ 148 /* hostkey */
148 if ((r = sshpkt_get_string(ssh, &server_host_key_blob, 149 if ((r = sshpkt_getb_froms(ssh, &server_host_key_blob)) != 0)
149 &sbloblen)) != 0 || 150 goto out;
150 (r = sshkey_from_blob(server_host_key_blob, sbloblen, 151 /* sshkey_fromb() consumes its buffer, so make a copy */
151 &server_host_key)) != 0) 152 if ((tmp = sshbuf_fromb(server_host_key_blob)) == NULL) {
153 r = SSH_ERR_ALLOC_FAIL;
154 goto out;
155 }
156 if ((r = sshkey_fromb(tmp, &server_host_key)) != 0)
152 goto out; 157 goto out;
153 if ((r = kex_verify_host_key(ssh, server_host_key)) != 0) 158 if ((r = kex_verify_host_key(ssh, server_host_key)) != 0)
154 goto out; 159 goto out;
@@ -192,9 +197,9 @@ input_kex_gen_reply(int type, u_int32_t seq, struct ssh *ssh)
192 kex->hash_alg, 197 kex->hash_alg,
193 kex->client_version, 198 kex->client_version,
194 kex->server_version, 199 kex->server_version,
195 sshbuf_ptr(kex->my), sshbuf_len(kex->my), 200 kex->my,
196 sshbuf_ptr(kex->peer), sshbuf_len(kex->peer), 201 kex->peer,
197 server_host_key_blob, sbloblen, 202 server_host_key_blob,
198 kex->client_pub, 203 kex->client_pub,
199 server_blob, 204 server_blob,
200 shared_secret, 205 shared_secret,
@@ -212,8 +217,9 @@ out:
212 explicit_bzero(kex->c25519_client_key, sizeof(kex->c25519_client_key)); 217 explicit_bzero(kex->c25519_client_key, sizeof(kex->c25519_client_key));
213 explicit_bzero(kex->sntrup4591761_client_key, 218 explicit_bzero(kex->sntrup4591761_client_key,
214 sizeof(kex->sntrup4591761_client_key)); 219 sizeof(kex->sntrup4591761_client_key));
215 free(server_host_key_blob); 220 sshbuf_free(server_host_key_blob);
216 free(signature); 221 free(signature);
222 sshbuf_free(tmp);
217 sshkey_free(server_host_key); 223 sshkey_free(server_host_key);
218 sshbuf_free(server_blob); 224 sshbuf_free(server_blob);
219 sshbuf_free(shared_secret); 225 sshbuf_free(shared_secret);
@@ -238,9 +244,9 @@ input_kex_gen_init(int type, u_int32_t seq, struct ssh *ssh)
238 struct sshbuf *shared_secret = NULL; 244 struct sshbuf *shared_secret = NULL;
239 struct sshbuf *server_pubkey = NULL; 245 struct sshbuf *server_pubkey = NULL;
240 struct sshbuf *client_pubkey = NULL; 246 struct sshbuf *client_pubkey = NULL;
241 u_char *server_host_key_blob = NULL, *signature = NULL; 247 struct sshbuf *server_host_key_blob = NULL;
242 u_char hash[SSH_DIGEST_MAX_LENGTH]; 248 u_char *signature = NULL, hash[SSH_DIGEST_MAX_LENGTH];
243 size_t slen, sbloblen, hashlen; 249 size_t slen, hashlen;
244 int r; 250 int r;
245 251
246 if ((r = kex_load_hostkey(ssh, &server_host_private, 252 if ((r = kex_load_hostkey(ssh, &server_host_private,
@@ -281,17 +287,20 @@ input_kex_gen_init(int type, u_int32_t seq, struct ssh *ssh)
281 goto out; 287 goto out;
282 288
283 /* calc H */ 289 /* calc H */
284 if ((r = sshkey_to_blob(server_host_public, &server_host_key_blob, 290 if ((server_host_key_blob = sshbuf_new()) == NULL) {
285 &sbloblen)) != 0) 291 r = SSH_ERR_ALLOC_FAIL;
292 goto out;
293 }
294 if ((r = sshkey_putb(server_host_public, server_host_key_blob)) != 0)
286 goto out; 295 goto out;
287 hashlen = sizeof(hash); 296 hashlen = sizeof(hash);
288 if ((r = kex_gen_hash( 297 if ((r = kex_gen_hash(
289 kex->hash_alg, 298 kex->hash_alg,
290 kex->client_version, 299 kex->client_version,
291 kex->server_version, 300 kex->server_version,
292 sshbuf_ptr(kex->peer), sshbuf_len(kex->peer), 301 kex->peer,
293 sshbuf_ptr(kex->my), sshbuf_len(kex->my), 302 kex->my,
294 server_host_key_blob, sbloblen, 303 server_host_key_blob,
295 client_pubkey, 304 client_pubkey,
296 server_pubkey, 305 server_pubkey,
297 shared_secret, 306 shared_secret,
@@ -305,7 +314,7 @@ input_kex_gen_init(int type, u_int32_t seq, struct ssh *ssh)
305 314
306 /* send server hostkey, ECDH pubkey 'Q_S' and signed H */ 315 /* send server hostkey, ECDH pubkey 'Q_S' and signed H */
307 if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_ECDH_REPLY)) != 0 || 316 if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_ECDH_REPLY)) != 0 ||
308 (r = sshpkt_put_string(ssh, server_host_key_blob, sbloblen)) != 0 || 317 (r = sshpkt_put_stringb(ssh, server_host_key_blob)) != 0 ||
309 (r = sshpkt_put_stringb(ssh, server_pubkey)) != 0 || 318 (r = sshpkt_put_stringb(ssh, server_pubkey)) != 0 ||
310 (r = sshpkt_put_string(ssh, signature, slen)) != 0 || 319 (r = sshpkt_put_string(ssh, signature, slen)) != 0 ||
311 (r = sshpkt_send(ssh)) != 0) 320 (r = sshpkt_send(ssh)) != 0)
@@ -315,7 +324,7 @@ input_kex_gen_init(int type, u_int32_t seq, struct ssh *ssh)
315 r = kex_send_newkeys(ssh); 324 r = kex_send_newkeys(ssh);
316out: 325out:
317 explicit_bzero(hash, sizeof(hash)); 326 explicit_bzero(hash, sizeof(hash));
318 free(server_host_key_blob); 327 sshbuf_free(server_host_key_blob);
319 free(signature); 328 free(signature);
320 sshbuf_free(shared_secret); 329 sshbuf_free(shared_secret);
321 sshbuf_free(client_pubkey); 330 sshbuf_free(client_pubkey);
diff --git a/kexgex.c b/kexgex.c
index f828f2b20..8040a1320 100644
--- a/kexgex.c
+++ b/kexgex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgex.c,v 1.31 2019/01/21 10:03:37 djm Exp $ */ 1/* $OpenBSD: kexgex.c,v 1.32 2019/01/23 00:30:41 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -48,9 +48,9 @@ kexgex_hash(
48 int hash_alg, 48 int hash_alg,
49 const struct sshbuf *client_version, 49 const struct sshbuf *client_version,
50 const struct sshbuf *server_version, 50 const struct sshbuf *server_version,
51 const u_char *ckexinit, size_t ckexinitlen, 51 const struct sshbuf *client_kexinit,
52 const u_char *skexinit, size_t skexinitlen, 52 const struct sshbuf *server_kexinit,
53 const u_char *serverhostkeyblob, size_t sbloblen, 53 const struct sshbuf *server_host_key_blob,
54 int min, int wantbits, int max, 54 int min, int wantbits, int max,
55 const BIGNUM *prime, 55 const BIGNUM *prime,
56 const BIGNUM *gen, 56 const BIGNUM *gen,
@@ -69,13 +69,13 @@ kexgex_hash(
69 if ((r = sshbuf_put_stringb(b, client_version)) < 0 || 69 if ((r = sshbuf_put_stringb(b, client_version)) < 0 ||
70 (r = sshbuf_put_stringb(b, server_version)) < 0 || 70 (r = sshbuf_put_stringb(b, server_version)) < 0 ||
71 /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */ 71 /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */
72 (r = sshbuf_put_u32(b, ckexinitlen+1)) != 0 || 72 (r = sshbuf_put_u32(b, sshbuf_len(client_kexinit) + 1)) != 0 ||
73 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 || 73 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
74 (r = sshbuf_put(b, ckexinit, ckexinitlen)) != 0 || 74 (r = sshbuf_putb(b, client_kexinit)) != 0 ||
75 (r = sshbuf_put_u32(b, skexinitlen+1)) != 0 || 75 (r = sshbuf_put_u32(b, sshbuf_len(server_kexinit) + 1)) != 0 ||
76 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 || 76 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
77 (r = sshbuf_put(b, skexinit, skexinitlen)) != 0 || 77 (r = sshbuf_putb(b, server_kexinit)) != 0 ||
78 (r = sshbuf_put_string(b, serverhostkeyblob, sbloblen)) != 0 || 78 (r = sshbuf_put_stringb(b, server_host_key_blob)) != 0 ||
79 (min != -1 && (r = sshbuf_put_u32(b, min)) != 0) || 79 (min != -1 && (r = sshbuf_put_u32(b, min)) != 0) ||
80 (r = sshbuf_put_u32(b, wantbits)) != 0 || 80 (r = sshbuf_put_u32(b, wantbits)) != 0 ||
81 (max != -1 && (r = sshbuf_put_u32(b, max)) != 0) || 81 (max != -1 && (r = sshbuf_put_u32(b, max)) != 0) ||
diff --git a/kexgexc.c b/kexgexc.c
index ac42127af..1c65b8a18 100644
--- a/kexgexc.c
+++ b/kexgexc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgexc.c,v 1.33 2019/01/21 10:07:22 djm Exp $ */ 1/* $OpenBSD: kexgexc.c,v 1.34 2019/01/23 00:30:41 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -146,20 +146,24 @@ input_kex_dh_gex_reply(int type, u_int32_t seq, struct ssh *ssh)
146 BIGNUM *dh_server_pub = NULL; 146 BIGNUM *dh_server_pub = NULL;
147 const BIGNUM *pub_key, *dh_p, *dh_g; 147 const BIGNUM *pub_key, *dh_p, *dh_g;
148 struct sshbuf *shared_secret = NULL; 148 struct sshbuf *shared_secret = NULL;
149 struct sshbuf *tmp = NULL, *server_host_key_blob = NULL;
149 struct sshkey *server_host_key = NULL; 150 struct sshkey *server_host_key = NULL;
150 u_char *signature = NULL, *server_host_key_blob = NULL; 151 u_char *signature = NULL;
151 u_char hash[SSH_DIGEST_MAX_LENGTH]; 152 u_char hash[SSH_DIGEST_MAX_LENGTH];
152 size_t slen, sbloblen, hashlen; 153 size_t slen, hashlen;
153 int r; 154 int r;
154 155
155 debug("got SSH2_MSG_KEX_DH_GEX_REPLY"); 156 debug("got SSH2_MSG_KEX_DH_GEX_REPLY");
156 /* key, cert */ 157 /* key, cert */
157 if ((r = sshpkt_get_string(ssh, &server_host_key_blob, 158 if ((r = sshpkt_getb_froms(ssh, &server_host_key_blob)) != 0)
158 &sbloblen)) != 0 ||
159 (r = sshkey_from_blob(server_host_key_blob, sbloblen,
160 &server_host_key)) != 0)
161 goto out; 159 goto out;
162 if ((r = kex_verify_host_key(ssh, server_host_key)) != 0) 160 /* sshkey_fromb() consumes its buffer, so make a copy */
161 if ((tmp = sshbuf_fromb(server_host_key_blob)) == NULL) {
162 r = SSH_ERR_ALLOC_FAIL;
163 goto out;
164 }
165 if ((r = sshkey_fromb(tmp, &server_host_key)) != 0 ||
166 (r = kex_verify_host_key(ssh, server_host_key)) != 0)
163 goto out; 167 goto out;
164 /* DH parameter f, server public DH key, signed H */ 168 /* DH parameter f, server public DH key, signed H */
165 if ((r = sshpkt_get_bignum2(ssh, &dh_server_pub)) != 0 || 169 if ((r = sshpkt_get_bignum2(ssh, &dh_server_pub)) != 0 ||
@@ -183,9 +187,9 @@ input_kex_dh_gex_reply(int type, u_int32_t seq, struct ssh *ssh)
183 kex->hash_alg, 187 kex->hash_alg,
184 kex->client_version, 188 kex->client_version,
185 kex->server_version, 189 kex->server_version,
186 sshbuf_ptr(kex->my), sshbuf_len(kex->my), 190 kex->my,
187 sshbuf_ptr(kex->peer), sshbuf_len(kex->peer), 191 kex->peer,
188 server_host_key_blob, sbloblen, 192 server_host_key_blob,
189 kex->min, kex->nbits, kex->max, 193 kex->min, kex->nbits, kex->max,
190 dh_p, dh_g, 194 dh_p, dh_g,
191 pub_key, 195 pub_key,
@@ -207,7 +211,8 @@ input_kex_dh_gex_reply(int type, u_int32_t seq, struct ssh *ssh)
207 BN_clear_free(dh_server_pub); 211 BN_clear_free(dh_server_pub);
208 sshbuf_free(shared_secret); 212 sshbuf_free(shared_secret);
209 sshkey_free(server_host_key); 213 sshkey_free(server_host_key);
210 free(server_host_key_blob); 214 sshbuf_free(tmp);
215 sshbuf_free(server_host_key_blob);
211 free(signature); 216 free(signature);
212 return r; 217 return r;
213} 218}
diff --git a/kexgexs.c b/kexgexs.c
index a617d4453..8ee3aaccb 100644
--- a/kexgexs.c
+++ b/kexgexs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgexs.c,v 1.41 2019/01/21 10:05:09 djm Exp $ */ 1/* $OpenBSD: kexgexs.c,v 1.42 2019/01/23 00:30:41 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -129,11 +129,11 @@ input_kex_dh_gex_init(int type, u_int32_t seq, struct ssh *ssh)
129 BIGNUM *dh_client_pub = NULL; 129 BIGNUM *dh_client_pub = NULL;
130 const BIGNUM *pub_key, *dh_p, *dh_g; 130 const BIGNUM *pub_key, *dh_p, *dh_g;
131 struct sshbuf *shared_secret = NULL; 131 struct sshbuf *shared_secret = NULL;
132 struct sshbuf *server_host_key_blob = NULL;
132 struct sshkey *server_host_public, *server_host_private; 133 struct sshkey *server_host_public, *server_host_private;
133 u_char *signature = NULL, *server_host_key_blob = NULL; 134 u_char *signature = NULL;
134 u_char hash[SSH_DIGEST_MAX_LENGTH]; 135 u_char hash[SSH_DIGEST_MAX_LENGTH];
135 size_t sbloblen, slen; 136 size_t slen, hashlen;
136 size_t hashlen;
137 int r; 137 int r;
138 138
139 if ((r = kex_load_hostkey(ssh, &server_host_private, 139 if ((r = kex_load_hostkey(ssh, &server_host_private,
@@ -150,8 +150,11 @@ input_kex_dh_gex_init(int type, u_int32_t seq, struct ssh *ssh)
150 } 150 }
151 if ((r = kex_dh_compute_key(kex, dh_client_pub, shared_secret)) != 0) 151 if ((r = kex_dh_compute_key(kex, dh_client_pub, shared_secret)) != 0)
152 goto out; 152 goto out;
153 if ((r = sshkey_to_blob(server_host_public, &server_host_key_blob, 153 if ((server_host_key_blob = sshbuf_new()) == NULL) {
154 &sbloblen)) != 0) 154 r = SSH_ERR_ALLOC_FAIL;
155 goto out;
156 }
157 if ((r = sshkey_putb(server_host_public, server_host_key_blob)) != 0)
155 goto out; 158 goto out;
156 159
157 /* calc H */ 160 /* calc H */
@@ -162,9 +165,9 @@ input_kex_dh_gex_init(int type, u_int32_t seq, struct ssh *ssh)
162 kex->hash_alg, 165 kex->hash_alg,
163 kex->client_version, 166 kex->client_version,
164 kex->server_version, 167 kex->server_version,
165 sshbuf_ptr(kex->peer), sshbuf_len(kex->peer), 168 kex->peer,
166 sshbuf_ptr(kex->my), sshbuf_len(kex->my), 169 kex->my,
167 server_host_key_blob, sbloblen, 170 server_host_key_blob,
168 kex->min, kex->nbits, kex->max, 171 kex->min, kex->nbits, kex->max,
169 dh_p, dh_g, 172 dh_p, dh_g,
170 dh_client_pub, 173 dh_client_pub,
@@ -180,7 +183,7 @@ input_kex_dh_gex_init(int type, u_int32_t seq, struct ssh *ssh)
180 183
181 /* send server hostkey, DH pubkey 'f' and signed H */ 184 /* send server hostkey, DH pubkey 'f' and signed H */
182 if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_DH_GEX_REPLY)) != 0 || 185 if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_DH_GEX_REPLY)) != 0 ||
183 (r = sshpkt_put_string(ssh, server_host_key_blob, sbloblen)) != 0 || 186 (r = sshpkt_put_stringb(ssh, server_host_key_blob)) != 0 ||
184 (r = sshpkt_put_bignum2(ssh, pub_key)) != 0 || /* f */ 187 (r = sshpkt_put_bignum2(ssh, pub_key)) != 0 || /* f */
185 (r = sshpkt_put_string(ssh, signature, slen)) != 0 || 188 (r = sshpkt_put_string(ssh, signature, slen)) != 0 ||
186 (r = sshpkt_send(ssh)) != 0) 189 (r = sshpkt_send(ssh)) != 0)
@@ -194,7 +197,7 @@ input_kex_dh_gex_init(int type, u_int32_t seq, struct ssh *ssh)
194 kex->dh = NULL; 197 kex->dh = NULL;
195 BN_clear_free(dh_client_pub); 198 BN_clear_free(dh_client_pub);
196 sshbuf_free(shared_secret); 199 sshbuf_free(shared_secret);
197 free(server_host_key_blob); 200 sshbuf_free(server_host_key_blob);
198 free(signature); 201 free(signature);
199 return r; 202 return r;
200} 203}