packer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * This program is copyright Alec Muffett 1993, portions copyright other authors.
  3. * The authors disclaim all responsibility or liability with respect to it's usage
  4. * or its effect upon hardware or computer systems.
  5. */
  6. #ifndef CRACKLIB_PACKER_H
  7. #define CRACKLIB_PACKER_H
  8. /* Moved here cause needed by mod_php */
  9. #define STRINGSIZE 1024
  10. #define TRUNCSTRINGSIZE (STRINGSIZE/4)
  11. #ifndef NUMWORDS
  12. #define NUMWORDS 16
  13. #endif
  14. #define MAXWORDLEN 32
  15. #define MAXBLOCKLEN (MAXWORDLEN * NUMWORDS)
  16. #ifdef IN_CRACKLIB
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include <crack.h>
  20. #if defined(ENABLE_NLS)
  21. #include <libintl.h>
  22. #define _(String) dgettext("cracklib", String)
  23. #else
  24. #define _(String) (String)
  25. #endif
  26. #if defined(HAVE_INTTYPES_H)
  27. #include <inttypes.h>
  28. #else
  29. #if defined(HAVE_STDINT_H)
  30. #include <stdint.h>
  31. #else
  32. typedef unsigned int uint32_t;
  33. typedef unsigned short uint16_t;
  34. #endif
  35. #endif
  36. struct pi_header
  37. {
  38. uint32_t pih_magic;
  39. uint32_t pih_numwords;
  40. uint16_t pih_blocklen;
  41. uint16_t pih_pad;
  42. };
  43. typedef struct
  44. {
  45. /* Might be FILE* or gzFile */
  46. void *ifp;
  47. void *dfp;
  48. void *wfp;
  49. uint32_t flags;
  50. #define PFOR_WRITE 0x0001
  51. #define PFOR_FLUSH 0x0002
  52. #define PFOR_USEHWMS 0x0004
  53. #define PFOR_USEZLIB 0x0008
  54. uint32_t hwms[256];
  55. struct pi_header header;
  56. int count;
  57. char data_put[NUMWORDS][MAXWORDLEN];
  58. char data_get[NUMWORDS][MAXWORDLEN];
  59. } PWDICT;
  60. #define PW_WORDS(x) ((x)->header.pih_numwords)
  61. #define PIH_MAGIC 0x70775631
  62. /* Internal routines */
  63. extern char *GetPW(PWDICT *pwp, uint32_t number);
  64. #else
  65. /* Dummy structure, this is an internal only opaque data type */
  66. typedef struct {
  67. int dummy;
  68. } PWDICT;
  69. #endif
  70. extern PWDICT *PWOpen(const char *prefix, char *mode);
  71. extern int PWClose(PWDICT *pwp);
  72. extern unsigned int FindPW(PWDICT *pwp, char *string);
  73. extern int PutPW(PWDICT *pwp, char *string);
  74. extern int PMatch(char *control, char *string);
  75. extern char *Mangle(char *input, char *control);
  76. extern char Chop(char *string);
  77. extern char *Trim(char *string);
  78. extern char *FascistLook(PWDICT *pwp, char *instring);
  79. extern char *FascistLookUser(PWDICT *pwp, char *instring, const char *user, const char *gecos);
  80. extern char *FascistGecos(char *password, int uid);
  81. extern char *FascistGecosUser(char *password, const char *user, const char *gecos);
  82. extern const char *FascistCheck(const char *password, const char *path);
  83. #endif