122347Spst/* opie.h: Data structures and values for the OPIE authentication 222347Spst system that a program might need. 322347Spst 429967Sache%%% portions-copyright-cmetz-96 592914SmarkmPortions of this software are Copyright 1996-1999 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 1892914Smarkm Modified by cmetz for OPIE 2.4. Added sequence number limits. Added 1992914Smarkm struct opie_otpkey and made many functions use it. Added 2092914Smarkm opiestrncpy(). Include header with libmissing prototypes. 2159121Skris Modified by cmetz for OPIE 2.32. Added symbolic flag names for 2259121Skris opiepasswd(). Added __opieparsechallenge() prototype. 2329967Sache Modified by cmetz for OPIE 2.31. Removed active attack protection. 2422347Spst Modified by cmetz for OPIE 2.3. Renamed PTR to VOIDPTR. Added 2522347Spst re-init key and extension file fields to struct opie. Added 2622347Spst opie_ prefix on struct opie members. Added opie_flags field 2722347Spst and definitions. Added more prototypes. Changed opiehash() 2822347Spst prototype. 2922347Spst Modified by cmetz for OPIE 2.22. Define __P correctly if this file 3022347Spst is included in a third-party program. 3122347Spst Modified by cmetz for OPIE 2.2. Re-did prototypes. Added FUNCTION 3222347Spst definition et al. Multiple-include protection. Added struct 3322347Spst utsname fake. Got rid of gethostname() cruft. Moved UINT4 3422347Spst here. Provide for *seek whence values. Move MDx context here 3522347Spst and unify. Re-did prototypes. 3622347Spst Modified at NRL for OPIE 2.0. 3722347Spst Written at Bellcore for the S/Key Version 1 software distribution 3822347Spst (skey.h). 3959121Skris 4059121Skris$FreeBSD$ 4122347Spst*/ 4222347Spst#ifndef _OPIE_H 4329967Sache#define _OPIE_H 1 4422347Spst 4522347Spststruct opie { 4622347Spst int opie_flags; 4722347Spst char opie_buf[256]; 4822347Spst char *opie_principal; 4922347Spst int opie_n; 5022347Spst char *opie_seed; 5122347Spst char *opie_val; 5222347Spst long opie_recstart; 5322347Spst}; 5422347Spst 5522347Spst#define __OPIE_FLAGS_RW 1 5622347Spst#define __OPIE_FLAGS_READ 2 5722347Spst 5822347Spst/* Minimum length of a secret password */ 5992914Smarkm#ifndef OPIE_SECRET_MIN 6022347Spst#define OPIE_SECRET_MIN 10 6192914Smarkm#endif /* OPIE_SECRET_MIN */ 6222347Spst 6322347Spst/* Maximum length of a secret password */ 6422347Spst#define OPIE_SECRET_MAX 127 6522347Spst 6622347Spst/* Minimum length of a seed */ 6722347Spst#define OPIE_SEED_MIN 5 6822347Spst 6922347Spst/* Maximum length of a seed */ 7022347Spst#define OPIE_SEED_MAX 16 7122347Spst 7260572Skris/* Max length of hash algorithm name (md4/md5) */ 7360572Skris#define OPIE_HASHNAME_MAX 3 7460572Skris 7522347Spst/* Maximum length of a challenge (otp-md? 9999 seed) */ 7660572Skris#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX) 7722347Spst 7822347Spst/* Maximum length of a response that we allow */ 7922347Spst#define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19) 8022347Spst 8122347Spst/* Maximum length of a principal (read: user name) */ 8222347Spst#define OPIE_PRINCIPAL_MAX 32 8322347Spst 8492914Smarkm/* Maximum sequence number */ 8592914Smarkm#ifndef OPIE_SEQUENCE_MAX 8692914Smarkm#define OPIE_SEQUENCE_MAX 9999 8792914Smarkm#endif /* OPIE_SEQUENCE_MAX */ 8822347Spst 8992914Smarkm/* Restricted sequence number */ 9092914Smarkm#ifndef OPIE_SEQUENCE_RESTRICT 9192914Smarkm#define OPIE_SEQUENCE_RESTRICT 9 9292914Smarkm#endif /* OPIE_SEQUENCE_RESTRICT */ 9392914Smarkm 9492914Smarkm#define UINT4 u_int32_t 9592914Smarkm 9692914Smarkmstruct opie_otpkey { 9792914Smarkm UINT4 words[2]; 9892914Smarkm}; 9992914Smarkm 10092914Smarkm#ifndef SEEK_SET 10192914Smarkm#define SEEK_SET 0 10292914Smarkm#endif /* SEEK_SET */ 10392914Smarkm 10492914Smarkm#ifndef SEEK_END 10592914Smarkm#define SEEK_END 2 10692914Smarkm#endif /* SEEK_END */ 10792914Smarkm 10823540Spst__BEGIN_DECLS 10922347Spstint opieaccessfile __P((char *)); 11022347Spstint rdnets __P((long)); 11122347Spstint isaddr __P((register char *)); 11222347Spstint opiealways __P((char *)); 11392914Smarkmchar *opieatob8 __P((struct opie_otpkey *, char *)); 11423540Spstvoid opiebackspace __P((char *)); 11592914Smarkmchar *opiebtoa8 __P((char *, struct opie_otpkey *)); 11692914Smarkmchar *opiebtoe __P((char *, struct opie_otpkey *)); 11792914Smarkmchar *opiebtoh __P((char *, struct opie_otpkey *)); 11892914Smarkmint opieetob __P((struct opie_otpkey *, char *)); 11922347Spstint opiechallenge __P((struct opie *,char *,char *)); 12022347Spstint opiegenerator __P((char *,char *,char *)); 12122347Spstint opiegetsequence __P((struct opie *)); 12292914Smarkmvoid opiehash __P((struct opie_otpkey *, unsigned)); 12322347Spstint opiehtoi __P((register char)); 12492914Smarkmint opiekeycrunch __P((int, struct opie_otpkey *, char *, char *)); 12522347Spstint opielock __P((char *)); 12659300Skrisint opieunlock __P((void)); 12759300Skrisvoid opieunlockaeh __P((void)); 12859300Skrisvoid opiedisableaeh __P((void)); 12922347Spstint opielookup __P((struct opie *,char *)); 13022347Spstint opiepasscheck __P((char *)); 13123540Spstvoid opierandomchallenge __P((char *)); 13222347Spstchar * opieskipspace __P((register char *)); 13323540Spstvoid opiestripcrlf __P((char *)); 13422347Spstint opieverify __P((struct opie *,char *)); 13529967Sacheint opiepasswd __P((struct opie *, int, char *, int, char *, char *)); 13622347Spstchar *opiereadpass __P((char *, int, int)); 13722347Spstint opielogin __P((char *line, char *name, char *host)); 13860572Skrisconst char *opie_get_algorithm __P((void)); 13960572Skrisint opie_haskey __P((char *username)); 14060572Skrischar *opie_keyinfo __P((char *)); 14160572Skrisint opie_passverify __P((char *username, char *passwd)); 14223540Spst__END_DECLS 14322347Spst 14429967Sache#if _OPIE 14529967Sache#define VOIDPTR void * 14629967Sache#define VOIDRET void 14729967Sache#define NOARGS void 14829967Sache#define FUNCTION(arglist, args) (args) 14929967Sache#define AND , 15029967Sache#define FUNCTION_NOARGS () 15123540Spst 15223540Spst__BEGIN_DECLS 15322347Spststruct utmp; 15429967Sacheint __opiegetutmpentry __P((char *, struct utmp *)); 15522347Spst#ifdef EOF 15622347SpstFILE *__opieopen __P((char *, int, int)); 15729967Sache#endif /* EOF */ 15829967Sacheint __opiereadrec __P((struct opie *)); 15929967Sacheint __opiewriterec __P((struct opie *)); 16059121Skrisint __opieparsechallenge __P((char *buffer, int *algorithm, int *sequence, char **seed, int *exts)); 16129972Sache__END_DECLS 16292914Smarkm 16392914Smarkm#define opiestrncpy(dst, src, n) \ 16492914Smarkm do { \ 16592914Smarkm strncpy(dst, src, n-1); \ 16692914Smarkm dst[n-1] = 0; \ 16792914Smarkm } while(0) 16892914Smarkm 16992914Smarkm/* #include "missing.h" */ 17029967Sache#endif /* _OPIE */ 17159121Skris 17259121Skris#define OPIEPASSWD_CONSOLE 1 17359121Skris#define OPIEPASSWD_FORCE 2 17459121Skris 17522347Spst#endif /* _OPIE_H */ 176