home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / pwgenera.zip / opie.h < prev    next >
C/C++ Source or Header  |  1996-03-20  |  5KB  |  195 lines

  1. /* opie.h: Data structures and values for the OPIE authentication
  2.     system that a program might need.
  3.  
  4. Portions of this software are Copyright 1996 by Craig Metz, All Rights
  5. Reserved. The Inner Net Copyright Notice and License Agreement applies to
  6. these portions of the software.
  7.  
  8. Portions of this software are Copyright 1995 by Randall Atkinson and Dan
  9. McDonald, All Rights Reserved. All Rights under this copyright are assigned
  10. to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
  11. License Agreement applies to this software.
  12.  
  13.     History:
  14.  
  15.     Modified by cmetz for OPIE 2.2. Re-did prototypes. Added FUNCTION
  16.                 definition et al. Multiple-include protection. Added struct
  17.         utsname fake. Got rid of gethostname() cruft. Moved UINT4
  18.                 here. Provide for *seek whence values. Move MDx context here
  19.                 and unify. Re-did prototypes.
  20.     Modified at NRL for OPIE 2.0.
  21.     Written at Bellcore for the S/Key Version 1 software distribution
  22.         (skey.h).
  23. */
  24. #ifndef _OPIE_H
  25. #define _OPIE_H
  26.  
  27. #if _OPIE
  28.  
  29. #if HAVE_VOIDPTR
  30. #define PTR void *
  31. #else /* HAVE_VOIDPTR */
  32. #define PTR char *
  33. #endif /* HAVE_VOIDPTR */
  34.  
  35. #if HAVE_VOIDRET
  36. #define VOIDRET void
  37. #else /* HAVE_VOIDRET */
  38. #define VOIDRET
  39. #endif /* HAVE_VOIDRET */
  40.  
  41. #if HAVE_VOIDARG
  42. #define NOARGS void
  43. #else /* HAVE_VOIDARG */
  44. #define NOARGS
  45. #endif /* HAVE_VOIDARG */
  46.  
  47. #if HAVE_ANSIDECL
  48. #define FUNCTION(arglist, args) (args)
  49. #define AND ,
  50. #else /* HAVE_ANSIDECL */
  51. #define FUNCTION(arglist, args) arglist args;
  52. #define AND ;
  53. #endif /* HAVE_ANSIDECL */
  54.  
  55. #define FUNCTION_NOARGS ()
  56.  
  57. #ifndef __P
  58. #if HAVE_ANSIPROTO
  59. #define __P(x) x
  60. #else /* HAVE_ANSIPROTO */
  61. #define __P(x) ()
  62. #endif /* HAVE_ANSIPROTO */
  63. #endif /* __P */
  64.  
  65. #ifndef HAVE_SYS_UTSNAME_H
  66. struct utsname {
  67.     char nodename[65];
  68.     };
  69. #endif /* HAVE_SYS_UTSNAME_H */
  70.  
  71. #ifndef MAXHOSTNAMELEN
  72. #define MAXHOSTNAMELEN 1024
  73. #endif /* MAXHOSTNAMELEN */
  74.  
  75. #else /* _OPIE */
  76. #ifdef __STDC__
  77. #define VOIDRET void
  78. #else /* __STDC__ */
  79. #define VOIDRET
  80. #endif /* __STDC__ */
  81. #endif /* _OPIE */
  82.  
  83. #ifndef __P
  84. #ifdef __ARGS
  85. #define __P __ARGS
  86. #else /* __ARGS */
  87. #ifdef __STDC__
  88. #define __P(x) (x)
  89. #else /* __STDC__ */
  90. #define __P(x) ()
  91. #endif /* __STDC__ */
  92. #endif /* __ARGS */
  93. #endif /* __P */
  94.  
  95. /* Server library's internal state block.
  96.    Code outside libopie.a should treat this as an opaque data block and
  97.    should not ever manipulate this structure in any way. Its format is
  98.    subject to change in future versions of OPIE.
  99. */
  100. struct opie {
  101.   void *keyfile;
  102.   char buf[256];
  103.   char *logname;
  104.   int n;
  105.   char *seed;
  106.   char *val;
  107.   long recstart;    /* needed so reread of buffer is efficient */
  108. };
  109.  
  110. /* Minimum length of a secret password */
  111. #ifndef OPIE_PASS_MIN
  112. #define OPIE_PASS_MIN 10
  113. #endif    /* OPIE_PASS_MIN */
  114.  
  115. /* Maximum length of a secret password */
  116. #ifndef OPIE_PASS_MAX
  117. #define OPIE_PASS_MAX 127
  118. #endif    /* OPIE_PASS_MAX */
  119.  
  120. /* Minimum length of a seed */
  121. #ifndef OPIE_SEED_MIN
  122. #define OPIE_SEED_MIN 5
  123. #endif    /* OPIE_SEED_MIN */
  124.  
  125. /* Maximum length of a seed */
  126. #ifndef OPIE_SEED_MAX
  127. #define OPIE_SEED_MAX 16
  128. #endif    /* OPIE_SEED_MAX */
  129.  
  130. /* Maximum length of a challenge (otp-md? 9999 seed) */
  131. #ifndef OPIE_CHALLENGE_MAX
  132. #define OPIE_CHALLENGE_MAX (7+1+4+1+OPIE_SEED_MAX)
  133. #endif    /* OPIE_CHALLENGE_MAX */
  134.  
  135. /* Maximum length of a response (six words up to four chars each w/spaces) */
  136. #ifndef OPIE_RESPONSE_MAX
  137. #define OPIE_RESPONSE_MAX (6*4+5)
  138. #endif    /* OPIE_RESPONSE_MAX */
  139.  
  140. /* Maximum length of a principal (read: user name) */
  141. #ifndef OPIE_PRINCIPAL_MAX
  142. #define OPIE_PRINCIPAL_MAX 32
  143. #endif    /* OPIE_PRINCIPAL_MAX */
  144.  
  145. #ifndef __alpha
  146. #define UINT4 unsigned long
  147. #else   /* __alpha */
  148. #define UINT4 unsigned int 
  149. #endif  /* __alpha */
  150.  
  151. struct opiemdx_ctx {
  152.     UINT4 state[4];
  153.     UINT4 count[2];
  154.     unsigned char buffer[64];
  155. };
  156.  
  157. #ifndef SEEK_SET
  158. #define SEEK_SET 0
  159. #endif /* SEEK_SET */
  160.  
  161. #ifndef SEEK_END
  162. #define SEEK_END 2
  163. #endif /* SEEK_END */
  164.  
  165. int  opieaccessfile __P((char *));
  166. int  rdnets __P((long));
  167. int  isaddr __P((register char *));
  168. int  opiealways __P((char *));
  169. int  opieatob8 __P((char *,char *));
  170. VOIDRET  opiebackspace __P((char *));
  171. int  opiebtoa8 __P((char *,char *));
  172. char * opiebtoe __P((char *,char *));
  173. int  opieetob __P((char *,char *));
  174. int  opiechallenge __P((struct opie *,char *,char *));
  175. int  opiegenerator __P((char *,char *,char *));
  176. int  opiegetsequence __P((struct opie *));
  177. VOIDRET  opiehash __P((char *,unsigned));
  178. int  opiehtoi __P((register char));
  179. int  opiekeycrunch __P((unsigned,char *,char *,char *));
  180. int  opielock __P((char *));
  181. int  opielookup __P((struct opie *,char *));
  182. VOIDRET  opiemd4init __P((struct opiemdx_ctx *));
  183. VOIDRET  opiemd4update __P((struct opiemdx_ctx *,unsigned char *,unsigned int));
  184. VOIDRET  opiemd4final __P((unsigned char *,struct opiemdx_ctx *));
  185. VOIDRET  opiemd5init __P((struct opiemdx_ctx *));
  186. VOIDRET  opiemd5update __P((struct opiemdx_ctx *,unsigned char *,unsigned int));
  187. VOIDRET  opiemd5final __P((unsigned char *,struct opiemdx_ctx *));
  188. int  opiepasscheck __P((char *));
  189. VOIDRET  opierandomchallenge __P((char *));
  190. char * opieskipspace __P((register char *));
  191. VOIDRET  opiestripcrlf __P((char *));
  192. int  opieverify __P((struct opie *,char *));
  193.  
  194. #endif /* _OPIE_H */
  195.