You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.0 KiB

11 years ago
  1. /*
  2. Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely, subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not
  10. claim that you wrote the original software. If you use this software
  11. in a product, an acknowledgment in the product documentation would be
  12. appreciated but is not required.
  13. 2. Altered source versions must be plainly marked as such, and must not be
  14. misrepresented as being the original software.
  15. 3. This notice may not be removed or altered from any source distribution.
  16. L. Peter Deutsch
  17. ghost@aladdin.com
  18. */
  19. /*$Id: md5.h,v 1.1.1.1 2001/10/18 22:50:24 jlovell Exp $ */
  20. /*
  21. Independent implementation of MD5 (RFC 1321).
  22. This code implements the MD5 Algorithm defined in RFC 1321.
  23. It is derived directly from the text of the RFC and not from the
  24. reference implementation.
  25. The original and principal author of md5.h is L. Peter Deutsch
  26. <ghost@aladdin.com>. Other authors are noted in the change history
  27. that follows (in reverse chronological order):
  28. 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
  29. 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
  30. added conditionalization for C++ compilation from Martin
  31. Purschke <purschke@bnl.gov>.
  32. 1999-05-03 lpd Original version.
  33. */
  34. #ifndef md5_INCLUDED
  35. # define md5_INCLUDED
  36. /*
  37. * This code has some adaptations for the Ghostscript environment, but it
  38. * will compile and run correctly in any environment with 8-bit chars and
  39. * 32-bit ints. Specifically, it assumes that if the following are
  40. * defined, they have the same meaning as in Ghostscript: P1, P2, P3,
  41. * ARCH_IS_BIG_ENDIAN.
  42. */
  43. typedef unsigned char md5_byte_t; /* 8-bit byte */
  44. typedef unsigned int md5_word_t; /* 32-bit word */
  45. /* Define the state of the MD5 Algorithm. */
  46. typedef struct md5_state_s {
  47. md5_word_t count[2]; /* message length in bits, lsw first */
  48. md5_word_t abcd[4]; /* digest buffer */
  49. md5_byte_t buf[64]; /* accumulate block */
  50. } md5_state_t;
  51. #ifdef __cplusplus
  52. extern "C"
  53. {
  54. #endif
  55. /* Initialize the algorithm. */
  56. #ifdef P1
  57. void md5_init(P1(md5_state_t *pms));
  58. #else
  59. void md5_init(md5_state_t *pms);
  60. #endif
  61. /* Append a string to the message. */
  62. #ifdef P3
  63. void md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes));
  64. #else
  65. void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
  66. #endif
  67. /* Finish the message and return the digest. */
  68. #ifdef P2
  69. void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
  70. #else
  71. void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
  72. #endif
  73. #ifdef __cplusplus
  74. } /* end extern "C" */
  75. #endif
  76. #endif /* md5_INCLUDED */