opie.h revision 22348
1/* opie.h: Data structures and values for the OPIE authentication
2	system that a program might need.
3
4%%% portions-copyright-cmetz
5Portions of this software are Copyright 1996 by Craig Metz, All Rights
6Reserved. The Inner Net License Version 2 applies to these portions of
7the software.
8You should have received a copy of the license with this software. If
9you didn't get a copy, you may request one from <license@inner.net>.
10
11Portions of this software are Copyright 1995 by Randall Atkinson and Dan
12McDonald, All Rights Reserved. All Rights under this copyright are assigned
13to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
14License Agreement applies to this software.
15
16	History:
17
18	Modified by cmetz for OPIE 2.3. Renamed PTR to VOIDPTR. Added
19		re-init key and extension file fields to struct opie. Added
20		opie_ prefix on struct opie members. Added opie_flags field
21		and definitions. Added more prototypes. Changed opiehash()
22		prototype.
23	Modified by cmetz for OPIE 2.22. Define __P correctly if this file
24		is included in a third-party program.
25	Modified by cmetz for OPIE 2.2. Re-did prototypes. Added FUNCTION
26                definition et al. Multiple-include protection. Added struct
27		utsname fake. Got rid of gethostname() cruft. Moved UINT4
28                here. Provide for *seek whence values. Move MDx context here
29                and unify. Re-did prototypes.
30	Modified at NRL for OPIE 2.0.
31	Written at Bellcore for the S/Key Version 1 software distribution
32		(skey.h).
33*/
34#ifndef _OPIE_H
35#define _OPIE_H
36
37#if _OPIE
38
39#if HAVE_VOIDPTR
40#define VOIDPTR void *
41#else /* HAVE_VOIDPTR */
42#define VOIDPTR char *
43#endif /* HAVE_VOIDPTR */
44
45#if HAVE_VOIDRET
46#define VOIDRET void
47#else /* HAVE_VOIDRET */
48#define VOIDRET
49#endif /* HAVE_VOIDRET */
50
51#if HAVE_VOIDARG
52#define NOARGS void
53#else /* HAVE_VOIDARG */
54#define NOARGS
55#endif /* HAVE_VOIDARG */
56
57#if HAVE_ANSIDECL
58#define FUNCTION(arglist, args) (args)
59#define AND ,
60#else /* HAVE_ANSIDECL */
61#define FUNCTION(arglist, args) arglist args;
62#define AND ;
63#endif /* HAVE_ANSIDECL */
64
65#define FUNCTION_NOARGS ()
66
67#ifndef __P
68#if HAVE_ANSIPROTO
69#define __P(x) x
70#else /* HAVE_ANSIPROTO */
71#define __P(x) ()
72#endif /* HAVE_ANSIPROTO */
73#endif /* __P */
74
75#ifndef HAVE_SYS_UTSNAME_H
76struct utsname {
77	char nodename[65];
78	};
79#endif /* HAVE_SYS_UTSNAME_H */
80
81#ifndef _SC_OPEN_MAX
82#define _SC_OPEN_MAX 1
83#endif /* _SC_OPEN_MAX */
84
85#ifndef MAXHOSTNAMELEN
86#define MAXHOSTNAMELEN 1024
87#endif /* MAXHOSTNAMELEN */
88
89#else /* _OPIE */
90#ifdef __STDC__
91#define VOIDRET void
92#define VOIDPTR void *
93#else /* __STDC__ */
94#define VOIDRET
95#define VOIDPTR char *
96#endif /* __STDC__ */
97#endif /* _OPIE */
98
99#ifndef __P
100#ifdef __ARGS
101#define __P __ARGS
102#else /* __ARGS */
103#ifdef __STDC__
104#define __P(x) x
105#else /* __STDC__ */
106#define __P(x) ()
107#endif /* __STDC__ */
108#endif /* __ARGS */
109#endif /* __P */
110
111struct opie {
112  int opie_flags;
113  char opie_buf[256];
114  char *opie_principal;
115  int opie_n;
116  char *opie_seed;
117  char *opie_val;
118  long opie_recstart;
119  char opie_extbuf[129]; /* > OPIE_PRINCIPAL_MAX + 1 + 16 + 2 + 1 */
120  long opie_extrecstart;
121  char *opie_reinitkey;
122};
123
124#define __OPIE_FLAGS_RW 1
125#define __OPIE_FLAGS_READ 2
126
127/* Minimum length of a secret password */
128#ifndef OPIE_SECRET_MIN
129#define OPIE_SECRET_MIN 10
130#endif	/* OPIE_SECRET_MIN */
131
132/* Maximum length of a secret password */
133#ifndef OPIE_SECRET_MAX
134#define OPIE_SECRET_MAX 127
135#endif	/* OPIE_SECRET_MAX */
136
137/* Minimum length of a seed */
138#ifndef OPIE_SEED_MIN
139#define OPIE_SEED_MIN 5
140#endif	/* OPIE_SEED_MIN */
141
142/* Maximum length of a seed */
143#ifndef OPIE_SEED_MAX
144#define OPIE_SEED_MAX 16
145#endif	/* OPIE_SEED_MAX */
146
147/* Maximum length of a challenge (otp-md? 9999 seed) */
148#ifndef OPIE_CHALLENGE_MAX
149#define OPIE_CHALLENGE_MAX (7+1+4+1+OPIE_SEED_MAX)
150#endif	/* OPIE_CHALLENGE_MAX */
151
152/* Maximum length of a response that we allow */
153#ifndef OPIE_RESPONSE_MAX
154#define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19)
155#endif	/* OPIE_RESPONSE_MAX */
156
157/* Maximum length of a principal (read: user name) */
158#ifndef OPIE_PRINCIPAL_MAX
159#define OPIE_PRINCIPAL_MAX 32
160#endif	/* OPIE_PRINCIPAL_MAX */
161
162#ifndef __alpha
163#define UINT4 unsigned long
164#else   /* __alpha */
165#define UINT4 unsigned int
166#endif  /* __alpha */
167
168struct opiemdx_ctx {
169	UINT4 state[4];
170	UINT4 count[2];
171	unsigned char buffer[64];
172};
173
174#ifndef SEEK_SET
175#define SEEK_SET 0
176#endif /* SEEK_SET */
177
178#ifndef SEEK_END
179#define SEEK_END 2
180#endif /* SEEK_END */
181
182int  opieaccessfile __P((char *));
183int  rdnets __P((long));
184int  isaddr __P((register char *));
185int  opiealways __P((char *));
186char *opieatob8 __P((char *,char *));
187VOIDRET  opiebackspace __P((char *));
188char *opiebtoa8 __P((char *,char *));
189char *opiebtoe __P((char *,char *));
190char *opiebtoh __P((char *,char *));
191int  opieetob __P((char *,char *));
192int  opiechallenge __P((struct opie *,char *,char *));
193int  opiegenerator __P((char *,char *,char *));
194int  opiegetsequence __P((struct opie *));
195VOIDRET  opiehash __P((VOIDPTR, unsigned));
196int  opiehtoi __P((register char));
197int  opiekeycrunch __P((int, char *, char *, char *));
198int  opielock __P((char *));
199int  opielookup __P((struct opie *,char *));
200VOIDRET  opiemd4init __P((struct opiemdx_ctx *));
201VOIDRET  opiemd4update __P((struct opiemdx_ctx *,unsigned char *,unsigned int));
202VOIDRET  opiemd4final __P((unsigned char *,struct opiemdx_ctx *));
203VOIDRET  opiemd5init __P((struct opiemdx_ctx *));
204VOIDRET  opiemd5update __P((struct opiemdx_ctx *,unsigned char *,unsigned int));
205VOIDRET  opiemd5final __P((unsigned char *,struct opiemdx_ctx *));
206int  opiepasscheck __P((char *));
207VOIDRET  opierandomchallenge __P((char *));
208char * opieskipspace __P((register char *));
209VOIDRET  opiestripcrlf __P((char *));
210int  opieverify __P((struct opie *,char *));
211int opiepasswd __P((struct opie *, int, char *, int, char *, char *));
212char *opiereadpass __P((char *, int, int));
213int opielogin __P((char *line, char *name, char *host));
214
215#if _OPIE
216struct utmp;
217int __opiegetutmpentry __P((char *, struct utmp *));
218#ifdef EOF
219FILE *__opieopen __P((char *, int, int));
220#endif /* EOF */
221int __opiereadrec __P((struct opie *));
222int __opiewriterec __P((struct opie *));
223#endif /* _OPIE */
224#endif /* _OPIE_H */
225