📄 sha1.h
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
*/
#include "vibecrypto.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#ifndef _SHA_1_H
#define _SHA_1_H
#ifdef __cplusplus
extern "C" {
#endif
/* The bulk of SHA-1 is done by a Transform function. This may be a
* separate function, some implementation may "inline" it.
*
* @param ctx The SHA1 context.
* @param block The block of data to use in updating the state.
* @return none
*/
typedef void VOLT_CALLING_CONV (*VSHA1Transform) VOLT_PROTO_LIST ((
Pointer ctx,
unsigned char *block
));
/* This is the standard SHA-1 context.
*/
typedef struct
{
UInt32 initState[5];
UInt32 state[5];
UInt32 W[80];
UInt32 countLow;
UInt32 countHigh;
unsigned char currentBlock[64];
unsigned int currentBlockLen;
unsigned int padding;
VSHA1Transform SHA1Transform;
} VoltSHA1Ctx;
/* Implements VDigestInit.
*/
int VOLT_CALLING_CONV SHA1Init VOLT_PROTO_LIST ((
VoltAlgorithmObject *obj
));
/* Implements VDigestUpdate.
*/
int VOLT_CALLING_CONV SHA1Update VOLT_PROTO_LIST ((
VoltAlgorithmObject *obj,
unsigned char *dataToDigest,
unsigned int dataToDigestLen
));
/* Implements VDigestFinal.
*/
int VOLT_CALLING_CONV SHA1Final VOLT_PROTO_LIST ((
VoltAlgorithmObject *obj,
unsigned char *digest
));
/* Implements VSHA1Transform.
*/
void VOLT_CALLING_CONV SHA1Transform VOLT_PROTO_LIST ((
Pointer ctx,
unsigned char *block
));
/* Implements VCtxDestroy.
*/
void VOLT_CALLING_CONV SHA1ClassCtxDestroy VOLT_PROTO_LIST ((
Pointer obj,
Pointer ctx
));
#if VOLT_ENDIAN == VOLT_BIG_ENDIAN
#define SHA1_GET_UINT32(_buf,_value) VOLT_GET_BIG_ENDIAN_UINT32(_buf,_value)
#else
#define SHA1_GET_UINT32(_buf,_value) VOLT_GET_LITTLE_ENDIAN_UINT32(_buf,_value)
#endif
/* Rotate a 32-bit value left by count.
*/
#define SHA1_ROTL(_value,_count) VOLT_UINT32_ROTL(_value,_count)
/* SHA-1 constants.
*/
#define SHA1_K0 0x5A827999
#define SHA1_K2 0x6ED9EBA1
#define SHA1_K4 0x8F1BBCDC
#define SHA1_K6 0xCA62C1D6
#define F0(_B,_C,_D) ( (_B & _C) | ((~_B) & _D) )
#define F2(_B,_C,_D) (_B ^ _C ^ _D)
#define F4(_B,_C,_D) ((_B & _C) | (_B & _D) | (_C & _D))
#define F6(_B,_C,_D) (_B ^ _C ^ _D)
#ifdef __cplusplus
}
#endif
#endif /* _SHA_1_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -