求助!关于RIPEMD-160算法的C语言实现程序。(4)
abu 2002-04-21 08:24:47 void MDMACfinish(dword *K, dword *MDbuf, byte *strptr,
dword lswlen, dword mswlen)
{ unsigned int i; /* counter */
dword X[16]; /* message words */
memset(X, 0, 16*sizeof(dword)); ?/*这个函数什么作用来的?*/
/* put bytes from strptr into X */
for (i=0; i<(lswlen&63); i++) {
/* byte i goes into word X[i div 4] at pos. 8*(i mod 4) */
X[i>>2] ^= (dword) *strptr++ << (8 * (i&3)); ?/*这个strptr指针未指向,那么
(dword)*strptr是什么意思?*/
}
/* append the bit m_n == 1 */
X[(lswlen>>2)&15] ^= (dword)1 << (8*(lswlen&3) + 7); ?/*这一句是“使左边两个相邻的字在右边至少相距七位”吗?lswlen是什么含义?初值是多少呢?*/
if ((lswlen & 63) > 55) { ?/*设定为“55”是为什么呢?*/
/* length goes to next block */
compress(K, MDbuf, X);
memset(X, 0, 16*sizeof(dword));
}
/* append length in bits*/
X[14] = lswlen << 3; ?/*为什么左移三?*/
X[15] = (lswlen >> 29) | (mswlen << 3); ?/*这一句什么作用?*/
compress(K, MDbuf, X);
/* last block */
for (i=0; i<4; i++) {
X[i] = K[9+i];
X[i+4] = K[9+i] ^ T[0][i];
X[i+8] = K[9+i] ^ T[1][i];
X[i+12] = K[9+i] ^ T[2][i];
}
compress(K, MDbuf, X);
return;
}(完)