blob: e23d2edd20f118817a220d2c21fada80f3e9d284 [file] [log] [blame]
deraadt@openbsd.org72687c82019-11-13 04:47:52 +00001/* $OpenBSD: auth2-kbdint.c,v 1.11 2019/11/13 04:47:52 deraadt Exp $ */
Ben Lindstrom855bf3a2002-06-06 20:27:55 +00002/*
3 * Copyright (c) 2000 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 */
25
26#include "includes.h"
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000027
Damien Millerd7834352006-08-05 12:39:39 +100028#include <sys/types.h>
29
djm@openbsd.orgbe02d7c2019-09-06 04:53:27 +000030#include <stdlib.h>
31#include <stdio.h>
deraadt@openbsd.org72687c82019-11-13 04:47:52 +000032#include <stdarg.h>
djm@openbsd.orgbe02d7c2019-09-06 04:53:27 +000033
Damien Millerd7834352006-08-05 12:39:39 +100034#include "xmalloc.h"
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000035#include "packet.h"
Damien Millerd7834352006-08-05 12:39:39 +100036#include "hostfile.h"
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000037#include "auth.h"
38#include "log.h"
Damien Miller7acefbb2014-07-18 14:11:24 +100039#include "misc.h"
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000040#include "servconf.h"
markus@openbsd.orgc7d39ac2018-07-09 21:35:50 +000041#include "ssherr.h"
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000042
43/* import */
44extern ServerOptions options;
45
46static int
markus@openbsd.orgeb272ea2017-05-30 14:29:59 +000047userauth_kbdint(struct ssh *ssh)
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000048{
markus@openbsd.orgc7d39ac2018-07-09 21:35:50 +000049 int r, authenticated = 0;
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000050 char *lang, *devs;
51
markus@openbsd.orgc7d39ac2018-07-09 21:35:50 +000052 if ((r = sshpkt_get_cstring(ssh, &lang, NULL)) != 0 ||
53 (r = sshpkt_get_cstring(ssh, &devs, NULL)) != 0 ||
54 (r = sshpkt_get_end(ssh)) != 0)
55 fatal("%s: %s", __func__, ssh_err(r));
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000056
57 debug("keyboard-interactive devs %s", devs);
58
59 if (options.challenge_response_authentication)
markus@openbsd.orgeb272ea2017-05-30 14:29:59 +000060 authenticated = auth2_challenge(ssh, devs);
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000061
Darren Tuckera627d422013-06-02 07:31:17 +100062 free(devs);
63 free(lang);
Ben Lindstrom855bf3a2002-06-06 20:27:55 +000064 return authenticated;
65}
66
67Authmethod method_kbdint = {
68 "keyboard-interactive",
69 userauth_kbdint,
70 &options.kbd_interactive_authentication
71};