opie.h revision 22347
122347Spst/* opie.h: Data structures and values for the OPIE authentication 222347Spst system that a program might need. 322347Spst 422347Spst%%% portions-copyright-cmetz 522347SpstPortions of this software are Copyright 1996 by Craig Metz, All Rights 622347SpstReserved. The Inner Net License Version 2 applies to these portions of 722347Spstthe software. 822347SpstYou should have received a copy of the license with this software. If 922347Spstyou didn't get a copy, you may request one from <license@inner.net>. 1022347Spst 1122347SpstPortions of this software are Copyright 1995 by Randall Atkinson and Dan 1222347SpstMcDonald, All Rights Reserved. All Rights under this copyright are assigned 1322347Spstto the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and 1422347SpstLicense Agreement applies to this software. 1522347Spst 1622347Spst History: 1722347Spst 1822347Spst Modified by cmetz for OPIE 2.3. Renamed PTR to VOIDPTR. Added 1922347Spst re-init key and extension file fields to struct opie. Added 2022347Spst opie_ prefix on struct opie members. Added opie_flags field 2122347Spst and definitions. Added more prototypes. Changed opiehash() 2222347Spst prototype. 2322347Spst Modified by cmetz for OPIE 2.22. Define __P correctly if this file 2422347Spst is included in a third-party program. 2522347Spst Modified by cmetz for OPIE 2.2. Re-did prototypes. Added FUNCTION 2622347Spst definition et al. Multiple-include protection. Added struct 2722347Spst utsname fake. Got rid of gethostname() cruft. Moved UINT4 2822347Spst here. Provide for *seek whence values. Move MDx context here 2922347Spst and unify. Re-did prototypes. 3022347Spst Modified at NRL for OPIE 2.0. 3122347Spst Written at Bellcore for the S/Key Version 1 software distribution 3222347Spst (skey.h). 3322347Spst*/ 3422347Spst#ifndef _OPIE_H 3522347Spst#define _OPIE_H 3622347Spst 3722347Spst#if _OPIE 3822347Spst 3922347Spst#if HAVE_VOIDPTR 4022347Spst#define VOIDPTR void * 4122347Spst#else /* HAVE_VOIDPTR */ 4222347Spst#define VOIDPTR char * 4322347Spst#endif /* HAVE_VOIDPTR */ 4422347Spst 4522347Spst#if HAVE_VOIDRET 4622347Spst#define VOIDRET void 4722347Spst#else /* HAVE_VOIDRET */ 4822347Spst#define VOIDRET 4922347Spst#endif /* HAVE_VOIDRET */ 5022347Spst 5122347Spst#if HAVE_VOIDARG 5222347Spst#define NOARGS void 5322347Spst#else /* HAVE_VOIDARG */ 5422347Spst#define NOARGS 5522347Spst#endif /* HAVE_VOIDARG */ 5622347Spst 5722347Spst#if HAVE_ANSIDECL 5822347Spst#define FUNCTION(arglist, args) (args) 5922347Spst#define AND , 6022347Spst#else /* HAVE_ANSIDECL */ 6122347Spst#define FUNCTION(arglist, args) arglist args; 6222347Spst#define AND ; 6322347Spst#endif /* HAVE_ANSIDECL */ 6422347Spst 6522347Spst#define FUNCTION_NOARGS () 6622347Spst 6722347Spst#ifndef __P 6822347Spst#if HAVE_ANSIPROTO 6922347Spst#define __P(x) x 7022347Spst#else /* HAVE_ANSIPROTO */ 7122347Spst#define __P(x) () 7222347Spst#endif /* HAVE_ANSIPROTO */ 7322347Spst#endif /* __P */ 7422347Spst 7522347Spst#ifndef HAVE_SYS_UTSNAME_H 7622347Spststruct utsname { 7722347Spst char nodename[65]; 7822347Spst }; 7922347Spst#endif /* HAVE_SYS_UTSNAME_H */ 8022347Spst 8122347Spst#ifndef _SC_OPEN_MAX 8222347Spst#define _SC_OPEN_MAX 1 8322347Spst#endif /* _SC_OPEN_MAX */ 8422347Spst 8522347Spst#ifndef MAXHOSTNAMELEN 8622347Spst#define MAXHOSTNAMELEN 1024 8722347Spst#endif /* MAXHOSTNAMELEN */ 8822347Spst 8922347Spst#else /* _OPIE */ 9022347Spst#ifdef __STDC__ 9122347Spst#define VOIDRET void 9222347Spst#define VOIDPTR void * 9322347Spst#else /* __STDC__ */ 9422347Spst#define VOIDRET 9522347Spst#define VOIDPTR char * 9622347Spst#endif /* __STDC__ */ 9722347Spst#endif /* _OPIE */ 9822347Spst 9922347Spst#ifndef __P 10022347Spst#ifdef __ARGS 10122347Spst#define __P __ARGS 10222347Spst#else /* __ARGS */ 10322347Spst#ifdef __STDC__ 10422347Spst#define __P(x) x 10522347Spst#else /* __STDC__ */ 10622347Spst#define __P(x) () 10722347Spst#endif /* __STDC__ */ 10822347Spst#endif /* __ARGS */ 10922347Spst#endif /* __P */ 11022347Spst 11122347Spststruct opie { 11222347Spst int opie_flags; 11322347Spst char opie_buf[256]; 11422347Spst char *opie_principal; 11522347Spst int opie_n; 11622347Spst char *opie_seed; 11722347Spst char *opie_val; 11822347Spst long opie_recstart; 11922347Spst char opie_extbuf[129]; /* > OPIE_PRINCIPAL_MAX + 1 + 16 + 2 + 1 */ 12022347Spst long opie_extrecstart; 12122347Spst char *opie_reinitkey; 12222347Spst}; 12322347Spst 12422347Spst#define __OPIE_FLAGS_RW 1 12522347Spst#define __OPIE_FLAGS_READ 2 12622347Spst 12722347Spst/* Minimum length of a secret password */ 12822347Spst#ifndef OPIE_SECRET_MIN 12922347Spst#define OPIE_SECRET_MIN 10 13022347Spst#endif /* OPIE_SECRET_MIN */ 13122347Spst 13222347Spst/* Maximum length of a secret password */ 13322347Spst#ifndef OPIE_SECRET_MAX 13422347Spst#define OPIE_SECRET_MAX 127 13522347Spst#endif /* OPIE_SECRET_MAX */ 13622347Spst 13722347Spst/* Minimum length of a seed */ 13822347Spst#ifndef OPIE_SEED_MIN 13922347Spst#define OPIE_SEED_MIN 5 14022347Spst#endif /* OPIE_SEED_MIN */ 14122347Spst 14222347Spst/* Maximum length of a seed */ 14322347Spst#ifndef OPIE_SEED_MAX 14422347Spst#define OPIE_SEED_MAX 16 14522347Spst#endif /* OPIE_SEED_MAX */ 14622347Spst 14722347Spst/* Maximum length of a challenge (otp-md? 9999 seed) */ 14822347Spst#ifndef OPIE_CHALLENGE_MAX 14922347Spst#define OPIE_CHALLENGE_MAX (7+1+4+1+OPIE_SEED_MAX) 15022347Spst#endif /* OPIE_CHALLENGE_MAX */ 15122347Spst 15222347Spst/* Maximum length of a response that we allow */ 15322347Spst#ifndef OPIE_RESPONSE_MAX 15422347Spst#define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19) 15522347Spst#endif /* OPIE_RESPONSE_MAX */ 15622347Spst 15722347Spst/* Maximum length of a principal (read: user name) */ 15822347Spst#ifndef OPIE_PRINCIPAL_MAX 15922347Spst#define OPIE_PRINCIPAL_MAX 32 16022347Spst#endif /* OPIE_PRINCIPAL_MAX */ 16122347Spst 16222347Spst#ifndef __alpha 16322347Spst#define UINT4 unsigned long 16422347Spst#else /* __alpha */ 16522347Spst#define UINT4 unsigned int 16622347Spst#endif /* __alpha */ 16722347Spst 16822347Spststruct opiemdx_ctx { 16922347Spst UINT4 state[4]; 17022347Spst UINT4 count[2]; 17122347Spst unsigned char buffer[64]; 17222347Spst}; 17322347Spst 17422347Spst#ifndef SEEK_SET 17522347Spst#define SEEK_SET 0 17622347Spst#endif /* SEEK_SET */ 17722347Spst 17822347Spst#ifndef SEEK_END 17922347Spst#define SEEK_END 2 18022347Spst#endif /* SEEK_END */ 18122347Spst 18222347Spstint opieaccessfile __P((char *)); 18322347Spstint rdnets __P((long)); 18422347Spstint isaddr __P((register char *)); 18522347Spstint opiealways __P((char *)); 18622347Spstchar *opieatob8 __P((char *,char *)); 18722347SpstVOIDRET opiebackspace __P((char *)); 18822347Spstchar *opiebtoa8 __P((char *,char *)); 18922347Spstchar *opiebtoe __P((char *,char *)); 19022347Spstchar *opiebtoh __P((char *,char *)); 19122347Spstint opieetob __P((char *,char *)); 19222347Spstint opiechallenge __P((struct opie *,char *,char *)); 19322347Spstint opiegenerator __P((char *,char *,char *)); 19422347Spstint opiegetsequence __P((struct opie *)); 19522347SpstVOIDRET opiehash __P((VOIDPTR, unsigned)); 19622347Spstint opiehtoi __P((register char)); 19722347Spstint opiekeycrunch __P((int, char *, char *, char *)); 19822347Spstint opielock __P((char *)); 19922347Spstint opielookup __P((struct opie *,char *)); 20022347SpstVOIDRET opiemd4init __P((struct opiemdx_ctx *)); 20122347SpstVOIDRET opiemd4update __P((struct opiemdx_ctx *,unsigned char *,unsigned int)); 20222347SpstVOIDRET opiemd4final __P((unsigned char *,struct opiemdx_ctx *)); 20322347SpstVOIDRET opiemd5init __P((struct opiemdx_ctx *)); 20422347SpstVOIDRET opiemd5update __P((struct opiemdx_ctx *,unsigned char *,unsigned int)); 20522347SpstVOIDRET opiemd5final __P((unsigned char *,struct opiemdx_ctx *)); 20622347Spstint opiepasscheck __P((char *)); 20722347SpstVOIDRET opierandomchallenge __P((char *)); 20822347Spstchar * opieskipspace __P((register char *)); 20922347SpstVOIDRET opiestripcrlf __P((char *)); 21022347Spstint opieverify __P((struct opie *,char *)); 21122347Spstint opiepasswd __P((struct opie *, int, char *, int, char *, char *)); 21222347Spstchar *opiereadpass __P((char *, int, int)); 21322347Spstint opielogin __P((char *line, char *name, char *host)); 21422347Spst 21522347Spst#if _OPIE 21622347Spststruct utmp; 21722347Spstint __opiegetutmpentry __P((char *, struct utmp *)); 21822347Spst#ifdef EOF 21922347SpstFILE *__opieopen __P((char *, int, int)); 22022347Spst#endif /* EOF */ 22122347Spstint __opiereadrec __P((struct opie *)); 22222347Spstint __opiewriterec __P((struct opie *)); 22322347Spst#endif /* _OPIE */ 22422347Spst#endif /* _OPIE_H */ 225