blob: 78bb66b08f7b90f39bb0c1573eae8cee73455356 [file] [log] [blame]
markus@openbsd.org1b11ea72018-02-23 15:58:37 +00001/* $OpenBSD: ssh-keysign.c,v 1.54 2018/02/23 15:58:38 markus Exp $ */
Ben Lindstrom1bad2562002-06-06 19:57:33 +00002/*
3 * Copyright (c) 2002 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
Damien Millerd7834352006-08-05 12:39:39 +100025
Ben Lindstrom1bad2562002-06-06 19:57:33 +000026#include "includes.h"
Damien Miller03e20032006-03-15 11:16:59 +110027
Damien Miller57cf6382006-07-10 21:13:46 +100028#include <fcntl.h>
Damien Miller6645e7a2006-03-15 14:42:54 +110029#ifdef HAVE_PATHS_H
Damien Miller03e20032006-03-15 11:16:59 +110030#include <paths.h>
Damien Miller6645e7a2006-03-15 14:42:54 +110031#endif
Damien Miller9f2abc42006-07-10 20:53:08 +100032#include <pwd.h>
Damien Millerded319c2006-09-01 15:38:36 +100033#include <stdarg.h>
Damien Millere7a1e5c2006-08-05 11:34:19 +100034#include <stdlib.h>
Damien Millere3476ed2006-07-24 14:13:33 +100035#include <string.h>
Damien Millere6b3b612006-07-24 14:01:23 +100036#include <unistd.h>
djm@openbsd.org452c0b62015-11-29 22:18:37 +000037#include <errno.h>
Ben Lindstrom1bad2562002-06-06 19:57:33 +000038
Damien Miller72ef7c12015-01-15 02:21:31 +110039#ifdef WITH_OPENSSL
Ben Lindstrom1bad2562002-06-06 19:57:33 +000040#include <openssl/evp.h>
Ben Lindstrom43ce2c82002-07-04 00:17:33 +000041#include <openssl/rand.h>
42#include <openssl/rsa.h>
Damien Miller72ef7c12015-01-15 02:21:31 +110043#endif
Ben Lindstrom1bad2562002-06-06 19:57:33 +000044
Damien Millerd7834352006-08-05 12:39:39 +100045#include "xmalloc.h"
Ben Lindstrom1bad2562002-06-06 19:57:33 +000046#include "log.h"
djm@openbsd.org1129dcf2015-01-15 09:40:00 +000047#include "sshkey.h"
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +000048#include "ssh.h"
Ben Lindstrom1bad2562002-06-06 19:57:33 +000049#include "ssh2.h"
50#include "misc.h"
djm@openbsd.org1129dcf2015-01-15 09:40:00 +000051#include "sshbuf.h"
Ben Lindstrom1bad2562002-06-06 19:57:33 +000052#include "authfile.h"
53#include "msg.h"
54#include "canohost.h"
55#include "pathnames.h"
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +000056#include "readconf.h"
Darren Tucker25f60a72004-08-15 17:23:34 +100057#include "uidswap.h"
djm@openbsd.org1195f4c2015-01-08 10:14:08 +000058#include "sshkey.h"
59#include "ssherr.h"
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +000060
Damien Millerade31d72015-01-27 23:06:23 +110061struct ssh *active_state = NULL; /* XXX needed for linking */
62
djm@openbsd.org452c0b62015-11-29 22:18:37 +000063extern char *__progname;
64
Damien Miller20a8f972003-05-18 20:50:30 +100065/* XXX readconf.c needs these */
66uid_t original_real_uid;
Ben Lindstrom1bad2562002-06-06 19:57:33 +000067
Ben Lindstrom35453522002-06-07 14:37:00 +000068extern char *__progname;
Ben Lindstrom35453522002-06-07 14:37:00 +000069
Ben Lindstrom1bad2562002-06-06 19:57:33 +000070static int
djm@openbsd.org1129dcf2015-01-15 09:40:00 +000071valid_request(struct passwd *pw, char *host, struct sshkey **ret,
72 u_char *data, size_t datalen)
Ben Lindstrom1bad2562002-06-06 19:57:33 +000073{
djm@openbsd.org1129dcf2015-01-15 09:40:00 +000074 struct sshbuf *b;
75 struct sshkey *key = NULL;
76 u_char type, *pkblob;
77 char *p;
78 size_t blen, len;
79 char *pkalg, *luser;
80 int r, pktype, fail;
Ben Lindstrom1bad2562002-06-06 19:57:33 +000081
djm@openbsd.org1195f4c2015-01-08 10:14:08 +000082 if (ret != NULL)
83 *ret = NULL;
Ben Lindstrom1bad2562002-06-06 19:57:33 +000084 fail = 0;
85
djm@openbsd.org1129dcf2015-01-15 09:40:00 +000086 if ((b = sshbuf_from(data, datalen)) == NULL)
87 fatal("%s: sshbuf_from failed", __func__);
Ben Lindstromcb72e4f2002-06-21 00:41:51 +000088
Damien Miller603e68f2006-04-23 12:05:32 +100089 /* session id, currently limited to SHA1 (20 bytes) or SHA256 (32) */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +000090 if ((r = sshbuf_get_string(b, NULL, &len)) != 0)
91 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Damien Miller603e68f2006-04-23 12:05:32 +100092 if (len != 20 && len != 32)
Ben Lindstroma2071572002-06-09 20:01:48 +000093 fail++;
Ben Lindstroma2071572002-06-09 20:01:48 +000094
djm@openbsd.org1129dcf2015-01-15 09:40:00 +000095 if ((r = sshbuf_get_u8(b, &type)) != 0)
96 fatal("%s: buffer error: %s", __func__, ssh_err(r));
97 if (type != SSH2_MSG_USERAUTH_REQUEST)
Ben Lindstrom1bad2562002-06-06 19:57:33 +000098 fail++;
99
100 /* server user */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000101 if ((r = sshbuf_skip_string(b)) != 0)
102 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000103
104 /* service */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000105 if ((r = sshbuf_get_cstring(b, &p, NULL)) != 0)
106 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000107 if (strcmp("ssh-connection", p) != 0)
108 fail++;
Darren Tuckera627d422013-06-02 07:31:17 +1000109 free(p);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000110
111 /* method */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000112 if ((r = sshbuf_get_cstring(b, &p, NULL)) != 0)
113 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000114 if (strcmp("hostbased", p) != 0)
115 fail++;
Darren Tuckera627d422013-06-02 07:31:17 +1000116 free(p);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000117
118 /* pubkey */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000119 if ((r = sshbuf_get_cstring(b, &pkalg, NULL)) != 0 ||
120 (r = sshbuf_get_string(b, &pkblob, &blen)) != 0)
121 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000122
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000123 pktype = sshkey_type_from_name(pkalg);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000124 if (pktype == KEY_UNSPEC)
125 fail++;
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000126 else if ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) {
127 error("%s: bad key blob: %s", __func__, ssh_err(r));
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000128 fail++;
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000129 } else if (key->type != pktype)
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000130 fail++;
Darren Tuckera627d422013-06-02 07:31:17 +1000131 free(pkalg);
132 free(pkblob);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000133
134 /* client host name, handle trailing dot */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000135 if ((r = sshbuf_get_cstring(b, &p, &len)) != 0)
136 fatal("%s: buffer error: %s", __func__, ssh_err(r));
137 debug2("%s: check expect chost %s got %s", __func__, host, p);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000138 if (strlen(host) != len - 1)
139 fail++;
140 else if (p[len - 1] != '.')
Ben Lindstromcb72e4f2002-06-21 00:41:51 +0000141 fail++;
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000142 else if (strncasecmp(host, p, len - 1) != 0)
Ben Lindstromcb72e4f2002-06-21 00:41:51 +0000143 fail++;
Darren Tuckera627d422013-06-02 07:31:17 +1000144 free(p);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000145
146 /* local user */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000147 if ((r = sshbuf_get_cstring(b, &luser, NULL)) != 0)
148 fatal("%s: buffer error: %s", __func__, ssh_err(r));
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000149
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000150 if (strcmp(pw->pw_name, luser) != 0)
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000151 fail++;
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000152 free(luser);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000153
154 /* end of message */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000155 if (sshbuf_len(b) != 0)
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000156 fail++;
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000157 sshbuf_free(b);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000158
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000159 debug3("%s: fail %d", __func__, fail);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000160
dtucker@openbsd.orgf1f047f2018-02-07 22:52:45 +0000161 if (fail)
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000162 sshkey_free(key);
markus@openbsd.org7d4f96f2015-03-24 20:09:11 +0000163 else if (ret != NULL)
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000164 *ret = key;
165
166 return (fail ? -1 : 0);
167}
168
169int
170main(int argc, char **argv)
171{
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000172 struct sshbuf *b;
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +0000173 Options options;
markus@openbsd.org1b11ea72018-02-23 15:58:37 +0000174#define NUM_KEYTYPES 5
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000175 struct sshkey *keys[NUM_KEYTYPES], *key = NULL;
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000176 struct passwd *pw;
djm@openbsd.org1195f4c2015-01-08 10:14:08 +0000177 int r, key_fd[NUM_KEYTYPES], i, found, version = 2, fd;
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000178 u_char *signature, *data, rver;
Damien Millerfcd62c02014-04-20 13:23:21 +1000179 char *host, *fp;
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000180 size_t slen, dlen;
Damien Miller72ef7c12015-01-15 02:21:31 +1100181#ifdef WITH_OPENSSL
Ben Lindstrom43ce2c82002-07-04 00:17:33 +0000182 u_int32_t rnd[256];
Damien Miller72ef7c12015-01-15 02:21:31 +1100183#endif
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000184
dtucker@openbsd.orgffb1e7e2016-02-15 09:47:49 +0000185 ssh_malloc_init(); /* must be called before any mallocs */
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000186 if (pledge("stdio rpath getpw dns id", NULL) != 0)
187 fatal("%s: pledge: %s", __progname, strerror(errno));
188
Darren Tuckerce321d82005-10-03 18:11:24 +1000189 /* Ensure that stdin and stdout are connected */
190 if ((fd = open(_PATH_DEVNULL, O_RDWR)) < 2)
191 exit(1);
192 /* Leave /dev/null fd iff it is attached to stderr */
193 if (fd > 2)
194 close(fd);
195
Damien Miller0588beb2011-02-18 09:18:45 +1100196 i = 0;
djm@openbsd.orgb1f383d2015-07-03 03:56:25 +0000197 /* XXX This really needs to read sshd_config for the paths */
Damien Miller0588beb2011-02-18 09:18:45 +1100198 key_fd[i++] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY);
199 key_fd[i++] = open(_PATH_HOST_ECDSA_KEY_FILE, O_RDONLY);
Damien Miller5be9d9e2013-12-07 11:24:01 +1100200 key_fd[i++] = open(_PATH_HOST_ED25519_KEY_FILE, O_RDONLY);
markus@openbsd.org1b11ea72018-02-23 15:58:37 +0000201 key_fd[i++] = open(_PATH_HOST_XMSS_KEY_FILE, O_RDONLY);
Damien Miller0588beb2011-02-18 09:18:45 +1100202 key_fd[i++] = open(_PATH_HOST_RSA_KEY_FILE, O_RDONLY);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000203
Darren Tucker34620d62004-08-29 16:32:59 +1000204 original_real_uid = getuid(); /* XXX readconf.c needs this */
205 if ((pw = getpwuid(original_real_uid)) == NULL)
Darren Tucker25f60a72004-08-15 17:23:34 +1000206 fatal("getpwuid failed");
207 pw = pwcopy(pw);
208
209 permanently_set_uid(pw);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000210
Ben Lindstrom5a6abda2002-06-09 19:41:48 +0000211 seed_rng();
Ben Lindstromdb41d232002-06-07 03:11:38 +0000212
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000213#ifdef DEBUG_SSH_KEYSIGN
214 log_init("ssh-keysign", SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 0);
Ben Lindstromcb72e4f2002-06-21 00:41:51 +0000215#endif
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000216
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +0000217 /* verify that ssh-keysign is enabled by the admin */
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +0000218 initialize_options(&options);
djm@openbsd.org957fbce2014-10-08 22:20:25 +0000219 (void)read_config_file(_PATH_HOST_CONFIG_FILE, pw, "", "", &options, 0);
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +0000220 fill_default_options(&options);
Ben Lindstromb6df73b2002-11-09 15:52:31 +0000221 if (options.enable_ssh_keysign != 1)
222 fatal("ssh-keysign not enabled in %s",
Ben Lindstrom5d35a2f2002-07-04 00:19:40 +0000223 _PATH_HOST_CONFIG_FILE);
224
Damien Miller0588beb2011-02-18 09:18:45 +1100225 for (i = found = 0; i < NUM_KEYTYPES; i++) {
226 if (key_fd[i] != -1)
227 found = 1;
228 }
229 if (found == 0)
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000230 fatal("could not open any host key");
231
Damien Miller72ef7c12015-01-15 02:21:31 +1100232#ifdef WITH_OPENSSL
Damien Miller4314c2b2010-09-10 11:12:09 +1000233 OpenSSL_add_all_algorithms();
Damien Millerfcd62c02014-04-20 13:23:21 +1000234 arc4random_buf(rnd, sizeof(rnd));
Ben Lindstrom43ce2c82002-07-04 00:17:33 +0000235 RAND_seed(rnd, sizeof(rnd));
Damien Miller72ef7c12015-01-15 02:21:31 +1100236#endif
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000237
238 found = 0;
Damien Miller0588beb2011-02-18 09:18:45 +1100239 for (i = 0; i < NUM_KEYTYPES; i++) {
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000240 keys[i] = NULL;
241 if (key_fd[i] == -1)
242 continue;
djm@openbsd.org1195f4c2015-01-08 10:14:08 +0000243 r = sshkey_load_private_type_fd(key_fd[i], KEY_UNSPEC,
244 NULL, &key, NULL);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000245 close(key_fd[i]);
djm@openbsd.org1195f4c2015-01-08 10:14:08 +0000246 if (r != 0)
247 debug("parse key %d: %s", i, ssh_err(r));
248 else if (key != NULL) {
249 keys[i] = key;
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000250 found = 1;
djm@openbsd.org1195f4c2015-01-08 10:14:08 +0000251 }
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000252 }
253 if (!found)
254 fatal("no hostkey found");
255
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000256 if (pledge("stdio dns", NULL) != 0)
257 fatal("%s: pledge: %s", __progname, strerror(errno));
258
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000259 if ((b = sshbuf_new()) == NULL)
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000260 fatal("%s: sshbuf_new failed", __progname);
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000261 if (ssh_msg_recv(STDIN_FILENO, b) < 0)
Damien Miller901119b2002-10-04 11:10:04 +1000262 fatal("ssh_msg_recv failed");
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000263 if ((r = sshbuf_get_u8(b, &rver)) != 0)
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000264 fatal("%s: buffer error: %s", __progname, ssh_err(r));
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000265 if (rver != version)
266 fatal("bad version: received %d, expected %d", rver, version);
267 if ((r = sshbuf_get_u32(b, (u_int *)&fd)) != 0)
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000268 fatal("%s: buffer error: %s", __progname, ssh_err(r));
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000269 if (fd < 0 || fd == STDIN_FILENO || fd == STDOUT_FILENO)
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000270 fatal("bad fd");
271 if ((host = get_local_name(fd)) == NULL)
Darren Tuckerdaaa4502010-01-13 22:43:33 +1100272 fatal("cannot get local name for fd");
Ben Lindstromcb72e4f2002-06-21 00:41:51 +0000273
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000274 if ((r = sshbuf_get_string(b, &data, &dlen)) != 0)
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000275 fatal("%s: buffer error: %s", __progname, ssh_err(r));
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000276 if (valid_request(pw, host, &key, data, dlen) < 0)
277 fatal("not a valid request");
Darren Tuckera627d422013-06-02 07:31:17 +1000278 free(host);
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000279
280 found = 0;
Damien Miller0588beb2011-02-18 09:18:45 +1100281 for (i = 0; i < NUM_KEYTYPES; i++) {
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000282 if (keys[i] != NULL &&
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000283 sshkey_equal_public(key, keys[i])) {
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000284 found = 1;
285 break;
286 }
287 }
Damien Millerfcd62c02014-04-20 13:23:21 +1000288 if (!found) {
djm@openbsd.org9ce86c92015-01-28 22:36:00 +0000289 if ((fp = sshkey_fingerprint(key, options.fingerprint_hash,
290 SSH_FP_DEFAULT)) == NULL)
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000291 fatal("%s: sshkey_fingerprint failed", __progname);
Damien Millerfcd62c02014-04-20 13:23:21 +1000292 fatal("no matching hostkey found for key %s %s",
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000293 sshkey_type(key), fp ? fp : "");
Damien Millerfcd62c02014-04-20 13:23:21 +1000294 }
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000295
markus@openbsd.org76c9fbb2015-12-04 16:41:28 +0000296 if ((r = sshkey_sign(keys[i], &signature, &slen, data, dlen, NULL, 0))
297 != 0)
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000298 fatal("sshkey_sign failed: %s", ssh_err(r));
Darren Tuckera627d422013-06-02 07:31:17 +1000299 free(data);
Ben Lindstromcb72e4f2002-06-21 00:41:51 +0000300
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000301 /* send reply */
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000302 sshbuf_reset(b);
303 if ((r = sshbuf_put_string(b, signature, slen)) != 0)
djm@openbsd.org452c0b62015-11-29 22:18:37 +0000304 fatal("%s: buffer error: %s", __progname, ssh_err(r));
djm@openbsd.org1129dcf2015-01-15 09:40:00 +0000305 if (ssh_msg_send(STDOUT_FILENO, version, b) == -1)
Damien Miller51bf11f2003-11-17 21:20:47 +1100306 fatal("ssh_msg_send failed");
Ben Lindstrom1bad2562002-06-06 19:57:33 +0000307
308 return (0);
309}