@@ -32,13 +32,13 @@ bool pow_md5_mine(uint8_t const *mask, uint8_t const *target, uint8_t *buffer, u
32
32
static_assert (__BYTE_ORDER == __LITTLE_ENDIAN , "" );
33
33
if (mask == NULL ) return false;
34
34
if (target == NULL ) return false;
35
- if (target == NULL ) return false;
36
- if (indices == NULL ) return false;
37
35
if (buffer == NULL ) return false;
36
+ if (indices == NULL ) return false;
38
37
for (int i = 0 ; i < pow_indices_length ; ++ i ) {
39
- if (indices [i ] < -1 or size <= indices [i ]) return false;
38
+ if (indices [i ] < -1 or ( int64_t ) size <= indices [i ]) return false;
40
39
}
41
- if (size > pow_md5_block_length - 9 ) return false;
40
+ if (indices [0 ] == -1 ) return false;
41
+ if (size > pow_sha1_block_length - sizeof (uint64_t ) / CHAR_BIT - 1 ) return false;
42
42
43
43
// load hash
44
44
const uint32_t mask_a = ((uint32_t * )mask )[0 ];
@@ -70,7 +70,9 @@ bool pow_md5_mine(uint8_t const *mask, uint8_t const *target, uint8_t *buffer, u
70
70
const int index7 = indices [7 ];
71
71
static_assert (pow_indices_length == 8 , "" );
72
72
repeat (i ,pow_indices_length ) {
73
- local [indices [i ]] = 0 ;
73
+ if (indices [i ] != -1 ) {
74
+ local [indices [i ]] = 0 ;
75
+ }
74
76
}
75
77
uint32_t * padded_alphabet = malloc (alphabet_size * sizeof (uint32_t ));
76
78
repeat (i ,alphabet_size ) {
@@ -89,7 +91,7 @@ bool pow_md5_mine(uint8_t const *mask, uint8_t const *target, uint8_t *buffer, u
89
91
repeat (i4 , alphabet_size ) { if (index4 != -1 ) local [index4 ] = alphabet [i4 ];
90
92
repeat (i3 , alphabet_size ) { if (index3 != -1 ) local [index3 ] = alphabet [i3 ];
91
93
repeat (i2 , alphabet_size ) { if (index2 != -1 ) local [index2 ] = alphabet [i2 ];
92
- cnt += alphabet_size * alphabet_size ;
94
+ cnt += alphabet_size * ( alphabet_size / vector_width * vector_width ) ;
93
95
repeat (i1 , alphabet_size ) { if (index1 != -1 ) local [index1 ] = alphabet [i1 ];
94
96
__m256i y0 = _mm256_set1_epi32 (((uint32_t * )local )[0 ]);
95
97
__m256i y1 = _mm256_set1_epi32 (((uint32_t * )local )[1 ]);
@@ -226,7 +228,7 @@ bool pow_md5_mine(uint8_t const *mask, uint8_t const *target, uint8_t *buffer, u
226
228
}
227
229
}
228
230
229
- // break if unnecessary
231
+ // break
230
232
} if (index1 == -1 or found ) break ;
231
233
} if (index2 == -1 or found ) break ;
232
234
} if (index3 == -1 or found ) break ;
0 commit comments