summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-06-18 23:34:19 +0000
committerDarren Tucker <dtucker@dtucker.net>2020-06-19 15:51:04 +1000
commit7775819c6de3e9547ac57b87c7dd2bfd28cefcc5 (patch)
treeb9892e35c102f3ac48b386509a9f0bd069464a61 /sshd.c
parentc514f3c0522855b4d548286eaa113e209051a6d2 (diff)
upstream: check public host key matches private; ok markus@ (as
part of previous diff) OpenBSD-Commit-ID: 65a4f66436028748b59fb88b264cb8c94ce2ba63
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sshd.c b/sshd.c
index 71f743a0d..44cc3ac92 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.556 2020/06/05 06:18:07 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.557 2020/06/18 23:34:19 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1849,10 +1849,19 @@ main(int ac, char **av)
1849 &pubkey, NULL)) != 0 && r != SSH_ERR_SYSTEM_ERROR) 1849 &pubkey, NULL)) != 0 && r != SSH_ERR_SYSTEM_ERROR)
1850 do_log2(ll, "Unable to load host key \"%s\": %s", 1850 do_log2(ll, "Unable to load host key \"%s\": %s",
1851 options.host_key_files[i], ssh_err(r)); 1851 options.host_key_files[i], ssh_err(r));
1852 if (pubkey == NULL && key != NULL) 1852 if (pubkey != NULL && key != NULL) {
1853 if (!sshkey_equal(pubkey, key)) {
1854 error("Public key for %s does not match "
1855 "private key", options.host_key_files[i]);
1856 sshkey_free(pubkey);
1857 pubkey = NULL;
1858 }
1859 }
1860 if (pubkey == NULL && key != NULL) {
1853 if ((r = sshkey_from_private(key, &pubkey)) != 0) 1861 if ((r = sshkey_from_private(key, &pubkey)) != 0)
1854 fatal("Could not demote key: \"%s\": %s", 1862 fatal("Could not demote key: \"%s\": %s",
1855 options.host_key_files[i], ssh_err(r)); 1863 options.host_key_files[i], ssh_err(r));
1864 }
1856 sensitive_data.host_keys[i] = key; 1865 sensitive_data.host_keys[i] = key;
1857 sensitive_data.host_pubkeys[i] = pubkey; 1866 sensitive_data.host_pubkeys[i] = pubkey;
1858 1867