rfc1321中文翻译内容摘要:

))。 static unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }。 /* F, G, H 和 I 是基本 MD5函数 */ define F(x, y, z) (((x) amp。 (y)) | ((~x) amp。 (z))) define G(x, y, z) (((x) amp。 (z)) | ((y) amp。 (~z))) define H(x, y, z) ((x) ^ (y) ^ (z)) define I(x, y, z) ((y) ^ ((x) | (~z))) /* ROTATE_LEFT 将 x循环左移 n位 */ 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)。 \ RFC 1321 MD5 MessageDigest Algorithm April 1992 Rivest 10 } 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)。 \ } /* MD5 初始化 . 开始一个 MD5操作写一个新的 context. */ void MD5Init (context) MD5_CTX *context。 /* context */ { contextcount[0] = contextcount[1] = 0。 contextstate[0] = 0x67452301。 contextstate[1] = 0xefcdab89。 contextstate[2] = 0x98badcfe。 contextstate[3] = 0x10325476。 } /*MD5 分组更新操作 . 继续一个 MD5操作 ,处理另一个消息分组并更新 context. */ void MD5Update (context, input, inputLen) MD5_CTX *context。 /* context */ unsigned char *input。 /* 输入分组 */ unsigned int inputLen。 /* 输入的分组的长度 */ { unsigned int i, index, partLen。 /* 计算字节数模 64的值 */ index = (unsigned int)((contextcount[0] 3) amp。 0x3F)。 /* Update number of bits */ if ((contextcount[0] += ((UINT4)inputLen 3)) ((UINT4)inputLen 3)) RFC 1321 MD5 MessageDigest Algorithm April 1992 Rivest 11 contextcount[1]++。 contextcount[1] += ((UINT4)inputLen 29)。 partLen = 64 index。 /* 按能达到的最大次数转换 */ if (inputLen = partLen) { MD5_memcpy ((POINTER)amp。 contextbuffer[index], (POINTER)input, partLen)。 MD5Transform (contextstate, contextbuffer)。 for (i = partLen。 i + 63 inputLen。 i += 64) MD5Transform (contextstate, amp。 input[i])。 index = 0。 } else i = 0。 /* 缓冲器保留输入值 */ MD5_memcpy ((POINTER)amp。 contextbuffer[index], (POINTER)amp。 input[i], inputLeni)。 } /* MD5 最终结果 . 以一个 MD5 报文摘要操作结束 , 写下报文摘要值 */ void MD5Final (digest, context) unsigned char digest[16]。 /*报文摘要 */ MD5_CTX *context。 /* context */ { unsigned char bits[8]。 unsigned int index, padLen。 /* 保存位数值 */ Encode (bits, contextcount, 8)。 index = (unsigned int)((contextcount[0] 3) amp。 0x3f)。 padLen = (index 56) ? (56 index) : (120 index)。 MD5Update (context, PADDING, padLen)。 /* 附加长度 (在补位之前 ) */ MD5Update (context, bits, 8)。 /* 将 state 存入 digest 中 */ RFC 1321 MD5 MessageDigest Algorithm April 1992 Rivest 12 Encode (digest, contextstate, 16)。 MD5_memset ((POINTER)context, 0, sizeof (*context))。 } /* MD5基本转换 . 转换状态基于分组 */ static void MD5Transform (state, block) UINT4 state[4]。 unsigned char block[64]。 { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]。 Decode (x, block, 64)。 /* Round 1 */ FF (a, b, c, d, x[ 0], S11, 0xd76aa478)。 /* 1 */ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756)。 /* 2 */ FF (c, d, a, b, x[ 2], S13, 0x242070db)。 /* 3 */ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee)。 /* 4 */ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf)。 /* 5 */ FF (d, a, b, c, x[ 5], S12, 0x4787c62a)。 /* 6 */ FF (c, d, a, b, x[ 6], S13, 0xa8304613)。 /* 7 */ FF (b, c, d, a, x[ 7], S14, 0xfd469501)。 /* 8 */ FF (a, b, c, d, x[ 8], S11, 0x698098d8)。 /* 9 */ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af)。 /* 10 */ FF (c, d, a, b, x[10], S13, 0xffff5bb1)。 /* 11 */ FF (b, c, d, a, x[11], S14, 0x895cd7be)。 /* 12 */ FF (a, b, c, d, x[12], S11, 0x6b901122)。 /* 13 */ FF (d, a, b, c, x[13], S12, 0xfd987193)。 /* 14 */ FF (c, d, a, b, x[14], S13, 0xa679438e)。 /* 15 */ FF (b, c, d, a, x[15], S14, 0x49b40821)。 /* 16 */ /* Round 2 */ GG (a, b, c, d, x[ 1], S21, 0xf61e2562)。 /* 17 */ GG (d, a, b, c, x[ 6], S22, 0xc040b340)。 /* 18 */ GG (c, d, a, b, x[11], S23, 0x265e5a51)。 /* 19 */ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa)。 /* 20 */ GG (a, b, c,。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。