|
@@ -66,11 +66,11 @@ static const uint32_t k[64] = {
|
66
|
66
|
};
|
67
|
67
|
|
68
|
68
|
/** MD5 shift amounts */
|
69
|
|
-static const uint8_t r[64] = {
|
70
|
|
- 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
|
71
|
|
- 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
|
72
|
|
- 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
|
73
|
|
- 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
|
|
69
|
+static const uint8_t r[4][4] = {
|
|
70
|
+ { 7, 12, 17, 22 },
|
|
71
|
+ { 5, 9, 14, 20 },
|
|
72
|
+ { 4, 11, 16, 23 },
|
|
73
|
+ { 6, 10, 15, 21 },
|
74
|
74
|
};
|
75
|
75
|
|
76
|
76
|
/**
|
|
@@ -174,6 +174,7 @@ static void md5_digest ( struct md5_context *context ) {
|
174
|
174
|
uint32_t g;
|
175
|
175
|
uint32_t temp;
|
176
|
176
|
struct md5_step *step;
|
|
177
|
+ unsigned int round;
|
177
|
178
|
unsigned int i;
|
178
|
179
|
|
179
|
180
|
/* Sanity checks */
|
|
@@ -201,13 +202,15 @@ static void md5_digest ( struct md5_context *context ) {
|
201
|
202
|
|
202
|
203
|
/* Main loop */
|
203
|
204
|
for ( i = 0 ; i < 64 ; i++ ) {
|
204
|
|
- step = &md5_steps[ i / 16 ];
|
|
205
|
+ round = ( i / 16 );
|
|
206
|
+ step = &md5_steps[round];
|
205
|
207
|
f = step->f ( &u.v );
|
206
|
208
|
g = ( ( ( step->coefficient * i ) + step->constant ) % 16 );
|
207
|
209
|
temp = *d;
|
208
|
210
|
*d = *c;
|
209
|
211
|
*c = *b;
|
210
|
|
- *b = ( *b + rol32 ( ( *a + f + k[i] + w[g] ), r[i] ) );
|
|
212
|
+ *b = ( *b + rol32 ( ( *a + f + k[i] + w[g] ),
|
|
213
|
+ r[round][ i % 4 ] ) );
|
211
|
214
|
*a = temp;
|
212
|
215
|
DBGC2 ( context, "%2d : %08x %08x %08x %08x\n",
|
213
|
216
|
i, *a, *b, *c, *d );
|