Windows2003-3790/termsrv/drivers/rdp/inc/cbchash.h
2020-09-30 16:53:55 +02:00

56 lines
1.3 KiB
C

/* (C) 1998 Microsoft Corp.
*
* cbchash.h
*
* Header for CBC64 hash function.
*/
#ifndef __CBCHASH_H
#define __CBCHASH_H
// Alpha must be odd.
#define CBC_RandomOddAlpha 0xF90919A1
#define CBC_RandomBeta 0xF993291A
// Holds state variables for CBC64, to allow FirstCBC64() and NextCBC64()
// behavior using the passed context.
typedef struct {
// Private variable to maintain state.
UINT32 Datum;
// Current key values. These are public for reading by the caller.
UINT32 Key1, Key2;
// Current plain checksum value. This is public for reading.
UINT32 Checksum;
} CBC64Context;
extern const UINT32 CBC_AB[2];
extern const UINT32 CBC_CD[2];
void __fastcall NextCBC64(CBC64Context *, UINT32 *, unsigned);
__inline void __fastcall FirstCBC64(
CBC64Context *pContext,
UINT32 *pData,
unsigned NumDWORDBlocks)
{
pContext->Key1 = pContext->Key2 = pContext->Datum = CBC_RandomOddAlpha *
(*pData) + CBC_RandomBeta;
pContext->Key1 = (pContext->Key1 << 1) ^
(CBC_CD[(pContext->Key1 & 0x80000000) >> 31]);
pContext->Key2 = (pContext->Key2 << 1) ^
(CBC_AB[(pContext->Key2 & 0x80000000) >> 31]);
pContext->Checksum = 0;
NextCBC64(pContext, pData + 1, NumDWORDBlocks - 1);
}
#endif // !defined(__CBCHASH_H)