Source code of Windows XP (NT5)
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.

110 lines
3.1 KiB

  1. #ifndef __MD4_H__
  2. #define __MD4_H__
  3. #ifndef RSA32API
  4. #define RSA32API __stdcall
  5. #endif
  6. /*
  7. ** ********************************************************************
  8. ** md4.h -- Header file for implementation of **
  9. ** MD4 Message Digest Algorithm **
  10. ** Updated: 2/13/90 by Ronald L. Rivest **
  11. ** (C) 1990 RSA Data Security, Inc. **
  12. ** ********************************************************************
  13. */
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. // MD4Update Errors
  18. #define MD4_SUCCESS 0
  19. #define MD4_TOO_BIG 1
  20. #define MD4_ALREADY_DONE 2
  21. // MD4 Digest length -- 4 word result == 16 bytes
  22. #define MD4DIGESTLEN 16
  23. // Block size of MD4 -- Assumes 8 bits per byte
  24. #define MD4BLOCKSIZE 64
  25. #define MD4BYTESTOBITS(bytes) ((bytes)*8) // MDupdate wants bits
  26. /* MDstruct is the data structure for a message digest computation.
  27. */
  28. typedef struct {
  29. unsigned long buffer[4]; /* Holds 4-word result of MD computation */
  30. unsigned char count[8]; /* Number of bits processed so far */
  31. unsigned int done; /* Nonzero means MD computation finished */
  32. } MDstruct, *MDptr;
  33. /* MDbegin(MD)
  34. ** Input: MD -- an MDptr
  35. ** Initialize the MDstruct prepatory to doing a message digest
  36. ** computation.
  37. **
  38. ** MTS: Assumes MDPtr is locked against simultaneous use.
  39. */
  40. extern void MDbegin(MDptr);
  41. /* MDupdate(MD,X,count)
  42. ** Input: MD -- an MDptr
  43. ** X -- a pointer to an array of unsigned characters.
  44. ** count -- the number of bits of X to use (an unsigned int).
  45. ** Updates MD using the first "count" bits of X.
  46. ** The array pointed to by X is not modified.
  47. ** If count is not a multiple of 8, MDupdate uses high bits of
  48. ** last byte.
  49. ** This is the basic input routine for a user.
  50. ** The routine terminates the MD computation when count < MD4BLOCKSIZE, so
  51. ** every MD computation should end with one call to MDupdate with a
  52. ** count less than MD4BLOCKSIZE. Zero is OK for a count.
  53. **
  54. ** Return values:
  55. ** MD4_SUCCESS: success
  56. ** MD4_TOO_LONG: Hash is already terminated
  57. ** MD4_ALREADY_DONE: Length is invalid (too big)
  58. **
  59. ** MTS: Assumes MDPtr is locked against simultaneous use.
  60. **
  61. **
  62. ** NOTE: MDupdate wants the length in BITS
  63. */
  64. extern int MDupdate(MDptr, const unsigned char *pbData, int wLen);
  65. /*
  66. This second implementation of MD4 entry points is the newer style,
  67. optimized implementation, compatible with newer code expecting these
  68. entry point names.
  69. Scott Field (sfield) 21-Oct-97
  70. */
  71. #ifndef UINT4
  72. #define UINT4 unsigned long
  73. #endif
  74. /* Data structure for MD4 (Message Digest) computation */
  75. typedef struct {
  76. UINT4 state[4]; /* state (ABCD) */
  77. UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
  78. unsigned char buffer[64]; /* input buffer */
  79. unsigned char digest[16]; /* actual digest after MD4Final call */
  80. } MD4_CTX;
  81. #define MD4_LEN 16
  82. void RSA32API MD4Init (MD4_CTX *);
  83. void RSA32API MD4Update (MD4_CTX *, unsigned char *, unsigned int);
  84. void RSA32API MD4Final (MD4_CTX * );
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif __MD4_H__