summaryrefslogtreecommitdiff
path: root/kex.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-01-21 10:05:09 +0000
committerDamien Miller <djm@mindrot.org>2019-01-21 21:47:28 +1100
commitbb39bafb6dc520cc097780f4611a52da7f19c3e2 (patch)
treeb5721488b62d4e8cc1ffa322ae659e5265a0c707 /kex.c
parentdec5e9d33891e3bc3f1395d7db0e56fdc7f86dfc (diff)
downloadopenssh-git-bb39bafb6dc520cc097780f4611a52da7f19c3e2.tar.gz
upstream: factor out kex_load_hostkey() - this is duplicated in
both the client and server implementations for most KEX methods. from markus@ ok djm@ OpenBSD-Commit-ID: 8232fa7c21fbfbcaf838313b0c166dc6c8762f3c
Diffstat (limited to 'kex.c')
-rw-r--r--kex.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/kex.c b/kex.c
index 0d5618ec..a0d13a88 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kex.c,v 1.144 2019/01/21 09:55:52 djm Exp $ */
+/* $OpenBSD: kex.c,v 1.145 2019/01/21 10:05:09 djm Exp $ */
/*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
*
@@ -1052,6 +1052,24 @@ kex_derive_keys_bn(struct ssh *ssh, u_char *hash, u_int hashlen,
}
#endif
+int
+kex_load_hostkey(struct ssh *ssh, struct sshkey **pubp, struct sshkey **prvp)
+{
+ struct kex *kex = ssh->kex;
+
+ *pubp = NULL;
+ *prvp = NULL;
+ if (kex->load_host_public_key == NULL ||
+ kex->load_host_private_key == NULL)
+ return SSH_ERR_INVALID_ARGUMENT;
+ *pubp = kex->load_host_public_key(kex->hostkey_type,
+ kex->hostkey_nid, ssh);
+ *prvp = kex->load_host_private_key(kex->hostkey_type,
+ kex->hostkey_nid, ssh);
+ if (*pubp == NULL)
+ return SSH_ERR_NO_HOSTKEY_LOADED;
+ return 0;
+}
#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH)
void