MCPcopy Create free account
hub / github.com/carbonengine/trinity / processBlock

Method processBlock

shadercompiler/md5.cpp:79–202  ·  view source on GitHub ↗

process 64 bytes

Source from the content-addressed store, hash-verified

77
78/// process 64 bytes
79void MD5::processBlock( const void* data )
80{
81 // get last hash
82 uint32_t a = m_hash[0];
83 uint32_t b = m_hash[1];
84 uint32_t c = m_hash[2];
85 uint32_t d = m_hash[3];
86
87 // data represented as 16x 32-bit words
88 const uint32_t* words = (uint32_t*)data;
89
90 // computations are little endian, swap data if necessary
91#if defined( __BYTE_ORDER ) && ( __BYTE_ORDER != 0 ) && ( __BYTE_ORDER == __BIG_ENDIAN )
92#define LITTLEENDIAN( x ) swap( x )
93#else
94#define LITTLEENDIAN( x ) ( x )
95#endif
96
97 // first round
98 uint32_t word0 = LITTLEENDIAN( words[0] );
99 a = rotate( a + f1( b, c, d ) + word0 + 0xd76aa478, 7 ) + b;
100 uint32_t word1 = LITTLEENDIAN( words[1] );
101 d = rotate( d + f1( a, b, c ) + word1 + 0xe8c7b756, 12 ) + a;
102 uint32_t word2 = LITTLEENDIAN( words[2] );
103 c = rotate( c + f1( d, a, b ) + word2 + 0x242070db, 17 ) + d;
104 uint32_t word3 = LITTLEENDIAN( words[3] );
105 b = rotate( b + f1( c, d, a ) + word3 + 0xc1bdceee, 22 ) + c;
106
107 uint32_t word4 = LITTLEENDIAN( words[4] );
108 a = rotate( a + f1( b, c, d ) + word4 + 0xf57c0faf, 7 ) + b;
109 uint32_t word5 = LITTLEENDIAN( words[5] );
110 d = rotate( d + f1( a, b, c ) + word5 + 0x4787c62a, 12 ) + a;
111 uint32_t word6 = LITTLEENDIAN( words[6] );
112 c = rotate( c + f1( d, a, b ) + word6 + 0xa8304613, 17 ) + d;
113 uint32_t word7 = LITTLEENDIAN( words[7] );
114 b = rotate( b + f1( c, d, a ) + word7 + 0xfd469501, 22 ) + c;
115
116 uint32_t word8 = LITTLEENDIAN( words[8] );
117 a = rotate( a + f1( b, c, d ) + word8 + 0x698098d8, 7 ) + b;
118 uint32_t word9 = LITTLEENDIAN( words[9] );
119 d = rotate( d + f1( a, b, c ) + word9 + 0x8b44f7af, 12 ) + a;
120 uint32_t word10 = LITTLEENDIAN( words[10] );
121 c = rotate( c + f1( d, a, b ) + word10 + 0xffff5bb1, 17 ) + d;
122 uint32_t word11 = LITTLEENDIAN( words[11] );
123 b = rotate( b + f1( c, d, a ) + word11 + 0x895cd7be, 22 ) + c;
124
125 uint32_t word12 = LITTLEENDIAN( words[12] );
126 a = rotate( a + f1( b, c, d ) + word12 + 0x6b901122, 7 ) + b;
127 uint32_t word13 = LITTLEENDIAN( words[13] );
128 d = rotate( d + f1( a, b, c ) + word13 + 0xfd987193, 12 ) + a;
129 uint32_t word14 = LITTLEENDIAN( words[14] );
130 c = rotate( c + f1( d, a, b ) + word14 + 0xa679438e, 17 ) + d;
131 uint32_t word15 = LITTLEENDIAN( words[15] );
132 b = rotate( b + f1( c, d, a ) + word15 + 0x49b40821, 22 ) + c;
133
134 // second round
135 a = rotate( a + f2( b, c, d ) + word1 + 0xf61e2562, 5 ) + b;
136 d = rotate( d + f2( a, b, c ) + word6 + 0xc040b340, 9 ) + a;

Callers

nothing calls this directly

Calls 5

rotateFunction · 0.85
f1Function · 0.85
f2Function · 0.85
f3Function · 0.85
f4Function · 0.85

Tested by

no test coverage detected