summaryrefslogtreecommitdiffstats
path: root/kexgexc.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2021-12-19 22:08:06 +0000
committerDamien Miller <djm@mindrot.org>2021-12-20 09:24:42 +1100
commitb42c61d6840d16ef392ed0f365e8c000734669aa (patch)
tree382b0382fa3ca143ebe2994658063e2de3bc3727 /kexgexc.c
parent26ca33d186473d58a32d812e19273ce078b6ffff (diff)
upstream: Record session ID, host key and sig at intital KEX
These will be used later for agent session ID / hostkey binding ok markus@ OpenBSD-Commit-ID: a9af29e33772b18e3e867c6fa8ab35e1694a81fe
Diffstat (limited to 'kexgexc.c')
-rw-r--r--kexgexc.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/kexgexc.c b/kexgexc.c
index 4a2e741d..e99e0cf2 100644
--- a/kexgexc.c
+++ b/kexgexc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kexgexc.c,v 1.37 2021/01/31 22:55:29 djm Exp $ */
+/* $OpenBSD: kexgexc.c,v 1.38 2021/12/19 22:08:06 djm Exp $ */
/*
* Copyright (c) 2000 Niels Provos. All rights reserved.
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -206,8 +206,26 @@ input_kex_dh_gex_reply(int type, u_int32_t seq, struct ssh *ssh)
hashlen, kex->hostkey_alg, ssh->compat, NULL)) != 0)
goto out;
- if ((r = kex_derive_keys(ssh, hash, hashlen, shared_secret)) == 0)
- r = kex_send_newkeys(ssh);
+ if ((r = kex_derive_keys(ssh, hash, hashlen, shared_secret)) != 0 ||
+ (r = kex_send_newkeys(ssh)) != 0)
+ goto out;
+
+ /* save initial signature and hostkey */
+ if ((kex->flags & KEX_INITIAL) != 0) {
+ if (kex->initial_hostkey != NULL || kex->initial_sig != NULL) {
+ r = SSH_ERR_INTERNAL_ERROR;
+ goto out;
+ }
+ if ((kex->initial_sig = sshbuf_new()) == NULL) {
+ r = SSH_ERR_ALLOC_FAIL;
+ goto out;
+ }
+ if ((r = sshbuf_put(kex->initial_sig, signature, slen)) != 0)
+ goto out;
+ kex->initial_hostkey = server_host_key;
+ server_host_key = NULL;
+ }
+ /* success */
out:
explicit_bzero(hash, sizeof(hash));
DH_free(kex->dh);