auth2-chall.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2001 Per Allansson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "includes.h"
RCSID("$OpenBSD: auth2-chall.c,v 1.20 2002/06/30 21:59:45 deraadt Exp $");
#pragma ident "%Z%%M% %I% %E% SMI"
#include "ssh2.h"
#include "auth.h"
#include "buffer.h"
#include "packet.h"
#include "xmalloc.h"
#include "dispatch.h"
#include "auth.h"
#include "log.h"
#ifndef lint
static void auth2_challenge_start(Authctxt *);
static int send_userauth_info_request(Authctxt *);
static void input_userauth_info_response(int, u_int32_t, void *);
#ifdef BSD_AUTH
extern KbdintDevice bsdauth_device;
#else
#ifdef SKEY
extern KbdintDevice skey_device;
#endif
#endif
KbdintDevice *devices[] = {
#ifdef BSD_AUTH
#else
#ifdef SKEY
#endif
#endif
};
typedef struct KbdintAuthctxt KbdintAuthctxt;
struct KbdintAuthctxt
{
char *devices;
void *ctxt;
};
static KbdintAuthctxt *
kbdint_alloc(const char *devs)
{
Buffer b;
int i;
buffer_init(&b);
for (i = 0; devices[i]; i++) {
if (buffer_len(&b) > 0)
}
buffer_free(&b);
} else {
}
kbdintctxt->nreq = 0;
return kbdintctxt;
}
static void
{
if (kbdintctxt->ctxt) {
}
}
static void
{
if (kbdintctxt->device)
if (kbdintctxt->devices) {
}
}
/* get next device */
static int
{
char *t;
int i;
if (kbdintctxt->device)
do {
if (len == 0)
break;
for (i = 0; devices[i]; i++)
t = kbdintctxt->devices;
xfree(t);
}
/*
* try challenge-response, set authctxt->method->postponed if we have to
* wait for the response.
*/
void
{
debug("auth2_challenge: user=%s devs=%s",
return;
}
}
/* unregister kbd-int callbacks and context */
static void
{
/* unregister callback */
}
}
void
{
}
/* side effect: sets authctxt->method->postponed if a reply was sent*/
static void
{
debug2("auth2_challenge_start: devices %s",
if (kbdint_next_device(kbdintctxt) == 0) {
return;
}
debug("auth2_challenge_start: trying authentication method '%s'",
return;
}
if (send_userauth_info_request(authctxt) == 0) {
return;
}
}
static int
{
int i;
return 0;
for (i = 0; i < kbdintctxt->nreq; i++) {
packet_put_char(echo_on[i]);
}
packet_send();
for (i = 0; i < kbdintctxt->nreq; i++)
return 1;
}
static void
{
fatal("input_userauth_info_response: no authctxt");
fatal("input_userauth_info_response: no kbdintctxt");
fatal("input_userauth_info_response: no device");
nresp = packet_get_int();
fatal("input_userauth_info_response: wrong number of replies");
if (nresp > 100)
fatal("input_userauth_info_response: too many replies");
if (nresp > 0) {
for (i = 0; i < nresp; i++)
}
} else {
res = -1;
}
for (i = 0; i < nresp; i++) {
}
if (response)
switch (res) {
case 0:
/* Success! */
break;
case 1:
/* Authentication needs further interaction */
}
break;
default:
/* Failure! */
break;
}
} else {
/* start next device */
/* may set authctxt->method->postponed */
}
}
void
privsep_challenge_enable(void)
{
#ifdef BSD_AUTH
extern KbdintDevice mm_bsdauth_device;
#endif
#ifdef SKEY
extern KbdintDevice mm_skey_device;
#endif
/* As long as SSHv1 has devices[0] hard coded this is fine */
#ifdef BSD_AUTH
devices[0] = &mm_bsdauth_device;
#else
#ifdef SKEY
devices[0] = &mm_skey_device;
#endif
#endif
}
#endif /* lint */