blob: a34e111ac140bf9bc5226b90767fca65b5f481f2 [file] [log] [blame]
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001/*
Damien Miller4af51302000-04-16 11:18:38 +10002 *
Damien Miller95def091999-11-25 00:26:21 +11003 * authfd.c
Damien Miller4af51302000-04-16 11:18:38 +10004 *
Damien Miller95def091999-11-25 00:26:21 +11005 * Author: Tatu Ylonen <ylo@cs.hut.fi>
Damien Miller4af51302000-04-16 11:18:38 +10006 *
Damien Miller95def091999-11-25 00:26:21 +11007 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
Damien Miller4af51302000-04-16 11:18:38 +10009 *
Damien Miller95def091999-11-25 00:26:21 +110010 * Created: Wed Mar 29 01:30:28 1995 ylo
Damien Miller4af51302000-04-16 11:18:38 +100011 *
Damien Miller95def091999-11-25 00:26:21 +110012 * Functions for connecting the local authentication agent.
Damien Miller4af51302000-04-16 11:18:38 +100013 *
Damien Miller95def091999-11-25 00:26:21 +110014 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100015
16#include "includes.h"
Damien Miller942da032000-08-18 13:59:06 +100017RCSID("$OpenBSD: authfd.c,v 1.24 2000/08/15 19:20:46 markus Exp $");
Damien Millerd4a8b7e1999-10-27 13:42:43 +100018
19#include "ssh.h"
20#include "rsa.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100021#include "buffer.h"
22#include "bufaux.h"
23#include "xmalloc.h"
24#include "getput.h"
25
26#include <openssl/rsa.h>
Damien Miller994cf142000-07-21 10:19:44 +100027#include <openssl/dsa.h>
28#include <openssl/evp.h>
29#include "key.h"
30#include "authfd.h"
31#include "kex.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100032
Damien Miller37023962000-07-11 17:31:38 +100033/* helper */
Damien Miller942da032000-08-18 13:59:06 +100034int decode_reply(int type);
Damien Miller37023962000-07-11 17:31:38 +100035
Damien Millerd4a8b7e1999-10-27 13:42:43 +100036/* Returns the number of the authentication fd, or -1 if there is none. */
37
38int
39ssh_get_authentication_socket()
40{
Damien Miller95def091999-11-25 00:26:21 +110041 const char *authsocket;
Damien Miller942da032000-08-18 13:59:06 +100042 int sock, len;
Damien Miller95def091999-11-25 00:26:21 +110043 struct sockaddr_un sunaddr;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100044
Damien Miller95def091999-11-25 00:26:21 +110045 authsocket = getenv(SSH_AUTHSOCKET_ENV_NAME);
46 if (!authsocket)
47 return -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100048
Damien Miller95def091999-11-25 00:26:21 +110049 sunaddr.sun_family = AF_UNIX;
50 strlcpy(sunaddr.sun_path, authsocket, sizeof(sunaddr.sun_path));
Damien Miller942da032000-08-18 13:59:06 +100051#ifdef HAVE_SUN_LEN_IN_SOCKADDR_UN
52 sunaddr.sun_len = len = SUN_LEN(&sunaddr)+1;
53#else /* HAVE_SUN_LEN_IN_SOCKADDR_UN */
54 len = SUN_LEN(&sunaddr)+1;
55#endif /* HAVE_SUN_LEN_IN_SOCKADDR_UN */
Damien Miller10f6f6b1999-11-17 17:29:08 +110056
Damien Miller95def091999-11-25 00:26:21 +110057 sock = socket(AF_UNIX, SOCK_STREAM, 0);
58 if (sock < 0)
59 return -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100060
Damien Miller95def091999-11-25 00:26:21 +110061 /* close on exec */
62 if (fcntl(sock, F_SETFD, 1) == -1) {
63 close(sock);
64 return -1;
65 }
Damien Miller942da032000-08-18 13:59:06 +100066 if (connect(sock, (struct sockaddr *) & sunaddr, len) < 0) {
Damien Miller95def091999-11-25 00:26:21 +110067 close(sock);
68 return -1;
69 }
70 return sock;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100071}
72
Damien Miller942da032000-08-18 13:59:06 +100073int
74ssh_request_reply(AuthenticationConnection *auth,
75 Buffer *request, Buffer *reply)
76{
77 int l, len;
78 char buf[1024];
79
80 /* Get the length of the message, and format it in the buffer. */
81 len = buffer_len(request);
82 PUT_32BIT(buf, len);
83
84 /* Send the length and then the packet to the agent. */
85 if (atomicio(write, auth->fd, buf, 4) != 4 ||
86 atomicio(write, auth->fd, buffer_ptr(request),
87 buffer_len(request)) != buffer_len(request)) {
88 error("Error writing to authentication socket.");
89 return 0;
90 }
91 /*
92 * Wait for response from the agent. First read the length of the
93 * response packet.
94 */
95 len = 4;
96 while (len > 0) {
97 l = read(auth->fd, buf + 4 - len, len);
98 if (l <= 0) {
99 error("Error reading response length from authentication socket.");
100 return 0;
101 }
102 len -= l;
103 }
104
105 /* Extract the length, and check it for sanity. */
106 len = GET_32BIT(buf);
107 if (len > 256 * 1024)
108 fatal("Authentication response too long: %d", len);
109
110 /* Read the rest of the response in to the buffer. */
111 buffer_clear(reply);
112 while (len > 0) {
113 l = len;
114 if (l > sizeof(buf))
115 l = sizeof(buf);
116 l = read(auth->fd, buf, l);
117 if (l <= 0) {
118 error("Error reading response from authentication socket.");
119 return 0;
120 }
121 buffer_append(reply, (char *) buf, l);
122 len -= l;
123 }
124 return 1;
125}
126
Damien Miller5428f641999-11-25 11:54:57 +1100127/*
128 * Closes the agent socket if it should be closed (depends on how it was
129 * obtained). The argument must have been returned by
130 * ssh_get_authentication_socket().
131 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000132
Damien Miller4af51302000-04-16 11:18:38 +1000133void
Damien Miller95def091999-11-25 00:26:21 +1100134ssh_close_authentication_socket(int sock)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000135{
Damien Miller95def091999-11-25 00:26:21 +1100136 if (getenv(SSH_AUTHSOCKET_ENV_NAME))
137 close(sock);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000138}
139
Damien Miller5428f641999-11-25 11:54:57 +1100140/*
141 * Opens and connects a private socket for communication with the
142 * authentication agent. Returns the file descriptor (which must be
143 * shut down and closed by the caller when no longer needed).
144 * Returns NULL if an error occurred and the connection could not be
145 * opened.
146 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000147
Damien Miller95def091999-11-25 00:26:21 +1100148AuthenticationConnection *
149ssh_get_authentication_connection()
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000150{
Damien Miller95def091999-11-25 00:26:21 +1100151 AuthenticationConnection *auth;
152 int sock;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000153
Damien Miller95def091999-11-25 00:26:21 +1100154 sock = ssh_get_authentication_socket();
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000155
Damien Miller5428f641999-11-25 11:54:57 +1100156 /*
157 * Fail if we couldn't obtain a connection. This happens if we
158 * exited due to a timeout.
159 */
Damien Miller95def091999-11-25 00:26:21 +1100160 if (sock < 0)
161 return NULL;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000162
Damien Miller95def091999-11-25 00:26:21 +1100163 auth = xmalloc(sizeof(*auth));
164 auth->fd = sock;
165 buffer_init(&auth->packet);
166 buffer_init(&auth->identities);
167 auth->howmany = 0;
168
169 return auth;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000170}
171
Damien Miller5428f641999-11-25 11:54:57 +1100172/*
173 * Closes the connection to the authentication agent and frees any associated
174 * memory.
175 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000176
Damien Miller4af51302000-04-16 11:18:38 +1000177void
Damien Miller95def091999-11-25 00:26:21 +1100178ssh_close_authentication_connection(AuthenticationConnection *ac)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000179{
Damien Miller95def091999-11-25 00:26:21 +1100180 buffer_free(&ac->packet);
181 buffer_free(&ac->identities);
182 close(ac->fd);
183 xfree(ac);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000184}
185
Damien Miller5428f641999-11-25 11:54:57 +1100186/*
187 * Returns the first authentication identity held by the agent.
188 * Returns true if an identity is available, 0 otherwise.
189 * The caller must initialize the integers before the call, and free the
190 * comment after a successful call (before calling ssh_get_next_identity).
191 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000192
193int
194ssh_get_first_identity(AuthenticationConnection *auth,
Damien Miller942da032000-08-18 13:59:06 +1000195 BIGNUM *e, BIGNUM *n, char **comment)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000196{
Damien Miller942da032000-08-18 13:59:06 +1000197 Buffer request;
198 int type;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000199
Damien Miller5428f641999-11-25 11:54:57 +1100200 /*
201 * Send a message to the agent requesting for a list of the
202 * identities it can represent.
203 */
Damien Miller942da032000-08-18 13:59:06 +1000204 buffer_init(&request);
205 buffer_put_char(&request, SSH_AGENTC_REQUEST_RSA_IDENTITIES);
206
207 buffer_clear(&auth->identities);
208 if (ssh_request_reply(auth, &request, &auth->identities) == 0) {
209 buffer_free(&request);
Damien Miller95def091999-11-25 00:26:21 +1100210 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000211 }
Damien Miller942da032000-08-18 13:59:06 +1000212 buffer_free(&request);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000213
Damien Miller95def091999-11-25 00:26:21 +1100214 /* Get message type, and verify that we got a proper answer. */
Damien Miller942da032000-08-18 13:59:06 +1000215 type = buffer_get_char(&auth->identities);
216 if (type != SSH_AGENT_RSA_IDENTITIES_ANSWER)
217 fatal("Bad authentication reply message type: %d", type);
Damien Miller95def091999-11-25 00:26:21 +1100218
219 /* Get the number of entries in the response and check it for sanity. */
220 auth->howmany = buffer_get_int(&auth->identities);
221 if (auth->howmany > 1024)
Damien Miller942da032000-08-18 13:59:06 +1000222 fatal("Too many identities in authentication reply: %d\n",
223 auth->howmany);
Damien Miller95def091999-11-25 00:26:21 +1100224
225 /* Return the first entry (if any). */
226 return ssh_get_next_identity(auth, e, n, comment);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000227}
228
Damien Miller5428f641999-11-25 11:54:57 +1100229/*
230 * Returns the next authentication identity for the agent. Other functions
231 * can be called between this and ssh_get_first_identity or two calls of this
232 * function. This returns 0 if there are no more identities. The caller
233 * must free comment after a successful return.
234 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000235
236int
237ssh_get_next_identity(AuthenticationConnection *auth,
Damien Miller942da032000-08-18 13:59:06 +1000238 BIGNUM *e, BIGNUM *n, char **comment)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000239{
Damien Miller95def091999-11-25 00:26:21 +1100240 unsigned int bits;
Damien Miller7e8e8201999-11-16 13:37:16 +1100241
Damien Miller95def091999-11-25 00:26:21 +1100242 /* Return failure if no more entries. */
243 if (auth->howmany <= 0)
244 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000245
Damien Miller5428f641999-11-25 11:54:57 +1100246 /*
247 * Get the next entry from the packet. These will abort with a fatal
248 * error if the packet is too short or contains corrupt data.
249 */
Damien Miller95def091999-11-25 00:26:21 +1100250 bits = buffer_get_int(&auth->identities);
251 buffer_get_bignum(&auth->identities, e);
252 buffer_get_bignum(&auth->identities, n);
253 *comment = buffer_get_string(&auth->identities, NULL);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000254
Damien Miller95def091999-11-25 00:26:21 +1100255 if (bits != BN_num_bits(n))
Damien Millerbd483e72000-04-30 10:00:53 +1000256 log("Warning: identity keysize mismatch: actual %d, announced %u",
257 BN_num_bits(n), bits);
Damien Miller7e8e8201999-11-16 13:37:16 +1100258
Damien Miller95def091999-11-25 00:26:21 +1100259 /* Decrement the number of remaining entries. */
260 auth->howmany--;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000261
Damien Miller95def091999-11-25 00:26:21 +1100262 return 1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000263}
264
Damien Miller5428f641999-11-25 11:54:57 +1100265/*
266 * Generates a random challenge, sends it to the agent, and waits for
267 * response from the agent. Returns true (non-zero) if the agent gave the
268 * correct answer, zero otherwise. Response type selects the style of
269 * response desired, with 0 corresponding to protocol version 1.0 (no longer
270 * supported) and 1 corresponding to protocol version 1.1.
271 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000272
273int
274ssh_decrypt_challenge(AuthenticationConnection *auth,
Damien Miller942da032000-08-18 13:59:06 +1000275 BIGNUM* e, BIGNUM *n, BIGNUM *challenge,
276 unsigned char session_id[16],
277 unsigned int response_type,
278 unsigned char response[16])
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000279{
Damien Miller95def091999-11-25 00:26:21 +1100280 Buffer buffer;
Damien Miller942da032000-08-18 13:59:06 +1000281 int success = 0;
282 int i;
283 int type;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000284
Damien Miller95def091999-11-25 00:26:21 +1100285 if (response_type == 0)
Damien Miller942da032000-08-18 13:59:06 +1000286 fatal("Compatibility with ssh protocol version "
287 "1.0 no longer supported.");
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000288
Damien Miller95def091999-11-25 00:26:21 +1100289 buffer_init(&buffer);
Damien Miller942da032000-08-18 13:59:06 +1000290 buffer_put_char(&buffer, SSH_AGENTC_RSA_CHALLENGE);
Damien Miller95def091999-11-25 00:26:21 +1100291 buffer_put_int(&buffer, BN_num_bits(n));
292 buffer_put_bignum(&buffer, e);
293 buffer_put_bignum(&buffer, n);
294 buffer_put_bignum(&buffer, challenge);
295 buffer_append(&buffer, (char *) session_id, 16);
296 buffer_put_int(&buffer, response_type);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000297
Damien Miller942da032000-08-18 13:59:06 +1000298 if (ssh_request_reply(auth, &buffer, &buffer) == 0) {
Damien Miller95def091999-11-25 00:26:21 +1100299 buffer_free(&buffer);
300 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000301 }
Damien Miller942da032000-08-18 13:59:06 +1000302 type = buffer_get_char(&buffer);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000303
Damien Miller942da032000-08-18 13:59:06 +1000304 if (type == SSH_AGENT_FAILURE) {
Damien Miller95def091999-11-25 00:26:21 +1100305 log("Agent admitted failure to authenticate using the key.");
Damien Miller942da032000-08-18 13:59:06 +1000306 } else if (type != SSH_AGENT_RSA_RESPONSE) {
307 fatal("Bad authentication response: %d", type);
308 } else {
309 success = 1;
310 /*
311 * Get the response from the packet. This will abort with a
312 * fatal error if the packet is corrupt.
313 */
314 for (i = 0; i < 16; i++)
315 response[i] = buffer_get_char(&buffer);
Damien Miller95def091999-11-25 00:26:21 +1100316 }
Damien Miller95def091999-11-25 00:26:21 +1100317 buffer_free(&buffer);
Damien Miller942da032000-08-18 13:59:06 +1000318 return success;
Damien Miller95def091999-11-25 00:26:21 +1100319}
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000320
Damien Miller994cf142000-07-21 10:19:44 +1000321/* Encode key for a message to the agent. */
322
323void
324ssh_encode_identity_rsa(Buffer *b, RSA *key, const char *comment)
325{
326 buffer_clear(b);
327 buffer_put_char(b, SSH_AGENTC_ADD_RSA_IDENTITY);
328 buffer_put_int(b, BN_num_bits(key->n));
329 buffer_put_bignum(b, key->n);
330 buffer_put_bignum(b, key->e);
331 buffer_put_bignum(b, key->d);
332 /* To keep within the protocol: p < q for ssh. in SSL p > q */
333 buffer_put_bignum(b, key->iqmp); /* ssh key->u */
334 buffer_put_bignum(b, key->q); /* ssh key->p, SSL key->q */
335 buffer_put_bignum(b, key->p); /* ssh key->q, SSL key->p */
336 buffer_put_string(b, comment, strlen(comment));
337}
338
339void
340ssh_encode_identity_dsa(Buffer *b, DSA *key, const char *comment)
341{
342 buffer_clear(b);
343 buffer_put_char(b, SSH2_AGENTC_ADD_IDENTITY);
344 buffer_put_cstring(b, KEX_DSS);
345 buffer_put_bignum2(b, key->p);
346 buffer_put_bignum2(b, key->q);
347 buffer_put_bignum2(b, key->g);
348 buffer_put_bignum2(b, key->pub_key);
349 buffer_put_bignum2(b, key->priv_key);
350 buffer_put_string(b, comment, strlen(comment));
351}
352
Damien Miller5428f641999-11-25 11:54:57 +1100353/*
354 * Adds an identity to the authentication server. This call is not meant to
355 * be used by normal applications.
356 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000357
Damien Miller4af51302000-04-16 11:18:38 +1000358int
Damien Miller994cf142000-07-21 10:19:44 +1000359ssh_add_identity(AuthenticationConnection *auth, Key *key, const char *comment)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000360{
Damien Miller95def091999-11-25 00:26:21 +1100361 Buffer buffer;
Damien Miller942da032000-08-18 13:59:06 +1000362 int type;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000363
Damien Miller95def091999-11-25 00:26:21 +1100364 buffer_init(&buffer);
Damien Miller994cf142000-07-21 10:19:44 +1000365
366 switch (key->type) {
367 case KEY_RSA:
368 ssh_encode_identity_rsa(&buffer, key->rsa, comment);
369 break;
370 case KEY_DSA:
371 ssh_encode_identity_dsa(&buffer, key->dsa, comment);
372 break;
373 default:
374 buffer_free(&buffer);
375 return 0;
376 break;
377 }
Damien Miller942da032000-08-18 13:59:06 +1000378 if (ssh_request_reply(auth, &buffer, &buffer) == 0) {
Damien Miller95def091999-11-25 00:26:21 +1100379 buffer_free(&buffer);
380 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000381 }
Damien Miller942da032000-08-18 13:59:06 +1000382 type = buffer_get_char(&buffer);
Damien Miller37023962000-07-11 17:31:38 +1000383 buffer_free(&buffer);
Damien Miller942da032000-08-18 13:59:06 +1000384 return decode_reply(type);
Damien Miller95def091999-11-25 00:26:21 +1100385}
386
Damien Miller5428f641999-11-25 11:54:57 +1100387/*
388 * Removes an identity from the authentication server. This call is not
389 * meant to be used by normal applications.
390 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000391
Damien Miller4af51302000-04-16 11:18:38 +1000392int
Damien Miller95def091999-11-25 00:26:21 +1100393ssh_remove_identity(AuthenticationConnection *auth, RSA *key)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000394{
Damien Miller95def091999-11-25 00:26:21 +1100395 Buffer buffer;
Damien Miller942da032000-08-18 13:59:06 +1000396 int type;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000397
Damien Miller95def091999-11-25 00:26:21 +1100398 buffer_init(&buffer);
399 buffer_put_char(&buffer, SSH_AGENTC_REMOVE_RSA_IDENTITY);
400 buffer_put_int(&buffer, BN_num_bits(key->n));
401 buffer_put_bignum(&buffer, key->e);
402 buffer_put_bignum(&buffer, key->n);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000403
Damien Miller942da032000-08-18 13:59:06 +1000404 if (ssh_request_reply(auth, &buffer, &buffer) == 0) {
Damien Miller95def091999-11-25 00:26:21 +1100405 buffer_free(&buffer);
406 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000407 }
Damien Miller942da032000-08-18 13:59:06 +1000408 type = buffer_get_char(&buffer);
Damien Miller37023962000-07-11 17:31:38 +1000409 buffer_free(&buffer);
Damien Miller942da032000-08-18 13:59:06 +1000410 return decode_reply(type);
Damien Miller95def091999-11-25 00:26:21 +1100411}
412
Damien Miller5428f641999-11-25 11:54:57 +1100413/*
414 * Removes all identities from the agent. This call is not meant to be used
415 * by normal applications.
416 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000417
Damien Miller4af51302000-04-16 11:18:38 +1000418int
Damien Miller95def091999-11-25 00:26:21 +1100419ssh_remove_all_identities(AuthenticationConnection *auth)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000420{
Damien Miller942da032000-08-18 13:59:06 +1000421 Buffer buffer;
422 int type;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000423
Damien Miller942da032000-08-18 13:59:06 +1000424 buffer_init(&buffer);
425 buffer_put_char(&buffer, SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000426
Damien Miller942da032000-08-18 13:59:06 +1000427 if (ssh_request_reply(auth, &buffer, &buffer) == 0) {
428 buffer_free(&buffer);
Damien Miller95def091999-11-25 00:26:21 +1100429 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000430 }
Damien Miller95def091999-11-25 00:26:21 +1100431 type = buffer_get_char(&buffer);
Damien Miller37023962000-07-11 17:31:38 +1000432 buffer_free(&buffer);
Damien Miller942da032000-08-18 13:59:06 +1000433 return decode_reply(type);
434}
435
436int
437decode_reply(int type)
438{
Damien Miller95def091999-11-25 00:26:21 +1100439 switch (type) {
440 case SSH_AGENT_FAILURE:
Damien Miller942da032000-08-18 13:59:06 +1000441 log("SSH_AGENT_FAILURE");
Damien Miller95def091999-11-25 00:26:21 +1100442 return 0;
443 case SSH_AGENT_SUCCESS:
Damien Miller95def091999-11-25 00:26:21 +1100444 return 1;
445 default:
Damien Miller37023962000-07-11 17:31:38 +1000446 fatal("Bad response from authentication agent: %d", type);
Damien Miller95def091999-11-25 00:26:21 +1100447 }
448 /* NOTREACHED */
449 return 0;
450}