All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
otp.h
Go to the documentation of this file.
1 /*
2  * $Id: db43962786fdadf53b7d63975da4f3074a3d8ae7 $
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 RCSIDH(otp_h, "$Id: db43962786fdadf53b7d63975da4f3074a3d8ae7 $")
27 
28 #include <sys/types.h>
29 
30 /*
31  * NOTE: This file must be synced between plugins/otpd/lsmd/gsmd/changepin.
32  */
33 
34 #ifndef OTP_MAX_CHALLENGE_LEN
35 #define OTP_MAX_CHALLENGE_LEN 16
36 #elif OTP_MAX_CHALLENGE_LEN != 16
37 #error OTP_MAX_CHALLENGE_LEN
38 #endif
39 
40 #define OTP_RC_OK 0
41 #define OTP_RC_USER_UNKNOWN 1
42 #define OTP_RC_AUTHINFO_UNAVAIL 2
43 #define OTP_RC_AUTH_ERR 3
44 #define OTP_RC_MAXTRIES 4
45 #define OTP_RC_SERVICE_ERR 5
46 #define OTP_RC_NEXTPASSCODE 6
47 #define OTP_RC_IPIN 7
48 
49 #define OTP_MAX_USERNAME_LEN 31
50 
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 {
57  PWE_NONE = 0,
58  PWE_PAP = 1,
59  PWE_CHAP = 3,
62 } otp_pwe_t;
63 
64 typedef struct otp_pwe_pap {
67 
68 typedef struct otp_pwe_chap {
69  uint8_t challenge[OTP_MAX_CHAP_CHALLENGE_LEN]; //!< CHAP challenge
70  size_t clen;
72  size_t rlen;
74 
75 typedef struct otp_request_t {
76  int version; //!< Should be 2.
78  char challenge[OTP_MAX_CHALLENGE_LEN + 1]; //!< USER challenge.
79  struct {
80  otp_pwe_t pwe;
81 
82  union {
83  otp_pwe_pap_t pap;
84  otp_pwe_chap_t chap;
85  } u;
86  } pwe;
87 
88  bool allow_async; //!< Async auth allowed?
89  bool allow_sync; //!< Sync auth allowed?
90  unsigned challenge_delay; //!< Min delay between async
91  //!< auths.
92  int resync; //!< Resync on async auth?
94 
95 typedef struct otp_reply_t {
96  int version; //!< Should be 1.
97  int rc;
99 } otp_reply_t;
100 
101 #endif /* _OTP_H */
Definition: otp.h:58
char challenge[OTP_MAX_CHALLENGE_LEN+1]
USER challenge.
Definition: otp.h:78
#define RCSIDH(h, id)
Definition: build.h:136
uint8_t challenge[OTP_MAX_CHAP_CHALLENGE_LEN]
CHAP challenge.
Definition: otp.h:69
#define OTP_MAX_CHAP_RESPONSE_LEN
Definition: otp.h:54
enum otp_pwe otp_pwe_t
char passcode[OTP_MAX_PASSCODE_LEN+1]
Definition: otp.h:98
struct otp_pwe_pap otp_pwe_pap_t
Definition: otp.h:59
Definition: otp.h:60
struct otp_reply_t otp_reply_t
#define OTP_MAX_CHAP_CHALLENGE_LEN
Definition: otp.h:53
struct otp_request_t otp_request_t
int version
Should be 2.
Definition: otp.h:76
uint8_t response[OTP_MAX_CHAP_RESPONSE_LEN]
Definition: otp.h:71
int rc
Definition: otp.h:97
char username[OTP_MAX_USERNAME_LEN+1]
Definition: otp.h:77
size_t rlen
Definition: otp.h:72
int resync
Resync on async auth?
Definition: otp.h:92
otp_pwe
Definition: otp.h:56
char passcode[OTP_MAX_PASSCODE_LEN+1]
Definition: otp.h:65
bool allow_sync
Sync auth allowed?
Definition: otp.h:89
bool allow_async
Async auth allowed?
Definition: otp.h:88
int version
Should be 1.
Definition: otp.h:96
#define OTP_MAX_CHALLENGE_LEN
Definition: otp.h:35
size_t clen
Definition: otp.h:70
struct otp_pwe_chap otp_pwe_chap_t
#define OTP_MAX_PASSCODE_LEN
Definition: otp.h:52
Definition: otp.h:57
struct otp_request_t::@20 pwe
unsigned challenge_delay
Min delay between async auths.
Definition: otp.h:90
#define OTP_MAX_USERNAME_LEN
Definition: otp.h:49