Leaked source code of windows server 2003
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.

55 lines
1.3 KiB

  1. /* (C) 1998 Microsoft Corp.
  2. *
  3. * cbchash.h
  4. *
  5. * Header for CBC64 hash function.
  6. */
  7. #ifndef __CBCHASH_H
  8. #define __CBCHASH_H
  9. // Alpha must be odd.
  10. #define CBC_RandomOddAlpha 0xF90919A1
  11. #define CBC_RandomBeta 0xF993291A
  12. // Holds state variables for CBC64, to allow FirstCBC64() and NextCBC64()
  13. // behavior using the passed context.
  14. typedef struct {
  15. // Private variable to maintain state.
  16. UINT32 Datum;
  17. // Current key values. These are public for reading by the caller.
  18. UINT32 Key1, Key2;
  19. // Current plain checksum value. This is public for reading.
  20. UINT32 Checksum;
  21. } CBC64Context;
  22. extern const UINT32 CBC_AB[2];
  23. extern const UINT32 CBC_CD[2];
  24. void __fastcall NextCBC64(CBC64Context *, UINT32 *, unsigned);
  25. __inline void __fastcall FirstCBC64(
  26. CBC64Context *pContext,
  27. UINT32 *pData,
  28. unsigned NumDWORDBlocks)
  29. {
  30. pContext->Key1 = pContext->Key2 = pContext->Datum = CBC_RandomOddAlpha *
  31. (*pData) + CBC_RandomBeta;
  32. pContext->Key1 = (pContext->Key1 << 1) ^
  33. (CBC_CD[(pContext->Key1 & 0x80000000) >> 31]);
  34. pContext->Key2 = (pContext->Key2 << 1) ^
  35. (CBC_AB[(pContext->Key2 & 0x80000000) >> 31]);
  36. pContext->Checksum = 0;
  37. NextCBC64(pContext, pData + 1, NumDWORDBlocks - 1);
  38. }
  39. #endif // !defined(__CBCHASH_H)