forked from rapier1/hpn-ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: make ssh->kex->session_id a sshbuf instead of u_char*/size_t
and use that instead of global variables containing copies of it. feedback/ok markus@ OpenBSD-Commit-ID: a4b1b1ca4afd2e37cb9f64f737b30a6a7f96af68
- Loading branch information
Showing
15 changed files
with
80 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: clientloop.c,v 1.357 2021/01/27 09:26:54 djm Exp $ */ | ||
/* $OpenBSD: clientloop.c,v 1.358 2021/01/27 10:05:28 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -2125,9 +2125,6 @@ client_global_hostkeys_private_confirm(struct ssh *ssh, int type, | |
|
||
if ((signdata = sshbuf_new()) == NULL) | ||
fatal_f("sshbuf_new failed"); | ||
/* Don't want to accidentally accept an unbound signature */ | ||
if (ssh->kex->session_id_len == 0) | ||
fatal_f("ssh->kex->session_id_len == 0"); | ||
/* | ||
* Expect a signature for each of the ctx->nnew private keys we | ||
* haven't seen before. They will be in the same order as the | ||
|
@@ -2140,8 +2137,8 @@ client_global_hostkeys_private_confirm(struct ssh *ssh, int type, | |
sshbuf_reset(signdata); | ||
if ( (r = sshbuf_put_cstring(signdata, | ||
"[email protected]")) != 0 || | ||
(r = sshbuf_put_string(signdata, ssh->kex->session_id, | ||
ssh->kex->session_id_len)) != 0 || | ||
(r = sshbuf_put_stringb(signdata, | ||
ssh->kex->session_id)) != 0 || | ||
(r = sshkey_puts(ctx->keys[i], signdata)) != 0) | ||
fatal_fr(r, "compose signdata"); | ||
/* Extract and verify signature */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: monitor.c,v 1.222 2021/01/27 09:26:54 djm Exp $ */ | ||
/* $OpenBSD: monitor.c,v 1.223 2021/01/27 10:05:28 djm Exp $ */ | ||
/* | ||
* Copyright 2002 Niels Provos <[email protected]> | ||
* Copyright 2002 Markus Friedl <[email protected]> | ||
|
@@ -104,7 +104,6 @@ static Gssctxt *gsscontext = NULL; | |
/* Imports */ | ||
extern ServerOptions options; | ||
extern u_int utmp_len; | ||
extern u_char session_id[]; | ||
extern struct sshbuf *loginmsg; | ||
extern struct sshauthopt *auth_opts; /* XXX move to permanent ssh->authctxt? */ | ||
|
||
|
@@ -1431,7 +1430,9 @@ mm_answer_keyverify(struct ssh *ssh, int sock, struct sshbuf *m) | |
break; | ||
} | ||
if (!valid_data) | ||
fatal_f("bad signature data blob"); | ||
fatal_f("bad %s signature data blob", | ||
key_blobtype == MM_USERKEY ? "userkey" : | ||
(key_blobtype == MM_HOSTKEY ? "hostkey" : "unknown")); | ||
|
||
if ((fp = sshkey_fingerprint(key, options.fingerprint_hash, | ||
SSH_FP_DEFAULT)) == NULL) | ||
|
@@ -1716,28 +1717,34 @@ monitor_apply_keystate(struct ssh *ssh, struct monitor *pmonitor) | |
fatal_fr(r, "packet_set_state"); | ||
sshbuf_free(child_state); | ||
child_state = NULL; | ||
|
||
if ((kex = ssh->kex) != NULL) { | ||
/* XXX set callbacks */ | ||
if ((kex = ssh->kex) == NULL) | ||
fatal_f("internal error: ssh->kex == NULL"); | ||
if (session_id2_len != sshbuf_len(ssh->kex->session_id)) { | ||
fatal_f("incorrect session id length %zu (expected %u)", | ||
sshbuf_len(ssh->kex->session_id), session_id2_len); | ||
} | ||
if (memcmp(sshbuf_ptr(ssh->kex->session_id), session_id2, | ||
session_id2_len) != 0) | ||
fatal_f("session ID mismatch"); | ||
/* XXX set callbacks */ | ||
#ifdef WITH_OPENSSL | ||
kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP14_SHA256] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP16_SHA512] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP18_SHA512] = kex_gen_server; | ||
kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; | ||
kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; | ||
kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP14_SHA256] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP16_SHA512] = kex_gen_server; | ||
kex->kex[KEX_DH_GRP18_SHA512] = kex_gen_server; | ||
kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; | ||
kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; | ||
# ifdef OPENSSL_HAS_ECC | ||
kex->kex[KEX_ECDH_SHA2] = kex_gen_server; | ||
kex->kex[KEX_ECDH_SHA2] = kex_gen_server; | ||
# endif | ||
#endif /* WITH_OPENSSL */ | ||
kex->kex[KEX_C25519_SHA256] = kex_gen_server; | ||
kex->kex[KEX_KEM_SNTRUP761X25519_SHA512] = kex_gen_server; | ||
kex->load_host_public_key=&get_hostkey_public_by_type; | ||
kex->load_host_private_key=&get_hostkey_private_by_type; | ||
kex->host_key_index=&get_hostkey_index; | ||
kex->sign = sshd_hostkey_sign; | ||
} | ||
kex->kex[KEX_C25519_SHA256] = kex_gen_server; | ||
kex->kex[KEX_KEM_SNTRUP761X25519_SHA512] = kex_gen_server; | ||
kex->load_host_public_key=&get_hostkey_public_by_type; | ||
kex->load_host_private_key=&get_hostkey_private_by_type; | ||
kex->host_key_index=&get_hostkey_index; | ||
kex->sign = sshd_hostkey_sign; | ||
} | ||
|
||
/* This function requires careful sanity checking */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: packet.c,v 1.298 2020/11/27 00:49:58 djm Exp $ */ | ||
/* $OpenBSD: packet.c,v 1.299 2021/01/27 10:05:28 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -2196,9 +2196,7 @@ kex_to_blob(struct sshbuf *m, struct kex *kex) | |
{ | ||
int r; | ||
|
||
if ((r = sshbuf_put_string(m, kex->session_id, | ||
kex->session_id_len)) != 0 || | ||
(r = sshbuf_put_u32(m, kex->we_need)) != 0 || | ||
if ((r = sshbuf_put_u32(m, kex->we_need)) != 0 || | ||
(r = sshbuf_put_cstring(m, kex->hostkey_alg)) != 0 || | ||
(r = sshbuf_put_u32(m, kex->hostkey_type)) != 0 || | ||
(r = sshbuf_put_u32(m, kex->hostkey_nid)) != 0 || | ||
|
@@ -2207,6 +2205,7 @@ kex_to_blob(struct sshbuf *m, struct kex *kex) | |
(r = sshbuf_put_stringb(m, kex->peer)) != 0 || | ||
(r = sshbuf_put_stringb(m, kex->client_version)) != 0 || | ||
(r = sshbuf_put_stringb(m, kex->server_version)) != 0 || | ||
(r = sshbuf_put_stringb(m, kex->session_id)) != 0 || | ||
(r = sshbuf_put_u32(m, kex->flags)) != 0) | ||
return r; | ||
return 0; | ||
|
@@ -2359,8 +2358,7 @@ kex_from_blob(struct sshbuf *m, struct kex **kexp) | |
|
||
if ((kex = kex_new()) == NULL) | ||
return SSH_ERR_ALLOC_FAIL; | ||
if ((r = sshbuf_get_string(m, &kex->session_id, &kex->session_id_len)) != 0 || | ||
(r = sshbuf_get_u32(m, &kex->we_need)) != 0 || | ||
if ((r = sshbuf_get_u32(m, &kex->we_need)) != 0 || | ||
(r = sshbuf_get_cstring(m, &kex->hostkey_alg, NULL)) != 0 || | ||
(r = sshbuf_get_u32(m, (u_int *)&kex->hostkey_type)) != 0 || | ||
(r = sshbuf_get_u32(m, (u_int *)&kex->hostkey_nid)) != 0 || | ||
|
@@ -2369,6 +2367,7 @@ kex_from_blob(struct sshbuf *m, struct kex **kexp) | |
(r = sshbuf_get_stringb(m, kex->peer)) != 0 || | ||
(r = sshbuf_get_stringb(m, kex->client_version)) != 0 || | ||
(r = sshbuf_get_stringb(m, kex->server_version)) != 0 || | ||
(r = sshbuf_get_stringb(m, kex->session_id)) != 0 || | ||
(r = sshbuf_get_u32(m, &kex->flags)) != 0) | ||
goto out; | ||
kex->server = 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: serverloop.c,v 1.224 2020/10/18 11:32:02 djm Exp $ */ | ||
/* $OpenBSD: serverloop.c,v 1.225 2021/01/27 10:05:28 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -779,8 +779,8 @@ server_input_hostkeys_prove(struct ssh *ssh, struct sshbuf **respp) | |
sshkey_type_plain(key->type) == KEY_RSA; | ||
if ((r = sshbuf_put_cstring(sigbuf, | ||
"[email protected]")) != 0 || | ||
(r = sshbuf_put_string(sigbuf, | ||
ssh->kex->session_id, ssh->kex->session_id_len)) != 0 || | ||
(r = sshbuf_put_stringb(sigbuf, | ||
ssh->kex->session_id)) != 0 || | ||
(r = sshkey_puts(key, sigbuf)) != 0 || | ||
(r = ssh->kex->sign(ssh, key_prv, key_pub, &sig, &slen, | ||
sshbuf_ptr(sigbuf), sshbuf_len(sigbuf), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.