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.

58 lines
1.3 KiB

  1. // Circular Hash
  2. //
  3. // This code implements a circular hash algorithm, intended as a variable
  4. // length hash function that is fast to update. (The hash function will be
  5. // called many times.) This is done by SHA-1'ing each of the inputs, then
  6. // circularly XORing this value into a buffer.
  7. #ifndef __CIRCHASH_H__
  8. #define __CIRCHASH_H__
  9. typedef struct {
  10. DWORD dwCircHashVer;
  11. DWORD dwCircSize;
  12. DWORD dwMode;
  13. DWORD dwCircInc;
  14. DWORD dwCurCircPos;
  15. DWORD dwAlgId;
  16. DWORD dwPad1;
  17. DWORD dwPad2;
  18. BYTE CircBuf[ 256 ];
  19. } CircularHash;
  20. // mode flags
  21. #define CH_MODE_FEEDBACK 0x01
  22. // alg flags
  23. #define CH_ALG_SHA1_NS 0 // SHA-1 without endian transform
  24. #define CH_ALG_MD4 1 // RSA MD4
  25. BOOL
  26. InitCircularHash(
  27. IN CircularHash *NewHash,
  28. IN DWORD dwUpdateInc,
  29. IN DWORD dwAlgId,
  30. IN DWORD dwMode
  31. );
  32. VOID
  33. DestroyCircularHash(
  34. IN CircularHash *OldHash
  35. );
  36. BOOL
  37. GetCircularHashValue(
  38. IN CircularHash *CurrentHash,
  39. OUT BYTE **ppbHashValue,
  40. OUT DWORD *pcbHashValue
  41. );
  42. BOOL
  43. UpdateCircularHash(
  44. IN CircularHash *CurrentHash,
  45. IN VOID *pvData,
  46. IN DWORD cbData
  47. );
  48. #endif // __CIRCHASH_H__