import from HEAD
[freeradius.git] / src / modules / rlm_otp / otp.h
1 /*
2  * $Id$
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 2 of the License, or
7  *   (at your option) any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *   GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program; if not, write to the Free Software
16  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  *
18  * Copyright 2005,2006 TRI-D Systems, Inc.
19  */
20
21 #ifndef OTP_H
22 #define OTP_H
23
24 #include "ident.h"
25 RCSIDH(otp_h, "$Id$");
26
27 #include <sys/types.h>
28
29 /*
30  * NOTE: This file must be synced between plugins and otpd.
31  */
32
33 #ifndef OTP_MAX_CHALLENGE_LEN
34 #define OTP_MAX_CHALLENGE_LEN   16
35 #elif OTP_MAX_CHALLENGE_LEN != 16
36 #error OTP_MAX_CHALLENGE_LEN
37 #endif
38
39 #define OTP_RC_OK               0
40 #define OTP_RC_USER_UNKNOWN     1
41 #define OTP_RC_AUTHINFO_UNAVAIL 2
42 #define OTP_RC_AUTH_ERR         3
43 #define OTP_RC_MAXTRIES         4
44 #define OTP_RC_SERVICE_ERR      5
45
46 #define OTP_MAX_USERNAME_LEN            31
47 #define OTP_MAX_PASSCODE_LEN            47
48 #define OTP_MAX_CHAP_CHALLENGE_LEN      16
49 #define OTP_MAX_CHAP_RESPONSE_LEN       50
50
51 typedef enum otp_pwe_t {
52   PWE_PAP = 1,
53   PWE_CHAP = 3,
54   PWE_MSCHAP = 5,
55   PWE_MSCHAP2 = 7,
56 } otp_pwe_t;
57
58 typedef struct otp_request_t {
59   int   version;                                        /* 1 */
60   char  username[OTP_MAX_USERNAME_LEN + 1];
61   char  challenge[OTP_MAX_CHALLENGE_LEN + 1];           /* USER challenge */
62   struct {
63     otp_pwe_t     pwe;
64     char          passcode[OTP_MAX_PASSCODE_LEN + 1];
65     unsigned char challenge[OTP_MAX_CHAP_CHALLENGE_LEN]; /* CHAP challenge */
66     size_t        clen;
67     unsigned char response[OTP_MAX_CHAP_RESPONSE_LEN];
68     size_t        rlen;
69   } pwe;
70   int           allow_async;            /* async auth allowed?           */
71   int           allow_sync;             /* sync auth allowed?            */
72   unsigned      challenge_delay;        /* min delay between async auths */
73   int           resync;                 /* resync on async auth?         */
74 } otp_request_t;
75
76 typedef struct otp_reply_t {
77   int   version;                                        /* 1 */
78   int   rc;
79   char  passcode[OTP_MAX_PASSCODE_LEN + 1];
80 } otp_reply_t;
81
82 #endif /* OTP_H */