summaryrefslogtreecommitdiff
path: root/ssh-agent.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-11-15 05:37:27 +0000
committerDamien Miller <djm@mindrot.org>2019-11-15 16:39:31 +1100
commitc63fba5e3472307167850bbd84187186af7fa9f0 (patch)
treebaa9ea6a040071c3b3db6d43f9d8256fa1e5772e /ssh-agent.c
parentd165bb5396e3f718480e6039ca2cf77f5a2c2885 (diff)
upstream: unshield security key privkey before attempting signature
in agent. spotted by dtucker@ OpenBSD-Commit-ID: fb67d451665385b8a0a55371231c50aac67b91d2
Diffstat (limited to 'ssh-agent.c')
-rw-r--r--ssh-agent.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/ssh-agent.c b/ssh-agent.c
index 702dec17..b1ebe078 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.245 2019/11/15 04:12:32 djm Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.246 2019/11/15 05:37:27 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -426,7 +426,7 @@ process_sign_request2(SocketEntry *e)
u_char *signature = NULL;
size_t dlen, slen = 0;
u_int compat = 0, flags;
- int r, ok = -1;
+ int was_shielded, r, r2, ok = -1;
struct sshbuf *msg;
struct sshkey *key = NULL;
struct identity *id;
@@ -449,9 +449,21 @@ process_sign_request2(SocketEntry *e)
goto send;
}
if (id->sk_provider != NULL) {
- if ((r = provider_sign(id->sk_provider, id->key, &signature,
+ was_shielded = sshkey_is_shielded(id->key);
+ if ((r = sshkey_unshield_private(id->key)) != 0) {
+ error("%s: unshield: %s", __func__, ssh_err(r));
+ goto send;
+ }
+ r = provider_sign(id->sk_provider, id->key, &signature,
&slen, data, dlen, agent_decode_alg(key, flags),
- compat)) != 0) {
+ compat);
+ if (was_shielded &&
+ (r2 = sshkey_shield_private(id->key)) != 0) {
+ error("%s: shield: %s", __func__, ssh_err(r));
+ r = r2;
+ goto send;
+ }
+ if (r != 0) {
error("%s: sign: %s", __func__, ssh_err(r));
goto send;
}