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)
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 0d5618ecc..a0d13a880 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.c,v 1.144 2019/01/21 09:55:52 djm Exp $ */ 1/* $OpenBSD: kex.c,v 1.145 2019/01/21 10:05:09 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -1052,6 +1052,24 @@ kex_derive_keys_bn(struct ssh *ssh, u_char *hash, u_int hashlen,
1052} 1052}
1053#endif 1053#endif
1054 1054
1055int
1056kex_load_hostkey(struct ssh *ssh, struct sshkey **pubp, struct sshkey **prvp)
1057{
1058 struct kex *kex = ssh->kex;
1059
1060 *pubp = NULL;
1061 *prvp = NULL;
1062 if (kex->load_host_public_key == NULL ||
1063 kex->load_host_private_key == NULL)
1064 return SSH_ERR_INVALID_ARGUMENT;
1065 *pubp = kex->load_host_public_key(kex->hostkey_type,
1066 kex->hostkey_nid, ssh);
1067 *prvp = kex->load_host_private_key(kex->hostkey_type,
1068 kex->hostkey_nid, ssh);
1069 if (*pubp == NULL)
1070 return SSH_ERR_NO_HOSTKEY_LOADED;
1071 return 0;
1072}
1055 1073
1056#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH) 1074#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH)
1057void 1075void