RTU/release/inc/lib60870_inc/md5.h

76 lines
1.7 KiB
C

#ifndef _MD5_H_
#define _MD5_H_
#include <stdint.h>
typedef unsigned char *POINTER;
typedef uint16_t UINT2;
typedef uint32_t UINT4;
#define MD5_BIT16 0x10
#define MD5_BIT32 0x20
#define PROTO_LIST(list) list
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
typedef struct _MD5_CTX
{
UINT4 state[4];
UINT4 count[2];
unsigned char buffer[64];
} MD5_CTX;
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac);\
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define TEST_BLOCK_LEN 1000
#define TEST_BLOCK_COUNT 1000
void StartMD5(MD5_CTX * context);
void EncodeMD5(MD5_CTX * context, unsigned char * input, int len);
void GetMD5(MD5_CTX * context, unsigned char * result);
void GetMD5String(MD5_CTX * context, char * result, unsigned char mode);
#endif //_MD5_H_