//#include #include #include #include #include int main(void) { unsigned char template[66] = "PBKDF2-HMAC-SHA256-collision-PBKDF2-HMAC-SHA256-collision-aaaaaaa"; uint32_t block; uint64_t i; for (block = 0; block < 1024; block++) { uint64_t start = (uint64_t)block << 37; uint64_t end = ((uint64_t)(block + 1) << 37) - 1; printf("block %u (%llx - %llx)\n", block, (unsigned long long)start, (unsigned long long)end); #pragma omp parallel for for (i = start; i <= end; i++) { unsigned char buf[sizeof(template)]; unsigned char digest[SHA256_DIGEST_LENGTH + 1]; uint64_t x = i; int j; memcpy(buf, template, sizeof(buf)); for (j = 6; j >= 0; j--) { static const unsigned char itoa64[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+"; buf[65 - 7 + j] = itoa64[x & 0x3f]; x >>= 6; } SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, buf, 65); SHA256_Final(digest, &ctx); for (j = 0; j < SHA256_DIGEST_LENGTH; j++) { unsigned char c = digest[j]; #if 0 if (c < ' ' || c > 0xfe) break; if (c >= 0x80 && c <= 0x9f) break; #else if (c < ' ' || c > 0x7e) break; #endif } if (j == SHA256_DIGEST_LENGTH) { #pragma omp critical { puts((char *)buf); digest[SHA256_DIGEST_LENGTH] = 0; puts((char *)digest); } } i++; #if 0 if ((i & 0xfffff) == 0xfffff) write(2, ".", 1); #endif } } puts("DONE"); return 0; }