###### Student_2017

2017-04-10 13:52 阅读 715

# 帮忙逐条解读具体的内容和功能？谢谢

1

void mcc_sechsharm_sha1_transform(unsigned long* iv, unsigned char* buf)
{
unsigned long bufi[16]; /* internal buffer /
unsigned long work[5]; /
internal work registers */
CHAR64LONG16 * block = (CHAR64LONG16 *) bufi;

``````/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/* Copy operating buffer to buf */
memcpy( bufi, buf, sizeof( bufi ) );

/* Copy context->iv[] to working vars */
work[0] = iv[0];                 /* a */
work[1] = iv[1];                 /* b */
work[2] = iv[2];                 /* c */
work[3] = iv[3];                 /* d */
work[4] = iv[4];                 /* e */

/* 4 rounds of 20 operations each. Loop unrolled */
/* Round 1 */
R0( block, work, 0, 1, 2, 3, 4,  0 );
R0( block, work, 4, 0, 1, 2, 3,  1 );
R0( block, work, 3, 4, 0, 1, 2,  2 );
R0( block, work, 2, 3, 4, 0, 1,  3 );
R0( block, work, 1, 2, 3, 4, 0,  4 );
R0( block, work, 0, 1, 2, 3, 4,  5 );
R0( block, work, 4, 0, 1, 2, 3,  6 );
R0( block, work, 3, 4, 0, 1, 2,  7 );
R0( block, work, 2, 3, 4, 0, 1,  8 );
R0( block, work, 1, 2, 3, 4, 0,  9 );
R0( block, work, 0, 1, 2, 3, 4, 10 );
R0( block, work, 4, 0, 1, 2, 3, 11 );
R0( block, work, 3, 4, 0, 1, 2, 12 );
R0( block, work, 2, 3, 4, 0, 1, 13 );
R0( block, work, 1, 2, 3, 4, 0, 14 );
R0( block, work, 0, 1, 2, 3, 4, 15 );
R1( block, work, 4, 0, 1, 2, 3, 16 );
R1( block, work, 3, 4, 0, 1, 2, 17 );
R1( block, work, 2, 3, 4, 0, 1, 18 );
R1( block, work, 1, 2, 3, 4, 0, 19 );

/* Round 2 */
R2( block, work, 0, 1, 2, 3, 4, 20 );
R2( block, work, 4, 0, 1, 2, 3, 21 );
R2( block, work, 3, 4, 0, 1, 2, 22 );
R2( block, work, 2, 3, 4, 0, 1, 23 );
R2( block, work, 1, 2, 3, 4, 0, 24 );
R2( block, work, 0, 1, 2, 3, 4, 25 );
R2( block, work, 4, 0, 1, 2, 3, 26 );
R2( block, work, 3, 4, 0, 1, 2, 27 );
R2( block, work, 2, 3, 4, 0, 1, 28 );
R2( block, work, 1, 2, 3, 4, 0, 29 );
R2( block, work, 0, 1, 2, 3, 4, 30 );
R2( block, work, 4, 0, 1, 2, 3, 31 );
R2( block, work, 3, 4, 0, 1, 2, 32 );
R2( block, work, 2, 3, 4, 0, 1, 33 );
R2( block, work, 1, 2, 3, 4, 0, 34 );
R2( block, work, 0, 1, 2, 3, 4, 35 );
R2( block, work, 4, 0, 1, 2, 3, 36 );
R2( block, work, 3, 4, 0, 1, 2, 37 );
R2( block, work, 2, 3, 4, 0, 1, 38 );
R2( block, work, 1, 2, 3, 4, 0, 39 );

/* Round 3 */
R3( block, work, 0, 1, 2, 3, 4, 40 );
R3( block, work, 4, 0, 1, 2, 3, 41 );
R3( block, work, 3, 4, 0, 1, 2, 42 );
R3( block, work, 2, 3, 4, 0, 1, 43 );
R3( block, work, 1, 2, 3, 4, 0, 44 );
R3( block, work, 0, 1, 2, 3, 4, 45 );
R3( block, work, 4, 0, 1, 2, 3, 46 );
R3( block, work, 3, 4, 0, 1, 2, 47 );
R3( block, work, 2, 3, 4, 0, 1, 48 );
R3( block, work, 1, 2, 3, 4, 0, 49 );
R3( block, work, 0, 1, 2, 3, 4, 50 );
R3( block, work, 4, 0, 1, 2, 3, 51 );
R3( block, work, 3, 4, 0, 1, 2, 52 );
R3( block, work, 2, 3, 4, 0, 1, 53 );
R3( block, work, 1, 2, 3, 4, 0, 54 );
R3( block, work, 0, 1, 2, 3, 4, 55 );
R3( block, work, 4, 0, 1, 2, 3, 56 );
R3( block, work, 3, 4, 0, 1, 2, 57 );
R3( block, work, 2, 3, 4, 0, 1, 58 );
R3( block, work, 1, 2, 3, 4, 0, 59 );

/* Round 4 */
R4( block, work, 0, 1, 2, 3, 4, 60 );
R4( block, work, 4, 0, 1, 2, 3, 61 );
R4( block, work, 3, 4, 0, 1, 2, 62 );
R4( block, work, 2, 3, 4, 0, 1, 63 );
R4( block, work, 1, 2, 3, 4, 0, 64 );
R4( block, work, 0, 1, 2, 3, 4, 65 );
R4( block, work, 4, 0, 1, 2, 3, 66 );
R4( block, work, 3, 4, 0, 1, 2, 67 );
R4( block, work, 2, 3, 4, 0, 1, 68 );
R4( block, work, 1, 2, 3, 4, 0, 69 );
R4( block, work, 0, 1, 2, 3, 4, 70 );
R4( block, work, 4, 0, 1, 2, 3, 71 );
R4( block, work, 3, 4, 0, 1, 2, 72 );
R4( block, work, 2, 3, 4, 0, 1, 73 );
R4( block, work, 1, 2, 3, 4, 0, 74 );
R4( block, work, 0, 1, 2, 3, 4, 75 );
R4( block, work, 4, 0, 1, 2, 3, 76 );
R4( block, work, 3, 4, 0, 1, 2, 77 );
R4( block, work, 2, 3, 4, 0, 1, 78 );
R4( block, work, 1, 2, 3, 4, 0, 79 );

/* Add the working vars back into context.iv[] */
iv[0] += work[0];
iv[1] += work[1];
iv[2] += work[2];
iv[3] += work[3];
iv[4] += work[4];
``````

}

• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享