pwdstorage.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. #ifndef _PWDSTORAGE_H
  7. #define _PWDSTORAGE_H
  8. #include "slapi-plugin.h"
  9. #include <ssl.h>
  10. #include "nspr.h"
  11. #include "ldif.h"
  12. #include "md5.h"
  13. #include <dirlite_strings.h> /* PLUGIN_MAGIC_VENDOR_STR */
  14. #define PWD_HASH_PREFIX_START '{'
  15. #define PWD_HASH_PREFIX_END '}'
  16. #define SHA1_SCHEME_NAME "SHA"
  17. #define SHA1_NAME_LEN 3
  18. #define SALTED_SHA1_SCHEME_NAME "SSHA"
  19. #define SALTED_SHA1_NAME_LEN 4
  20. #define CRYPT_SCHEME_NAME "crypt"
  21. #define CRYPT_NAME_LEN 5
  22. #define NS_MTA_MD5_SCHEME_NAME "NS-MTA-MD5"
  23. #define NS_MTA_MD5_NAME_LEN 10
  24. #define CLEARTEXT_SCHEME_NAME "clear"
  25. #define CLEARTEXT_NAME_LEN 5
  26. SECStatus sha1_salted_hash(unsigned char *hash_out, char *pwd, struct berval *salt);
  27. int sha1_pw_cmp( char *userpwd, char *dbpwd );
  28. char * sha1_pw_enc( char *pwd );
  29. char * salted_sha1_pw_enc( char *pwd );
  30. int clear_pw_cmp( char *userpwd, char *dbpwd );
  31. char *clear_pw_enc( char *pwd );
  32. void crypt_init();
  33. int crypt_pw_cmp( char *userpwd, char *dbpwd );
  34. char *crypt_pw_enc( char *pwd );
  35. int ns_mta_md5_pw_cmp( char *userpwd, char *dbpwd );
  36. #if !defined(NET_SSL)
  37. /******************************************/
  38. /*
  39. * Some of the stuff below depends on a definition for uint32, so
  40. * we include one here. Other definitions appear in nspr/prtypes.h,
  41. * at least. All the platforms we support use 32-bit ints.
  42. */
  43. typedef unsigned int uint32;
  44. /******************************************/
  45. /*
  46. * The following is from ds.h, which the libsec sec.h stuff depends on (see
  47. * comment below).
  48. */
  49. /*
  50. ** A status code. Status's are used by procedures that return status
  51. ** values. Again the motivation is so that a compiler can generate
  52. ** warnings when return values are wrong. Correct testing of status codes:
  53. **
  54. ** DSStatus rv;
  55. ** rv = some_function (some_argument);
  56. ** if (rv != DSSuccess)
  57. ** do_an_error_thing();
  58. **
  59. */
  60. typedef enum DSStatusEnum {
  61. DSWouldBlock = -2,
  62. DSFailure = -1,
  63. DSSuccess = 0
  64. } DSStatus;
  65. /******************************************/
  66. /*
  67. * All of the SHA1-related defines are from libsec's "sec.h" -- including
  68. * it directly pulls in way too much stuff that we conflict with. Ugh.
  69. */
  70. /*
  71. * Number of bytes each hash algorithm produces
  72. */
  73. #define SHA1_LENGTH 20
  74. /******************************************/
  75. /*
  76. ** SHA-1 secure hash function
  77. */
  78. /*
  79. ** Hash a null terminated string "src" into "dest" using SHA-1
  80. */
  81. DSStatus SHA1_Hash(unsigned char *dest, char *src);
  82. #endif /* !defined(NET_SSL) */
  83. #endif /* _PWDSTORAGE_H */