summaryrefslogtreecommitdiff
path: root/kexgsss.c
diff options
context:
space:
mode:
Diffstat (limited to 'kexgsss.c')
-rw-r--r--kexgsss.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/kexgsss.c b/kexgsss.c
index 268eeccae..6447dc97b 100644
--- a/kexgsss.c
+++ b/kexgsss.c
@@ -56,15 +56,14 @@ kexgss_server(Kex *kex)
56 gss_buffer_desc gssbuf, recv_tok, msg_tok; 56 gss_buffer_desc gssbuf, recv_tok, msg_tok;
57 gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; 57 gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
58 Gssctxt *ctxt = NULL; 58 Gssctxt *ctxt = NULL;
59 unsigned int klen, kout; 59 u_int slen, klen, kout, hashlen;
60 unsigned char *kbuf, *hash; 60 u_char *kbuf, *hash;
61 DH *dh; 61 DH *dh;
62 int min = -1, max = -1, nbits = -1; 62 int min = -1, max = -1, nbits = -1;
63 BIGNUM *shared_secret = NULL; 63 BIGNUM *shared_secret = NULL;
64 BIGNUM *dh_client_pub = NULL; 64 BIGNUM *dh_client_pub = NULL;
65 int type = 0; 65 int type = 0;
66 int gex; 66 int gex;
67 u_int slen;
68 gss_OID oid; 67 gss_OID oid;
69 68
70 /* Initialise GSSAPI */ 69 /* Initialise GSSAPI */
@@ -189,7 +188,8 @@ kexgss_server(Kex *kex)
189 xfree(kbuf); 188 xfree(kbuf);
190 189
191 if (gex) { 190 if (gex) {
192 hash = kexgex_hash( 191 kexgex_hash(
192 kex->evp_md,
193 kex->client_version_string, kex->server_version_string, 193 kex->client_version_string, kex->server_version_string,
194 buffer_ptr(&kex->peer), buffer_len(&kex->peer), 194 buffer_ptr(&kex->peer), buffer_len(&kex->peer),
195 buffer_ptr(&kex->my), buffer_len(&kex->my), 195 buffer_ptr(&kex->my), buffer_len(&kex->my),
@@ -198,29 +198,31 @@ kexgss_server(Kex *kex)
198 dh->p, dh->g, 198 dh->p, dh->g,
199 dh_client_pub, 199 dh_client_pub,
200 dh->pub_key, 200 dh->pub_key,
201 shared_secret 201 shared_secret,
202 &hash, &hashlen
202 ); 203 );
203 } 204 }
204 else { 205 else {
205 /* The GSSAPI hash is identical to the Diffie Helman one */ 206 /* The GSSAPI hash is identical to the Diffie Helman one */
206 hash = kex_dh_hash( 207 kex_dh_hash(
207 kex->client_version_string, kex->server_version_string, 208 kex->client_version_string, kex->server_version_string,
208 buffer_ptr(&kex->peer), buffer_len(&kex->peer), 209 buffer_ptr(&kex->peer), buffer_len(&kex->peer),
209 buffer_ptr(&kex->my), buffer_len(&kex->my), 210 buffer_ptr(&kex->my), buffer_len(&kex->my),
210 NULL, 0, /* Change this if we start sending host keys */ 211 NULL, 0, /* Change this if we start sending host keys */
211 dh_client_pub, dh->pub_key, shared_secret 212 dh_client_pub, dh->pub_key, shared_secret,
213 &hash, &hashlen
212 ); 214 );
213 } 215 }
214 BN_free(dh_client_pub); 216 BN_free(dh_client_pub);
215 217
216 if (kex->session_id == NULL) { 218 if (kex->session_id == NULL) {
217 kex->session_id_len = 20; 219 kex->session_id_len = hashlen;
218 kex->session_id = xmalloc(kex->session_id_len); 220 kex->session_id = xmalloc(kex->session_id_len);
219 memcpy(kex->session_id, hash, kex->session_id_len); 221 memcpy(kex->session_id, hash, kex->session_id_len);
220 } 222 }
221 223
222 gssbuf.value = hash; 224 gssbuf.value = hash;
223 gssbuf.length = 20; /* Hashlen appears to always be 20 */ 225 gssbuf.length = hashlen;
224 226
225 if (GSS_ERROR(PRIVSEP(ssh_gssapi_sign(ctxt,&gssbuf,&msg_tok)))) 227 if (GSS_ERROR(PRIVSEP(ssh_gssapi_sign(ctxt,&gssbuf,&msg_tok))))
226 fatal("Couldn't get MIC"); 228 fatal("Couldn't get MIC");
@@ -247,7 +249,7 @@ kexgss_server(Kex *kex)
247 249
248 DH_free(dh); 250 DH_free(dh);
249 251
250 kex_derive_keys(kex, hash, shared_secret); 252 kex_derive_keys(kex, hash, hashlen, shared_secret);
251 BN_clear_free(shared_secret); 253 BN_clear_free(shared_secret);
252 kex_finish(kex); 254 kex_finish(kex);
253} 255}