summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-06-21 04:21:04 +0000
committerDamien Miller <djm@mindrot.org>2019-06-21 14:24:35 +1000
commit4f7a56d5e02e3d04ab69eac1213817a7536d0562 (patch)
treeb17da67f20831b53f9b00c6647c5eb1bdf88d626 /sshd.c
parent4cd6b12cc9c10bf59c8b425041f3ea5091285a0f (diff)
upstream: Add protection for private keys at rest in RAM against
speculation and memory sidechannel attacks like Spectre, Meltdown, Rowhammer and Rambleed. This change encrypts private keys when they are not in use with a symmetic key that is derived from a relatively large "prekey" consisting of random data (currently 16KB). Attackers must recover the entire prekey with high accuracy before they can attempt to decrypt the shielded private key, but the current generation of attacks have bit error rates that, when applied cumulatively to the entire prekey, make this unlikely. Implementation-wise, keys are encrypted "shielded" when loaded and then automatically and transparently unshielded when used for signatures or when being saved/serialised. Hopefully we can remove this in a few years time when computer architecture has become less unsafe. been in snaps for a bit already; thanks deraadt@ ok dtucker@ deraadt@ OpenBSD-Commit-ID: 19767213c312e46f94b303a512ef8e9218a39bd4
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sshd.c b/sshd.c
index be23fbc80..735a11060 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.535 2019/06/06 05:13:13 otto Exp $ */ 1/* $OpenBSD: sshd.c,v 1.536 2019/06/21 04:21:05 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
@@ -1375,7 +1375,7 @@ set_process_rdomain(struct ssh *ssh, const char *name)
1375 1375
1376static void 1376static void
1377accumulate_host_timing_secret(struct sshbuf *server_cfg, 1377accumulate_host_timing_secret(struct sshbuf *server_cfg,
1378 const struct sshkey *key) 1378 struct sshkey *key)
1379{ 1379{
1380 static struct ssh_digest_ctx *ctx; 1380 static struct ssh_digest_ctx *ctx;
1381 u_char *hash; 1381 u_char *hash;
@@ -1723,6 +1723,12 @@ main(int ac, char **av)
1723 &key, NULL)) != 0 && r != SSH_ERR_SYSTEM_ERROR) 1723 &key, NULL)) != 0 && r != SSH_ERR_SYSTEM_ERROR)
1724 do_log2(ll, "Unable to load host key \"%s\": %s", 1724 do_log2(ll, "Unable to load host key \"%s\": %s",
1725 options.host_key_files[i], ssh_err(r)); 1725 options.host_key_files[i], ssh_err(r));
1726 if (r == 0 && (r = sshkey_shield_private(key)) != 0) {
1727 do_log2(ll, "Unable to shield host key \"%s\": %s",
1728 options.host_key_files[i], ssh_err(r));
1729 sshkey_free(key);
1730 key = NULL;
1731 }
1726 if ((r = sshkey_load_public(options.host_key_files[i], 1732 if ((r = sshkey_load_public(options.host_key_files[i],
1727 &pubkey, NULL)) != 0 && r != SSH_ERR_SYSTEM_ERROR) 1733 &pubkey, NULL)) != 0 && r != SSH_ERR_SYSTEM_ERROR)
1728 do_log2(ll, "Unable to load host key \"%s\": %s", 1734 do_log2(ll, "Unable to load host key \"%s\": %s",