opie.h revision 23540
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
37struct opie {
38  int opie_flags;
39  char opie_buf[256];
40  char *opie_principal;
41  int opie_n;
42  char *opie_seed;
43  char *opie_val;
44  long opie_recstart;
45  char opie_extbuf[129]; /* > OPIE_PRINCIPAL_MAX + 1 + 16 + 2 + 1 */
46  long opie_extrecstart;
47  char *opie_reinitkey;
48};
49
50#define __OPIE_FLAGS_RW 1
51#define __OPIE_FLAGS_READ 2
52
53/* Minimum length of a secret password */
54#define OPIE_SECRET_MIN 10
55
56/* Maximum length of a secret password */
57#define OPIE_SECRET_MAX 127
58
59/* Minimum length of a seed */
60#define OPIE_SEED_MIN 5
61
62/* Maximum length of a seed */
63#define OPIE_SEED_MAX 16
64
65/* Maximum length of a challenge (otp-md? 9999 seed) */
66#define OPIE_CHALLENGE_MAX (7+1+4+1+OPIE_SEED_MAX)
67
68/* Maximum length of a response that we allow */
69#define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19)
70
71/* Maximum length of a principal (read: user name) */
72#define OPIE_PRINCIPAL_MAX 32
73
74struct opiemdx_ctx {
75	u_int32_t state[4];
76	u_int32_t count[2];
77	unsigned char buffer[64];
78};
79
80__BEGIN_DECLS
81int  opieaccessfile __P((char *));
82int  rdnets __P((long));
83int  isaddr __P((register char *));
84int  opiealways __P((char *));
85char *opieatob8 __P((char *,char *));
86void opiebackspace __P((char *));
87char *opiebtoa8 __P((char *,char *));
88char *opiebtoe __P((char *,char *));
89char *opiebtoh __P((char *,char *));
90int  opieetob __P((char *,char *));
91int  opiechallenge __P((struct opie *,char *,char *));
92int  opiegenerator __P((char *,char *,char *));
93int  opiegetsequence __P((struct opie *));
94void opiehash __P((void *, unsigned));
95int  opiehtoi __P((register char));
96int  opiekeycrunch __P((int, char *, char *, char *));
97int  opielock __P((char *));
98int  opielookup __P((struct opie *,char *));
99int  opiepasscheck __P((char *));
100void opierandomchallenge __P((char *));
101char * opieskipspace __P((register char *));
102void opiestripcrlf __P((char *));
103int  opieverify __P((struct opie *,char *));
104int  opiepasswd __P((struct opie *, int, char *, int, char *, char *));
105char *opiereadpass __P((char *, int, int));
106int opielogin __P((char *line, char *name, char *host));
107__END_DECLS
108
109#if _OPIE		/* internal glue support */
110
111#define	VOIDPTR void *
112#define	VOIDRET void
113#define	NOARGS	void
114#define	FUNCTION(arglist, args) (args)
115#define	AND	,
116#define	FUNCTION_NOARGS ()
117#define	UINT4	u_int32_t
118
119__BEGIN_DECLS
120struct utmp;
121int   __opiegetutmpentry __P((char *, struct utmp *));
122int   __opiereadrec __P((struct opie *));
123int   __opiewriterec __P((struct opie *));
124
125#ifdef EOF
126FILE *__opieopen __P((char *, int, int));
127#endif
128
129__END_DECLS
130
131#endif /* _OPIE */
132
133#endif /* _OPIE_H */
134