summaryrefslogtreecommitdiff
path: root/kex.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-01-21 09:55:52 +0000
committerDamien Miller <djm@mindrot.org>2019-01-21 21:47:28 +1100
commit5ae3f6d314465026d028af82609c1d49ad197655 (patch)
tree6fa154f6478dd9b35d90716573420f3c517c49ab /kex.c
parent7be8572b32a15d5c3dba897f252e2e04e991c307 (diff)
downloadopenssh-git-5ae3f6d314465026d028af82609c1d49ad197655.tar.gz
upstream: save the derived session id in kex_derive_keys() rather
than making each kex method implementation do it. from markus@ ok djm@ OpenBSD-Commit-ID: d61ade9c8d1e13f665f8663c552abff8c8a30673
Diffstat (limited to 'kex.c')
-rw-r--r--kex.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/kex.c b/kex.c
index 30e1c261..0d5618ec 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kex.c,v 1.143 2018/12/27 03:25:25 djm Exp $ */
+/* $OpenBSD: kex.c,v 1.144 2019/01/21 09:55:52 djm Exp $ */
/*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
*
@@ -1009,6 +1009,14 @@ kex_derive_keys(struct ssh *ssh, u_char *hash, u_int hashlen,
u_int i, j, mode, ctos;
int r;
+ /* save initial hash as session id */
+ if (kex->session_id == NULL) {
+ kex->session_id_len = hashlen;
+ kex->session_id = malloc(kex->session_id_len);
+ if (kex->session_id == NULL)
+ return SSH_ERR_ALLOC_FAIL;
+ memcpy(kex->session_id, hash, kex->session_id_len);
+ }
for (i = 0; i < NKEYS; i++) {
if ((r = derive_key(ssh, 'A'+i, kex->we_need, hash, hashlen,
shared_secret, &keys[i])) != 0) {