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.
29 #include <sys/types.h>
32 #include "otp.h" /* OTP_MAX_CHALLENGE_LEN, otp_pwe_t */
34 /* otpd rendezvous point */
35 #define OTP_OTPD_RP "/var/run/otpd/socket"
37 /* Default prompt for presentation of challenge */
38 #define OTP_CHALLENGE_PROMPT "Challenge: %s\n Response: "
42 * You shouldn't change anything past this point
46 /* struct used for instance/option data */
47 typedef struct otp_option_t {
48 const char *name; /* instance name for otp_token_authorize() */
49 char *otpd_rp; /* otpd rendezvous point */
50 char *chal_prompt; /* text to present challenge to user, must have %s */
51 int challenge_len; /* challenge length, min 5 digits */
52 int challenge_delay; /* max delay time for response, in seconds */
53 int allow_sync; /* useful to override pwdfile card_type settings */
54 int allow_async; /* C/R mode allowed? */
56 int mschapv2_mppe_policy; /* whether or not do to mppe for mschapv2 */
57 int mschapv2_mppe_types; /* key type/length for mschapv2/mppe */
58 int mschap_mppe_policy; /* whether or not do to mppe for mschap */
59 int mschap_mppe_types; /* key type/length for mschap/mppe */
63 void otp_mppe(REQUEST *, otp_pwe_t, const otp_option_t *, const char *);
66 extern int otp_pw_valid(REQUEST *, int, const char *, const otp_option_t *,
70 #define OTP_MAX_RADSTATE_LEN 2 + (OTP_MAX_CHALLENGE_LEN * 2 + 8 + 8 + 32)*2 + 1
71 extern int otp_gen_state(char [OTP_MAX_RADSTATE_LEN],
72 unsigned char [OTP_MAX_RADSTATE_LEN],
73 const unsigned char [OTP_MAX_CHALLENGE_LEN], size_t,
74 int32_t, int32_t, const unsigned char [16]);
78 extern void otp_pwe_init(void);
79 extern otp_pwe_t otp_pwe_present(const REQUEST *);
82 extern void otp_get_random(char *, size_t);
83 extern void otp_async_challenge(char [OTP_MAX_CHALLENGE_LEN + 1], int);
84 extern int otp_a2x(const char *, unsigned char *);
85 extern void otp_x2a(const unsigned char *, size_t, char *);
86 extern void _otp_pthread_mutex_init(pthread_mutex_t *,
87 const pthread_mutexattr_t *, const char *);
88 extern void _otp_pthread_mutex_lock(pthread_mutex_t *, const char *);
89 extern int _otp_pthread_mutex_trylock(pthread_mutex_t *, const char *);
90 extern void _otp_pthread_mutex_unlock(pthread_mutex_t *, const char *);
92 #define otp_pthread_mutex_init(a, b) _otp_pthread_mutex_init((a), (b), __func__)
93 #define otp_pthread_mutex_lock(a) _otp_pthread_mutex_lock((a), __func__)
94 #define otp_pthread_mutex_trylock(a) _otp_pthread_mutex_trylock((a), __func__)
95 #define otp_pthread_mutex_unlock(a) _otp_pthread_mutex_unlock((a), __func__)