blob: 8a0ffef5dfb8224a549a4e93d274298148cee4be [file] [log] [blame]
djm@openbsd.org89a8d452020-01-25 00:03:36 +00001/* $OpenBSD: ssh-pkcs11-client.c,v 1.16 2020/01/25 00:03:36 djm Exp $ */
Damien Miller7ea845e2010-02-12 09:21:02 +11002/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
djm@openbsd.org93f02102019-01-20 22:51:37 +00004 * Copyright (c) 2014 Pedro Martelletto. All rights reserved.
Damien Miller7ea845e2010-02-12 09:21:02 +11005 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
Damien Miller8ad0fbd2010-02-12 09:49:06 +110019#include "includes.h"
20
Damien Millerdfa41562010-02-12 10:06:28 +110021#ifdef ENABLE_PKCS11
22
Damien Miller7ea845e2010-02-12 09:21:02 +110023#include <sys/types.h>
Damien Miller8ad0fbd2010-02-12 09:49:06 +110024#ifdef HAVE_SYS_TIME_H
25# include <sys/time.h>
26#endif
Damien Miller7ea845e2010-02-12 09:21:02 +110027#include <sys/socket.h>
28
29#include <stdarg.h>
30#include <string.h>
31#include <unistd.h>
32#include <errno.h>
33
djm@openbsd.org93f02102019-01-20 22:51:37 +000034#include <openssl/ecdsa.h>
Damien Miller86687062014-07-02 15:28:02 +100035#include <openssl/rsa.h>
36
Damien Miller48f54b92018-09-13 12:13:50 +100037#include "openbsd-compat/openssl-compat.h"
38
Damien Miller7ea845e2010-02-12 09:21:02 +110039#include "pathnames.h"
40#include "xmalloc.h"
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000041#include "sshbuf.h"
Damien Miller7ea845e2010-02-12 09:21:02 +110042#include "log.h"
43#include "misc.h"
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000044#include "sshkey.h"
Damien Miller7ea845e2010-02-12 09:21:02 +110045#include "authfd.h"
46#include "atomicio.h"
47#include "ssh-pkcs11.h"
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000048#include "ssherr.h"
Damien Miller7ea845e2010-02-12 09:21:02 +110049
50/* borrows code from sftp-server and ssh-agent */
51
djm@openbsd.orgc7670b02019-01-21 12:53:35 +000052static int fd = -1;
53static pid_t pid = -1;
Damien Miller7ea845e2010-02-12 09:21:02 +110054
55static void
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000056send_msg(struct sshbuf *m)
Damien Miller7ea845e2010-02-12 09:21:02 +110057{
58 u_char buf[4];
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000059 size_t mlen = sshbuf_len(m);
60 int r;
Damien Miller7ea845e2010-02-12 09:21:02 +110061
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000062 POKE_U32(buf, mlen);
Damien Miller7ea845e2010-02-12 09:21:02 +110063 if (atomicio(vwrite, fd, buf, 4) != 4 ||
markus@openbsd.org49f47e62018-07-09 21:59:10 +000064 atomicio(vwrite, fd, sshbuf_mutable_ptr(m),
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000065 sshbuf_len(m)) != sshbuf_len(m))
Damien Miller7ea845e2010-02-12 09:21:02 +110066 error("write to helper failed");
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000067 if ((r = sshbuf_consume(m, mlen)) != 0)
68 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Damien Miller7ea845e2010-02-12 09:21:02 +110069}
70
71static int
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000072recv_msg(struct sshbuf *m)
Damien Miller7ea845e2010-02-12 09:21:02 +110073{
74 u_int l, len;
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000075 u_char c, buf[1024];
76 int r;
Damien Miller7ea845e2010-02-12 09:21:02 +110077
78 if ((len = atomicio(read, fd, buf, 4)) != 4) {
79 error("read from helper failed: %u", len);
80 return (0); /* XXX */
81 }
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000082 len = PEEK_U32(buf);
Damien Miller7ea845e2010-02-12 09:21:02 +110083 if (len > 256 * 1024)
84 fatal("response too long: %u", len);
85 /* read len bytes into m */
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000086 sshbuf_reset(m);
Damien Miller7ea845e2010-02-12 09:21:02 +110087 while (len > 0) {
88 l = len;
89 if (l > sizeof(buf))
90 l = sizeof(buf);
91 if (atomicio(read, fd, buf, l) != l) {
92 error("response from helper failed.");
93 return (0); /* XXX */
94 }
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000095 if ((r = sshbuf_put(m, buf, l)) != 0)
96 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Damien Miller7ea845e2010-02-12 09:21:02 +110097 len -= l;
98 }
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +000099 if ((r = sshbuf_get_u8(m, &c)) != 0)
100 fatal("%s: buffer error: %s", __func__, ssh_err(r));
101 return c;
Damien Miller7ea845e2010-02-12 09:21:02 +1100102}
103
104int
105pkcs11_init(int interactive)
106{
107 return (0);
108}
109
110void
111pkcs11_terminate(void)
112{
tb@openbsd.org34843802018-02-05 05:37:46 +0000113 if (fd >= 0)
114 close(fd);
Damien Miller7ea845e2010-02-12 09:21:02 +1100115}
116
117static int
djm@openbsd.org93f02102019-01-20 22:51:37 +0000118rsa_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa, int padding)
Damien Miller7ea845e2010-02-12 09:21:02 +1100119{
djm@openbsd.org0c509922019-01-20 22:57:45 +0000120 struct sshkey *key = NULL;
121 struct sshbuf *msg = NULL;
122 u_char *blob = NULL, *signature = NULL;
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000123 size_t blen, slen = 0;
124 int r, ret = -1;
Damien Miller7ea845e2010-02-12 09:21:02 +1100125
126 if (padding != RSA_PKCS1_PADDING)
djm@openbsd.org0c509922019-01-20 22:57:45 +0000127 goto fail;
128 key = sshkey_new(KEY_UNSPEC);
129 if (key == NULL) {
130 error("%s: sshkey_new failed", __func__);
131 goto fail;
132 }
133 key->type = KEY_RSA;
134 RSA_up_ref(rsa);
135 key->rsa = rsa;
136 if ((r = sshkey_to_blob(key, &blob, &blen)) != 0) {
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000137 error("%s: sshkey_to_blob: %s", __func__, ssh_err(r));
djm@openbsd.org0c509922019-01-20 22:57:45 +0000138 goto fail;
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000139 }
140 if ((msg = sshbuf_new()) == NULL)
141 fatal("%s: sshbuf_new failed", __func__);
142 if ((r = sshbuf_put_u8(msg, SSH2_AGENTC_SIGN_REQUEST)) != 0 ||
143 (r = sshbuf_put_string(msg, blob, blen)) != 0 ||
144 (r = sshbuf_put_string(msg, from, flen)) != 0 ||
145 (r = sshbuf_put_u32(msg, 0)) != 0)
146 fatal("%s: buffer error: %s", __func__, ssh_err(r));
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000147 send_msg(msg);
148 sshbuf_reset(msg);
Damien Miller7ea845e2010-02-12 09:21:02 +1100149
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000150 if (recv_msg(msg) == SSH2_AGENT_SIGN_RESPONSE) {
151 if ((r = sshbuf_get_string(msg, &signature, &slen)) != 0)
152 fatal("%s: buffer error: %s", __func__, ssh_err(r));
153 if (slen <= (size_t)RSA_size(rsa)) {
Damien Miller7ea845e2010-02-12 09:21:02 +1100154 memcpy(to, signature, slen);
155 ret = slen;
156 }
Darren Tuckera627d422013-06-02 07:31:17 +1000157 free(signature);
Damien Miller7ea845e2010-02-12 09:21:02 +1100158 }
djm@openbsd.org0c509922019-01-20 22:57:45 +0000159 fail:
160 free(blob);
161 sshkey_free(key);
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000162 sshbuf_free(msg);
Damien Miller7ea845e2010-02-12 09:21:02 +1100163 return (ret);
164}
165
Damien Millere2cb4452019-01-21 11:32:28 +1100166#ifdef HAVE_EC_KEY_METHOD_NEW
djm@openbsd.org93f02102019-01-20 22:51:37 +0000167static ECDSA_SIG *
168ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv,
169 const BIGNUM *rp, EC_KEY *ec)
Damien Miller7ea845e2010-02-12 09:21:02 +1100170{
djm@openbsd.org0c509922019-01-20 22:57:45 +0000171 struct sshkey *key = NULL;
172 struct sshbuf *msg = NULL;
djm@openbsd.org93f02102019-01-20 22:51:37 +0000173 ECDSA_SIG *ret = NULL;
djm@openbsd.org0c509922019-01-20 22:57:45 +0000174 const u_char *cp;
175 u_char *blob = NULL, *signature = NULL;
176 size_t blen, slen = 0;
177 int r, nid;
djm@openbsd.org93f02102019-01-20 22:51:37 +0000178
djm@openbsd.org0c509922019-01-20 22:57:45 +0000179 nid = sshkey_ecdsa_key_to_nid(ec);
180 if (nid < 0) {
djm@openbsd.org93f02102019-01-20 22:51:37 +0000181 error("%s: couldn't get curve nid", __func__);
djm@openbsd.org0c509922019-01-20 22:57:45 +0000182 goto fail;
djm@openbsd.org93f02102019-01-20 22:51:37 +0000183 }
djm@openbsd.org0c509922019-01-20 22:57:45 +0000184
185 key = sshkey_new(KEY_UNSPEC);
186 if (key == NULL) {
187 error("%s: sshkey_new failed", __func__);
188 goto fail;
189 }
190 key->ecdsa = ec;
191 key->ecdsa_nid = nid;
192 key->type = KEY_ECDSA;
193 EC_KEY_up_ref(ec);
194
195 if ((r = sshkey_to_blob(key, &blob, &blen)) != 0) {
djm@openbsd.org93f02102019-01-20 22:51:37 +0000196 error("%s: sshkey_to_blob: %s", __func__, ssh_err(r));
djm@openbsd.org0c509922019-01-20 22:57:45 +0000197 goto fail;
djm@openbsd.org93f02102019-01-20 22:51:37 +0000198 }
199 if ((msg = sshbuf_new()) == NULL)
200 fatal("%s: sshbuf_new failed", __func__);
201 if ((r = sshbuf_put_u8(msg, SSH2_AGENTC_SIGN_REQUEST)) != 0 ||
202 (r = sshbuf_put_string(msg, blob, blen)) != 0 ||
203 (r = sshbuf_put_string(msg, dgst, dgst_len)) != 0 ||
204 (r = sshbuf_put_u32(msg, 0)) != 0)
205 fatal("%s: buffer error: %s", __func__, ssh_err(r));
djm@openbsd.org93f02102019-01-20 22:51:37 +0000206 send_msg(msg);
207 sshbuf_reset(msg);
208
209 if (recv_msg(msg) == SSH2_AGENT_SIGN_RESPONSE) {
210 if ((r = sshbuf_get_string(msg, &signature, &slen)) != 0)
211 fatal("%s: buffer error: %s", __func__, ssh_err(r));
212 cp = signature;
213 ret = d2i_ECDSA_SIG(NULL, &cp, slen);
214 free(signature);
215 }
216
djm@openbsd.org0c509922019-01-20 22:57:45 +0000217 fail:
218 free(blob);
219 sshkey_free(key);
djm@openbsd.org93f02102019-01-20 22:51:37 +0000220 sshbuf_free(msg);
221 return (ret);
222}
Damien Millere2cb4452019-01-21 11:32:28 +1100223#endif /* HAVE_EC_KEY_METHOD_NEW */
djm@openbsd.org93f02102019-01-20 22:51:37 +0000224
225static RSA_METHOD *helper_rsa;
Damien Millere2cb4452019-01-21 11:32:28 +1100226#ifdef HAVE_EC_KEY_METHOD_NEW
djm@openbsd.org93f02102019-01-20 22:51:37 +0000227static EC_KEY_METHOD *helper_ecdsa;
Damien Millere2cb4452019-01-21 11:32:28 +1100228#endif /* HAVE_EC_KEY_METHOD_NEW */
djm@openbsd.org93f02102019-01-20 22:51:37 +0000229
230/* redirect private key crypto operations to the ssh-pkcs11-helper */
231static void
232wrap_key(struct sshkey *k)
233{
234 if (k->type == KEY_RSA)
235 RSA_set_method(k->rsa, helper_rsa);
Damien Millere2cb4452019-01-21 11:32:28 +1100236#ifdef HAVE_EC_KEY_METHOD_NEW
djm@openbsd.org93f02102019-01-20 22:51:37 +0000237 else if (k->type == KEY_ECDSA)
238 EC_KEY_set_method(k->ecdsa, helper_ecdsa);
Damien Millere2cb4452019-01-21 11:32:28 +1100239#endif /* HAVE_EC_KEY_METHOD_NEW */
djm@openbsd.org93f02102019-01-20 22:51:37 +0000240 else
241 fatal("%s: unknown key type", __func__);
242}
243
244static int
245pkcs11_start_helper_methods(void)
246{
Damien Millere2cb4452019-01-21 11:32:28 +1100247 if (helper_rsa != NULL)
djm@openbsd.org93f02102019-01-20 22:51:37 +0000248 return (0);
249
Damien Millere2cb4452019-01-21 11:32:28 +1100250#ifdef HAVE_EC_KEY_METHOD_NEW
djm@openbsd.org93f02102019-01-20 22:51:37 +0000251 int (*orig_sign)(int, const unsigned char *, int, unsigned char *,
252 unsigned int *, const BIGNUM *, const BIGNUM *, EC_KEY *) = NULL;
253 if (helper_ecdsa != NULL)
254 return (0);
255 helper_ecdsa = EC_KEY_METHOD_new(EC_KEY_OpenSSL());
256 if (helper_ecdsa == NULL)
257 return (-1);
258 EC_KEY_METHOD_get_sign(helper_ecdsa, &orig_sign, NULL, NULL);
259 EC_KEY_METHOD_set_sign(helper_ecdsa, orig_sign, NULL, ecdsa_do_sign);
Damien Millere2cb4452019-01-21 11:32:28 +1100260#endif /* HAVE_EC_KEY_METHOD_NEW */
Damien Miller7ea845e2010-02-12 09:21:02 +1100261
djm@openbsd.org482d23b2018-09-13 02:08:33 +0000262 if ((helper_rsa = RSA_meth_dup(RSA_get_default_method())) == NULL)
263 fatal("%s: RSA_meth_dup failed", __func__);
264 if (!RSA_meth_set1_name(helper_rsa, "ssh-pkcs11-helper") ||
djm@openbsd.org93f02102019-01-20 22:51:37 +0000265 !RSA_meth_set_priv_enc(helper_rsa, rsa_encrypt))
djm@openbsd.org482d23b2018-09-13 02:08:33 +0000266 fatal("%s: failed to prepare method", __func__);
djm@openbsd.org93f02102019-01-20 22:51:37 +0000267
Damien Miller7ea845e2010-02-12 09:21:02 +1100268 return (0);
269}
270
271static int
272pkcs11_start_helper(void)
273{
274 int pair[2];
djm@openbsd.orgc7670b02019-01-21 12:53:35 +0000275 char *helper, *verbosity = NULL;
276
277 if (log_level_get() >= SYSLOG_LEVEL_DEBUG1)
278 verbosity = "-vvv";
Damien Miller7ea845e2010-02-12 09:21:02 +1100279
djm@openbsd.org93f02102019-01-20 22:51:37 +0000280 if (pkcs11_start_helper_methods() == -1) {
281 error("pkcs11_start_helper_methods failed");
282 return (-1);
283 }
284
Damien Miller7ea845e2010-02-12 09:21:02 +1100285 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) {
286 error("socketpair: %s", strerror(errno));
287 return (-1);
288 }
289 if ((pid = fork()) == -1) {
290 error("fork: %s", strerror(errno));
291 return (-1);
292 } else if (pid == 0) {
293 if ((dup2(pair[1], STDIN_FILENO) == -1) ||
294 (dup2(pair[1], STDOUT_FILENO) == -1)) {
295 fprintf(stderr, "dup2: %s\n", strerror(errno));
296 _exit(1);
297 }
298 close(pair[0]);
299 close(pair[1]);
djm@openbsd.org854bd862019-01-20 22:54:30 +0000300 helper = getenv("SSH_PKCS11_HELPER");
301 if (helper == NULL || strlen(helper) == 0)
302 helper = _PATH_SSH_PKCS11_HELPER;
djm@openbsd.orgc7670b02019-01-21 12:53:35 +0000303 debug("%s: starting %s %s", __func__, helper,
304 verbosity == NULL ? "" : verbosity);
305 execlp(helper, helper, verbosity, (char *)NULL);
djm@openbsd.org854bd862019-01-20 22:54:30 +0000306 fprintf(stderr, "exec: %s: %s\n", helper, strerror(errno));
Damien Miller7ea845e2010-02-12 09:21:02 +1100307 _exit(1);
308 }
309 close(pair[1]);
310 fd = pair[0];
311 return (0);
312}
313
314int
djm@openbsd.org89a8d452020-01-25 00:03:36 +0000315pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp,
316 char ***labelsp)
Damien Miller7ea845e2010-02-12 09:21:02 +1100317{
markus@openbsd.org54d90ac2017-05-30 08:52:19 +0000318 struct sshkey *k;
djm@openbsd.org93f02102019-01-20 22:51:37 +0000319 int r, type;
Damien Miller7ea845e2010-02-12 09:21:02 +1100320 u_char *blob;
djm@openbsd.org89a8d452020-01-25 00:03:36 +0000321 char *label;
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000322 size_t blen;
323 u_int nkeys, i;
324 struct sshbuf *msg;
Damien Miller7ea845e2010-02-12 09:21:02 +1100325
326 if (fd < 0 && pkcs11_start_helper() < 0)
327 return (-1);
328
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000329 if ((msg = sshbuf_new()) == NULL)
330 fatal("%s: sshbuf_new failed", __func__);
331 if ((r = sshbuf_put_u8(msg, SSH_AGENTC_ADD_SMARTCARD_KEY)) != 0 ||
332 (r = sshbuf_put_cstring(msg, name)) != 0 ||
333 (r = sshbuf_put_cstring(msg, pin)) != 0)
334 fatal("%s: buffer error: %s", __func__, ssh_err(r));
335 send_msg(msg);
336 sshbuf_reset(msg);
Damien Miller7ea845e2010-02-12 09:21:02 +1100337
djm@openbsd.org93f02102019-01-20 22:51:37 +0000338 type = recv_msg(msg);
339 if (type == SSH2_AGENT_IDENTITIES_ANSWER) {
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000340 if ((r = sshbuf_get_u32(msg, &nkeys)) != 0)
341 fatal("%s: buffer error: %s", __func__, ssh_err(r));
342 *keysp = xcalloc(nkeys, sizeof(struct sshkey *));
djm@openbsd.org89a8d452020-01-25 00:03:36 +0000343 if (labelsp)
344 *labelsp = xcalloc(nkeys, sizeof(char *));
Damien Miller7ea845e2010-02-12 09:21:02 +1100345 for (i = 0; i < nkeys; i++) {
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000346 /* XXX clean up properly instead of fatal() */
347 if ((r = sshbuf_get_string(msg, &blob, &blen)) != 0 ||
djm@openbsd.org89a8d452020-01-25 00:03:36 +0000348 (r = sshbuf_get_cstring(msg, &label, NULL)) != 0)
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000349 fatal("%s: buffer error: %s",
350 __func__, ssh_err(r));
351 if ((r = sshkey_from_blob(blob, blen, &k)) != 0)
352 fatal("%s: bad key: %s", __func__, ssh_err(r));
djm@openbsd.org93f02102019-01-20 22:51:37 +0000353 wrap_key(k);
Damien Miller7ea845e2010-02-12 09:21:02 +1100354 (*keysp)[i] = k;
djm@openbsd.org89a8d452020-01-25 00:03:36 +0000355 if (labelsp)
356 (*labelsp)[i] = label;
357 else
358 free(label);
Darren Tuckera627d422013-06-02 07:31:17 +1000359 free(blob);
Damien Miller7ea845e2010-02-12 09:21:02 +1100360 }
djm@openbsd.org93f02102019-01-20 22:51:37 +0000361 } else if (type == SSH2_AGENT_FAILURE) {
362 if ((r = sshbuf_get_u32(msg, &nkeys)) != 0)
363 nkeys = -1;
Damien Miller7ea845e2010-02-12 09:21:02 +1100364 } else {
365 nkeys = -1;
366 }
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000367 sshbuf_free(msg);
Damien Miller7ea845e2010-02-12 09:21:02 +1100368 return (nkeys);
369}
370
371int
372pkcs11_del_provider(char *name)
373{
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000374 int r, ret = -1;
375 struct sshbuf *msg;
Damien Miller7ea845e2010-02-12 09:21:02 +1100376
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000377 if ((msg = sshbuf_new()) == NULL)
378 fatal("%s: sshbuf_new failed", __func__);
379 if ((r = sshbuf_put_u8(msg, SSH_AGENTC_REMOVE_SMARTCARD_KEY)) != 0 ||
380 (r = sshbuf_put_cstring(msg, name)) != 0 ||
381 (r = sshbuf_put_cstring(msg, "")) != 0)
382 fatal("%s: buffer error: %s", __func__, ssh_err(r));
383 send_msg(msg);
384 sshbuf_reset(msg);
Damien Miller7ea845e2010-02-12 09:21:02 +1100385
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000386 if (recv_msg(msg) == SSH_AGENT_SUCCESS)
Damien Miller7ea845e2010-02-12 09:21:02 +1100387 ret = 0;
markus@openbsd.orgff55f4a2018-07-09 20:39:28 +0000388 sshbuf_free(msg);
Damien Miller7ea845e2010-02-12 09:21:02 +1100389 return (ret);
390}
Damien Millerdfa41562010-02-12 10:06:28 +1100391
392#endif /* ENABLE_PKCS11 */