All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
extern.h
Go to the documentation of this file.
1 /*
2  * $Id: f4024cabdf0beb970e3a964433312ff944af1dc8 $
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 2001,2002 Google, Inc.
19  * Copyright 2005,2006 TRI-D Systems, Inc.
20  */
21 
22 #ifndef EXTERN_H
23 #define EXTERN_H
24 
25 RCSIDH(extern_h, "$Id: f4024cabdf0beb970e3a964433312ff944af1dc8 $")
26 
27 #include <freeradius-devel/radiusd.h>
28 #include <freeradius-devel/modules.h>
29 
30 #include <sys/types.h>
31 #include <pthread.h>
32 
33 #include "otp.h" /* OTP_MAX_CHALLENGE_LEN, otp_pwe_t */
34 
35 /* otpd rendezvous point */
36 #define OTP_OTPD_RP "/var/run/otpd/socket"
37 
38 /* Default prompt for presentation of challenge */
39 #define OTP_CHALLENGE_PROMPT "Challenge: %{reply:OTP-Challenge}\n Response: "
40 
41 typedef struct rlm_otp_t {
42  char const *name; //!< Instance name for mod_authorize().
43  char const *otpd_rp; //!< Otpd rendezvous point.
44  char const *chal_prompt; //!< Text to present challenge to user
45  //!< must have %s.
46 
47  uint8_t hmac_key[16]; //!< because it doesn't track State
48 
49  uint32_t challenge_len; //!< Challenge length, min 5 digits.
50  uint32_t challenge_delay; //!< Max delay time for response, in seconds.
51  bool allow_sync; //!< Useful to override pwdfile
52  //!< card_type settings.
53  bool allow_async; //!< C/R mode allowed?
54 
55  uint32_t mschapv2_mppe_policy; //!< Whether or not do to mppe for
56  //!< mschapv2.
57  uint32_t mschapv2_mppe_types; //!< Key type/length for mschapv2/mppe.
58  uint32_t mschap_mppe_policy; //!< Whether or not do to mppe for
59  //!< mschap .
60  uint32_t mschap_mppe_types; //!< key type/length for mschap/mppe.
61 } rlm_otp_t;
62 
63 /* otp_mppe.c */
64 void otp_mppe(REQUEST *, otp_pwe_t, rlm_otp_t const *, char const *);
65 
66 /* otp_pw_valid.c */
67 int otp_pw_valid(REQUEST *, int, char const *, rlm_otp_t const *, char []);
68 
69 /* otp_radstate.c */
70 #define OTP_MAX_RADSTATE_LEN 2 + (OTP_MAX_CHALLENGE_LEN * 2 + 8 + 8 + 32)*2 + 1
71 
73  char const [OTP_MAX_CHALLENGE_LEN],
74  size_t,
75  int32_t, int32_t, uint8_t const [16]);
76 
77 /* otp_pwe.c */
78 extern const fr_dict_attr_t *pwattr[8];
79 void otp_pwe_init(void);
81 
82 /* otp_util.c */
83 void otp_get_random(uint8_t *, size_t);
84 void otp_async_challenge(char[OTP_MAX_CHALLENGE_LEN + 1], size_t);
85 ssize_t otp_a2x(uint8_t const *, size_t, uint8_t *);
86 
87 void _otp_pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t const *,
88  char const *);
89 void _otp_pthread_mutex_lock(pthread_mutex_t *, char const *);
90 int _otp_pthread_mutex_trylock(pthread_mutex_t *, char const *);
91 void _otp_pthread_mutex_unlock(pthread_mutex_t *, char const *);
92 
93 #define otp_pthread_mutex_init(a, b) _otp_pthread_mutex_init((a), (b), __func__)
94 #define otp_pthread_mutex_lock(a) _otp_pthread_mutex_lock((a), __func__)
95 #define otp_pthread_mutex_trylock(a) _otp_pthread_mutex_trylock((a), __func__)
96 #define otp_pthread_mutex_unlock(a) _otp_pthread_mutex_unlock((a), __func__)
97 
98 #endif /* EXTERN_H */
#define OTP_MAX_RADSTATE_LEN
Definition: extern.h:70
uint32_t challenge_delay
Max delay time for response, in seconds.
Definition: extern.h:50
#define RCSIDH(h, id)
Definition: build.h:136
const fr_dict_attr_t * pwattr[8]
Definition: otp_pwe.c:48
char const * otpd_rp
Otpd rendezvous point.
Definition: extern.h:43
void otp_pwe_init(void)
Definition: otp_pwe.c:53
uint32_t mschapv2_mppe_types
Key type/length for mschapv2/mppe.
Definition: extern.h:57
uint32_t mschap_mppe_policy
Whether or not do to mppe for mschap .
Definition: extern.h:58
enum otp_pwe otp_pwe_t
int _otp_pthread_mutex_trylock(pthread_mutex_t *, char const *)
Guaranteed trylock.
Definition: otp_util.c:114
Dictionary attribute.
Definition: dict.h:77
bool allow_async
C/R mode allowed?
Definition: extern.h:53
struct rlm_otp_t rlm_otp_t
size_t otp_gen_state(char[OTP_MAX_RADSTATE_LEN], char const [OTP_MAX_CHALLENGE_LEN], size_t, int32_t, int32_t, uint8_t const [16])
Generate an OTP state value.
Definition: otp_radstate.c:108
char const * chal_prompt
Text to present challenge to user must have s.
Definition: extern.h:44
void otp_async_challenge(char[OTP_MAX_CHALLENGE_LEN+1], size_t)
Generate a random challenge (ascii chars 0-9)
Definition: otp_util.c:63
char const * name
Instance name for mod_authorize().
Definition: extern.h:42
void otp_get_random(uint8_t *, size_t)
Generate some random bytes.
Definition: otp_util.c:37
int otp_pw_valid(REQUEST *, int, char const *, rlm_otp_t const *, char[])
void _otp_pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t const *, char const *)
Guaranteed initialization.
Definition: otp_util.c:82
uint32_t challenge_len
Challenge length, min 5 digits.
Definition: extern.h:49
void otp_mppe(REQUEST *, otp_pwe_t, rlm_otp_t const *, char const *)
Definition: otp_mppe.c:45
uint32_t mschapv2_mppe_policy
Whether or not do to mppe for mschapv2.
Definition: extern.h:55
void _otp_pthread_mutex_unlock(pthread_mutex_t *, char const *)
Guaranteed unlock.
Definition: otp_util.c:132
#define OTP_MAX_CHALLENGE_LEN
Definition: otp.h:35
otp_pwe_t otp_pwe_present(REQUEST const *)
Definition: otp_pwe.c:120
ssize_t otp_a2x(uint8_t const *, size_t, uint8_t *)
bool allow_sync
Useful to override pwdfile card_type settings.
Definition: extern.h:51
void _otp_pthread_mutex_lock(pthread_mutex_t *, char const *)
Guaranteed lock.
Definition: otp_util.c:98
uint32_t mschap_mppe_types
key type/length for mschap/mppe.
Definition: extern.h:60
uint8_t hmac_key[16]
because it doesn't track State
Definition: extern.h:47