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.
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.
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
18 * Copyright 2001,2002 Google, Inc.
19 * Copyright 2005,2006 TRI-D Systems, Inc.
26 RCSIDH(extern_h, "$Id$")
28 #include <freeradius-devel/autoconf.h>
29 #include <freeradius-devel/radiusd.h>
30 #include <freeradius-devel/modules.h>
32 #include <sys/types.h>
35 #include "otp.h" /* OTP_MAX_CHALLENGE_LEN, otp_pwe_t */
37 /* otpd rendezvous point */
38 #define OTP_OTPD_RP "/var/run/otpd/socket"
40 /* Default prompt for presentation of challenge */
41 #define OTP_CHALLENGE_PROMPT "Challenge: %s\n Response: "
45 * You shouldn't change anything past this point
49 /* struct used for instance/option data */
50 typedef struct otp_option_t {
51 const char *name; /* instance name for otp_token_authorize() */
52 char *otpd_rp; /* otpd rendezvous point */
53 char *chal_prompt; /* text to present challenge to user, must have %s */
54 int challenge_len; /* challenge length, min 5 digits */
55 int challenge_delay; /* max delay time for response, in seconds */
56 int allow_sync; /* useful to override pwdfile card_type settings */
57 int allow_async; /* C/R mode allowed? */
59 int mschapv2_mppe_policy; /* whether or not do to mppe for mschapv2 */
60 int mschapv2_mppe_types; /* key type/length for mschapv2/mppe */
61 int mschap_mppe_policy; /* whether or not do to mppe for mschap */
62 int mschap_mppe_types; /* key type/length for mschap/mppe */
66 void otp_mppe(REQUEST *, otp_pwe_t, const otp_option_t *, const char *);
69 extern int otp_pw_valid(REQUEST *, int, const char *, const otp_option_t *,
73 #define OTP_MAX_RADSTATE_LEN 2 + (OTP_MAX_CHALLENGE_LEN * 2 + 8 + 8 + 32)*2 + 1
74 extern int otp_gen_state(char [OTP_MAX_RADSTATE_LEN],
75 unsigned char [OTP_MAX_RADSTATE_LEN],
76 const unsigned char [OTP_MAX_CHALLENGE_LEN], size_t,
77 int32_t, int32_t, const unsigned char [16]);
81 extern void otp_pwe_init(void);
82 extern otp_pwe_t otp_pwe_present(const REQUEST *);
85 extern void otp_get_random(char *, size_t);
86 extern void otp_async_challenge(char [OTP_MAX_CHALLENGE_LEN + 1], int);
87 extern int otp_a2x(const char *, unsigned char *);
88 extern void otp_x2a(const unsigned char *, size_t, char *);
89 extern void _otp_pthread_mutex_init(pthread_mutex_t *,
90 const pthread_mutexattr_t *, const char *);
91 extern void _otp_pthread_mutex_lock(pthread_mutex_t *, const char *);
92 extern int _otp_pthread_mutex_trylock(pthread_mutex_t *, const char *);
93 extern void _otp_pthread_mutex_unlock(pthread_mutex_t *, const char *);
95 #define otp_pthread_mutex_init(a, b) _otp_pthread_mutex_init((a), (b), __func__)
96 #define otp_pthread_mutex_lock(a) _otp_pthread_mutex_lock((a), __func__)
97 #define otp_pthread_mutex_trylock(a) _otp_pthread_mutex_trylock((a), __func__)
98 #define otp_pthread_mutex_unlock(a) _otp_pthread_mutex_unlock((a), __func__)
100 #endif /* EXTERN_H */