02e882f7378ad3ed3aed3f6990d98e155a4537e6
[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  *  For alternative licensing terms, contact licensing@tri-dsystems.com.
19  *
20  * Copyright 2005-2007 TRI-D Systems, Inc.
21  */
22
23 #ifndef OTP_H
24 #define OTP_H
25
26 #include <freeradius-devel/ident.h>
27 RCSIDH(otp_h, "$Id$")
28
29 #include <sys/types.h>
30
31 /*
32  * NOTE: This file must be synced between plugins/otpd/lsmd/gsmd/changepin.
33  */
34
35 #ifndef OTP_MAX_CHALLENGE_LEN
36 #define OTP_MAX_CHALLENGE_LEN   16
37 #elif OTP_MAX_CHALLENGE_LEN != 16
38 #error OTP_MAX_CHALLENGE_LEN
39 #endif
40
41 #define OTP_RC_OK               0
42 #define OTP_RC_USER_UNKNOWN     1
43 #define OTP_RC_AUTHINFO_UNAVAIL 2
44 #define OTP_RC_AUTH_ERR         3
45 #define OTP_RC_MAXTRIES         4
46 #define OTP_RC_SERVICE_ERR      5
47 #define OTP_RC_NEXTPASSCODE     6
48 #define OTP_RC_IPIN             7
49
50 #define OTP_MAX_USERNAME_LEN            31
51 /* only needs to be MAX_PIN_LEN (16) + MAX_RESPONSE_LEN (16) */
52 #define OTP_MAX_PASSCODE_LEN            47
53 #define OTP_MAX_CHAP_CHALLENGE_LEN      16
54 #define OTP_MAX_CHAP_RESPONSE_LEN       50
55
56 typedef enum otp_pwe_t {
57   PWE_PAP = 1,
58   PWE_CHAP = 3,
59   PWE_MSCHAP = 5,
60   PWE_MSCHAP2 = 7,
61 } otp_pwe_t;
62
63 typedef struct otp_request_t {
64   int   version;                                        /* 2 */
65   char  username[OTP_MAX_USERNAME_LEN + 1];
66   char  challenge[OTP_MAX_CHALLENGE_LEN + 1];           /* USER challenge */
67   struct {
68     otp_pwe_t     pwe;
69     union {
70       struct {
71         char      passcode[OTP_MAX_PASSCODE_LEN + 1];
72       } pap;
73       struct {
74         unsigned char challenge[OTP_MAX_CHAP_CHALLENGE_LEN]; /* CHAP chal */
75         size_t    clen;
76         unsigned char response[OTP_MAX_CHAP_RESPONSE_LEN];
77         size_t    rlen;
78       } chap;
79     } u;
80   } pwe;
81   int           allow_async;            /* async auth allowed?           */
82   int           allow_sync;             /* sync auth allowed?            */
83   unsigned      challenge_delay;        /* min delay between async auths */
84   int           resync;                 /* resync on async auth?         */
85 } otp_request_t;
86
87 typedef struct otp_reply_t {
88   int   version;                                        /* 1 */
89   int   rc;
90   char  passcode[OTP_MAX_PASSCODE_LEN + 1];
91 } otp_reply_t;
92
93 #endif /* OTP_H */