17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * Copyright (c) 2001 Markus Friedl. All rights reserved.
37c478bd9Sstevel@tonic-gate * Copyright (c) 2001 Per Allansson. All rights reserved.
47c478bd9Sstevel@tonic-gate *
57c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
67c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions
77c478bd9Sstevel@tonic-gate * are met:
87c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
97c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
107c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
117c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
127c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
157c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
167c478bd9Sstevel@tonic-gate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
177c478bd9Sstevel@tonic-gate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
187c478bd9Sstevel@tonic-gate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
197c478bd9Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
207c478bd9Sstevel@tonic-gate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
217c478bd9Sstevel@tonic-gate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
227c478bd9Sstevel@tonic-gate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
237c478bd9Sstevel@tonic-gate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate /*
26*6f786aceSNobutomo Nakano * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
277c478bd9Sstevel@tonic-gate * Use is subject to license terms.
287c478bd9Sstevel@tonic-gate */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate #include "includes.h"
317c478bd9Sstevel@tonic-gate RCSID("$OpenBSD: auth2-chall.c,v 1.20 2002/06/30 21:59:45 deraadt Exp $");
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate #include "ssh2.h"
347c478bd9Sstevel@tonic-gate #include "auth.h"
357c478bd9Sstevel@tonic-gate #include "buffer.h"
367c478bd9Sstevel@tonic-gate #include "packet.h"
377c478bd9Sstevel@tonic-gate #include "xmalloc.h"
387c478bd9Sstevel@tonic-gate #include "dispatch.h"
397c478bd9Sstevel@tonic-gate #include "auth.h"
407c478bd9Sstevel@tonic-gate #include "log.h"
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate #ifndef lint
437c478bd9Sstevel@tonic-gate static void auth2_challenge_start(Authctxt *);
447c478bd9Sstevel@tonic-gate static int send_userauth_info_request(Authctxt *);
457c478bd9Sstevel@tonic-gate static void input_userauth_info_response(int, u_int32_t, void *);
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate #ifdef BSD_AUTH
487c478bd9Sstevel@tonic-gate extern KbdintDevice bsdauth_device;
497c478bd9Sstevel@tonic-gate #else
507c478bd9Sstevel@tonic-gate #ifdef SKEY
517c478bd9Sstevel@tonic-gate extern KbdintDevice skey_device;
527c478bd9Sstevel@tonic-gate #endif
537c478bd9Sstevel@tonic-gate #endif
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate KbdintDevice *devices[] = {
567c478bd9Sstevel@tonic-gate #ifdef BSD_AUTH
577c478bd9Sstevel@tonic-gate &bsdauth_device,
587c478bd9Sstevel@tonic-gate #else
597c478bd9Sstevel@tonic-gate #ifdef SKEY
607c478bd9Sstevel@tonic-gate &skey_device,
617c478bd9Sstevel@tonic-gate #endif
627c478bd9Sstevel@tonic-gate #endif
637c478bd9Sstevel@tonic-gate NULL
647c478bd9Sstevel@tonic-gate };
657c478bd9Sstevel@tonic-gate
667c478bd9Sstevel@tonic-gate typedef struct KbdintAuthctxt KbdintAuthctxt;
677c478bd9Sstevel@tonic-gate struct KbdintAuthctxt
687c478bd9Sstevel@tonic-gate {
697c478bd9Sstevel@tonic-gate char *devices;
707c478bd9Sstevel@tonic-gate void *ctxt;
717c478bd9Sstevel@tonic-gate KbdintDevice *device;
727c478bd9Sstevel@tonic-gate u_int nreq;
737c478bd9Sstevel@tonic-gate };
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate static KbdintAuthctxt *
kbdint_alloc(const char * devs)767c478bd9Sstevel@tonic-gate kbdint_alloc(const char *devs)
777c478bd9Sstevel@tonic-gate {
787c478bd9Sstevel@tonic-gate KbdintAuthctxt *kbdintctxt;
797c478bd9Sstevel@tonic-gate Buffer b;
807c478bd9Sstevel@tonic-gate int i;
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate kbdintctxt = xmalloc(sizeof(KbdintAuthctxt));
837c478bd9Sstevel@tonic-gate if (strcmp(devs, "") == 0) {
847c478bd9Sstevel@tonic-gate buffer_init(&b);
857c478bd9Sstevel@tonic-gate for (i = 0; devices[i]; i++) {
867c478bd9Sstevel@tonic-gate if (buffer_len(&b) > 0)
877c478bd9Sstevel@tonic-gate buffer_append(&b, ",", 1);
887c478bd9Sstevel@tonic-gate buffer_append(&b, devices[i]->name,
897c478bd9Sstevel@tonic-gate strlen(devices[i]->name));
907c478bd9Sstevel@tonic-gate }
917c478bd9Sstevel@tonic-gate buffer_append(&b, "\0", 1);
927c478bd9Sstevel@tonic-gate kbdintctxt->devices = xstrdup(buffer_ptr(&b));
937c478bd9Sstevel@tonic-gate buffer_free(&b);
947c478bd9Sstevel@tonic-gate } else {
957c478bd9Sstevel@tonic-gate kbdintctxt->devices = xstrdup(devs);
967c478bd9Sstevel@tonic-gate }
977c478bd9Sstevel@tonic-gate debug("kbdint_alloc: devices '%s'", kbdintctxt->devices);
987c478bd9Sstevel@tonic-gate kbdintctxt->ctxt = NULL;
997c478bd9Sstevel@tonic-gate kbdintctxt->device = NULL;
1007c478bd9Sstevel@tonic-gate kbdintctxt->nreq = 0;
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate return kbdintctxt;
1037c478bd9Sstevel@tonic-gate }
1047c478bd9Sstevel@tonic-gate static void
kbdint_reset_device(KbdintAuthctxt * kbdintctxt)1057c478bd9Sstevel@tonic-gate kbdint_reset_device(KbdintAuthctxt *kbdintctxt)
1067c478bd9Sstevel@tonic-gate {
1077c478bd9Sstevel@tonic-gate if (kbdintctxt->ctxt) {
1087c478bd9Sstevel@tonic-gate kbdintctxt->device->free_ctx(kbdintctxt->ctxt);
1097c478bd9Sstevel@tonic-gate kbdintctxt->ctxt = NULL;
1107c478bd9Sstevel@tonic-gate }
1117c478bd9Sstevel@tonic-gate kbdintctxt->device = NULL;
1127c478bd9Sstevel@tonic-gate }
1137c478bd9Sstevel@tonic-gate static void
kbdint_free(KbdintAuthctxt * kbdintctxt)1147c478bd9Sstevel@tonic-gate kbdint_free(KbdintAuthctxt *kbdintctxt)
1157c478bd9Sstevel@tonic-gate {
1167c478bd9Sstevel@tonic-gate if (kbdintctxt->device)
1177c478bd9Sstevel@tonic-gate kbdint_reset_device(kbdintctxt);
1187c478bd9Sstevel@tonic-gate if (kbdintctxt->devices) {
1197c478bd9Sstevel@tonic-gate xfree(kbdintctxt->devices);
1207c478bd9Sstevel@tonic-gate kbdintctxt->devices = NULL;
1217c478bd9Sstevel@tonic-gate }
1227c478bd9Sstevel@tonic-gate xfree(kbdintctxt);
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate /* get next device */
1257c478bd9Sstevel@tonic-gate static int
kbdint_next_device(KbdintAuthctxt * kbdintctxt)1267c478bd9Sstevel@tonic-gate kbdint_next_device(KbdintAuthctxt *kbdintctxt)
1277c478bd9Sstevel@tonic-gate {
1287c478bd9Sstevel@tonic-gate size_t len;
1297c478bd9Sstevel@tonic-gate char *t;
1307c478bd9Sstevel@tonic-gate int i;
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate if (kbdintctxt->device)
1337c478bd9Sstevel@tonic-gate kbdint_reset_device(kbdintctxt);
1347c478bd9Sstevel@tonic-gate do {
1357c478bd9Sstevel@tonic-gate len = kbdintctxt->devices ?
1367c478bd9Sstevel@tonic-gate strcspn(kbdintctxt->devices, ",") : 0;
1377c478bd9Sstevel@tonic-gate
1387c478bd9Sstevel@tonic-gate if (len == 0)
1397c478bd9Sstevel@tonic-gate break;
1407c478bd9Sstevel@tonic-gate for (i = 0; devices[i]; i++)
1417c478bd9Sstevel@tonic-gate if (strncmp(kbdintctxt->devices, devices[i]->name, len) == 0)
1427c478bd9Sstevel@tonic-gate kbdintctxt->device = devices[i];
1437c478bd9Sstevel@tonic-gate t = kbdintctxt->devices;
1447c478bd9Sstevel@tonic-gate kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;
1457c478bd9Sstevel@tonic-gate xfree(t);
1467c478bd9Sstevel@tonic-gate debug2("kbdint_next_device: devices %s", kbdintctxt->devices ?
1477c478bd9Sstevel@tonic-gate kbdintctxt->devices : "<empty>");
1487c478bd9Sstevel@tonic-gate } while (kbdintctxt->devices && !kbdintctxt->device);
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate return kbdintctxt->device ? 1 : 0;
1517c478bd9Sstevel@tonic-gate }
1527c478bd9Sstevel@tonic-gate
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate * try challenge-response, set authctxt->method->postponed if we have to
1557c478bd9Sstevel@tonic-gate * wait for the response.
1567c478bd9Sstevel@tonic-gate */
1577c478bd9Sstevel@tonic-gate void
auth2_challenge(Authctxt * authctxt,char * devs)1587c478bd9Sstevel@tonic-gate auth2_challenge(Authctxt *authctxt, char *devs)
1597c478bd9Sstevel@tonic-gate {
1607c478bd9Sstevel@tonic-gate debug("auth2_challenge: user=%s devs=%s",
1617c478bd9Sstevel@tonic-gate authctxt->user ? authctxt->user : "<nouser>",
1627c478bd9Sstevel@tonic-gate devs ? devs : "<no devs>");
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate if (authctxt->user == NULL || !devs)
1657c478bd9Sstevel@tonic-gate return;
1667c478bd9Sstevel@tonic-gate if (authctxt->method->method_data != NULL) {
1677c478bd9Sstevel@tonic-gate auth2_challenge_abandon(authctxt);
1687c478bd9Sstevel@tonic-gate authctxt->method->abandoned = 0;
1697c478bd9Sstevel@tonic-gate }
1707c478bd9Sstevel@tonic-gate authctxt->method->method_data = (void *) kbdint_alloc(devs);
1717c478bd9Sstevel@tonic-gate auth2_challenge_start(authctxt);
1727c478bd9Sstevel@tonic-gate }
1737c478bd9Sstevel@tonic-gate
1747c478bd9Sstevel@tonic-gate /* unregister kbd-int callbacks and context */
1757c478bd9Sstevel@tonic-gate static void
auth2_challenge_stop(Authctxt * authctxt)1767c478bd9Sstevel@tonic-gate auth2_challenge_stop(Authctxt *authctxt)
1777c478bd9Sstevel@tonic-gate {
1787c478bd9Sstevel@tonic-gate /* unregister callback */
1797c478bd9Sstevel@tonic-gate dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL);
1807c478bd9Sstevel@tonic-gate if (authctxt->method->method_data != NULL) {
1817c478bd9Sstevel@tonic-gate kbdint_free((KbdintAuthctxt *) authctxt->method->method_data);
1827c478bd9Sstevel@tonic-gate authctxt->method->method_data = NULL;
1837c478bd9Sstevel@tonic-gate }
1847c478bd9Sstevel@tonic-gate }
1857c478bd9Sstevel@tonic-gate
1867c478bd9Sstevel@tonic-gate void
auth2_challenge_abandon(Authctxt * authctxt)1877c478bd9Sstevel@tonic-gate auth2_challenge_abandon(Authctxt *authctxt)
1887c478bd9Sstevel@tonic-gate {
1897c478bd9Sstevel@tonic-gate auth2_challenge_stop(authctxt);
1907c478bd9Sstevel@tonic-gate authctxt->method->abandoned = 1;
1917c478bd9Sstevel@tonic-gate authctxt->method->postponed = 0;
1927c478bd9Sstevel@tonic-gate authctxt->method->authenticated = 0;
1937c478bd9Sstevel@tonic-gate authctxt->method->abandons++;
1947c478bd9Sstevel@tonic-gate authctxt->method->attempts++;
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate /* side effect: sets authctxt->method->postponed if a reply was sent*/
1987c478bd9Sstevel@tonic-gate static void
auth2_challenge_start(Authctxt * authctxt)1997c478bd9Sstevel@tonic-gate auth2_challenge_start(Authctxt *authctxt)
2007c478bd9Sstevel@tonic-gate {
2017c478bd9Sstevel@tonic-gate KbdintAuthctxt *kbdintctxt = (KbdintAuthctxt *)
2027c478bd9Sstevel@tonic-gate authctxt->method->method_data;
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gate debug2("auth2_challenge_start: devices %s",
2057c478bd9Sstevel@tonic-gate kbdintctxt->devices ? kbdintctxt->devices : "<empty>");
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gate if (kbdint_next_device(kbdintctxt) == 0) {
2087c478bd9Sstevel@tonic-gate auth2_challenge_stop(authctxt);
2097c478bd9Sstevel@tonic-gate return;
2107c478bd9Sstevel@tonic-gate }
2117c478bd9Sstevel@tonic-gate debug("auth2_challenge_start: trying authentication method '%s'",
2127c478bd9Sstevel@tonic-gate kbdintctxt->device->name);
2137c478bd9Sstevel@tonic-gate
2147c478bd9Sstevel@tonic-gate if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) {
2157c478bd9Sstevel@tonic-gate auth2_challenge_stop(authctxt);
2167c478bd9Sstevel@tonic-gate return;
2177c478bd9Sstevel@tonic-gate }
2187c478bd9Sstevel@tonic-gate if (send_userauth_info_request(authctxt) == 0) {
2197c478bd9Sstevel@tonic-gate auth2_challenge_stop(authctxt);
2207c478bd9Sstevel@tonic-gate return;
2217c478bd9Sstevel@tonic-gate }
2227c478bd9Sstevel@tonic-gate dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE,
2237c478bd9Sstevel@tonic-gate &input_userauth_info_response);
2247c478bd9Sstevel@tonic-gate
2257c478bd9Sstevel@tonic-gate authctxt->method->postponed = 1;
2267c478bd9Sstevel@tonic-gate }
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate static int
send_userauth_info_request(Authctxt * authctxt)2297c478bd9Sstevel@tonic-gate send_userauth_info_request(Authctxt *authctxt)
2307c478bd9Sstevel@tonic-gate {
2317c478bd9Sstevel@tonic-gate KbdintAuthctxt *kbdintctxt;
2327c478bd9Sstevel@tonic-gate char *name, *instr, **prompts;
2337c478bd9Sstevel@tonic-gate int i;
2347c478bd9Sstevel@tonic-gate u_int *echo_on;
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate kbdintctxt = (KbdintAuthctxt *) authctxt->method->method_data;
2377c478bd9Sstevel@tonic-gate if (kbdintctxt->device->query(kbdintctxt->ctxt,
2387c478bd9Sstevel@tonic-gate &name, &instr, &kbdintctxt->nreq, &prompts, &echo_on))
2397c478bd9Sstevel@tonic-gate return 0;
2407c478bd9Sstevel@tonic-gate
2417c478bd9Sstevel@tonic-gate packet_start(SSH2_MSG_USERAUTH_INFO_REQUEST);
2427c478bd9Sstevel@tonic-gate packet_put_cstring(name);
243*6f786aceSNobutomo Nakano packet_put_utf8_cstring(instr);
2447c478bd9Sstevel@tonic-gate packet_put_cstring(""); /* language not used */
2457c478bd9Sstevel@tonic-gate packet_put_int(kbdintctxt->nreq);
2467c478bd9Sstevel@tonic-gate for (i = 0; i < kbdintctxt->nreq; i++) {
247*6f786aceSNobutomo Nakano packet_put_utf8_cstring(prompts[i]);
2487c478bd9Sstevel@tonic-gate packet_put_char(echo_on[i]);
2497c478bd9Sstevel@tonic-gate }
2507c478bd9Sstevel@tonic-gate packet_send();
2517c478bd9Sstevel@tonic-gate packet_write_wait();
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gate for (i = 0; i < kbdintctxt->nreq; i++)
2547c478bd9Sstevel@tonic-gate xfree(prompts[i]);
2557c478bd9Sstevel@tonic-gate xfree(prompts);
2567c478bd9Sstevel@tonic-gate xfree(echo_on);
2577c478bd9Sstevel@tonic-gate xfree(name);
2587c478bd9Sstevel@tonic-gate xfree(instr);
2597c478bd9Sstevel@tonic-gate return 1;
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate static void
input_userauth_info_response(int type,u_int32_t seq,void * ctxt)2637c478bd9Sstevel@tonic-gate input_userauth_info_response(int type, u_int32_t seq, void *ctxt)
2647c478bd9Sstevel@tonic-gate {
2657c478bd9Sstevel@tonic-gate Authctxt *authctxt = ctxt;
2667c478bd9Sstevel@tonic-gate KbdintAuthctxt *kbdintctxt;
2677c478bd9Sstevel@tonic-gate int i, res, len;
2687c478bd9Sstevel@tonic-gate u_int nresp;
2697c478bd9Sstevel@tonic-gate char **response = NULL, *method;
2707c478bd9Sstevel@tonic-gate
2717c478bd9Sstevel@tonic-gate if (authctxt == NULL)
2727c478bd9Sstevel@tonic-gate fatal("input_userauth_info_response: no authctxt");
2737c478bd9Sstevel@tonic-gate kbdintctxt = (KbdintAuthctxt *) authctxt->method->method_data;
2747c478bd9Sstevel@tonic-gate if (kbdintctxt == NULL || kbdintctxt->ctxt == NULL)
2757c478bd9Sstevel@tonic-gate fatal("input_userauth_info_response: no kbdintctxt");
2767c478bd9Sstevel@tonic-gate if (kbdintctxt->device == NULL)
2777c478bd9Sstevel@tonic-gate fatal("input_userauth_info_response: no device");
2787c478bd9Sstevel@tonic-gate
2797c478bd9Sstevel@tonic-gate nresp = packet_get_int();
2807c478bd9Sstevel@tonic-gate if (nresp != kbdintctxt->nreq)
2817c478bd9Sstevel@tonic-gate fatal("input_userauth_info_response: wrong number of replies");
2827c478bd9Sstevel@tonic-gate if (nresp > 100)
2837c478bd9Sstevel@tonic-gate fatal("input_userauth_info_response: too many replies");
2847c478bd9Sstevel@tonic-gate if (nresp > 0) {
2857c478bd9Sstevel@tonic-gate response = xmalloc(nresp * sizeof(char *));
2867c478bd9Sstevel@tonic-gate for (i = 0; i < nresp; i++)
2877c478bd9Sstevel@tonic-gate response[i] = packet_get_string(NULL);
2887c478bd9Sstevel@tonic-gate }
2897c478bd9Sstevel@tonic-gate packet_check_eom();
2907c478bd9Sstevel@tonic-gate
2917c478bd9Sstevel@tonic-gate if (authctxt->valid) {
2927c478bd9Sstevel@tonic-gate res = kbdintctxt->device->respond(kbdintctxt->ctxt,
2937c478bd9Sstevel@tonic-gate nresp, response);
2947c478bd9Sstevel@tonic-gate } else {
2957c478bd9Sstevel@tonic-gate res = -1;
2967c478bd9Sstevel@tonic-gate }
2977c478bd9Sstevel@tonic-gate
2987c478bd9Sstevel@tonic-gate for (i = 0; i < nresp; i++) {
2997c478bd9Sstevel@tonic-gate memset(response[i], 'r', strlen(response[i]));
3007c478bd9Sstevel@tonic-gate xfree(response[i]);
3017c478bd9Sstevel@tonic-gate }
3027c478bd9Sstevel@tonic-gate if (response)
3037c478bd9Sstevel@tonic-gate xfree(response);
3047c478bd9Sstevel@tonic-gate
3057c478bd9Sstevel@tonic-gate authctxt->method->postponed = 0; /* reset */
3067c478bd9Sstevel@tonic-gate switch (res) {
3077c478bd9Sstevel@tonic-gate case 0:
3087c478bd9Sstevel@tonic-gate /* Success! */
3097c478bd9Sstevel@tonic-gate authctxt->method->authenticated = 1;
3107c478bd9Sstevel@tonic-gate break;
3117c478bd9Sstevel@tonic-gate case 1:
3127c478bd9Sstevel@tonic-gate /* Authentication needs further interaction */
3137c478bd9Sstevel@tonic-gate if (send_userauth_info_request(authctxt) == 1) {
3147c478bd9Sstevel@tonic-gate authctxt->method->postponed = 1;
3157c478bd9Sstevel@tonic-gate }
3167c478bd9Sstevel@tonic-gate break;
3177c478bd9Sstevel@tonic-gate default:
3187c478bd9Sstevel@tonic-gate /* Failure! */
3197c478bd9Sstevel@tonic-gate break;
3207c478bd9Sstevel@tonic-gate }
3217c478bd9Sstevel@tonic-gate
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gate len = strlen("keyboard-interactive") + 2 +
3247c478bd9Sstevel@tonic-gate strlen(kbdintctxt->device->name);
3257c478bd9Sstevel@tonic-gate method = xmalloc(len);
3267c478bd9Sstevel@tonic-gate snprintf(method, len, "keyboard-interactive/%s",
3277c478bd9Sstevel@tonic-gate kbdintctxt->device->name);
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate if (authctxt->method->authenticated || authctxt->method->abandoned) {
3307c478bd9Sstevel@tonic-gate auth2_challenge_stop(authctxt);
3317c478bd9Sstevel@tonic-gate } else {
3327c478bd9Sstevel@tonic-gate /* start next device */
3337c478bd9Sstevel@tonic-gate /* may set authctxt->method->postponed */
3347c478bd9Sstevel@tonic-gate auth2_challenge_start(authctxt);
3357c478bd9Sstevel@tonic-gate }
3367c478bd9Sstevel@tonic-gate userauth_finish(authctxt, method);
3377c478bd9Sstevel@tonic-gate xfree(method);
3387c478bd9Sstevel@tonic-gate }
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate void
privsep_challenge_enable(void)3417c478bd9Sstevel@tonic-gate privsep_challenge_enable(void)
3427c478bd9Sstevel@tonic-gate {
3437c478bd9Sstevel@tonic-gate #ifdef BSD_AUTH
3447c478bd9Sstevel@tonic-gate extern KbdintDevice mm_bsdauth_device;
3457c478bd9Sstevel@tonic-gate #endif
3467c478bd9Sstevel@tonic-gate #ifdef SKEY
3477c478bd9Sstevel@tonic-gate extern KbdintDevice mm_skey_device;
3487c478bd9Sstevel@tonic-gate #endif
3497c478bd9Sstevel@tonic-gate /* As long as SSHv1 has devices[0] hard coded this is fine */
3507c478bd9Sstevel@tonic-gate #ifdef BSD_AUTH
3517c478bd9Sstevel@tonic-gate devices[0] = &mm_bsdauth_device;
3527c478bd9Sstevel@tonic-gate #else
3537c478bd9Sstevel@tonic-gate #ifdef SKEY
3547c478bd9Sstevel@tonic-gate devices[0] = &mm_skey_device;
3557c478bd9Sstevel@tonic-gate #endif
3567c478bd9Sstevel@tonic-gate #endif
3577c478bd9Sstevel@tonic-gate }
3587c478bd9Sstevel@tonic-gate #endif /* lint */
359