📄 vmsha1.h
字号:
#ifndef VM_SECURE_HASH_H_INCLUDED
#define VM_SECURE_HASH_H_INCLUDED
/*****************************************************************************/
/* HEADER FILE */
/*****************************************************************************/
/*
$Archive: $
$Revision: $
$Date: $
$Author: $
Description: Declaration of a class that is designed after the NIST
proposed Secure Hash Standard.
Based on work put into the public domain by:
Peter C. Gutmann on 2 September 1992
*/
/*****************************************************************************/
// Set according to whether the machine is little-endian or not
//
#define LITTLE_ENDIAN
//#undef LITTLE_ENDIAN
typedef unsigned char BYTE;
typedef unsigned long ULONG;
// The SHS block size and message digest sizes, in bytes
//
#define ciBlockSize 64
#define ciDigestSize 20
#define ciMessageDigest 5
#define ciSHSDataSize 16
// The structure for storing SHS info
//
typedef struct
{
ULONG m_ulaDigest[ ciMessageDigest ]; // Message digest
ULONG m_CountLo; // this and the next field combine
ULONG m_CountHi; // into a 64-bit bit count
ULONG m_ulaData[ ciSHSDataSize ]; // SHS data buffer
} VM_SHS_INFO, *P_VM_SHS_INFO;
class VMSHA1Hash
{
public:
VMSHA1Hash( void ){;};
~VMSHA1Hash( void ){;};
void Hash( P_VM_SHS_INFO pshsInfo, const BYTE* pbInput, long lLength );
protected:
void Init( P_VM_SHS_INFO pshsInfo );
void Update( P_VM_SHS_INFO pshsInfo, const BYTE* pBuffer, long iCount );
void Final( P_VM_SHS_INFO pshsInfo );
void Transform( P_VM_SHS_INFO pshsInfo );
private:
inline void Expand( ULONG ulArray[], short sCount );
inline void DoRound1( ULONG ulValueAtIndex );
inline void DoRound2( ULONG ulValueAtIndex );
inline void DoRound3( ULONG ulValueAtIndex );
inline void DoRound4( ULONG ulValueAtIndex );
#ifdef LITTLE_ENDIAN
void ReverseByte( ULONG* pBuffer, int iByteCount );
#endif
private:
// The buffers of 5 32-bit words
//
ULONG m_A;
ULONG m_B;
ULONG m_C;
ULONG m_D;
ULONG m_E;
};
#endif
/*****************************************************************************/
/* Check-in history */
/*
*$Log: $
*/
/*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -