filename
stringlengths
78
241
omp_pragma_line
stringlengths
24
416
context_chars
int64
100
100
text
stringlengths
152
177k
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/eigrp_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { MD5_CTX ctx; if (cur_salt->algo_type == 2) { memcpy(&ctx, &cur_salt->prep_salt, sizeof(MD5_CTX)); MD5_Update(&ctx, saved_key[index], saved_len[index]); if (saved_len[index] < 16) { MD5_Update(&ctx, zeropad, 16 - saved_len[index]); } // do we have extra_salt? if (cur_salt->have_extra_salt) { MD5_Update(&ctx, cur_salt->extra_salt, cur_salt->extra_salt_length); } MD5_Final((unsigned char*)crypt_out[index], &ctx); } else { HMAC_SHA256_CTX hctx[1]; unsigned char output[32]; unsigned char buffer[1 + PLAINTEXT_LENGTH + 45 + 1] = { 0 }; // HMAC key ==> '\n' + password + IP address buffer[0] = '\n'; // WTF? memcpy(buffer + 1, saved_key[index], saved_len[index]); memcpy(buffer + 1 + saved_len[index], cur_salt->ip, cur_salt->ip_length); HMAC_SHA256_Init(hctx, buffer, 1 + saved_len[index] + cur_salt->ip_length); HMAC_SHA256_Update(hctx, cur_salt->salt, cur_salt->length); HMAC_SHA256_Final(output, hctx); memcpy((unsigned char*)crypt_out[index], output, BINARY_SIZE); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/hsrp_fmt_plug.c
#pragma omp parallel for
100
ypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { MD5_CTX ctx; int len = saved_len[index]; if (dirty) { // we use the saved_key buffer in-line. unsigned int *block = (unsigned int*)saved_key[index]; MD5_Init(&saved_ctx[index]); // set bit saved_key[index][len] = 0x80; block[14] = len << 3; #if !ARCH_LITTLE_ENDIAN block[14] = JOHNSWAP(block[14]); MD5_Update(&saved_ctx[index], (unsigned char*)block, 64); // clear the bit, so that get_key returns proper key. saved_key[index][len] = 0; } memcpy(&ctx, &saved_ctx[index], sizeof(MD5_CTX)); // data MD5_Update(&ctx, cur_salt->salt, cur_salt->length); // key (again) MD5_Update(&ctx, saved_key[index], len); MD5_Final((unsigned char*)crypt_out[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/gpg_fmt_plug.c
#pragma omp parallel for
100
hm); if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { int res; unsigned char keydata[64]; gpg_common_cur_salt->s2kfun(saved_key[index], keydata, ks); res = gpg_common_check(keydata, ks); if (res) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/lastpass_sniffed_fmt_plug.c
#pragma omp parallel for
100
ypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { uint32_t key[MIN_KEYS_PER_CRYPT][8]; unsigned i; #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT]; union { uint32_t *pout[MIN_KEYS_PER_CRYPT]; unsigned char *poutc; } x; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; x.pout[i] = key[i]; } pbkdf2_sha256_sse((const unsigned char **)pin, lens, (unsigned char*)cur_salt->username, strlen(cur_salt->username), cur_salt->iterations, &(x.poutc), 32, 0); #else pbkdf2_sha256((unsigned char*)saved_key[index], strlen(saved_key[index]), (unsigned char*)cur_salt->username, strlen(cur_salt->username), cur_salt->iterations, (unsigned char*)(&key[0]),32,0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { unsigned char *Key = (unsigned char*)key[i]; AES_KEY akey; unsigned char iv[16]; unsigned char out[32]; AES_set_encrypt_key(Key, 256, &akey); memset(iv, 0, sizeof(iv)); AES_cbc_encrypt((const unsigned char*)cur_salt->username, out, 32, &akey, iv, AES_ENCRYPT); memcpy(crypt_key[index+i], out, 16); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/opencl_DES_bs_f_plug.c
#pragma omp parallel for
100
ng %d per-salt kernels, one dot per three salts done: ", num_salts); #if _OPENMP && PARALLEL_BUILD <LOOP-START>for (i = 0; i < num_salts; i++) { init_kernel(salt_list[i], gpu_id, 1, 0, forced_global_keys ? 0 :local_work_size); #if _OPENMP && PARALLEL_BUILD if (omp_get_thread_num() == 0) { opencl_process_event(); } if (num_salts > 10 && (i % 3) == 2 && !ocl_any_test_running && john_main_process) fprintf(stderr, "."); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/whirlpool_fmt_plug.c
#pragma omp parallel for
100
int crypt_0(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_whirlpool0_context ctx; sph_whirlpool0_init(&ctx); sph_whirlpool0(&ctx, saved_key[index], strlen(saved_key[index])); sph_whirlpool0_close(&ctx, (unsigned char*)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/whirlpool_fmt_plug.c
#pragma omp parallel for
100
int crypt_1(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_whirlpool1_context ctx; sph_whirlpool1_init(&ctx); sph_whirlpool1(&ctx, saved_key[index], strlen(saved_key[index])); sph_whirlpool1_close(&ctx, (unsigned char*)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/whirlpool_fmt_plug.c
#pragma omp parallel for
100
int crypt_2(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { #if (AC_BUILT && HAVE_WHIRLPOOL) || \ (!AC_BUILT && OPENSSL_VERSION_NUMBER >= 0x10000000 && !HAVE_NO_SSL_WHIRLPOOL) WHIRLPOOL_CTX ctx; WHIRLPOOL_Init(&ctx); WHIRLPOOL_Update(&ctx, saved_key[index], strlen(saved_key[index])); WHIRLPOOL_Final((unsigned char*)crypt_out[index], &ctx); #else sph_whirlpool_context ctx; sph_whirlpool_init(&ctx); sph_whirlpool(&ctx, saved_key[index], strlen(saved_key[index])); sph_whirlpool_close(&ctx, (unsigned char*)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/vmx_fmt_plug.c
#pragma omp parallel for
100
*pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0]) * cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MAX_KEYS_PER_CRYPT) { unsigned char master[MAX_KEYS_PER_CRYPT][32]; int i; #ifdef SIMD_COEF_32 int lens[MAX_KEYS_PER_CRYPT]; unsigned char *pin[MAX_KEYS_PER_CRYPT], *pout[MAX_KEYS_PER_CRYPT]; for (i = 0; i < MAX_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha1_sse((const unsigned char**)pin, lens, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pout, 32, 0); #else for (i = 0; i < MAX_KEYS_PER_CRYPT; ++i) { pbkdf2_sha1((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, master[i], 32, 0); } for (i = 0; i < MAX_KEYS_PER_CRYPT; ++i) { cracked[index+i] = vmx_decrypt(cur_salt, master[i], cur_salt->blob); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawMD4_fmt_plug.c
#pragma omp parallel for
100
nt; int index; int loops = (count + MIN_KEYS_PER_CRYPT - 1) / MIN_KEYS_PER_CRYPT; #ifdef _OPENMP <LOOP-START>for (index = 0; index < loops; index++) { #if SIMD_COEF_32 SIMDmd4body(saved_key[index], crypt_key[index], NULL, SSEi_REVERSE_STEPS | SSEi_MIXED_IN); #else MD4_CTX ctx; MD4_Init(&ctx); MD4_Update(&ctx, saved_key[index], saved_len[index]); MD4_Final((unsigned char *)crypt_key[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ecryptfs_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { int j; SHA512_CTX ctx; #ifdef SIMD_COEF_64 unsigned char tmpBuf[64]; unsigned int i; unsigned char _IBuf[8*SHA_BUF_SIZ*MIN_KEYS_PER_CRYPT+MEM_ALIGN_CACHE], *keys; uint64_t *keys64; keys = (unsigned char*)mem_align(_IBuf, MEM_ALIGN_CACHE); keys64 = (uint64_t*)keys; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { SHA512_Init(&ctx); SHA512_Update(&ctx, cur_salt->salt, ECRYPTFS_SALT_SIZE); SHA512_Update(&ctx, saved_key[index+i], strlen(saved_key[index+i])); SHA512_Final((unsigned char *)tmpBuf, &ctx); for (j = 0; j < 64; ++j) keys[GETPOS_512(j, i)] = tmpBuf[j]; } uint64_t rounds = ECRYPTFS_DEFAULT_NUM_HASH_ITERATIONS - 1; SIMDSHA512body(keys, keys64, &rounds, SSEi_HALF_IN|SSEi_LOOP); // Last one with FLAT_OUT SIMDSHA512body(keys, (uint64_t*)crypt_out[index], NULL, SSEi_HALF_IN|SSEi_FLAT_OUT); #else SHA512_Init(&ctx); SHA512_Update(&ctx, cur_salt->salt, ECRYPTFS_SALT_SIZE); SHA512_Update(&ctx, saved_key[index], strlen(saved_key[index])); SHA512_Final((unsigned char *)crypt_out[index], &ctx); /* now "h" (crypt_out[index] becomes our input, total SHA-512 calls => 65536 */ for (j = 1; j <= ECRYPTFS_DEFAULT_NUM_HASH_ITERATIONS; j++) { SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, (unsigned char*)crypt_out[index], BINARY_SIZE); SHA512_Final((unsigned char *)crypt_out[index], &ctx); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/openssl_enc_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { if (decrypt(saved_key[index]) == 0) cracked[index] = 1; else cracked[index] = 0; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/krb5_asrep_fmt_plug.c
#pragma omp parallel for
100
ndex; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char tkey[MIN_KEYS_PER_CRYPT][32]; int len[MIN_KEYS_PER_CRYPT]; int i; unsigned char K3[16]; #ifdef _MSC_VER unsigned char ddata[65536]; #else unsigned char ddata[cur_salt->edata2len]; unsigned char checksum[16]; RC4_KEY rckey; if (cur_salt->etype == 23) { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (new_keys) { MD4_CTX ctx; unsigned char key[16]; UTF16 wkey[PLAINTEXT_LENGTH + 1]; int len; len = enc_to_utf16(wkey, PLAINTEXT_LENGTH, (UTF8*)saved_key[index+i], strlen(saved_key[index+i])); if (len <= 0) { saved_key[index+i][-len] = 0; len = strlen16(wkey); } MD4_Init(&ctx); MD4_Update(&ctx, (char*)wkey, 2 * len); MD4_Final(key, &ctx); hmac_md5(key, data, 4, saved_K1[index+i]); } hmac_md5(saved_K1[index+i], cur_salt->edata1, 16, K3); RC4_set_key(&rckey, 16, K3); RC4(&rckey, 32, cur_salt->edata2, ddata); /* check the checksum */ RC4(&rckey, cur_salt->edata2len - 32, cur_salt->edata2 + 32, ddata + 32); hmac_md5(saved_K1[index+i], ddata, cur_salt->edata2len, checksum); if (!memcmp(checksum, cur_salt->edata1, 16)) { cracked[index+i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } } else if (cur_salt->etype == 17 || cur_salt->etype == 18) { // See "krb5int_decode_tgs_rep", "krb5int_enctypes_list", "krb5int_dk_decrypt" (key function), // "krb5_k_decrypt", and "krb5_kdc_rep_decrypt_proc" // from krb5 software package. // https://www.ietf.org/rfc/rfc3962.txt document, https://www.ietf.org/rfc/rfc3961.txt, and // http://www.zeroshell.org/kerberos/Kerberos-operation/ const int key_size = (cur_salt->etype == 17) ? 16 : 32; #ifdef SIMD_COEF_32 unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { len[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = tkey[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, len, (unsigned char*)cur_salt->salt, strlen(cur_salt->salt), 4096, pout, key_size, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { len[i] = strlen(saved_key[index+i]); pbkdf2_sha1((const unsigned char*)saved_key[index], len[i], (unsigned char*)cur_salt->salt, strlen(cur_salt->salt), 4096, tkey[i], key_size, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { unsigned char Ki[32]; #ifdef _MSC_VER unsigned char plaintext[65536]; #else unsigned char plaintext[cur_salt->edata2len]; unsigned char checksum[20]; unsigned char base_key[32]; unsigned char Ke[32]; dk(base_key, tkey[i], key_size, constant, 16); dk(Ke, base_key, key_size, ke_input, 16); krb_decrypt(cur_salt->edata2, cur_salt->edata2len, plaintext, Ke, key_size); // derive checksum of plaintext dk(Ki, base_key, key_size, ki_input, 16); hmac_sha1(Ki, key_size, plaintext, cur_salt->edata2len, checksum, 20); if (!memcmp(checksum, cur_salt->edata1, 12)) { cracked[index+i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/androidfde_fmt_plug.c
#pragma omp parallel for
100
unt = *pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0])*max_cracked); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { hash_plugin_check_hash(index); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/md2_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_md2_context ctx; sph_md2_init(&ctx); sph_md2(&ctx, saved_key[index], strlen(saved_key[index])); sph_md2_close(&ctx, (unsigned char*)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/NETSPLITLM_fmt_plug.c
#pragma omp parallel for default(none) private(i, ks) shared(count, output, challenge, saved_pre)
100
pcount, struct db_salt *salt) { int count = *pcount; DES_key_schedule ks; int i; #ifdef _OPENMP <LOOP-START>for (i=0; i<count; i++) { /* DES-encrypt challenge using the partial LM hash */ setup_des_key(saved_pre[i], &ks); DES_ecb_encrypt((DES_cblock*)challenge, (DES_cblock*)output[i], &ks, DES_ENCRYPT); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i, ks) shared(count, output, challenge, saved_pre)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/lotus5_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += LOTUS_N) { struct { union { unsigned char m[64]; unsigned char m4[4][16]; ARCH_WORD m4w[4][16 / ARCH_SIZE]; } u; } ctx[LOTUS_N]; int password_length; memset(ctx[0].u.m4[0], 0, 16); password_length = strlen(saved_key[index]); memset(ctx[0].u.m4[1], (PLAINTEXT_LENGTH - password_length), PLAINTEXT_LENGTH); memcpy(ctx[0].u.m4[1], saved_key[index], password_length); memcpy(ctx[0].u.m4[2], ctx[0].u.m4[1], 16); memset(ctx[1].u.m4[0], 0, 16); password_length = strlen(saved_key[index + 1]); memset(ctx[1].u.m4[1], (PLAINTEXT_LENGTH - password_length), PLAINTEXT_LENGTH); memcpy(ctx[1].u.m4[1], saved_key[index + 1], password_length); memcpy(ctx[1].u.m4[2], ctx[1].u.m4[1], 16); #if LOTUS_N == 3 memset(ctx[2].u.m4[0], 0, 16); password_length = strlen(saved_key[index + 2]); memset(ctx[2].u.m4[1], (PLAINTEXT_LENGTH - password_length), PLAINTEXT_LENGTH); memcpy(ctx[2].u.m4[1], saved_key[index + 2], password_length); memcpy(ctx[2].u.m4[2], ctx[2].u.m4[1], 16); lotus_transform_password(ctx[0].u.m4[1], ctx[0].u.m4[3], ctx[1].u.m4[1], ctx[1].u.m4[3], ctx[2].u.m4[1], ctx[2].u.m4[3]); lotus_mix(ctx[0].u.m, ctx[1].u.m, ctx[2].u.m); #else lotus_transform_password(ctx[0].u.m4[1], ctx[0].u.m4[3], ctx[1].u.m4[1], ctx[1].u.m4[3]); lotus_mix(ctx[0].u.m, ctx[1].u.m); memcpy(ctx[0].u.m4[1], ctx[0].u.m4[3], 16); memcpy(ctx[1].u.m4[1], ctx[1].u.m4[3], 16); #if LOTUS_N == 3 memcpy(ctx[2].u.m4[1], ctx[2].u.m4[3], 16); { int i; for (i = 0; i < 16 / ARCH_SIZE; i++) { ctx[0].u.m4w[2][i] = ctx[0].u.m4w[0][i] ^ ctx[0].u.m4w[1][i]; ctx[1].u.m4w[2][i] = ctx[1].u.m4w[0][i] ^ ctx[1].u.m4w[1][i]; #if LOTUS_N == 3 ctx[2].u.m4w[2][i] = ctx[2].u.m4w[0][i] ^ ctx[2].u.m4w[1][i]; } } #if LOTUS_N == 3 lotus_mix(ctx[0].u.m, ctx[1].u.m, ctx[2].u.m); #else lotus_mix(ctx[0].u.m, ctx[1].u.m); memcpy(crypt_key[index], ctx[0].u.m4[0], BINARY_SIZE); memcpy(crypt_key[index + 1], ctx[1].u.m4[0], BINARY_SIZE); #if LOTUS_N == 3 memcpy(crypt_key[index + 2], ctx[2].u.m4[0], BINARY_SIZE); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/itunes_fmt_plug.c
#pragma omp parallel for
100
= *pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0])*cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][32]; int i; if (cur_salt->version == 9) { // iTunes Backup < 10 #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; int loops = MIN_KEYS_PER_CRYPT / SSE_GROUP_SZ_SHA1; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } for (i = 0; i < loops; i++) pbkdf2_sha1_sse((const unsigned char**)(pin + i * SSE_GROUP_SZ_SHA1), &lens[i * SSE_GROUP_SZ_SHA1], cur_salt->salt, SALTLEN, cur_salt->iterations, pout + (i * SSE_GROUP_SZ_SHA1), 32, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha1((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, SALTLEN, cur_salt->iterations, master[i], 32, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { cracked[index+i] = itunes_common_decrypt(cur_salt, master[i]); } } else { // iTunes Backup 10.x #if defined(SIMD_COEF_64) && defined(SIMD_COEF_32) int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; int loops = MIN_KEYS_PER_CRYPT / SSE_GROUP_SZ_SHA256; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } for (i = 0; i < loops; i++) pbkdf2_sha256_sse((const unsigned char**)(pin + i * SSE_GROUP_SZ_SHA256), &lens[i * SSE_GROUP_SZ_SHA256], cur_salt->dpsl, SALTLEN, cur_salt->dpic, pout + (i * SSE_GROUP_SZ_SHA256), 32, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = 32; pin[i] = (unsigned char*)master[i]; pout[i] = master[i]; } loops = MIN_KEYS_PER_CRYPT / SSE_GROUP_SZ_SHA1; for (i = 0; i < loops; i++) pbkdf2_sha1_sse((const unsigned char**)(pin + i * SSE_GROUP_SZ_SHA1), &lens[i * SSE_GROUP_SZ_SHA1], cur_salt->salt, SALTLEN, cur_salt->iterations, pout + (i * SSE_GROUP_SZ_SHA1), 32, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { pbkdf2_sha256((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->dpsl, SALTLEN, cur_salt->dpic, master[i], 32, 0); pbkdf2_sha1(master[i], 32, cur_salt->salt, SALTLEN, cur_salt->iterations, master[i], 32, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { cracked[index+i] = itunes_common_decrypt(cur_salt, master[i]); } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/luks_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char *af_decrypted = (unsigned char *)mem_alloc(cur_salt->afsize + 20); int i, iterations = cur_salt->bestiter; int dklen = john_ntohl(cur_salt->myphdr.keyBytes); uint32_t keycandidate[MIN_KEYS_PER_CRYPT][256/4]; uint32_t masterkeycandidate[MIN_KEYS_PER_CRYPT][256/4]; #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT]; union { uint32_t *pout[MIN_KEYS_PER_CRYPT]; unsigned char *poutc; } x; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; x.pout[i] = keycandidate[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, (const unsigned char*)(cur_salt->myphdr.keyblock[cur_salt->bestslot].passwordSalt), LUKS_SALTSIZE, iterations, &(x.poutc), dklen, 0); #else pbkdf2_sha1((const unsigned char *)saved_key[index], strlen(saved_key[index]), (const unsigned char*)(cur_salt->myphdr.keyblock[cur_salt->bestslot].passwordSalt), LUKS_SALTSIZE, iterations, (unsigned char*)keycandidate[0], dklen, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { // Decrypt the blocksi decrypt_aes_cbc_essiv(cur_salt->cipherbuf, af_decrypted, (unsigned char*)keycandidate[i], cur_salt->afsize, cur_salt); // AFMerge the blocks AF_merge(af_decrypted, (unsigned char*)masterkeycandidate[i], cur_salt->afsize, john_ntohl(cur_salt->myphdr.keyblock[cur_salt->bestslot].stripes)); } // pbkdf2 again #ifdef SIMD_COEF_32 for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = john_ntohl(cur_salt->myphdr.keyBytes); pin[i] = (unsigned char*)masterkeycandidate[i]; x.pout[i] = crypt_out[index+i]; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, (const unsigned char*)cur_salt->myphdr.mkDigestSalt, LUKS_SALTSIZE, john_ntohl(cur_salt->myphdr.mkDigestIterations), &(x.poutc), LUKS_DIGESTSIZE, 0); #else pbkdf2_sha1((unsigned char*)masterkeycandidate[0], john_ntohl(cur_salt->myphdr.keyBytes), (const unsigned char*)cur_salt->myphdr.mkDigestSalt, LUKS_SALTSIZE, john_ntohl(cur_salt->myphdr.mkDigestIterations), (unsigned char*)crypt_out[index], LUKS_DIGESTSIZE, 0); MEM_FREE(af_decrypted); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/bitcoin_fmt_plug.c
#pragma omp parallel for
100
= 0; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { SHA512_CTX sha_ctx; int i; #ifdef SIMD_COEF_64 /* We use SSEi_HALF_IN, so can halve SHA_BUF_SIZ */ #undef SHA_BUF_SIZ #define SHA_BUF_SIZ 8 char unaligned_buf[MIN_KEYS_PER_CRYPT*SHA_BUF_SIZ*sizeof(uint64_t)+MEM_ALIGN_SIMD]; uint64_t *key_iv = (uint64_t*)mem_align(unaligned_buf, MEM_ALIGN_SIMD); JTR_ALIGN(8) unsigned char hash1[SHA512_DIGEST_LENGTH]; // 512 bits int index2; for (index2 = 0; index2 < MIN_KEYS_PER_CRYPT; index2++) { // The first hash for this password SHA512_Init(&sha_ctx); SHA512_Update(&sha_ctx, saved_key[index+index2], strlen(saved_key[index+index2])); SHA512_Update(&sha_ctx, cur_salt->cry_salt, cur_salt->cry_salt_length); SHA512_Final(hash1, &sha_ctx); // Now copy and convert hash1 from flat into SIMD_COEF_64 buffers. for (i = 0; i < SHA512_DIGEST_LENGTH/sizeof(uint64_t); ++i) { key_iv[SIMD_COEF_64*i + (index2&(SIMD_COEF_64-1)) + index2/SIMD_COEF_64*SHA_BUF_SIZ*SIMD_COEF_64] = sha_ctx.h[i]; } } // the first iteration is already done above uint64_t rounds = cur_salt->cry_rounds - 1; SIMDSHA512body(key_iv, key_iv, &rounds, SSEi_HALF_IN|SSEi_LOOP); for (index2 = 0; index2 < MIN_KEYS_PER_CRYPT; index2++) { AES_KEY aes_key; union { unsigned char uc[32]; uint64_t u64[4]; } key; unsigned char iv[16]; unsigned char output[16]; memcpy(iv, cur_salt->cry_master + cur_salt->cry_master_length - 32, 16); // Copy and convert from SIMD_COEF_64 buffers back into flat buffers, in little-endian #if ARCH_LITTLE_ENDIAN==1 for (i = 0; i < 4; i++) // the derived key key.u64[i] = JOHNSWAP64(key_iv[SIMD_COEF_64*i + (index2&(SIMD_COEF_64-1)) + index2/SIMD_COEF_64*SHA_BUF_SIZ*SIMD_COEF_64]); #else for (i = 0; i < 4; i++) // the derived key key.u64[i] = key_iv[SIMD_COEF_64*i + (index2&(SIMD_COEF_64-1)) + index2/SIMD_COEF_64*SHA_BUF_SIZ*SIMD_COEF_64]; AES_set_decrypt_key(key.uc, 256, &aes_key); AES_cbc_encrypt(cur_salt->cry_master + cur_salt->cry_master_length - 16, output, 16, &aes_key, iv, AES_DECRYPT); if (check_pkcs_pad(output, 16, 16) == cur_salt->final_block_fill) { cracked[index + index2] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } #else AES_KEY aes_key; unsigned char key_iv[SHA512_DIGEST_LENGTH]; // buffer for both the derived key and initial IV unsigned char iv[16]; // updated IV for the final block unsigned char output[16]; memcpy(iv, cur_salt->cry_master + cur_salt->cry_master_length - 32, 16); SHA512_Init(&sha_ctx); SHA512_Update(&sha_ctx, saved_key[index], strlen(saved_key[index])); SHA512_Update(&sha_ctx, cur_salt->cry_salt, cur_salt->cry_salt_length); SHA512_Final(key_iv, &sha_ctx); for (i = 1; i < cur_salt->cry_rounds; i++) { // start at 1; the first iteration is already done SHA512_Init(&sha_ctx); SHA512_Update(&sha_ctx, key_iv, SHA512_DIGEST_LENGTH); SHA512_Final(key_iv, &sha_ctx); } AES_set_decrypt_key(key_iv, 256, &aes_key); AES_cbc_encrypt(cur_salt->cry_master + cur_salt->cry_master_length - 16, output, 16, &aes_key, iv, AES_DECRYPT); if (check_pkcs_pad(output, 16, 16) == cur_salt->final_block_fill) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/qnx_fmt_plug.c
#pragma omp parallel for
100
ile (tot_todo % MIN_KEYS_PER_CRYPT) MixOrder[tot_todo++] = count; } } #endif #ifdef _OPENMP <LOOP-START>for (index = 0; index < tot_todo; index += inc) { #ifdef SIMD_COEF_32 if (!MixOrder) { int i, len = saved_len[index]; char *pass = saved_key[index]; switch (cur_salt->type) { case 5: { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, cur_salt->salt, cur_salt->len); for (i = 0; i <= cur_salt->rounds; ++i) MD5_Update(&ctx, pass, len); MD5_Final((unsigned char*)(crypt_out[index]), &ctx); break; } case 256: { SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, cur_salt->salt, cur_salt->len); for (i = 0; i <= cur_salt->rounds; ++i) SHA256_Update(&ctx, pass, len); SHA256_Final((unsigned char*)(crypt_out[index]), &ctx); break; } case 512: { SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, cur_salt->salt, cur_salt->len); if (len && 128 % len == 0 && cur_salt->len+len*cur_salt->rounds > 256) { // we can optimize this, by filling buffer (after the // first salted buffer), and then simply calling // jtr_sha512_hash_block 'natively' never having to // refill the buffer again. int ex; for (i = 0; i <= cur_salt->rounds; ++i) { SHA512_Update(&ctx, pass, len); if (ctx.total > 128+cur_salt->len) break; } ++i; ex = (256-ctx.total)/len; i += ex; ctx.total += ex*len; jtr_sha512_hash_block(&ctx, ctx.buffer, 1); while (i+128/len <= cur_salt->rounds) { ctx.total += 128; jtr_sha512_hash_block(&ctx, ctx.buffer, 1); i += 128/len; } for (;i <= cur_salt->rounds; ++i) ctx.total += len; } else { for (i = 0; i <= cur_salt->rounds; ++i) SHA512_Update(&ctx, pass, len); } ctx.bIsQnxBuggy = 1; SHA512_Final((unsigned char*)(crypt_out[index]), &ctx); break; } } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/solarwinds_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MAX_KEYS_PER_CRYPT) { unsigned char master[MAX_KEYS_PER_CRYPT][1024]; int i; #ifdef SIMD_COEF_32 int len[MAX_KEYS_PER_CRYPT]; unsigned char *pin[MAX_KEYS_PER_CRYPT], *pout[MAX_KEYS_PER_CRYPT]; for (i = 0; i < MAX_KEYS_PER_CRYPT; ++i) { len[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = master[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, len, (unsigned char *)cur_salt->salt, 8, 1000, pout, 1024, 0); #else for (i = 0; i < MAX_KEYS_PER_CRYPT; ++i) pbkdf2_sha1((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), (unsigned char *)cur_salt->salt, 8, 1000, master[i], 1024, 0); for (i = 0; i < MAX_KEYS_PER_CRYPT; ++i) { SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, master[i], 1024); SHA512_Final((unsigned char*)crypt_out[index+i], &ctx); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/enpass_fmt_plug.c
#pragma omp parallel for
100
OUP_SZ_SHA512; #else const int batch_size = MAX_KEYS_PER_CRYPT; #endif int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += batch_size) { unsigned char master[MAX_KEYS_PER_CRYPT][32]; unsigned char output[24]; unsigned char *iv_in; unsigned char iv_out[16]; int size, i; AES_KEY akey; if (cur_salt->version == 5) { #ifdef SIMD_COEF_32 int len[MAX_BATCH_SIZE]; unsigned char *pin[MAX_BATCH_SIZE], *pout[MAX_BATCH_SIZE]; for (i = 0; i < batch_size; ++i) { len[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = master[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, len, cur_salt->salt, 16, cur_salt->iterations, pout, 32, 0); #else for (i = 0; i < batch_size; ++i) pbkdf2_sha1((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, 16, cur_salt->iterations, master[i], 32, 0); } else { #ifdef SIMD_COEF_32 int len[MAX_BATCH_SIZE]; unsigned char *pin[MAX_BATCH_SIZE], *pout[MAX_BATCH_SIZE]; for (i = 0; i < batch_size; ++i) { len[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = master[i]; } pbkdf2_sha512_sse((const unsigned char **)pin, len, cur_salt->salt, 16, cur_salt->iterations, pout, 32, 0); #else for (i = 0; i < batch_size; ++i) pbkdf2_sha512((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, 16, cur_salt->iterations, master[i], 32, 0); } for (i = 0; i < batch_size; ++i) { // memcpy(output, SQLITE_FILE_HEADER, FILE_HEADER_SZ); // See "sqlcipher_page_cipher" and "sqlite3Codec" functions size = page_sz - reserve_sz; iv_in = cur_salt->data + 16 + size; // initial 16 bytes are salt memcpy(iv_out, iv_in, 16); AES_set_decrypt_key(master[i], 256, &akey); /* * decrypting 8 bytes from offset 16 is enough since the * verify_page function looks at output[16..23] only. */ AES_cbc_encrypt(cur_salt->data + 16, output + 16, 8, &akey, iv_out, AES_DECRYPT); if (enpass_verify_page(output) == 0) cracked[index+i] = 1; else cracked[index+i] = 0; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/padlock_fmt_plug.c
#pragma omp parallel for
100
= *pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0])*cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][32]; unsigned char output[4096] = {0}; int i; unsigned char *tag = cur_salt->ct + cur_salt->ctlen - cur_salt->tag_len; // last "tag_len" bytes #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha256_sse((const unsigned char**)pin, lens, cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, pout, 32, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha256((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, master[i], 32, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { memset(output, 0, 4096); // avoid possible false positives that can be caused by older "valid" decrypted data aes_ccm_auth_decrypt(master[i], 256, cur_salt->ctlen - cur_salt->tag_len, cur_salt->iv, 13, cur_salt->add, // 13 is the correct iv size for padlock + sjcl combo cur_salt->addlen, cur_salt->ct, output, tag, cur_salt->tag_len); // CCM tag calculation is broken in Padlock + SJCL combination. Padlock sends "add" data to SJCL // without doing base64 decoding! As a result the JavaScript code in SJCL behaves very weirdly. // Instead of trying to emulate this broken behavior and struggling with JavaScript, we simply use // known plaintext attack here! if (cur_salt->ctlen - cur_salt->tag_len == 2) { // special case, empty database if (strncmp((const char*)output, "[]", 2) == 0) cracked[index+i] = 1; } else { // general case if (output[0] != '[') cracked[index+i] = 0; else if (strstr((const char*)output, "\"updated\"")) cracked[index+i] = 1; } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/xmpp_scram_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { int index; const int count = *pcount; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #if !defined (SIMD_COEF_32) unsigned char out[BINARY_SIZE]; SHA_CTX ctx; pbkdf2_sha1((unsigned char*)saved_key[index], strlen(saved_key[index]), cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, out, BINARY_SIZE, 0); hmac_sha1(out, BINARY_SIZE, (unsigned char*)"Client Key", 10, out, BINARY_SIZE); SHA1_Init(&ctx); SHA1_Update(&ctx, out, BINARY_SIZE); SHA1_Final((unsigned char*)crypt_out[index], &ctx); #else SHA_CTX ctx; int i; unsigned char *pin[SIMD_KEYS]; int lens[SIMD_KEYS]; unsigned char out_[SIMD_KEYS][BINARY_SIZE], *out[SIMD_KEYS]; for (i = 0; i < SIMD_KEYS; ++i) { pin[i] = (unsigned char*)saved_key[index+i]; lens[i] = strlen(saved_key[index+i]); out[i] = out_[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, out, BINARY_SIZE, 0); for (i = 0; i < SIMD_KEYS; ++i) { hmac_sha1(out[i], BINARY_SIZE, (unsigned char*)"Client Key", 10, out[i], BINARY_SIZE); SHA1_Init(&ctx); SHA1_Update(&ctx, out[i], BINARY_SIZE); SHA1_Final((unsigned char*)crypt_out[index+i], &ctx); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/telegram_fmt_plug.c
#pragma omp parallel for
100
CNT; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += inc) { unsigned char pkey[MIN_KEYS_PER_CRYPT][256]; /* 2048 bits, yes */ int i; if (cur_salt->version == 1) { #ifdef SIMD_COEF_32 int len[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < inc; ++i) { len[i] = strlen(saved_key[index + i]); pin[i] = (unsigned char*)saved_key[index + i]; pout[i] = pkey[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, len, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pout, 136 /* 256 */, 0); #else for (i = 0; i < inc; i++) { pbkdf2_sha1((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pkey[i], 136, 0); } } else { /* (cur_salt->version == 2) */ #ifdef SIMD_COEF_64 int len[MIN_KEYS_PER_CRYPT]; unsigned char pbkdf2_key[MIN_KEYS_PER_CRYPT][64]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < inc; i++) { SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, (unsigned char*)cur_salt->salt, cur_salt->salt_length); SHA512_Update(&ctx, (unsigned char*)saved_key[index + i], strlen(saved_key[index + i])); SHA512_Update(&ctx, (unsigned char*)cur_salt->salt, cur_salt->salt_length); SHA512_Final(pbkdf2_key[i], &ctx); len[i] = 64; pin[i] = pbkdf2_key[i]; pout[i] = pkey[i]; } pbkdf2_sha512_sse((const unsigned char **)pin, len, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pout, 136 /* 256 */, 0); #else for (i = 0; i < inc; i++) { unsigned char pbkdf2_key[64]; SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, (unsigned char*)cur_salt->salt, cur_salt->salt_length); SHA512_Update(&ctx, (unsigned char*)saved_key[index + i], strlen(saved_key[index + i])); SHA512_Update(&ctx, (unsigned char*)cur_salt->salt, cur_salt->salt_length); SHA512_Final(pbkdf2_key, &ctx); pbkdf2_sha512(pbkdf2_key, 64, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pkey[i], 136, 0); } } for (i = 0; i < inc; i++) { if (telegram_check_password(pkey[i], cur_salt)) { cracked[index + i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ike_fmt_plug.c
#pragma omp parallel for
100
ypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { compute_hash(cur_salt, saved_key[index], (unsigned char*)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/securezip_fmt_plug.c
#pragma omp parallel for
100
dex; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { if (securezip_decrypt(cur_salt, saved_key[index])) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/krb5pa-md5_fmt_plug.c
#pragma omp parallel for
100
pcount; const unsigned char one[] = { 1, 0, 0, 0 }; int i; if (!keys_prepared) { #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { int len; unsigned char K[KEY_SIZE]; unsigned char K1[KEY_SIZE]; // K = MD4(UTF-16LE(password)), ordinary 16-byte NTLM hash len = E_md4hash((unsigned char *) saved_plain[i], saved_len[i], K); if (len <= 0) ((char*)(saved_plain[i]))[-len] = 0; // match truncation // K1 = HMAC-MD5(K, 1) // 1 is encoded as little endian in 4 bytes (0x01000000) hmac_md5(K, (unsigned char *) &one, 4, K1); // We do key setup of the next HMAC_MD5 here. rest in inner loop hmac_md5_init_K16(K1, &saved_ctx[i]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/krb5pa-md5_fmt_plug.c
#pragma omp parallel for
100
in inner loop hmac_md5_init_K16(K1, &saved_ctx[i]); } keys_prepared = 1; } #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { unsigned char K3[KEY_SIZE], cleartext[TIMESTAMP_SIZE]; HMACMD5Context ctx; // key set up with K1 is stored in saved_ctx[i] // K3 = HMAC-MD5(K1, CHECKSUM) memcpy(&ctx, &saved_ctx[i], sizeof(ctx)); hmac_md5_update((unsigned char*)cur_salt->checksum, CHECKSUM_SIZE, &ctx); hmac_md5_final(K3, &ctx); // Decrypt part of the timestamp with the derived key K3 RC4_single(K3, KEY_SIZE, cur_salt->timestamp, 16, cleartext); // Bail out unless we see known plaintext if (cleartext[14] == '2' && cleartext[15] == '0') { // Decrypt the rest of the timestamp RC4_single(K3, KEY_SIZE, cur_salt->timestamp, TIMESTAMP_SIZE, cleartext); if (cleartext[28] == 'Z') { // create checksum K2 = HMAC-MD5(K1, plaintext) memcpy(&ctx, &saved_ctx[i], sizeof(ctx)); hmac_md5_update(cleartext, TIMESTAMP_SIZE, &ctx); hmac_md5_final((unsigned char*)output[i], &ctx); } } else { output[i][0] = 0; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sha256crypt_fmt_plug.c
#pragma omp parallel for
100
x = 0; index < count; ++index) MixOrder[index] = index; tot_todo = count; #endif #ifdef _OPENMP <LOOP-START>for (index = 0; index < tot_todo; index += MIN_KEYS_PER_CRYPT) { // portably align temp_result char * pointer machine word size. union xx { unsigned char c[BINARY_SIZE]; ARCH_WORD a[BINARY_SIZE/sizeof(ARCH_WORD)]; } u; unsigned char *temp_result = u.c; SHA256_CTX ctx; SHA256_CTX alt_ctx; size_t cnt; int idx; char *cp; char p_bytes[PLAINTEXT_LENGTH+1]; char s_bytes[PLAINTEXT_LENGTH+1]; char tmp_cls[sizeof(cryptloopstruct)+MEM_ALIGN_SIMD]; cryptloopstruct *crypt_struct; #ifdef SIMD_COEF_32 char tmp_sse_out[8*MIN_KEYS_PER_CRYPT*4+MEM_ALIGN_SIMD]; uint32_t *sse_out; sse_out = (uint32_t *)mem_align(tmp_sse_out, MEM_ALIGN_SIMD); crypt_struct = (cryptloopstruct *)mem_align(tmp_cls,MEM_ALIGN_SIMD); for (idx = 0; idx < MIN_KEYS_PER_CRYPT; ++idx) { /* Prepare for the real work. */ SHA256_Init(&ctx); /* Add the key string. */ SHA256_Update(&ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* The last part is the salt string. This must be at most 16 characters and it ends at the first `$' character (for compatibility with existing implementations). */ SHA256_Update(&ctx, cur_salt->salt, cur_salt->len); /* Compute alternate SHA256 sum with input KEY, SALT, and KEY. The final result will be added to the first context. */ SHA256_Init(&alt_ctx); /* Add key. */ SHA256_Update(&alt_ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Add salt. */ SHA256_Update(&alt_ctx, cur_salt->salt, cur_salt->len); /* Add key again. */ SHA256_Update(&alt_ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Now get result of this (32 bytes) and add it to the other context. */ SHA256_Final((unsigned char*)crypt_out[MixOrder[index+idx]], &alt_ctx); /* Add for any character in the key one byte of the alternate sum. */ for (cnt = saved_len[MixOrder[index+idx]]; cnt > BINARY_SIZE; cnt -= BINARY_SIZE) SHA256_Update(&ctx, (unsigned char*)crypt_out[MixOrder[index+idx]], BINARY_SIZE); SHA256_Update(&ctx, (unsigned char*)crypt_out[MixOrder[index+idx]], cnt); /* Take the binary representation of the length of the key and for every 1 add the alternate sum, for every 0 the key. */ for (cnt = saved_len[MixOrder[index+idx]]; cnt > 0; cnt >>= 1) if ((cnt & 1) != 0) SHA256_Update(&ctx, (unsigned char*)crypt_out[MixOrder[index+idx]], BINARY_SIZE); else SHA256_Update(&ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Create intermediate result. */ SHA256_Final((unsigned char*)crypt_out[MixOrder[index+idx]], &ctx); /* Start computation of P byte sequence. */ SHA256_Init(&alt_ctx); /* For every character in the password add the entire password. */ for (cnt = 0; cnt < saved_len[MixOrder[index+idx]]; ++cnt) SHA256_Update(&alt_ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Finish the digest. */ SHA256_Final(temp_result, &alt_ctx); /* Create byte sequence P. */ cp = p_bytes; for (cnt = saved_len[MixOrder[index+idx]]; cnt >= BINARY_SIZE; cnt -= BINARY_SIZE) cp = (char *) memcpy (cp, temp_result, BINARY_SIZE) + BINARY_SIZE; memcpy (cp, temp_result, cnt); /* Start computation of S byte sequence. */ SHA256_Init(&alt_ctx); /* repeat the following 16+A[0] times, where A[0] represents the first byte in digest A interpreted as an 8-bit unsigned value */ for (cnt = 0; cnt < 16 + ((unsigned char*)crypt_out[MixOrder[index+idx]])[0]; ++cnt) SHA256_Update(&alt_ctx, cur_salt->salt, cur_salt->len); /* Finish the digest. */ SHA256_Final(temp_result, &alt_ctx); /* Create byte sequence S. */ cp = s_bytes; for (cnt = cur_salt->len; cnt >= BINARY_SIZE; cnt -= BINARY_SIZE) cp = (char *) memcpy (cp, temp_result, BINARY_SIZE) + BINARY_SIZE; memcpy (cp, temp_result, cnt); /* Repeatedly run the collected hash value through SHA256 to burn CPU cycles. */ LoadCryptStruct(crypt_struct, MixOrder[index+idx], idx, p_bytes, s_bytes); } idx = 0; #ifdef SIMD_COEF_32 for (cnt = 1; ; ++cnt) { if (crypt_struct->datlen[idx]==128) { unsigned char *cp = crypt_struct->bufs[0][idx]; SIMDSHA256body(cp, sse_out, NULL, SSEi_FLAT_IN|SSEi_2BUF_INPUT_FIRST_BLK); SIMDSHA256body(&cp[64], sse_out, sse_out, SSEi_FLAT_IN|SSEi_2BUF_INPUT_FIRST_BLK|SSEi_RELOAD); } else { unsigned char *cp = crypt_struct->bufs[0][idx]; SIMDSHA256body(cp, sse_out, NULL, SSEi_FLAT_IN|SSEi_2BUF_INPUT_FIRST_BLK); } if (cnt == cur_salt->rounds) break; { unsigned int j, k; for (k = 0; k < MIN_KEYS_PER_CRYPT; ++k) { uint32_t *o = (uint32_t *)crypt_struct->cptr[k][idx]; #if !ARCH_ALLOWS_UNALIGNED if (!is_aligned(o, 4)) { unsigned char *cp = (unsigned char*)o; for (j = 0; j < 32; ++j) *cp++ = ((unsigned char*)sse_out)[GETPOS(j, k)]; } else for (j = 0; j < 8; ++j) #if ARCH_LITTLE_ENDIAN==1 *o++ = JOHNSWAP(sse_out[(j*SIMD_COEF_32)+(k&(SIMD_COEF_32-1))+k/SIMD_COEF_32*8*SIMD_COEF_32]); #else *o++ = sse_out[(j*SIMD_COEF_32)+(k&(SIMD_COEF_32-1))+k/SIMD_COEF_32*8*SIMD_COEF_32]; } } if (++idx == 42) idx = 0; } { unsigned int j, k; for (k = 0; k < MIN_KEYS_PER_CRYPT; ++k) { uint32_t *o = (uint32_t *)crypt_out[MixOrder[index+k]]; for (j = 0; j < 8; ++j) #if ARCH_LITTLE_ENDIAN==1 *o++ = JOHNSWAP(sse_out[(j*SIMD_COEF_32)+(k&(SIMD_COEF_32-1))+k/SIMD_COEF_32*8*SIMD_COEF_32]); #else *o++ = sse_out[(j*SIMD_COEF_32)+(k&(SIMD_COEF_32-1))+k/SIMD_COEF_32*8*SIMD_COEF_32]; } } #else SHA256_Init(&ctx); for (cnt = 1; ; ++cnt) { // calling with 64 byte, or 128 byte always, will force the update to properly crypt the data. // NOTE the data is fully formed. It ends in a 0x80, is padded with nulls, AND has bit appended. SHA256_Update(&ctx, crypt_struct->bufs[0][idx], crypt_struct->datlen[idx]); if (cnt == cur_salt->rounds) break; #if ARCH_LITTLE_ENDIAN { int j; uint32_t *o = (uint32_t *)crypt_struct->cptr[0][idx]; for (j = 0; j < 8; ++j) *o++ = JOHNSWAP(ctx.h[j]); } #else memcpy(crypt_struct->cptr[0][idx], ctx.h, BINARY_SIZE); if (++idx == 42) idx = 0; // this memcpy is 'good enough', used instead of SHA256_Init() memcpy(ctx.h, ctx_init, sizeof(ctx_init)); } #if ARCH_LITTLE_ENDIAN { int j; uint32_t *o = (uint32_t *)crypt_out[MixOrder[index]]; for (j = 0; j < 8; ++j) *o++ = JOHNSWAP(ctx.h[j]); } #else memcpy(crypt_out[MixOrder[index]], ctx.h, BINARY_SIZE); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/fvde_fmt_plug.c
#pragma omp parallel for
100
> type == 2) outlen = 32; memset(cracked, 0, sizeof(cracked[0])*cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][32]; int i; #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha256_sse((const unsigned char**)pin, lens, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pout, outlen, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha256((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, master[i], outlen, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { cracked[index+i] = fvde_decrypt(cur_salt, master[i]); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/zip_fmt_plug.c
#pragma omp parallel for
100
onst stuff like key_len being in the shared list, * while other versions demand they do. WAT! */ <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_32 unsigned char pwd_ver[MIN_KEYS_PER_CRYPT][3 * BLK_SZ]; int i, lens[MIN_KEYS_PER_CRYPT]; int something_hit = 0, hits[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[i + index]); pin[i] = (unsigned char*)saved_key[i + index]; pout[i] = pwd_ver[i] + early_skip - late_skip; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, saved_salt->salt, SALT_LENGTH(saved_salt->v.mode), KEYING_ITERATIONS, pout, BLK_SZ, early_skip); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) if (!memcmp(pwd_ver[i] + (2 * key_len - late_skip), saved_salt->passverify, 2)) something_hit = hits[i] = 1; if (something_hit) { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pout[i] = pwd_ver[i]; pbkdf2_sha1_sse((const unsigned char **)pin, lens, saved_salt->salt, SALT_LENGTH(saved_salt->v.mode), KEYING_ITERATIONS, pout, late_size, late_skip); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (hits[i]) { hmac_sha1(pwd_ver[i] + key_len - late_skip, key_len, (const unsigned char*)saved_salt->datablob, saved_salt->comp_len, crypt_key[index+i], WINZIP_BINARY_SIZE); } else memset(crypt_key[index + i], 0, WINZIP_BINARY_SIZE); } } else { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) memset(crypt_key[index + i], 0, WINZIP_BINARY_SIZE); } #else unsigned char pwd_ver[3 * BLK_SZ]; /* Get the block that contains the two-byte verifier */ pbkdf2_sha1((unsigned char *)saved_key[index], strlen(saved_key[index]), saved_salt->salt, SALT_LENGTH(saved_salt->v.mode), KEYING_ITERATIONS, pwd_ver + early_skip - late_skip, BLK_SZ, early_skip); /* Early-rejection */ if (!memcmp(pwd_ver + 2 * key_len - late_skip, saved_salt->passverify, 2)) { /* Get the remaining block(s) needed for the HMAC */ pbkdf2_sha1((unsigned char *)saved_key[index], strlen(saved_key[index]), saved_salt->salt, SALT_LENGTH(saved_salt->v.mode), KEYING_ITERATIONS, pwd_ver, late_size, late_skip); hmac_sha1(pwd_ver + key_len - late_skip, key_len, (const unsigned char*)saved_salt->datablob, saved_salt->comp_len, crypt_key[index], WINZIP_BINARY_SIZE); } else memset(crypt_key[index], 0, WINZIP_BINARY_SIZE); }<LOOP-END> <OMP-START>#pragma omp parallel for <OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawKeccak_256_fmt_plug.c
#pragma omp parallel for
100
ypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { Keccak_HashInstance hash; Keccak_HashInitialize(&hash, 1088, 512, 256, 0x01); Keccak_HashUpdate(&hash, (unsigned char*)saved_key[index], saved_len[index] * 8); Keccak_HashFinal(&hash, (unsigned char*)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/XSHA_fmt_plug.c
#pragma omp parallel for
100
struct db_salt *salt) { int count = *pcount; #ifdef SIMD_COEF_32 int i = 0; #if defined(_OPENMP) <LOOP-START>for (i = 0; i < threads; i++) { unsigned int *in = &saved_key[i*NBKEYS*SHA_BUF_SIZ]; unsigned int *out = &crypt_key[i*NBKEYS*BINARY_SIZE/4]; unsigned int j; for (j=0; j < NBKEYS; j++) in[(j&(SIMD_COEF_32-1)) + j/SIMD_COEF_32*SHA_BUF_SIZ*SIMD_COEF_32] = cur_salt; SIMDSHA1body(in, out, NULL, SSEi_MIXED_IN); #if defined(_OPENMP) }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/XSHA_fmt_plug.c
#pragma omp parallel for default(none) private(i) shared(count, ctx_salt, saved_key, saved_len, crypt_out)
100
HA1body(in, out, NULL, SSEi_MIXED_IN); #if defined(_OPENMP) } #endif #else int i; #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { SHA_CTX ctx; memcpy(&ctx, &ctx_salt, sizeof(ctx)); SHA1_Update(&ctx, saved_key[i], saved_len[i]); SHA1_Final((unsigned char *)(crypt_out[i]), &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, ctx_salt, saved_key, saved_len, crypt_out)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pbkdf2-hmac-sha1_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SSE_GROUP_SZ_SHA1 int lens[SSE_GROUP_SZ_SHA1], i; unsigned char *pin[SSE_GROUP_SZ_SHA1]; union { uint32_t *pout[SSE_GROUP_SZ_SHA1]; unsigned char *poutc; } x; for (i = 0; i < SSE_GROUP_SZ_SHA1; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; x.pout[i] = crypt_out[index+i]; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, cur_salt->salt, cur_salt->length, cur_salt->rounds, &(x.poutc), PBKDF2_SHA1_BINARY_SIZE, 0); #else pbkdf2_sha1((const unsigned char*)(saved_key[index]), strlen(saved_key[index]), cur_salt->salt, cur_salt->length, cur_salt->rounds, (unsigned char*)crypt_out[index], PBKDF2_SHA1_BINARY_SIZE, 0); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/panama_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_panama_context ctx; sph_panama_init(&ctx); sph_panama(&ctx, saved_key[index], strlen(saved_key[index])); sph_panama_close(&ctx, (unsigned char*)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ethereum_fmt_plug.c
#pragma omp parallel for
100
t, struct db_salt *salt) { const int count = *pcount; int index; int failed = 0; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][32]; int i; if (cur_salt->type == 0) { #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha256_sse((const unsigned char**)pin, lens, cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, pout, 32, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha256((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, master[i], 32, 0); } else if (cur_salt->type == 1) { #ifdef _OPENMP int t = omp_get_thread_num(); if (t >= max_threads) { failed = -1; continue; } #else const int t = 0; yescrypt_params_t params = { .N = cur_salt->N, .r = cur_salt->r, .p = cur_salt->p }; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (yescrypt_kdf(NULL, &local[t], (const uint8_t *)saved_key[index + i], strlen(saved_key[index + i]), (const uint8_t *)cur_salt->salt, strlen((const char *)cur_salt->salt), &params, master[i], 32)) { failed = errno ? errno : EINVAL; #ifndef _OPENMP goto fail_with_errno; } } } else if (cur_salt->type == 2) { if (new_keys) { /* Presale. No salt! */ #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; int slens[MIN_KEYS_PER_CRYPT]; unsigned char *sin[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; sin[i] = pin[i]; slens[i] = lens[i]; } pbkdf2_sha256_sse_varying_salt((const unsigned char**)pin, lens, sin, slens, 2000, pout, 16, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { memcpy(saved_presale[index + i], pout[i], 32); } #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { pbkdf2_sha256((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), (unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), 2000, master[i], 16, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { memcpy(saved_presale[index + i], master[i], 32); } } else { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) memcpy(master[i], saved_presale[index + i], 32); } } if (cur_salt->type == 0 || cur_salt->type == 1) { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { Keccak_HashInstance hash; Keccak_HashInitialize(&hash, 1088, 512, 256, 0x01); // delimitedSuffix is 0x06 for SHA-3, and 0x01 for Keccak Keccak_HashUpdate(&hash, master[i] + 16, 16 * 8); Keccak_HashUpdate(&hash, cur_salt->ct, cur_salt->ctlen * 8); Keccak_HashFinal(&hash, (unsigned char*)crypt_out[index+i]); } } else { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { AES_KEY akey; Keccak_HashInstance hash; unsigned char iv[16]; unsigned char seed[4096]; int padbyte; int datalen; AES_set_decrypt_key(master[i], 128, &akey); memcpy(iv, cur_salt->encseed, 16); AES_cbc_encrypt(cur_salt->encseed + 16, seed, cur_salt->eslen - 16, &akey, iv, AES_DECRYPT); if (check_pkcs_pad(seed, cur_salt->eslen - 16, 16) < 0) { memset(crypt_out[index+i], 0, BINARY_SIZE); continue; } padbyte = seed[cur_salt->eslen - 16 - 1]; datalen = cur_salt->eslen - 16 - padbyte; if (datalen < 0) { memset(crypt_out[index+i], 0, BINARY_SIZE); continue; } Keccak_HashInitialize(&hash, 1088, 512, 256, 0x01); Keccak_HashUpdate(&hash, seed, datalen * 8); Keccak_HashUpdate(&hash, dpad.data, 1 * 8); Keccak_HashFinal(&hash, (unsigned char*)crypt_out[index+i]); } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/episerver_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>#ifdef SIMD_COEF_32 for (index = 0; index < count; index += (cur_salt->version == 0 ? NBKEYS_SHA1 : NBKEYS_SHA256)) { uint32_t *in = &saved_key[HASH_IDX_IN]; uint32_t *out = &crypt_out[HASH_IDX_OUT]; if (cur_salt->version == 0) SIMDSHA1body(in, out, NULL, SSEi_MIXED_IN); else //if (cur_salt->version == 1) SIMDSHA256body(in, out, NULL, SSEi_MIXED_IN); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pgpwde_fmt_plug.c
#pragma omp parallel for
100
count = *pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0]) * count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char key[40]; int ret; S2KPGPWDE(saved_key[index], cur_salt->salt, key, 32); ret = pgpwde_decrypt_and_verify(key, cur_salt->esk, 128); cracked[index] = (0 == ret); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/django_scrypt_fmt_plug.c
#pragma omp parallel for default(none) private(index) shared(count, failed, params, max_threads, local, saved_key, cur_salt, crypt_out)
100
params_t params = { .N = 1ULL << cur_salt->N, .r = cur_salt->r, .p = cur_salt->p }; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { #ifdef _OPENMP int t = omp_get_thread_num(); if (t >= max_threads) { failed = -1; continue; } #else const int t = 0; if (yescrypt_kdf(NULL, &local[t], (const uint8_t *)saved_key[index], strlen(saved_key[index]), (const uint8_t *)cur_salt->salt, strlen(cur_salt->salt), &params, (uint8_t *)crypt_out[index], sizeof(crypt_out[index]))) { failed = errno ? errno : EINVAL; #ifndef _OPENMP break; } }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(index) shared(count, failed, params, max_threads, local, saved_key, cur_salt, crypt_out)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/wow_srp_fmt_plug.c
#pragma omp parallel for
100
t crypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int j; #ifdef _OPENMP <LOOP-START>for (j = 0; j < count; ++j) { SHA_CTX ctx; unsigned char Tmp[20]; memset(crypt_out[j], 0, sizeof(crypt_out[j])); SHA1_Init(&ctx); SHA1_Update(&ctx, user_id, strlen((char*)user_id)); SHA1_Update(&ctx, ":", 1); SHA1_Update(&ctx, saved_key[j], strlen(saved_key[j])); SHA1_Final(Tmp, &ctx); SHA1_Init(&ctx); SHA1_Update(&ctx, saved_salt, strlen((char*)saved_salt)); SHA1_Update(&ctx, Tmp, 20); SHA1_Final(Tmp, &ctx); // Ok, now Tmp is v //if (!strcmp(saved_key[j], "ENTERNOW__1") && !strcmp((char*)user_id, "DIP")) { // printf("salt=%s user=%s pass=%s, ", (char*)saved_salt, (char*)user_id, saved_key[j]); // dump_stuff_msg("sha$h ", Tmp, 20); //} #ifdef HAVE_LIBGMP { unsigned char HashStr[80], *p; int i, todo; p = HashStr; for (i = 0; i < 20; ++i) { *p++ = itoa16[Tmp[i]>>4]; *p++ = itoa16[Tmp[i]&0xF]; } *p = 0; mpz_set_str(pSRP_CTX[j].z_exp, (char*)HashStr, 16); mpz_powm (pSRP_CTX[j].z_rop, pSRP_CTX[j].z_base, pSRP_CTX[j].z_exp, pSRP_CTX[j].z_mod ); mpz_get_str ((char*)HashStr, 16, pSRP_CTX[j].z_rop); p = HashStr; todo = strlen((char*)p); if (todo&1) { ((unsigned char*)(crypt_out[j]))[0] = atoi16[ARCH_INDEX(*p)]; ++p; --todo; } else { ((unsigned char*)(crypt_out[j]))[0] = (atoi16[ARCH_INDEX(*p)] << 4) | atoi16[ARCH_INDEX(p[1])]; p += 2; todo -= 2; } todo >>= 1; for (i = 1; i <= todo; i++) { ((unsigned char*)(crypt_out[j]))[i] = (atoi16[ARCH_INDEX(*p)] << 4) | atoi16[ARCH_INDEX(p[1])]; p += 2; } //if (!strcmp(saved_key[j], "ENTERNOW__1") && !strcmp((char*)user_id, "DIP")) { // dump_stuff_msg("crypt ", crypt_out[j], 32); //} } #else // using oSSL's BN to do expmod. pSRP_CTX[j].z_exp = BN_bin2bn(Tmp,20,pSRP_CTX[j].z_exp); BN_mod_exp(pSRP_CTX[j].z_rop, pSRP_CTX[j].z_base, pSRP_CTX[j].z_exp, pSRP_CTX[j].z_mod, pSRP_CTX[j].BN_ctx); BN_bn2bin(pSRP_CTX[j].z_rop, (unsigned char*)(crypt_out[j])); //if (!strcmp(saved_key[j], "ENTERNOW__1") && !strcmp((char*)user_id, "DIP")) { // dump_stuff_msg("crypt ", crypt_out[j], 32); //} }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pdf_fmt_plug.c
#pragma omp parallel for
100
= 0; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char output[32]; pdf_compute_user_password((unsigned char*)saved_key[index], output); if (crypt_out->R == 2 || crypt_out->R == 5 || crypt_out->R == 6) if (memcmp(output, crypt_out->u, 32) == 0) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } if (crypt_out->R == 3 || crypt_out->R == 4) if (memcmp(output, crypt_out->u, 16) == 0) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/salted_sha1_fmt_plug.c
#pragma omp parallel for
100
unt = *pcount; int index; int inc = 1; #ifdef SIMD_COEF_32 inc = NBKEYS; #endif #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += inc) { #ifdef SIMD_COEF_32 unsigned int i; for (i=0;i<NBKEYS;i++) set_onesalt(i+index); SIMDSHA1body(saved_key[index/NBKEYS], crypt_key[index/NBKEYS], NULL, SSEi_MIXED_IN); #else SHA_CTX ctx; SHA1_Init( &ctx ); SHA1_Update( &ctx, (unsigned char *) saved_key[index], strlen( saved_key[index] ) ); SHA1_Update( &ctx, (unsigned char *) saved_salt->data.c, saved_salt->len); SHA1_Final( (unsigned char *)crypt_key[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/mscash2_fmt_plug.c
#pragma omp parallel for default(none) private(i) shared(count, key, md4hash)
100
ly when the // now get NTLM of the password (MD4 of unicode) if (new_key) { #if defined(_OPENMP) <LOOP-START>for (i = 0; i < count; ++i) { int utf16len; UTF16 pass_unicode[PLAINTEXT_LENGTH+1]; MD4_CTX ctx; utf16len = enc_to_utf16(pass_unicode, PLAINTEXT_LENGTH, &key[(PLAINTEXT_LENGTH + 1)*i], strlen((char*)&key[(PLAINTEXT_LENGTH + 1)*i])); if (utf16len <= 0) { key[(PLAINTEXT_LENGTH + 1)*i-utf16len] = 0; if (utf16len != 0) utf16len = strlen16(pass_unicode); } MD4_Init(&ctx); MD4_Update(&ctx, pass_unicode, utf16len<<1); MD4_Final(&md4hash[HASH_LEN*i], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, key, md4hash)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/mscash2_fmt_plug.c
#pragma omp parallel for
100
D4_Final(&md4hash[HASH_LEN*i], &ctx); } new_key = 0; } #ifdef _OPENMP #if defined(WITH_UBSAN) <LOOP-START>#else #pragma omp parallel for default(none) shared(count, salt_buffer, salt_len, crypt_out, md4hash) for (t1 = 0; t1 < count; t1 += MS_NUM_KEYS) { MD4_CTX ctx; int i; int t = t1 / MS_NUM_KEYS; for (i = 0; i < MS_NUM_KEYS; ++i) { // Get DCC1. That is MD4( NTLM . unicode(lc username) ) MD4_Init(&ctx); MD4_Update(&ctx, &md4hash[(t * MS_NUM_KEYS + i) * HASH_LEN], 16); MD4_Update(&ctx, salt_buffer, salt_len); MD4_Final((unsigned char*)&crypt_out[(t * MS_NUM_KEYS + i) * 4], &ctx); // now we have DCC1 (mscash) which is MD4 (MD4(unicode(pass)) . unicode(lc username)) #ifndef SIMD_COEF_32 // Non-SSE: Compute DCC2 one at a time pbkdf2(&crypt_out[(t * MS_NUM_KEYS + i) * 4]); } #ifdef SIMD_COEF_32 // SSE: Compute DCC2 in parallel, once per thread pbkdf2_sse2(t); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/mscash2_fmt_plug.c
#pragma omp parallel for default(none) shared(count, salt_buffer, salt_len, crypt_out, md4hash)
100
&ctx); } new_key = 0; } #ifdef _OPENMP #if defined(WITH_UBSAN) #pragma omp parallel for #else <LOOP-START>for (t1 = 0; t1 < count; t1 += MS_NUM_KEYS) { MD4_CTX ctx; int i; int t = t1 / MS_NUM_KEYS; for (i = 0; i < MS_NUM_KEYS; ++i) { // Get DCC1. That is MD4( NTLM . unicode(lc username) ) MD4_Init(&ctx); MD4_Update(&ctx, &md4hash[(t * MS_NUM_KEYS + i) * HASH_LEN], 16); MD4_Update(&ctx, salt_buffer, salt_len); MD4_Final((unsigned char*)&crypt_out[(t * MS_NUM_KEYS + i) * 4], &ctx); // now we have DCC1 (mscash) which is MD4 (MD4(unicode(pass)) . unicode(lc username)) #ifndef SIMD_COEF_32 // Non-SSE: Compute DCC2 one at a time pbkdf2(&crypt_out[(t * MS_NUM_KEYS + i) * 4]); } #ifdef SIMD_COEF_32 // SSE: Compute DCC2 in parallel, once per thread pbkdf2_sse2(t); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) shared(count, salt_buffer, salt_len, crypt_out, md4hash)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pgpsda_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char key[SHA1_DIGEST_LENGTH]; CAST_KEY ck; pgpsda_kdf(saved_key[index], cur_salt->salt, key); CAST_set_key(&ck, 16, key); memset((unsigned char*)crypt_out[index], 0, BINARY_SIZE); CAST_ecb_encrypt(key, (unsigned char*)crypt_out[index], &ck, CAST_ENCRYPT); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/geli_fmt_plug.c
#pragma omp parallel for
100
= *pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0])*cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][G_ELI_USERKEYLEN]; unsigned char key[MIN_KEYS_PER_CRYPT][G_ELI_USERKEYLEN]; int i; #ifdef SIMD_COEF_64 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha512_sse((const unsigned char**)pin, lens, cur_salt->md_salt, G_ELI_SALTLEN, cur_salt->md_iterations, pout, G_ELI_USERKEYLEN, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha512((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->md_salt, G_ELI_SALTLEN, cur_salt->md_iterations, master[i], G_ELI_USERKEYLEN, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { JTR_hmac_sha512((const unsigned char*)"", 0, master[i], G_ELI_USERKEYLEN, key[i], G_ELI_USERKEYLEN); cracked[index+i] = geli_decrypt_verify(cur_salt, key[i]); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/net_ah_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { HMACMD5Context ctx; hmac_md5_init_rfc2104((const unsigned char*)saved_key[index], strlen(saved_key[index]), &ctx); hmac_md5_update(cur_salt->salt, cur_salt->length, &ctx); hmac_md5_final((unsigned char*)crypt_out[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/hmacMD5_fmt_plug.c
#pragma omp parallel for
100
crypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #if _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_32 int i; if (new_keys) { SIMDmd5body(&ipad[index * PAD_SIZE], (unsigned int*)&prep_ipad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN); SIMDmd5body(&opad[index * PAD_SIZE], (unsigned int*)&prep_opad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN); } SIMDmd5body(cur_salt->salt[0], (unsigned int*)&crypt_key[index * PAD_SIZE], (unsigned int*)&prep_ipad[index * BINARY_SIZE], SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT); for (i = 1; i <= (cur_salt->salt_len + 8) / PAD_SIZE; i++) { SIMDmd5body(cur_salt->salt[i], (unsigned int*)&crypt_key[index * PAD_SIZE], (unsigned int*)&crypt_key[index * PAD_SIZE], SSEi_MIXED_IN|SSEi_RELOAD_INP_FMT|SSEi_OUTPUT_AS_INP_FMT); } SIMDmd5body(&crypt_key[index * PAD_SIZE], (unsigned int*)&crypt_key[index * PAD_SIZE], (unsigned int*)&prep_opad[index * BINARY_SIZE], SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT); #else MD5_CTX ctx; if (new_keys) { MD5_Init(&ipad_ctx[index]); MD5_Update(&ipad_ctx[index], ipad[index], PAD_SIZE); MD5_Init(&opad_ctx[index]); MD5_Update(&opad_ctx[index], opad[index], PAD_SIZE); } memcpy(&ctx, &ipad_ctx[index], sizeof(ctx)); MD5_Update(&ctx, cur_salt, strlen((char*)cur_salt)); MD5_Final((unsigned char*) crypt_key[index], &ctx); memcpy(&ctx, &opad_ctx[index], sizeof(ctx)); MD5_Update(&ctx, crypt_key[index], BINARY_SIZE); MD5_Final((unsigned char*) crypt_key[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ospf_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { int plen = strlen(saved_key[index]); unsigned char key[64]; unsigned char out[64]; if (cur_salt->type == 1) { SHA_CTX ctx; // process password according to rfc5709 if (plen < SHA_DIGEST_LENGTH) { memcpy(key, saved_key[index], plen); memset(key + plen, 0, SHA_DIGEST_LENGTH - plen); } else if (plen == SHA_DIGEST_LENGTH) { memcpy(key, saved_key[index], SHA_DIGEST_LENGTH); } else { SHA1_Init(&ctx); SHA1_Update(&ctx, saved_key[index], plen); SHA1_Final(key, &ctx); } // salt already has ospf_apad appended hmac_sha1(key, 20, cur_salt->salt, cur_salt->salt_length + SHA_DIGEST_LENGTH, out, 16); memcpy((unsigned char*)crypt_out[index], out, 16); } else if (cur_salt->type == 2) { SHA256_CTX ctx; if (plen < SHA256_DIGEST_LENGTH) { memcpy(key, saved_key[index], plen); memset(key + plen, 0, SHA256_DIGEST_LENGTH - plen); } else if (plen == SHA256_DIGEST_LENGTH) { memcpy(key, saved_key[index], SHA256_DIGEST_LENGTH); } else { SHA256_Init(&ctx); SHA256_Update(&ctx, saved_key[index], plen); SHA256_Final(key, &ctx); } hmac_sha256(key, 32, cur_salt->salt, cur_salt->salt_length + SHA256_DIGEST_LENGTH, out, 16); memcpy((unsigned char*)crypt_out[index], out, 16); } else if (cur_salt->type == 3) { SHA512_CTX ctx; if (plen < SHA384_DIGEST_LENGTH) { memcpy(key, saved_key[index], plen); memset(key + plen, 0, SHA384_DIGEST_LENGTH - plen); } else if (plen == SHA384_DIGEST_LENGTH) { memcpy(key, saved_key[index], SHA384_DIGEST_LENGTH); } else { SHA384_Init(&ctx); SHA384_Update(&ctx, saved_key[index], plen); SHA384_Final(key, &ctx); } hmac_sha384(key, 48, cur_salt->salt, cur_salt->salt_length + SHA384_DIGEST_LENGTH, out, 16); memcpy((unsigned char*)crypt_out[index], out, 16); } else if (cur_salt->type == 4) { SHA512_CTX ctx; if (plen < SHA512_DIGEST_LENGTH) { memcpy(key, saved_key[index], plen); memset(key + plen, 0, SHA512_DIGEST_LENGTH - plen); } else if (plen == SHA512_DIGEST_LENGTH) { memcpy(key, saved_key[index], SHA512_DIGEST_LENGTH); } else { SHA512_Init(&ctx); SHA512_Update(&ctx, saved_key[index], plen); SHA512_Final(key, &ctx); } hmac_sha512(key, 64, cur_salt->salt, cur_salt->salt_length + SHA512_DIGEST_LENGTH, out, 16); memcpy((unsigned char*)crypt_out[index], out, 16); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawSHA256_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_32 SIMDSHA256body(&saved_key[(unsigned int)index/SIMD_COEF_32*SHA_BUF_SIZ*SIMD_COEF_32], &crypt_out[(unsigned int)index/SIMD_COEF_32*8*SIMD_COEF_32], NULL, SSEi_REVERSE_STEPS | SSEi_MIXED_IN); #else SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, saved_key[index], saved_len[index]); SHA256_Final((unsigned char *)crypt_out[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sha512crypt_fmt_plug.c
#pragma omp parallel for
100
x = 0; index < count; ++index) MixOrder[index] = index; tot_todo = count; #endif #ifdef _OPENMP <LOOP-START>for (index = 0; index < tot_todo; index += MIN_KEYS_PER_CRYPT) { // portably align temp_result char * pointer machine word size. union xx { unsigned char c[BINARY_SIZE]; ARCH_WORD a[BINARY_SIZE/sizeof(ARCH_WORD)]; } u; unsigned char *temp_result = u.c; SHA512_CTX ctx; SHA512_CTX alt_ctx; size_t cnt; int idx; char *cp; char p_bytes[PLAINTEXT_LENGTH+1]; char s_bytes[PLAINTEXT_LENGTH+1]; char tmp_cls[sizeof(cryptloopstruct)+MEM_ALIGN_SIMD]; cryptloopstruct *crypt_struct; #ifdef SIMD_COEF_64 char tmp_sse_out[8*MIN_KEYS_PER_CRYPT*8+MEM_ALIGN_SIMD]; uint64_t *sse_out; sse_out = (uint64_t *)mem_align(tmp_sse_out, MEM_ALIGN_SIMD); crypt_struct = (cryptloopstruct *)mem_align(tmp_cls,MEM_ALIGN_SIMD); for (idx = 0; idx < MIN_KEYS_PER_CRYPT; ++idx) { /* Prepare for the real work. */ SHA512_Init(&ctx); /* Add the key string. */ SHA512_Update(&ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* The last part is the salt string. This must be at most 16 characters and it ends at the first `$' character (for compatibility with existing implementations). */ SHA512_Update(&ctx, cur_salt->salt, cur_salt->len); /* Compute alternate SHA512 sum with input KEY, SALT, and KEY. The final result will be added to the first context. */ SHA512_Init(&alt_ctx); /* Add key. */ SHA512_Update(&alt_ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Add salt. */ SHA512_Update(&alt_ctx, cur_salt->salt, cur_salt->len); /* Add key again. */ SHA512_Update(&alt_ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Now get result of this (64 bytes) and add it to the other context. */ SHA512_Final((unsigned char*)crypt_out[MixOrder[index+idx]], &alt_ctx); /* Add for any character in the key one byte of the alternate sum. */ for (cnt = saved_len[MixOrder[index+idx]]; cnt > BINARY_SIZE; cnt -= BINARY_SIZE) SHA512_Update(&ctx, (unsigned char*)crypt_out[MixOrder[index+idx]], BINARY_SIZE); SHA512_Update(&ctx, (unsigned char*)crypt_out[MixOrder[index+idx]], cnt); /* Take the binary representation of the length of the key and for every 1 add the alternate sum, for every 0 the key. */ for (cnt = saved_len[MixOrder[index+idx]]; cnt > 0; cnt >>= 1) if ((cnt & 1) != 0) SHA512_Update(&ctx, (unsigned char*)crypt_out[MixOrder[index+idx]], BINARY_SIZE); else SHA512_Update(&ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Create intermediate result. */ SHA512_Final((unsigned char*)crypt_out[MixOrder[index+idx]], &ctx); /* Start computation of P byte sequence. */ SHA512_Init(&alt_ctx); /* For every character in the password add the entire password. */ for (cnt = 0; cnt < saved_len[MixOrder[index+idx]]; ++cnt) SHA512_Update(&alt_ctx, (unsigned char*)saved_key[MixOrder[index+idx]], saved_len[MixOrder[index+idx]]); /* Finish the digest. */ SHA512_Final(temp_result, &alt_ctx); /* Create byte sequence P. */ cp = p_bytes; for (cnt = saved_len[MixOrder[index+idx]]; cnt >= BINARY_SIZE; cnt -= BINARY_SIZE) cp = (char *) memcpy (cp, temp_result, BINARY_SIZE) + BINARY_SIZE; memcpy (cp, temp_result, cnt); /* Start computation of S byte sequence. */ SHA512_Init(&alt_ctx); /* repeat the following 16+A[0] times, where A[0] represents the first byte in digest A interpreted as an 8-bit unsigned value */ for (cnt = 0; cnt < 16 + ((unsigned char*)crypt_out[MixOrder[index+idx]])[0]; ++cnt) SHA512_Update(&alt_ctx, cur_salt->salt, cur_salt->len); /* Finish the digest. */ SHA512_Final(temp_result, &alt_ctx); /* Create byte sequence S. */ cp = s_bytes; for (cnt = cur_salt->len; cnt >= BINARY_SIZE; cnt -= BINARY_SIZE) cp = (char *) memcpy (cp, temp_result, BINARY_SIZE) + BINARY_SIZE; memcpy (cp, temp_result, cnt); /* Repeatedly run the collected hash value through SHA512 to burn CPU cycles. */ LoadCryptStruct(crypt_struct, MixOrder[index+idx], idx, p_bytes, s_bytes); } idx = 0; #ifdef SIMD_COEF_64 for (cnt = 1; ; ++cnt) { if (crypt_struct->datlen[idx]==256) { unsigned char *cp = crypt_struct->bufs[0][idx]; SIMDSHA512body(cp, sse_out, NULL, SSEi_FLAT_IN|SSEi_2BUF_INPUT_FIRST_BLK); SIMDSHA512body(&cp[128], sse_out, sse_out, SSEi_FLAT_IN|SSEi_2BUF_INPUT_FIRST_BLK|SSEi_RELOAD); } else { unsigned char *cp = crypt_struct->bufs[0][idx]; SIMDSHA512body(cp, sse_out, NULL, SSEi_FLAT_IN|SSEi_2BUF_INPUT_FIRST_BLK); } if (cnt == cur_salt->rounds) break; { unsigned int j, k; for (k = 0; k < MIN_KEYS_PER_CRYPT; ++k) { uint64_t *o = (uint64_t *)crypt_struct->cptr[k][idx]; #if !ARCH_ALLOWS_UNALIGNED if (!is_aligned(o, 8)) { unsigned char *cp = (unsigned char*)o; for (j = 0; j < 64; ++j) *cp++ = ((unsigned char*)sse_out)[GETPOS(j, k)]; } else for (j = 0; j < 8; ++j) #if ARCH_LITTLE_ENDIAN==1 *o++ = JOHNSWAP64(sse_out[j*SIMD_COEF_64+(k&(SIMD_COEF_64-1))+k/SIMD_COEF_64*8*SIMD_COEF_64]); #else *o++ = sse_out[j*SIMD_COEF_64+(k&(SIMD_COEF_64-1))+k/SIMD_COEF_64*8*SIMD_COEF_64]; } } if (++idx == 42) idx = 0; } { unsigned int j, k; for (k = 0; k < MIN_KEYS_PER_CRYPT; ++k) { uint64_t *o = (uint64_t *)crypt_out[MixOrder[index+k]]; for (j = 0; j < 8; ++j) #if ARCH_LITTLE_ENDIAN==1 *o++ = JOHNSWAP64(sse_out[j*SIMD_COEF_64+(k&(SIMD_COEF_64-1))+k/SIMD_COEF_64*8*SIMD_COEF_64]); #else *o++ = sse_out[j*SIMD_COEF_64+(k&(SIMD_COEF_64-1))+k/SIMD_COEF_64*8*SIMD_COEF_64]; } } #else SHA512_Init(&ctx); for (cnt = 1; ; ++cnt) { // calling with 128 byte, or 256 byte always, will force the update to properly crypt the data. // NOTE the data is fully formed. It ends in a 0x80, is padded with nulls, AND has bit appended. SHA512_Update(&ctx, crypt_struct->bufs[0][idx], crypt_struct->datlen[idx]); if (cnt == cur_salt->rounds) break; #if ARCH_LITTLE_ENDIAN { int j; uint64_t *o = (uint64_t *)crypt_struct->cptr[0][idx]; for (j = 0; j < 8; ++j) *o++ = JOHNSWAP64(ctx.h[j]); } #else memcpy(crypt_struct->cptr[0][idx], ctx.h, BINARY_SIZE); if (++idx == 42) idx = 0; // this memcpy is 'good enough', used instead of SHA512_Init() memcpy(ctx.h, ctx_init, sizeof(ctx_init)); } #if ARCH_LITTLE_ENDIAN { int j; uint64_t *o = (uint64_t *)crypt_out[MixOrder[index]]; for (j = 0; j < 8; ++j) *o++ = JOHNSWAP64(ctx.h[j]); } #else memcpy(crypt_out[MixOrder[index]], ctx.h, BINARY_SIZE); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/chap_fmt_plug.c
#pragma omp parallel for
100
ypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, &cur_salt->id, 1); MD5_Update(&ctx, saved_key[index], strlen(saved_key[index])); MD5_Update(&ctx, cur_salt->challenge, cur_salt->challenge_length); MD5_Final((unsigned char*)crypt_out[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rsvp_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char buf[64]; if (cur_salt->type == 1) { MD5_CTX ctx; if (new_keys[cur_salt->type]) { int i, len = strlen(saved_key[index]); unsigned char *p = (unsigned char*)saved_key[index]; unsigned char pad[64]; if (len > 64) { MD5_Init(&ctx); MD5_Update(&ctx, p, len); MD5_Final(buf, &ctx); len = 16; p = buf; } for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x36; } MD5_Init(&ipad_mctx[index]); MD5_Update(&ipad_mctx[index], pad, len); if (len < 64) MD5_Update(&ipad_mctx[index], ipad_constant_block, 64-len); for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x5C; } MD5_Init(&opad_mctx[index]); MD5_Update(&opad_mctx[index], pad, len); if (len < 64) MD5_Update(&opad_mctx[index], opad_constant_block, 64-len); } memcpy(&ctx, &ipad_mctx[index], sizeof(ctx)); MD5_Update(&ctx, cur_salt->salt, cur_salt->salt_length); MD5_Final(buf, &ctx); memcpy(&ctx, &opad_mctx[index], sizeof(ctx)); MD5_Update(&ctx, buf, 16); MD5_Final((unsigned char*)(crypt_out[index]), &ctx); } else if (cur_salt->type == 2) { SHA_CTX ctx; if (new_keys[cur_salt->type]) { int i, len = strlen(saved_key[index]); unsigned char *p = (unsigned char*)saved_key[index]; unsigned char pad[64]; if (len > 64) { SHA1_Init(&ctx); SHA1_Update(&ctx, p, len); SHA1_Final(buf, &ctx); len = 20; p = buf; } for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x36; } SHA1_Init(&ipad_ctx[index]); SHA1_Update(&ipad_ctx[index], pad, len); if (len < 64) SHA1_Update(&ipad_ctx[index], ipad_constant_block, 64-len); for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x5C; } SHA1_Init(&opad_ctx[index]); SHA1_Update(&opad_ctx[index], pad, len); if (len < 64) SHA1_Update(&opad_ctx[index], opad_constant_block, 64-len); } memcpy(&ctx, &ipad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, cur_salt->salt, cur_salt->salt_length); SHA1_Final(buf, &ctx); memcpy(&ctx, &opad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, buf, 20); // NOTE, this writes 20 bytes. That is why we had to bump up the size of each crypt_out[] value, // even though we only look at the first 16 bytes when comparing the saved binary. SHA1_Final((unsigned char*)(crypt_out[index]), &ctx); } else if (cur_salt->type == 3) { SHA256_CTX ctx; if (new_keys[cur_salt->type]) { int i, len = strlen(saved_key[index]); unsigned char *p = (unsigned char*)saved_key[index]; unsigned char pad[64]; if (len > 64) { SHA224_Init(&ctx); SHA224_Update(&ctx, p, len); SHA224_Final(buf, &ctx); len = 28; p = buf; } for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x36; } SHA224_Init(&ipad_ctx_224[index]); SHA224_Update(&ipad_ctx_224[index], pad, len); if (len < 64) SHA224_Update(&ipad_ctx_224[index], ipad_constant_block, 64-len); for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x5C; } SHA224_Init(&opad_ctx_224[index]); SHA224_Update(&opad_ctx_224[index], pad, len); if (len < 64) SHA224_Update(&opad_ctx_224[index], opad_constant_block, 64-len); } memcpy(&ctx, &ipad_ctx_224[index], sizeof(ctx)); SHA224_Update(&ctx, cur_salt->salt, cur_salt->salt_length); SHA224_Final(buf, &ctx); memcpy(&ctx, &opad_ctx_224[index], sizeof(ctx)); SHA224_Update(&ctx, buf, 28); SHA224_Final((unsigned char*)(crypt_out[index]), &ctx); } else if (cur_salt->type == 4) { SHA256_CTX ctx; if (new_keys[cur_salt->type]) { int i, len = strlen(saved_key[index]); unsigned char *p = (unsigned char*)saved_key[index]; unsigned char pad[64]; if (len > 64) { SHA256_Init(&ctx); SHA256_Update(&ctx, p, len); SHA256_Final(buf, &ctx); len = 32; p = buf; } for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x36; } SHA256_Init(&ipad_ctx_256[index]); SHA256_Update(&ipad_ctx_256[index], pad, len); if (len < 64) SHA256_Update(&ipad_ctx_256[index], ipad_constant_block, 64-len); for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x5C; } SHA256_Init(&opad_ctx_256[index]); SHA256_Update(&opad_ctx_256[index], pad, len); if (len < 64) SHA256_Update(&opad_ctx_256[index], opad_constant_block, 64-len); } memcpy(&ctx, &ipad_ctx_256[index], sizeof(ctx)); SHA256_Update(&ctx, cur_salt->salt, cur_salt->salt_length); SHA256_Final(buf, &ctx); memcpy(&ctx, &opad_ctx_256[index], sizeof(ctx)); SHA256_Update(&ctx, buf, 32); SHA256_Final((unsigned char*)(crypt_out[index]), &ctx); } else if (cur_salt->type == 5) { SHA512_CTX ctx; if (new_keys[cur_salt->type]) { int i, len = strlen(saved_key[index]); unsigned char *p = (unsigned char*)saved_key[index]; unsigned char pad[128]; if (len > 128) { SHA384_Init(&ctx); SHA384_Update(&ctx, p, len); SHA384_Final(buf, &ctx); len = 48; p = buf; } for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x36; } SHA384_Init(&ipad_ctx_384[index]); SHA384_Update(&ipad_ctx_384[index], pad, len); if (len < 128) SHA384_Update(&ipad_ctx_384[index], ipad_constant_block, 128-len); for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x5C; } SHA384_Init(&opad_ctx_384[index]); SHA384_Update(&opad_ctx_384[index], pad, len); if (len < 128) SHA384_Update(&opad_ctx_384[index], opad_constant_block, 128-len); } memcpy(&ctx, &ipad_ctx_384[index], sizeof(ctx)); SHA384_Update(&ctx, cur_salt->salt, cur_salt->salt_length); SHA384_Final(buf, &ctx); memcpy(&ctx, &opad_ctx_384[index], sizeof(ctx)); SHA384_Update(&ctx, buf, 48); SHA384_Final((unsigned char*)(crypt_out[index]), &ctx); } else if (cur_salt->type == 6) { SHA512_CTX ctx; if (new_keys[cur_salt->type]) { int i, len = strlen(saved_key[index]); unsigned char *p = (unsigned char*)saved_key[index]; unsigned char pad[128]; if (len > 128) { SHA512_Init(&ctx); SHA512_Update(&ctx, p, len); SHA512_Final(buf, &ctx); len = 64; p = buf; } for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x36; } SHA512_Init(&ipad_ctx_512[index]); SHA512_Update(&ipad_ctx_512[index], pad, len); if (len < 128) SHA512_Update(&ipad_ctx_512[index], ipad_constant_block, 128-len); for (i = 0; i < len; ++i) { pad[i] = p[i] ^ 0x5C; } SHA512_Init(&opad_ctx_512[index]); SHA512_Update(&opad_ctx_512[index], pad, len); if (len < 128) SHA512_Update(&opad_ctx_512[index], opad_constant_block, 128-len); } memcpy(&ctx, &ipad_ctx_512[index], sizeof(ctx)); SHA512_Update(&ctx, cur_salt->salt, cur_salt->salt_length); SHA512_Final(buf, &ctx); memcpy(&ctx, &opad_ctx_512[index], sizeof(ctx)); SHA512_Update(&ctx, buf, 64); SHA512_Final((unsigned char*)(crypt_out[index]), &ctx); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/c3_fmt.c
#pragma omp parallel for default(none) private(index) shared(warned, count, crypt_out, saved_key, saved_salt, crypt_data, stderr)
100
tatic int warned = 0; int count = *pcount; int index; #if defined(_OPENMP) && defined(__GLIBC__) <LOOP-START>for (index = 0; index < count; index++) { char *hash; int t = omp_get_thread_num(); if (t < MAX_THREADS) { struct crypt_data **data = &crypt_data[t]; if (!*data) { /* Stagger the structs to reduce their competition for the same cache lines */ size_t mask = MEM_ALIGN_PAGE, shift = 0; while (t) { mask >>= 1; if (mask < MEM_ALIGN_CACHE) break; if (t & 1) shift += mask; t >>= 1; } *data = (void *)((char *) mem_alloc_tiny(sizeof(**data) + shift, MEM_ALIGN_PAGE) + shift); memset(*data, 0, sizeof(**data)); } hash = crypt_r(saved_key[index], saved_salt, *data); } else { /* should not happen */ struct crypt_data data; memset(&data, 0, sizeof(data)); hash = crypt_r(saved_key[index], saved_salt, &data); } if (!hash) { #pragma omp critical if (!warned) { fprintf(stderr, "Warning: crypt_r() returned NULL\n"); warned = 1; } hash = ""; } strnzcpy(crypt_out[index], hash, BINARY_SIZE); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(index) shared(warned, count, crypt_out, saved_key, saved_salt, crypt_data, stderr)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/c3_fmt.c
#pragma omp parallel for
100
use for SHA-crypt and * SunMD5 hashes, which are not yet supported by non-jumbo John natively. */ <LOOP-START>#else #undef FMT_OMP #define FMT_OMP 0 for (index = 0; index < count; index++) { char *hash = crypt(saved_key[index], saved_salt); if (!hash) { #if defined(_OPENMP) && defined(__sun) #pragma omp critical if (!warned) { fprintf(stderr, "Warning: crypt() returned NULL\n"); warned = 1; } hash = ""; } strnzcpy(crypt_out[index], hash, BINARY_SIZE); }<LOOP-END> <OMP-START>#pragma omp parallel for <OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/md5crypt_long_fmt.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { crypt_md5(saved_key[index], (char*)cur_salt->salt, cur_salt->is_standard, (char *)crypt_out[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sl3_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_32 unsigned int i; for (i=0;i<NBKEYS;i++) set_onesalt(i + index); SIMDSHA1body(saved_key[index/NBKEYS], crypt_key[index/NBKEYS], NULL, SSEi_MIXED_IN); #else SHA_CTX ctx; SHA1_Init( &ctx ); SHA1_Update( &ctx, (unsigned char*)saved_key[index], PLAINTEXT_LENGTH); SHA1_Update( &ctx, (unsigned char*)saved_salt, SALT_SIZE); SHA1_Final( (unsigned char*)crypt_key[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ntlmv1_mschapv2_fmt_plug.c
#pragma omp parallel for
100
_per_crypt = 0; #ifdef SIMD_COEF_32 #if (BLOCK_LOOPS > 1) #if defined(_OPENMP) && defined(SSE_OMP) <LOOP-START>for (i = 0; i < BLOCK_LOOPS; i++) SIMDmd4body(&saved_key[i * NBKEYS * 64], (unsigned int*)&nthash[i * NBKEYS * 16], NULL, SSEi_MIXED_IN); #else SIMDmd4body(saved_key, (unsigned int*)nthash, NULL, SSEi_MIXED_IN); if (use_bitmap) for (i = 0; i < NBKEYS * BLOCK_LOOPS; i++) { unsigned int value; value = *(uint32_t*) &nthash[GETOUTPOS_W32(3, i)] >> 16; crypt_key[i] = value; #if defined(_OPENMP) && defined(SSE_OMP) #pragma omp atomic bitmap[value >> 5] |= 1U << (value & 0x1f); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ntlmv1_mschapv2_fmt_plug.c
#pragma omp parallel for
100
crypt_key[i] = *(uint32_t*) &nthash[GETOUTPOS_W32(3, i)] >> 16; } #else #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { MD4_CTX ctx; MD4_Init( &ctx ); MD4_Update(&ctx, saved_key[i], saved_len[i]); MD4_Final((uchar*)&nthash[i * 16], &ctx); crypt_key[i] = ((unsigned short*)&nthash[i * 16])[7]; if (use_bitmap) { unsigned int value = crypt_key[i]; #ifdef _OPENMP #pragma omp atomic bitmap[value >> 5] |= 1U << (value & 0x1f); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/wbb3_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char hexhash[40]; SHA_CTX ctx; if (dirty) { unsigned char out[20]; SHA1_Init(&ctx); SHA1_Update(&ctx, saved_key[index], strlen(saved_key[index])); SHA1_Final(out, &ctx); hex_encode(out, 20, hexhash1[index]); } SHA1_Init(&ctx); SHA1_Update(&ctx, cur_salt->salt, 40); SHA1_Update(&ctx, hexhash1[index], 40); SHA1_Final((unsigned char*)crypt_out[index], &ctx); hex_encode((unsigned char*)crypt_out[index], 20, hexhash); SHA1_Init(&ctx); SHA1_Update(&ctx, cur_salt->salt, 40); SHA1_Update(&ctx, hexhash, 40); SHA1_Final((unsigned char*)crypt_out[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ansible_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][32]; int i; #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha256_sse((const unsigned char**)pin, lens, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pout, 32, 32); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha256((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, master[i], 32, 32); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { JTR_hmac_sha256(master[i], 32, cur_salt->blob, cur_salt->bloblen, (unsigned char*)crypt_out[index+i], 16); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/radius_fmt_plug.c
#pragma omp parallel for
100
ndex; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { if (check_password(index, cur_salt)) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pwsafe_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index+=MIN_KEYS_PER_CRYPT) { SHA256_CTX ctx; #ifdef SIMD_COEF_32 unsigned int i; unsigned char _IBuf[64*MIN_KEYS_PER_CRYPT+MEM_ALIGN_CACHE], *keys, tmpBuf[32]; uint32_t *keys32, j; keys = (unsigned char*)mem_align(_IBuf, MEM_ALIGN_CACHE); keys32 = (uint32_t*)keys; memset(keys, 0, 64*MIN_KEYS_PER_CRYPT); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { SHA256_Init(&ctx); SHA256_Update(&ctx, saved_key[index+i], strlen(saved_key[index+i])); SHA256_Update(&ctx, cur_salt->salt, 32); SHA256_Final(tmpBuf, &ctx); for (j = 0; j < 32; ++j) keys[GETPOS(j, i)] = tmpBuf[j]; keys[GETPOS(j, i)] = 0x80; // 32 bytes of crypt data (0x100 bits). keys[GETPOS(62, i)] = 0x01; } for (i = 0; i < cur_salt->iterations; i++) { SIMDSHA256body(keys, keys32, NULL, SSEi_MIXED_IN|SSEi_OUTPUT_AS_INP_FMT); } // Last one with FLAT_OUT SIMDSHA256body(keys, crypt_out[index], NULL, SSEi_MIXED_IN|SSEi_OUTPUT_AS_INP_FMT|SSEi_FLAT_OUT); #else SHA256_Init(&ctx); SHA256_Update(&ctx, saved_key[index], strlen(saved_key[index])); SHA256_Update(&ctx, cur_salt->salt, 32); SHA256_Final((unsigned char*)crypt_out[index], &ctx); #if 1 // This complex crap only boosted speed on my quad-HT from 5016 to 5285. // A ton of complex code for VERY little gain. The SIMD change gave us // a 4x improvement with very little change. This pwsafe_sha256_iterate // does get 5% gain, but 400% is so much better, lol. I put the other // code in to be able to dump data out easier, getting dump_stuff() // data in flat, to be able to help get the SIMD code working. pwsafe_sha256_iterate(ctx.h, cur_salt->iterations); memcpy(crypt_out[index], ctx.h, 32); #else { int i; for (i = 0; i <= cur_salt->iterations; ++i) { SHA256_Init(&ctx); SHA256_Update(&ctx, (unsigned char*)crypt_out[index], 32); SHA256_Final((unsigned char*)crypt_out[index], &ctx); } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sapH_fmt_plug.c
#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)
100
key[index], BINARY_SIZE); } static void crypt_all_1(int count) { int idx=0; #if defined(_OPENMP) <LOOP-START>for (idx = 0; idx < count; idx += NBKEYS1) { SHA_CTX ctx; uint32_t i; #if !defined (SIMD_COEF_32) uint32_t len = strlen(saved_plain[idx]); unsigned char tmp[PLAINTEXT_LENGTH+SHA1_BINARY_SIZE], *cp=&tmp[len]; SHA1_Init(&ctx); SHA1_Update(&ctx, saved_plain[idx], len); SHA1_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); strcpy((char*)tmp, saved_plain[idx]); len += SHA1_BINARY_SIZE; SHA1_Final(cp, &ctx); for (i = 1; i < sapH_cur_salt->iter; ++i) { SHA1_Init(&ctx); SHA1_Update(&ctx, tmp, len); SHA1_Final(cp, &ctx); } memcpy(crypt_key[idx], cp, BINARY_SIZE); #else unsigned char _IBuf[64*NBKEYS1+MEM_ALIGN_SIMD], *keys, tmpBuf[20], _OBuf[20*NBKEYS1+MEM_ALIGN_SIMD], *crypt; uint32_t j, *crypt32, offs[NBKEYS1], len; keys = (unsigned char*)mem_align(_IBuf, MEM_ALIGN_SIMD); crypt = (unsigned char*)mem_align(_OBuf, MEM_ALIGN_SIMD); crypt32 = (uint32_t*)crypt; memset(keys, 0, 64*NBKEYS1); for (i = 0; i < NBKEYS1; ++i) { len = strlen(saved_plain[idx+i]); SHA1_Init(&ctx); SHA1_Update(&ctx, saved_plain[idx+i], len); SHA1_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); SHA1_Final(tmpBuf, &ctx); memcpy(&keys[i<<6], saved_plain[idx+i], len); memcpy(&keys[(i<<6)+len], tmpBuf, 20); keys[(i<<6)+len+20] = 0x80; offs[i] = len; len += 20; #if ARCH_LITTLE_ENDIAN keys[(i<<6)+60] = (len<<3)&0xff; keys[(i<<6)+61] = (len>>5); #else keys[(i<<6)+62] = (len>>5); keys[(i<<6)+63] = (len<<3)&0xff; } for (i = 1; i < sapH_cur_salt->iter; ++i) { uint32_t k; SIMDSHA1body(keys, crypt32, NULL, SSEi_FLAT_IN); for (k = 0; k < NBKEYS1; ++k) { uint32_t *pcrypt = &crypt32[ ((k/SIMD_COEF_32)*(SIMD_COEF_32*5)) + (k&(SIMD_COEF_32-1))]; uint32_t *Icp32 = (uint32_t *)(&keys[(k<<6)+offs[k]]); for (j = 0; j < 5; ++j) { // likely location for BE porting #if ARCH_ALLOWS_UNALIGNED #if ARCH_LITTLE_ENDIAN Icp32[j] = JOHNSWAP(*pcrypt); #else Icp32[j] = *pcrypt; #else #if ARCH_LITTLE_ENDIAN uint32_t tmp = JOHNSWAP(*pcrypt); memcpy(&Icp32[j], &tmp, 4); #else memcpy(&Icp32[j], pcrypt, 4); pcrypt += SIMD_COEF_32; } } } // now marshal into crypt_out; for (i = 0; i < NBKEYS1; ++i) { uint32_t *Optr32 = (uint32_t*)(crypt_key[idx+i]); uint32_t *Iptr32 = &crypt32[ ((i/SIMD_COEF_32)*(SIMD_COEF_32*5)) + (i&(SIMD_COEF_32-1))]; // we only want 16 bytes, not 20 for (j = 0; j < 4; ++j) { #if ARCH_LITTLE_ENDIAN Optr32[j] = JOHNSWAP(*Iptr32); #else Optr32[j] = *Iptr32; Iptr32 += SIMD_COEF_32; } } }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sapH_fmt_plug.c
#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)
100
COEF_32; } } #endif } } static void crypt_all_256(int count) { int idx; #if defined(_OPENMP) <LOOP-START>for (idx = 0; idx < count; idx += NBKEYS256) { SHA256_CTX ctx; uint32_t i; #if !defined (SIMD_COEF_32) uint32_t len = strlen(saved_plain[idx]); unsigned char tmp[PLAINTEXT_LENGTH+SHA256_BINARY_SIZE], *cp=&tmp[len]; SHA256_Init(&ctx); SHA256_Update(&ctx, saved_plain[idx], len); SHA256_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); strcpy((char*)tmp, saved_plain[idx]); len += SHA256_BINARY_SIZE; SHA256_Final(cp, &ctx); for (i = 1; i < sapH_cur_salt->iter; ++i) { SHA256_Init(&ctx); SHA256_Update(&ctx, tmp, len); SHA256_Final(cp, &ctx); } memcpy(crypt_key[idx], cp, BINARY_SIZE); #else unsigned char _IBuf[64*NBKEYS256+MEM_ALIGN_SIMD], *keys, tmpBuf[32], _OBuf[32*NBKEYS256+MEM_ALIGN_SIMD], *crypt; uint32_t j, *crypt32, offs[NBKEYS256], len; keys = (unsigned char*)mem_align(_IBuf, MEM_ALIGN_SIMD); crypt = (unsigned char*)mem_align(_OBuf, MEM_ALIGN_SIMD); crypt32 = (uint32_t*)crypt; memset(keys, 0, 64*NBKEYS256); for (i = 0; i < NBKEYS256; ++i) { len = strlen(saved_plain[idx+i]); SHA256_Init(&ctx); SHA256_Update(&ctx, saved_plain[idx+i], len); SHA256_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); SHA256_Final(tmpBuf, &ctx); memcpy(&keys[i<<6], saved_plain[idx+i], len); memcpy(&keys[(i<<6)+len], tmpBuf, 32); keys[(i<<6)+len+32] = 0x80; offs[i] = len; len += 32; #if ARCH_LITTLE_ENDIAN keys[(i<<6)+60] = (len<<3)&0xff; keys[(i<<6)+61] = (len>>5); #else keys[(i<<6)+62] = (len>>5); keys[(i<<6)+63] = (len<<3)&0xff; } for (i = 1; i < sapH_cur_salt->iter; ++i) { uint32_t k; SIMDSHA256body(keys, crypt32, NULL, SSEi_FLAT_IN); for (k = 0; k < NBKEYS256; ++k) { uint32_t *pcrypt = &crypt32[ ((k/SIMD_COEF_32)*(SIMD_COEF_32*8)) + (k&(SIMD_COEF_32-1))]; uint32_t *Icp32 = (uint32_t *)(&keys[(k<<6)+offs[k]]); for (j = 0; j < 8; ++j) { #if ARCH_ALLOWS_UNALIGNED #if ARCH_LITTLE_ENDIAN Icp32[j] = JOHNSWAP(*pcrypt); #else Icp32[j] = *pcrypt; #else #if ARCH_LITTLE_ENDIAN uint32_t tmp = JOHNSWAP(*pcrypt); memcpy(&Icp32[j], &tmp, 4); #else memcpy(&Icp32[j], pcrypt, 4); pcrypt += SIMD_COEF_32; } } } // now marshal into crypt_out; for (i = 0; i < NBKEYS256; ++i) { uint32_t *Optr32 = (uint32_t*)(crypt_key[idx+i]); uint32_t *Iptr32 = &crypt32[ ((i/SIMD_COEF_32)*(SIMD_COEF_32*8)) + (i&(SIMD_COEF_32-1))]; // we only want 16 bytes, not 32 for (j = 0; j < 4; ++j) { #if ARCH_LITTLE_ENDIAN Optr32[j] = JOHNSWAP(*Iptr32); #else Optr32[j] = *Iptr32; Iptr32 += SIMD_COEF_32; } } }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sapH_fmt_plug.c
#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)
100
COEF_32; } } #endif } } static void crypt_all_384(int count) { int idx; #if defined(_OPENMP) <LOOP-START>for (idx = 0; idx < count; idx+=NBKEYS512) { SHA512_CTX ctx; uint32_t i; #if !defined SIMD_COEF_64 uint32_t len = strlen(saved_plain[idx]); unsigned char tmp[PLAINTEXT_LENGTH+SHA384_BINARY_SIZE], *cp=&tmp[len]; SHA384_Init(&ctx); SHA384_Update(&ctx, saved_plain[idx], len); SHA384_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); strcpy((char*)tmp, saved_plain[idx]); len += SHA384_BINARY_SIZE; SHA384_Final(cp, &ctx); for (i = 1; i < sapH_cur_salt->iter; ++i) { SHA384_Init(&ctx); SHA384_Update(&ctx, tmp, len); SHA384_Final(cp, &ctx); } memcpy(crypt_key[idx], cp, BINARY_SIZE); #else unsigned char _IBuf[128*NBKEYS512+MEM_ALIGN_SIMD], *keys, tmpBuf[64], _OBuf[64*NBKEYS512+MEM_ALIGN_SIMD], *crypt; uint64_t j, *crypt64, offs[NBKEYS512]; uint32_t len; keys = (unsigned char*)mem_align(_IBuf, MEM_ALIGN_SIMD); crypt = (unsigned char*)mem_align(_OBuf, MEM_ALIGN_SIMD); crypt64 = (uint64_t*)crypt; memset(keys, 0, 128*NBKEYS512); for (i = 0; i < NBKEYS512; ++i) { len = strlen(saved_plain[idx+i]); SHA384_Init(&ctx); SHA384_Update(&ctx, saved_plain[idx+i], len); SHA384_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); SHA384_Final(tmpBuf, &ctx); memcpy(&keys[i<<7], saved_plain[idx+i], len); memcpy(&keys[(i<<7)+len], tmpBuf, 48); keys[(i<<7)+len+48] = 0x80; offs[i] = len; len += 48; #if ARCH_LITTLE_ENDIAN keys[(i<<7)+120] = (len<<3)&0xff; keys[(i<<7)+121] = (len>>5); #else keys[(i<<7)+126] = (len>>5); keys[(i<<7)+127] = (len<<3)&0xff; } for (i = 1; i < sapH_cur_salt->iter; ++i) { uint32_t k; SIMDSHA512body(keys, crypt64, NULL, SSEi_FLAT_IN|SSEi_CRYPT_SHA384); for (k = 0; k < NBKEYS512; ++k) { uint64_t *pcrypt = &crypt64[ ((k/SIMD_COEF_64)*(SIMD_COEF_64*8)) + (k&(SIMD_COEF_64-1))]; uint64_t *Icp64 = (uint64_t *)(&keys[(k<<7)+offs[k]]); for (j = 0; j < 6; ++j) { #if ARCH_ALLOWS_UNALIGNED #if ARCH_LITTLE_ENDIAN Icp64[j] = JOHNSWAP64(*pcrypt); #else Icp64[j] = *pcrypt; #else #if ARCH_LITTLE_ENDIAN uint64_t tmp = JOHNSWAP64(*pcrypt); memcpy(&Icp64[j], &tmp, 8); #else memcpy(&Icp64[j], pcrypt, 8); pcrypt += SIMD_COEF_64; } } } // now marshal into crypt_out; for (i = 0; i < NBKEYS512; ++i) { uint64_t *Optr64 = (uint64_t*)(crypt_key[idx+i]); uint64_t *Iptr64 = &crypt64[ ((i/SIMD_COEF_64)*(SIMD_COEF_64*8)) + (i&(SIMD_COEF_64-1))]; // we only want 16 bytes, not 48 for (j = 0; j < 2; ++j) { #if ARCH_LITTLE_ENDIAN Optr64[j] = JOHNSWAP64(*Iptr64); #else Optr64[j] = *Iptr64; Iptr64 += SIMD_COEF_64; } } }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sapH_fmt_plug.c
#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)
100
COEF_64; } } #endif } } static void crypt_all_512(int count) { int idx; #if defined(_OPENMP) <LOOP-START>for (idx = 0; idx < count; idx+=NBKEYS512) { SHA512_CTX ctx; uint32_t i; #if !defined SIMD_COEF_64 uint32_t len = strlen(saved_plain[idx]); unsigned char tmp[PLAINTEXT_LENGTH+SHA512_BINARY_SIZE], *cp=&tmp[len]; SHA512_Init(&ctx); SHA512_Update(&ctx, saved_plain[idx], len); SHA512_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); strcpy((char*)tmp, saved_plain[idx]); len += SHA512_BINARY_SIZE; SHA512_Final(cp, &ctx); for (i = 1; i < sapH_cur_salt->iter; ++i) { SHA512_Init(&ctx); SHA512_Update(&ctx, tmp, len); SHA512_Final(cp, &ctx); } memcpy(crypt_key[idx], cp, BINARY_SIZE); #else unsigned char _IBuf[128*NBKEYS512+MEM_ALIGN_SIMD], *keys, tmpBuf[64], _OBuf[64*NBKEYS512+MEM_ALIGN_SIMD], *crypt; uint64_t j, *crypt64, offs[NBKEYS512]; uint32_t len; keys = (unsigned char*)mem_align(_IBuf, MEM_ALIGN_SIMD); crypt = (unsigned char*)mem_align(_OBuf, MEM_ALIGN_SIMD); crypt64 = (uint64_t*)crypt; memset(keys, 0, 128*NBKEYS512); for (i = 0; i < NBKEYS512; ++i) { len = strlen(saved_plain[idx+i]); SHA512_Init(&ctx); SHA512_Update(&ctx, saved_plain[idx+i], len); SHA512_Update(&ctx, sapH_cur_salt->s, sapH_cur_salt->slen); SHA512_Final(tmpBuf, &ctx); memcpy(&keys[i<<7], saved_plain[idx+i], len); memcpy(&keys[(i<<7)+len], tmpBuf, 64); keys[(i<<7)+len+64] = 0x80; offs[i] = len; len += 64; #if ARCH_LITTLE_ENDIAN keys[(i<<7)+120] = (len<<3)&0xff; keys[(i<<7)+121] = (len>>5); #else keys[(i<<7)+126] = (len>>5); keys[(i<<7)+127] = (len<<3)&0xff; } for (i = 1; i < sapH_cur_salt->iter; ++i) { uint32_t k; SIMDSHA512body(keys, crypt64, NULL, SSEi_FLAT_IN); for (k = 0; k < NBKEYS512; ++k) { uint64_t *pcrypt = &crypt64[ ((k/SIMD_COEF_64)*(SIMD_COEF_64*8)) + (k&(SIMD_COEF_64-1))]; uint64_t *Icp64 = (uint64_t *)(&keys[(k<<7)+offs[k]]); for (j = 0; j < 8; ++j) { #if ARCH_ALLOWS_UNALIGNED #if ARCH_LITTLE_ENDIAN Icp64[j] = JOHNSWAP64(*pcrypt); #else Icp64[j] = *pcrypt; #else #if ARCH_LITTLE_ENDIAN uint64_t tmp = JOHNSWAP64(*pcrypt); memcpy(&Icp64[j], &tmp, 8); #else memcpy(&Icp64[j], pcrypt, 8); pcrypt += SIMD_COEF_64; } } } // now marshal into crypt_out; for (i = 0; i < NBKEYS512; ++i) { uint64_t *Optr64 = (uint64_t*)(crypt_key[idx+i]); uint64_t *Iptr64 = &crypt64[((i/SIMD_COEF_64)*(SIMD_COEF_64*8)) + (i&(SIMD_COEF_64-1))]; // we only want 16 bytes, not 64 for (j = 0; j < 2; ++j) { #if ARCH_LITTLE_ENDIAN Optr64[j] = JOHNSWAP64(*Iptr64); #else Optr64[j] = *Iptr64; Iptr64 += SIMD_COEF_64; } } }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(idx) shared(count, sapH_cur_salt, saved_plain, crypt_key)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/mozilla_ng_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { SHA_CTX ctx, ctxi, ctxo; int i; union { unsigned char uc[64]; uint32_t ui[64/4]; } pad; unsigned char buffer[20]; unsigned char tk[20]; unsigned char key[40]; DES_cblock ivec; DES_key_schedule ks1, ks2, ks3; // HP = SHA1(global-salt||password) // Copy already calculated partial hash data memcpy(&ctx, &cur_salt->pctx, sizeof(SHA_CTX)); SHA1_Update(&ctx, saved_key[index], saved_len[index]); SHA1_Final(buffer, &ctx); // CHP = SHA1(HP||entry-salt) // entry-salt (ES) is local_salt SHA1_Init(&ctx); SHA1_Update(&ctx, buffer, 20); SHA1_Update(&ctx, cur_salt->local_salt, cur_salt->local_salt_length); SHA1_Final(buffer, &ctx); // Step 0 for all hmac, store off the first half (the key is the same for all 3) // this will avoid having to setup the ipad/opad 2 times, and also avoids 4 SHA calls // reducing the hmac calls from 12 SHA limbs, down to 8 and ipad/opad loads from 3 // down to 1. It adds 4 CTX memcpy's, but that is a very fair trade off. SHA1_Init(&ctxi); SHA1_Init(&ctxo); memset(pad.uc, 0x36, 64); for (i = 0; i < 20; ++i) pad.uc[i] ^= buffer[i]; SHA1_Update(&ctxi, pad.uc, 64); for (i = 0; i < 64/4; ++i) pad.ui[i] ^= 0x36363636^0x5c5c5c5c; SHA1_Update(&ctxo, pad.uc, 64); // k1 = HMAC(PES||ES) // use CHP as the key, PES is ES which is zero padded to length 20 // NOTE, memcpy ctxi/ctxo to harvest off the preloaded hmac key memcpy(&ctx, &ctxi, sizeof(ctx)); SHA1_Update(&ctx, cur_salt->local_salt, 20); SHA1_Update(&ctx, cur_salt->local_salt, cur_salt->local_salt_length); SHA1_Final(buffer, &ctx); memcpy(&ctx, &ctxo, sizeof(ctx)); SHA1_Update(&ctx, buffer, 20); SHA1_Final(key, &ctx); // tk = HMAC(PES) // use CHP as the key // NOTE, memcpy ctxi/ctxo to harvest off the preloaded hmac key memcpy(&ctx, &ctxi, sizeof(ctx)); SHA1_Update(&ctx, cur_salt->local_salt, 20); SHA1_Final(buffer, &ctx); memcpy(&ctx, &ctxo, sizeof(ctx)); SHA1_Update(&ctx, buffer, 20); SHA1_Final(tk, &ctx); // k2 = HMAC(tk||ES) // use CHP as the key // NOTE, ctxi and ctxo are no longer needed after this hmac, so we simply use them SHA1_Update(&ctxi, tk, 20); SHA1_Update(&ctxi, cur_salt->local_salt, cur_salt->local_salt_length); SHA1_Final(buffer, &ctxi); SHA1_Update(&ctxo, buffer, 20); SHA1_Final(key+20, &ctxo); // k = k1||k2 // encrypt "password-check" string using this key DES_set_key_unchecked((DES_cblock *) key, &ks1); DES_set_key_unchecked((DES_cblock *) (key+8), &ks2); DES_set_key_unchecked((DES_cblock *) (key+16), &ks3); memcpy(ivec, key + 32, 8); // last 8 bytes! // PKCS#5 padding (standard block padding) DES_ede3_cbc_encrypt((unsigned char*)"password-check\x02\x02", (unsigned char*)crypt_out[index], 16, &ks1, &ks2, &ks3, &ivec, DES_ENCRYPT); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/DES_bs_b.c
#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, salt, precheck)
100
volatile #endif int precheck = salt && !salt->bitmap; #endif #ifdef _OPENMP #ifdef vtestallones <LOOP-START>#else #pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p) for_each_t(n) { #if DES_BS_EXPAND DES_bs_vector *k; #else ARCH_WORD **k; int iterations, rounds_and_swapped; #if DES_BS_VECTOR_LOOPS int depth; if (DES_bs_all.keys_changed) goto finalize_keys; body: #if DES_bs_mt DES_bs_set_salt_for_thread(t, DES_bs_all_by_tnum(-1).salt); { vtype zero = vzero; DES_bs_clear_block } #if DES_BS_EXPAND k = DES_bs_all.KS.v; #else k = DES_bs_all.KS.p; rounds_and_swapped = 8; iterations = 25; start: for_each_depth() s1(x(0), x(1), x(2), x(3), x(4), x(5), z(40), z(48), z(54), z(62)); for_each_depth() s2(x(6), x(7), x(8), x(9), x(10), x(11), z(44), z(59), z(33), z(49)); for_each_depth() s3(y(7, 12), y(8, 13), y(9, 14), y(10, 15), y(11, 16), y(12, 17), z(55), z(47), z(61), z(37)); for_each_depth() s4(y(11, 18), y(12, 19), y(13, 20), y(14, 21), y(15, 22), y(16, 23), z(57), z(51), z(41), z(32)); for_each_depth() s5(x(24), x(25), x(26), x(27), x(28), x(29), z(39), z(45), z(56), z(34)); for_each_depth() s6(x(30), x(31), x(32), x(33), x(34), x(35), z(35), z(60), z(42), z(50)); for_each_depth() s7(y(23, 36), y(24, 37), y(25, 38), y(26, 39), y(27, 40), y(28, 41), z(63), z(43), z(53), z(38)); for_each_depth() s8(y(27, 42), y(28, 43), y(29, 44), y(30, 45), y(31, 46), y(0, 47), z(36), z(58), z(46), z(52)); if (rounds_and_swapped == 0x100) goto next; swap: for_each_depth() s1(x(48), x(49), x(50), x(51), x(52), x(53), z(8), z(16), z(22), z(30)); for_each_depth() s2(x(54), x(55), x(56), x(57), x(58), x(59), z(12), z(27), z(1), z(17)); for_each_depth() s3(y(39, 60), y(40, 61), y(41, 62), y(42, 63), y(43, 64), y(44, 65), z(23), z(15), z(29), z(5)); for_each_depth() s4(y(43, 66), y(44, 67), y(45, 68), y(46, 69), y(47, 70), y(48, 71), z(25), z(19), z(9), z(0)); for_each_depth() s5(x(72), x(73), x(74), x(75), x(76), x(77), z(7), z(13), z(24), z(2)); for_each_depth() s6(x(78), x(79), x(80), x(81), x(82), x(83), z(3), z(28), z(10), z(18)); for_each_depth() s7(y(55, 84), y(56, 85), y(57, 86), y(58, 87), y(59, 88), y(60, 89), z(31), z(11), z(21), z(6)); for_each_depth() s8(y(59, 90), y(60, 91), y(61, 92), y(62, 93), y(63, 94), y(32, 95), z(4), z(26), z(14), z(20)); k += 96; if (--rounds_and_swapped) goto start; k -= (0x300 + 48); rounds_and_swapped = 0x108; if (--iterations) goto swap; #ifdef vtestallones if (precheck) { struct db_password *pw = salt->list; do { uint32_t binary = *(uint32_t *)pw->binary; for_each_depth() { uint32_t u = binary; vtype mask = *z(26); if (u & (1 << 26)) vnot(mask, mask); int bit = 0; do { vtype v = *z(bit); if (u & 1) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 1); if (u & 2) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 2); if (u & 4) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 3); if (u & 8) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; u >>= 4; } while ((bit += 4) <= 28); #if DES_bs_mt precheck = 0; goto next_batch; #else return keys_count; next_depth: ; } } while ((pw = pw->next)); } #if DES_bs_mt next_batch: #if DES_bs_mt continue; #else return keys_count; next: k -= (0x300 - 48); rounds_and_swapped = 8; iterations--; goto start; finalize_keys: DES_bs_all.keys_changed = 0; #if DES_bs_mt DES_bs_finalize_keys(t); #else DES_bs_finalize_keys(); goto body; }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, salt, precheck)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/DES_bs_b.c
#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p)
100
nes #pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, salt, precheck) #else <LOOP-START>for_each_t(n) { #if DES_BS_EXPAND DES_bs_vector *k; #else ARCH_WORD **k; int iterations, rounds_and_swapped; #if DES_BS_VECTOR_LOOPS int depth; if (DES_bs_all.keys_changed) goto finalize_keys; body: #if DES_bs_mt DES_bs_set_salt_for_thread(t, DES_bs_all_by_tnum(-1).salt); { vtype zero = vzero; DES_bs_clear_block } #if DES_BS_EXPAND k = DES_bs_all.KS.v; #else k = DES_bs_all.KS.p; rounds_and_swapped = 8; iterations = 25; start: for_each_depth() s1(x(0), x(1), x(2), x(3), x(4), x(5), z(40), z(48), z(54), z(62)); for_each_depth() s2(x(6), x(7), x(8), x(9), x(10), x(11), z(44), z(59), z(33), z(49)); for_each_depth() s3(y(7, 12), y(8, 13), y(9, 14), y(10, 15), y(11, 16), y(12, 17), z(55), z(47), z(61), z(37)); for_each_depth() s4(y(11, 18), y(12, 19), y(13, 20), y(14, 21), y(15, 22), y(16, 23), z(57), z(51), z(41), z(32)); for_each_depth() s5(x(24), x(25), x(26), x(27), x(28), x(29), z(39), z(45), z(56), z(34)); for_each_depth() s6(x(30), x(31), x(32), x(33), x(34), x(35), z(35), z(60), z(42), z(50)); for_each_depth() s7(y(23, 36), y(24, 37), y(25, 38), y(26, 39), y(27, 40), y(28, 41), z(63), z(43), z(53), z(38)); for_each_depth() s8(y(27, 42), y(28, 43), y(29, 44), y(30, 45), y(31, 46), y(0, 47), z(36), z(58), z(46), z(52)); if (rounds_and_swapped == 0x100) goto next; swap: for_each_depth() s1(x(48), x(49), x(50), x(51), x(52), x(53), z(8), z(16), z(22), z(30)); for_each_depth() s2(x(54), x(55), x(56), x(57), x(58), x(59), z(12), z(27), z(1), z(17)); for_each_depth() s3(y(39, 60), y(40, 61), y(41, 62), y(42, 63), y(43, 64), y(44, 65), z(23), z(15), z(29), z(5)); for_each_depth() s4(y(43, 66), y(44, 67), y(45, 68), y(46, 69), y(47, 70), y(48, 71), z(25), z(19), z(9), z(0)); for_each_depth() s5(x(72), x(73), x(74), x(75), x(76), x(77), z(7), z(13), z(24), z(2)); for_each_depth() s6(x(78), x(79), x(80), x(81), x(82), x(83), z(3), z(28), z(10), z(18)); for_each_depth() s7(y(55, 84), y(56, 85), y(57, 86), y(58, 87), y(59, 88), y(60, 89), z(31), z(11), z(21), z(6)); for_each_depth() s8(y(59, 90), y(60, 91), y(61, 92), y(62, 93), y(63, 94), y(32, 95), z(4), z(26), z(14), z(20)); k += 96; if (--rounds_and_swapped) goto start; k -= (0x300 + 48); rounds_and_swapped = 0x108; if (--iterations) goto swap; #ifdef vtestallones if (precheck) { struct db_password *pw = salt->list; do { uint32_t binary = *(uint32_t *)pw->binary; for_each_depth() { uint32_t u = binary; vtype mask = *z(26); if (u & (1 << 26)) vnot(mask, mask); int bit = 0; do { vtype v = *z(bit); if (u & 1) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 1); if (u & 2) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 2); if (u & 4) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 3); if (u & 8) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; u >>= 4; } while ((bit += 4) <= 28); #if DES_bs_mt precheck = 0; goto next_batch; #else return keys_count; next_depth: ; } } while ((pw = pw->next)); } #if DES_bs_mt next_batch: #if DES_bs_mt continue; #else return keys_count; next: k -= (0x300 - 48); rounds_and_swapped = 8; iterations--; goto start; finalize_keys: DES_bs_all.keys_changed = 0; #if DES_bs_mt DES_bs_finalize_keys(t); #else DES_bs_finalize_keys(); goto body; }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/DES_bs_b.c
#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, count, keys_count)
100
#if DES_bs_mt int t, n = (keys_count + (DES_BS_DEPTH - 1)) / DES_BS_DEPTH; #endif #ifdef _OPENMP <LOOP-START>for_each_t(n) { #if DES_BS_EXPAND DES_bs_vector *k; #else ARCH_WORD **k; int iterations, rounds_and_swapped; #if DES_BS_VECTOR_LOOPS int depth; if (DES_bs_all.keys_changed) goto finalize_keys; body: #if DES_bs_mt DES_bs_set_salt_for_thread(t, DES_bs_all_by_tnum(-1).salt); { vtype zero = vzero; DES_bs_clear_block } #if DES_BS_EXPAND k = DES_bs_all.KS.v; #else k = DES_bs_all.KS.p; rounds_and_swapped = 8; iterations = count; start: for_each_depth() s1(x(0), x(1), x(2), x(3), x(4), x(5), z(40), z(48), z(54), z(62)); for_each_depth() s2(x(6), x(7), x(8), x(9), x(10), x(11), z(44), z(59), z(33), z(49)); for_each_depth() s3(x(12), x(13), x(14), x(15), x(16), x(17), z(55), z(47), z(61), z(37)); for_each_depth() s4(x(18), x(19), x(20), x(21), x(22), x(23), z(57), z(51), z(41), z(32)); for_each_depth() s5(x(24), x(25), x(26), x(27), x(28), x(29), z(39), z(45), z(56), z(34)); for_each_depth() s6(x(30), x(31), x(32), x(33), x(34), x(35), z(35), z(60), z(42), z(50)); for_each_depth() s7(x(36), x(37), x(38), x(39), x(40), x(41), z(63), z(43), z(53), z(38)); for_each_depth() s8(x(42), x(43), x(44), x(45), x(46), x(47), z(36), z(58), z(46), z(52)); if (rounds_and_swapped == 0x100) goto next; swap: for_each_depth() s1(x(48), x(49), x(50), x(51), x(52), x(53), z(8), z(16), z(22), z(30)); for_each_depth() s2(x(54), x(55), x(56), x(57), x(58), x(59), z(12), z(27), z(1), z(17)); for_each_depth() s3(x(60), x(61), x(62), x(63), x(64), x(65), z(23), z(15), z(29), z(5)); for_each_depth() s4(x(66), x(67), x(68), x(69), x(70), x(71), z(25), z(19), z(9), z(0)); for_each_depth() s5(x(72), x(73), x(74), x(75), x(76), x(77), z(7), z(13), z(24), z(2)); for_each_depth() s6(x(78), x(79), x(80), x(81), x(82), x(83), z(3), z(28), z(10), z(18)); for_each_depth() s7(x(84), x(85), x(86), x(87), x(88), x(89), z(31), z(11), z(21), z(6)); for_each_depth() s8(x(90), x(91), x(92), x(93), x(94), x(95), z(4), z(26), z(14), z(20)); k += 96; if (--rounds_and_swapped) goto start; k -= (0x300 + 48); rounds_and_swapped = 0x108; if (--iterations) goto swap; #if DES_bs_mt continue; #else return; next: k -= (0x300 - 48); rounds_and_swapped = 8; if (--iterations) goto start; #if DES_bs_mt continue; #else return; finalize_keys: DES_bs_all.keys_changed = 0; #if DES_bs_mt DES_bs_finalize_keys(t); #else DES_bs_finalize_keys(); goto body; }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, count, keys_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/DES_bs_b.c
#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, salt, precheck)
100
volatile #endif int precheck = salt && !salt->bitmap; #endif #ifdef _OPENMP #ifdef vtestallones <LOOP-START>#else #pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p) for_each_t(n) { ARCH_WORD **k; int rounds; #if DES_BS_VECTOR_LOOPS int depth; { vtype z = vzero, o = vones; DES_bs_set_block_8(0, z, z, z, z, z, z, z, z); DES_bs_set_block_8(8, o, o, o, z, o, z, z, z); DES_bs_set_block_8(16, z, z, z, z, z, z, z, o); DES_bs_set_block_8(24, z, z, o, z, z, o, o, o); DES_bs_set_block_8(32, z, z, z, o, z, o, o, o); DES_bs_set_block_8(40, z, z, z, z, z, o, z, z); DES_bs_set_block_8(48, o, o, z, z, z, z, o, z); DES_bs_set_block_8(56, o, z, o, z, o, o, o, o); } #if DES_bs_mt DES_bs_finalize_keys_LM(t); #else DES_bs_finalize_keys_LM(); k = DES_bs_all.KS.p; rounds = 8; do { for_each_depth() s1(y(31, 0), y(0, 1), y(1, 2), y(2, 3), y(3, 4), y(4, 5), z(40), z(48), z(54), z(62)); for_each_depth() s2(y(3, 6), y(4, 7), y(5, 8), y(6, 9), y(7, 10), y(8, 11), z(44), z(59), z(33), z(49)); for_each_depth() s3(y(7, 12), y(8, 13), y(9, 14), y(10, 15), y(11, 16), y(12, 17), z(55), z(47), z(61), z(37)); for_each_depth() s4(y(11, 18), y(12, 19), y(13, 20), y(14, 21), y(15, 22), y(16, 23), z(57), z(51), z(41), z(32)); for_each_depth() s5(y(15, 24), y(16, 25), y(17, 26), y(18, 27), y(19, 28), y(20, 29), z(39), z(45), z(56), z(34)); for_each_depth() s6(y(19, 30), y(20, 31), y(21, 32), y(22, 33), y(23, 34), y(24, 35), z(35), z(60), z(42), z(50)); for_each_depth() s7(y(23, 36), y(24, 37), y(25, 38), y(26, 39), y(27, 40), y(28, 41), z(63), z(43), z(53), z(38)); for_each_depth() s8(y(27, 42), y(28, 43), y(29, 44), y(30, 45), y(31, 46), y(0, 47), z(36), z(58), z(46), z(52)); for_each_depth() s1(y(63, 48), y(32, 49), y(33, 50), y(34, 51), y(35, 52), y(36, 53), z(8), z(16), z(22), z(30)); for_each_depth() s2(y(35, 54), y(36, 55), y(37, 56), y(38, 57), y(39, 58), y(40, 59), z(12), z(27), z(1), z(17)); for_each_depth() s3(y(39, 60), y(40, 61), y(41, 62), y(42, 63), y(43, 64), y(44, 65), z(23), z(15), z(29), z(5)); for_each_depth() s4(y(43, 66), y(44, 67), y(45, 68), y(46, 69), y(47, 70), y(48, 71), z(25), z(19), z(9), z(0)); for_each_depth() s5(y(47, 72), y(48, 73), y(49, 74), y(50, 75), y(51, 76), y(52, 77), z(7), z(13), z(24), z(2)); for_each_depth() s6(y(51, 78), y(52, 79), y(53, 80), y(54, 81), y(55, 82), y(56, 83), z(3), z(28), z(10), z(18)); for_each_depth() s7(y(55, 84), y(56, 85), y(57, 86), y(58, 87), y(59, 88), y(60, 89), z(31), z(11), z(21), z(6)); for_each_depth() s8(y(59, 90), y(60, 91), y(61, 92), y(62, 93), y(63, 94), y(32, 95), z(4), z(26), z(14), z(20)); k += 96; } while (--rounds); #ifdef vtestallones if (precheck) { struct db_password *pw = salt->list; do { uint32_t binary = *(uint32_t *)pw->binary; for_each_depth() { uint32_t u = binary; vtype mask = *z(20); if (u & (1 << 20)) vnot(mask, mask); vtype v = *z(14); if (u & (1 << 14)) vnot(v, v); vor(mask, mask, v); v = *z(26); if (u & (1 << 26)) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; int bit = 0; do { v = *z(bit); if (u & 1) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 1); if (u & 2) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 2); if (u & 4) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 3); if (u & 8) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; u >>= 4; } while ((bit += 4) <= 28); #if DES_bs_mt precheck = 0; goto next_batch; #else return keys_count; next_depth: ; } } while ((pw = pw->next)); } #if DES_bs_mt next_batch: ; }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, salt, precheck)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/DES_bs_b.c
#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p)
100
nes #pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, salt, precheck) #else <LOOP-START>for_each_t(n) { ARCH_WORD **k; int rounds; #if DES_BS_VECTOR_LOOPS int depth; { vtype z = vzero, o = vones; DES_bs_set_block_8(0, z, z, z, z, z, z, z, z); DES_bs_set_block_8(8, o, o, o, z, o, z, z, z); DES_bs_set_block_8(16, z, z, z, z, z, z, z, o); DES_bs_set_block_8(24, z, z, o, z, z, o, o, o); DES_bs_set_block_8(32, z, z, z, o, z, o, o, o); DES_bs_set_block_8(40, z, z, z, z, z, o, z, z); DES_bs_set_block_8(48, o, o, z, z, z, z, o, z); DES_bs_set_block_8(56, o, z, o, z, o, o, o, o); } #if DES_bs_mt DES_bs_finalize_keys_LM(t); #else DES_bs_finalize_keys_LM(); k = DES_bs_all.KS.p; rounds = 8; do { for_each_depth() s1(y(31, 0), y(0, 1), y(1, 2), y(2, 3), y(3, 4), y(4, 5), z(40), z(48), z(54), z(62)); for_each_depth() s2(y(3, 6), y(4, 7), y(5, 8), y(6, 9), y(7, 10), y(8, 11), z(44), z(59), z(33), z(49)); for_each_depth() s3(y(7, 12), y(8, 13), y(9, 14), y(10, 15), y(11, 16), y(12, 17), z(55), z(47), z(61), z(37)); for_each_depth() s4(y(11, 18), y(12, 19), y(13, 20), y(14, 21), y(15, 22), y(16, 23), z(57), z(51), z(41), z(32)); for_each_depth() s5(y(15, 24), y(16, 25), y(17, 26), y(18, 27), y(19, 28), y(20, 29), z(39), z(45), z(56), z(34)); for_each_depth() s6(y(19, 30), y(20, 31), y(21, 32), y(22, 33), y(23, 34), y(24, 35), z(35), z(60), z(42), z(50)); for_each_depth() s7(y(23, 36), y(24, 37), y(25, 38), y(26, 39), y(27, 40), y(28, 41), z(63), z(43), z(53), z(38)); for_each_depth() s8(y(27, 42), y(28, 43), y(29, 44), y(30, 45), y(31, 46), y(0, 47), z(36), z(58), z(46), z(52)); for_each_depth() s1(y(63, 48), y(32, 49), y(33, 50), y(34, 51), y(35, 52), y(36, 53), z(8), z(16), z(22), z(30)); for_each_depth() s2(y(35, 54), y(36, 55), y(37, 56), y(38, 57), y(39, 58), y(40, 59), z(12), z(27), z(1), z(17)); for_each_depth() s3(y(39, 60), y(40, 61), y(41, 62), y(42, 63), y(43, 64), y(44, 65), z(23), z(15), z(29), z(5)); for_each_depth() s4(y(43, 66), y(44, 67), y(45, 68), y(46, 69), y(47, 70), y(48, 71), z(25), z(19), z(9), z(0)); for_each_depth() s5(y(47, 72), y(48, 73), y(49, 74), y(50, 75), y(51, 76), y(52, 77), z(7), z(13), z(24), z(2)); for_each_depth() s6(y(51, 78), y(52, 79), y(53, 80), y(54, 81), y(55, 82), y(56, 83), z(3), z(28), z(10), z(18)); for_each_depth() s7(y(55, 84), y(56, 85), y(57, 86), y(58, 87), y(59, 88), y(60, 89), z(31), z(11), z(21), z(6)); for_each_depth() s8(y(59, 90), y(60, 91), y(61, 92), y(62, 93), y(63, 94), y(32, 95), z(4), z(26), z(14), z(20)); k += 96; } while (--rounds); #ifdef vtestallones if (precheck) { struct db_password *pw = salt->list; do { uint32_t binary = *(uint32_t *)pw->binary; for_each_depth() { uint32_t u = binary; vtype mask = *z(20); if (u & (1 << 20)) vnot(mask, mask); vtype v = *z(14); if (u & (1 << 14)) vnot(v, v); vor(mask, mask, v); v = *z(26); if (u & (1 << 26)) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; int bit = 0; do { v = *z(bit); if (u & 1) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 1); if (u & 2) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 2); if (u & 4) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; v = *z(bit + 3); if (u & 8) vnot(v, v); vor(mask, mask, v); if (vtestallones(mask)) goto next_depth; u >>= 4; } while ((bit += 4) <= 28); #if DES_bs_mt precheck = 0; goto next_batch; #else return keys_count; next_depth: ; } } while ((pw = pw->next)); } #if DES_bs_mt next_batch: ; }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/DES_bs_b.c
#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, DES_bs_P)
100
#if DES_bs_mt int t, n = (keys_count + (DES_BS_DEPTH - 1)) / DES_BS_DEPTH; #endif #ifdef _OPENMP <LOOP-START>for_each_t(n) { ARCH_WORD **k; int rounds; #if DES_BS_VECTOR int depth; int i; for (i = 0; i < 64; i++) { #if DES_BS_VECTOR for (depth = 0; depth < DES_BS_VECTOR; depth++) DES_bs_all.B[i][depth] = DES_bs_P[i][depth]; #else DES_bs_all.B[i] = DES_bs_P[i]; } #if DES_bs_mt DES_bs_finalize_keys_plain(t); #else DES_bs_finalize_keys_plain(); k = DES_bs_all.KS.p; rounds = 8; do { for_each_depth() s1(y(31, 0), y(0, 1), y(1, 2), y(2, 3), y(3, 4), y(4, 5), z(40), z(48), z(54), z(62)); for_each_depth() s2(y(3, 6), y(4, 7), y(5, 8), y(6, 9), y(7, 10), y(8, 11), z(44), z(59), z(33), z(49)); for_each_depth() s3(y(7, 12), y(8, 13), y(9, 14), y(10, 15), y(11, 16), y(12, 17), z(55), z(47), z(61), z(37)); for_each_depth() s4(y(11, 18), y(12, 19), y(13, 20), y(14, 21), y(15, 22), y(16, 23), z(57), z(51), z(41), z(32)); for_each_depth() s5(y(15, 24), y(16, 25), y(17, 26), y(18, 27), y(19, 28), y(20, 29), z(39), z(45), z(56), z(34)); for_each_depth() s6(y(19, 30), y(20, 31), y(21, 32), y(22, 33), y(23, 34), y(24, 35), z(35), z(60), z(42), z(50)); for_each_depth() s7(y(23, 36), y(24, 37), y(25, 38), y(26, 39), y(27, 40), y(28, 41), z(63), z(43), z(53), z(38)); for_each_depth() s8(y(27, 42), y(28, 43), y(29, 44), y(30, 45), y(31, 46), y(0, 47), z(36), z(58), z(46), z(52)); for_each_depth() s1(y(63, 48), y(32, 49), y(33, 50), y(34, 51), y(35, 52), y(36, 53), z(8), z(16), z(22), z(30)); for_each_depth() s2(y(35, 54), y(36, 55), y(37, 56), y(38, 57), y(39, 58), y(40, 59), z(12), z(27), z(1), z(17)); for_each_depth() s3(y(39, 60), y(40, 61), y(41, 62), y(42, 63), y(43, 64), y(44, 65), z(23), z(15), z(29), z(5)); for_each_depth() s4(y(43, 66), y(44, 67), y(45, 68), y(46, 69), y(47, 70), y(48, 71), z(25), z(19), z(9), z(0)); for_each_depth() s5(y(47, 72), y(48, 73), y(49, 74), y(50, 75), y(51, 76), y(52, 77), z(7), z(13), z(24), z(2)); for_each_depth() s6(y(51, 78), y(52, 79), y(53, 80), y(54, 81), y(55, 82), y(56, 83), z(3), z(28), z(10), z(18)); for_each_depth() s7(y(55, 84), y(56, 85), y(57, 86), y(58, 87), y(59, 88), y(60, 89), z(31), z(11), z(21), z(6)); for_each_depth() s8(y(59, 90), y(60, 91), y(61, 92), y(62, 93), y(63, 94), y(32, 95), z(4), z(26), z(14), z(20)); k += 96; } while (--rounds); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(t) shared(n, DES_bs_all_p, DES_bs_P)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sip_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { /* password */ MD5_CTX md5_ctx; unsigned char md5_bin_hash[MD5_LEN]; char dynamic_hash[MD5_LEN_HEX+1]; /* Generate dynamic hash including pw (see above) */ //MD5_Init(&md5_ctx); //MD5_Update(&md5_ctx, (unsigned char*)pSalt->dynamic_hash_data, pSalt->dynamic_hash_data_len); // salt.ctx_dyna_data contains the ctx already loaded. memcpy(&md5_ctx, &(pSalt->ctx_dyna_data), sizeof(md5_ctx)); MD5_Update(&md5_ctx, (unsigned char*)saved_key[index], strlen(saved_key[index])); MD5_Final(md5_bin_hash, &md5_ctx); bin_to_hex(bin2hex_table, md5_bin_hash, MD5_LEN, dynamic_hash, MD5_LEN_HEX); /* Generate digest response hash */ MD5_Init(&md5_ctx); MD5_Update(&md5_ctx, (unsigned char*)dynamic_hash, MD5_LEN_HEX); MD5_Update(&md5_ctx, (unsigned char*)pSalt->static_hash_data, pSalt->static_hash_data_len); MD5_Final((unsigned char*)crypt_key[index], &md5_ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/zed_fmt_plug.c
#pragma omp parallel for
100
if defined(SIMD_COEF_32) inc = SSE_GROUP_SZ_SHA256; #else algo = 256; #endif } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += inc) { #if !defined(SIMD_COEF_32) pkcs12_pbe_derive_key(algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, salt_len, (unsigned char*)crypt_out[index], BINARY_SIZE); #else int j; if (cur_salt->algo == 21) { unsigned char *mackey[SSE_GROUP_SZ_SHA1]; const unsigned char *keys[SSE_GROUP_SZ_SHA1]; size_t lens[SSE_GROUP_SZ_SHA1]; for (j = 0; j < SSE_GROUP_SZ_SHA1; j++) { mackey[j] = (unsigned char*)(crypt_out[index + j]); lens[j] = saved_len[index + j]; keys[j] = (const unsigned char*)(saved_key[index + j]); } pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys, lens, cur_salt->salt, salt_len, mackey, BINARY_SIZE); } else if (cur_salt->algo == 22) { unsigned char *mackey[SSE_GROUP_SZ_SHA256]; const unsigned char *keys[SSE_GROUP_SZ_SHA256]; size_t lens[SSE_GROUP_SZ_SHA256]; for (j = 0; j < SSE_GROUP_SZ_SHA256; j++) { mackey[j] = (unsigned char*)(crypt_out[index + j]); lens[j] = saved_len[index + j]; keys[j] = (const unsigned char*)(saved_key[index + j]); } pkcs12_pbe_derive_key_simd_sha256(cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys, lens, cur_salt->salt, salt_len, mackey, BINARY_SIZE); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pst_fmt_plug.c
#pragma omp parallel for private(i)
100
crypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int i; #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; ++i) { CRC32_t crc = 0; unsigned char *p = (unsigned char*)saved_key[i]; while (*p) crc = jtr_crc32(crc, *p++); crypt_out[i] = crc; }<LOOP-END> <OMP-START>#pragma omp parallel for private(i)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/notes_fmt_plug.c
#pragma omp parallel for
100
*pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0]) * cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][16]; int i; #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha256_sse((const unsigned char**)pin, lens, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, pout, 16, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha256((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, master[i], 16, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { cracked[index+i] = notes_decrypt(cur_salt, master[i]); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/andotp_fmt_plug.c
#pragma omp parallel for
100
ndex; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { if (check_password(index, cur_salt)) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawSHA224_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_32 SIMDSHA256body(&saved_key[(unsigned int)index/SIMD_COEF_32*SHA_BUF_SIZ*SIMD_COEF_32], &crypt_out[(unsigned int)index/SIMD_COEF_32*8*SIMD_COEF_32], NULL, SSEi_REVERSE_STEPS|SSEi_MIXED_IN|SSEi_CRYPT_SHA224); #else SHA256_CTX ctx; SHA224_Init(&ctx); SHA224_Update(&ctx, saved_key[index], saved_len[index]); SHA224_Final((unsigned char *)crypt_out[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/dynamic_fmt.c
#pragma omp parallel for
100
fdef _OPENMP int i; unsigned int inc = OMP_MD5_INC; // if (dynamic_use_sse!=1) // inc = OMP_INC; <LOOP-START>for (i = 0; i < m_count; i += inc) DynamicFunc__crypt2_md5(i,i+inc,omp_get_thread_num()); #else DynamicFunc__crypt2_md5(); } static void __nonMP_DynamicFunc__clean_input() { unsigned int i=0; #ifdef SIMD_COEF_32 if (dynamic_use_sse==1) { memset(input_buf, 0, MMX_INP_BUF_SZ); memset(total_len, 0, MMX_TOT_LEN_SZ); return; } for (; i < MAX_KEYS_PER_CRYPT_X86; ++i) { //if (total_len_X86[i]) { #if MD5_X2 if (i&1) memset(input_buf_X86[i>>MD5_X2].x2.b2, 0, COMPUTE_EX_LEN(total_len_X86[i])); else memset(input_buf_X86[i>>MD5_X2].x1.b, 0, COMPUTE_EX_LEN(total_len_X86[i])); total_len_X86[i] = 0; //} } return; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/dynamic_fmt.c
#pragma omp parallel for shared(curdat, inc, m_count)
100
ularity); inc = ((inc + curdat.omp_granularity-1)/curdat.omp_granularity)*curdat.omp_granularity; <LOOP-START>for (j = 0; j < m_count; j += inc) { unsigned int i; unsigned int top=j+inc; /* The last block may 'appear' to have more keys than we have in the entire buffer space. This is due to the granularity. If so, reduce that last one to stop at end of our buffers. NOT doing this is causes a huge buffer overflow. */ if (top > curdat.pFmtMain->params.max_keys_per_crypt) top = curdat.pFmtMain->params.max_keys_per_crypt; // we now run a full script in this thread, using only a subset of // the data, from [j,top) The next thread will run from [top,top+inc) // each thread will take the next inc values, until we get to m_count for (i = 0; curdat.dynamic_FUNCTIONS[i]; ++i) (*(curdat.dynamic_FUNCTIONS[i]))(j,top,omp_get_thread_num()); }<LOOP-END> <OMP-START>#pragma omp parallel for shared(curdat, inc, m_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/lastpass_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { uint32_t key[MIN_KEYS_PER_CRYPT][8]; int i; #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT]; union { uint32_t *pout[MIN_KEYS_PER_CRYPT]; unsigned char *poutc; } x; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; x.pout[i] = key[i]; } pbkdf2_sha256_sse((const unsigned char **)pin, lens, cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, &(x.poutc), 32, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { pbkdf2_sha256((unsigned char*)saved_key[i+index], strlen(saved_key[i+index]), cur_salt->salt, cur_salt->salt_length, cur_salt->iterations, (unsigned char*)key[i], 32, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { AES_KEY akey; AES_set_encrypt_key((unsigned char*)key[i], 256, &akey); AES_ecb_encrypt((unsigned char*)"lastpass rocks\x02\x02", (unsigned char*)crypt_out[i+index], &akey, AES_ENCRYPT); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawSHA512_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_64 SIMDSHA512body(&saved_key[index/SIMD_COEF_64*SHA_BUF_SIZ*SIMD_COEF_64], &crypt_out[index/SIMD_COEF_64*8*SIMD_COEF_64], NULL, SSEi_REVERSE_STEPS | SSEi_MIXED_IN); #else SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, saved_key[index], saved_len[index]); SHA512_Final((unsigned char *)crypt_out[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/palshop_fmt_plug.c
#pragma omp parallel for
100
ypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char m1[53], buffer[16+20], *cp; int i; MD5_CTX mctx; SHA_CTX sctx; // m1 = md5($p) MD5_Init(&mctx); MD5_Update(&mctx, saved_key[index], saved_len[index]); MD5_Final(buffer, &mctx); // s1 = sha1($p) SHA1_Init(&sctx); SHA1_Update(&sctx, saved_key[index], saved_len[index]); SHA1_Final(buffer+16, &sctx); // data = m1[11:] + s1[:29] + m1[0:1] // 51 bytes! cp = m1; *cp++ = itoa16[buffer[5]&0xF]; for (i = 6; i < 25+6; ++i) { cp[0] = itoa16[buffer[i]>>4]; cp[1] = itoa16[buffer[i]&0xF]; cp += 2; } cp[-1] = itoa16[buffer[0]>>4]; // m2 MD5_Init(&mctx); MD5_Update(&mctx, m1, 51); MD5_Final(buffer, &mctx); // s2 = sha1(data) // SHA1_Init(&sctx); // SHA1_Update(&sctx, data, 51); // SHA1_Final((unsigned char*)crypt_out[index], &sctx); // hex_encode((unsigned char*)crypt_out[index], 20, s1); // hash = m2[11:] + s2[:29] + m2[0], but starting 20 bytes should be enough! //memcpy((unsigned char*)crypt_out[index], m2 + 11, 20); // we actually take m2[12:32] (skipping that first 'odd' byte.0 // in binary now, skipping the unneeded hex conversion. memcpy((unsigned char*)crypt_out[index], buffer+6, 10); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/racf_kdfaes_fmt_plug.c
#pragma omp parallel for
100
rypt_all(int *pcount, struct db_salt *salt) { int count = *pcount; int index = 0; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { int x, i, n, n_key, ml; char mac1[32] = { 0 }; char t1[32] = { 0 }; unsigned char key[32]; unsigned char m[MAX_SALT_SIZE + HASH_OUTPUT_SIZE + 32]; unsigned char *t1f = mem_alloc(HASH_OUTPUT_SIZE * cur_salt->mfact); unsigned char *h_out = (unsigned char*)crypt_out[index]; unsigned char plaint[16]; AES_KEY akey; unsigned char zeroiv[16]; unsigned char dh[8]; ml = cur_salt->length; memset(key, 0, sizeof(key)); memcpy(m, cur_salt->salt, ml); // get des hash get_des_hash(saved_key[index], dh); // k1 // kdf for (n = 0; n < cur_salt->mfact; n++) { JTR_hmac_sha256(dh, 8, m, ml, h_out, HASH_OUTPUT_SIZE); ml = 32; memcpy(t1, h_out, HASH_OUTPUT_SIZE); for (x = 0; x < (cur_salt->rfact*100)-1 ; x++) { memcpy(mac1, h_out, HASH_OUTPUT_SIZE); JTR_hmac_sha256(dh, 8, h_out, ml, h_out, HASH_OUTPUT_SIZE); for (i = 0; i < HASH_OUTPUT_SIZE; i++) t1[i] ^= h_out[i]; } memcpy(m, mac1, 16); memcpy(m+16, t1, HASH_OUTPUT_SIZE); memcpy(m+48, "\x00\x00\x00\x01", 4); ml = 52; memcpy(t1f+(n*HASH_OUTPUT_SIZE), t1, HASH_OUTPUT_SIZE); } memcpy(key, t1, 32); for (n = 0; n < cur_salt->mfact; n++) { n_key = (((uint32_t)key[30] << 8) | key[31]) & (cur_salt->mfact - 1); memcpy(m, t1f + (n_key * HASH_OUTPUT_SIZE), HASH_OUTPUT_SIZE); memcpy(m + HASH_OUTPUT_SIZE, "\x00\x00\x00\x01", 4); JTR_hmac_sha256(key, HASH_OUTPUT_SIZE, m, HASH_OUTPUT_SIZE + 4, h_out, HASH_OUTPUT_SIZE); memcpy(t1f + (n*HASH_OUTPUT_SIZE), h_out, HASH_OUTPUT_SIZE); memcpy(key, h_out, HASH_OUTPUT_SIZE); } memcpy(t1f + (HASH_OUTPUT_SIZE * (cur_salt->mfact-1)), "\x00\x00\x00\x01", 4); ml = (HASH_OUTPUT_SIZE * (cur_salt->mfact-1))+4; JTR_hmac_sha256(key, HASH_OUTPUT_SIZE, t1f, ml, h_out, HASH_OUTPUT_SIZE); ml = 32; memcpy(t1, h_out, HASH_OUTPUT_SIZE); for (x = 0; x < (cur_salt->rfact*100)-1; x++) { JTR_hmac_sha256(key, HASH_OUTPUT_SIZE, h_out, ml, h_out, HASH_OUTPUT_SIZE); for (i = 0; i < HASH_OUTPUT_SIZE; i++) t1[i] ^= h_out[i]; } memcpy(h_out, t1, HASH_OUTPUT_SIZE); // encrypt user name memset(plaint, '\x00', sizeof(plaint)); memcpy(plaint, cur_salt->userid, 8); memset(zeroiv, 0, 16); AES_set_encrypt_key((unsigned char*)crypt_out[index], 256, &akey); AES_cbc_encrypt(plaint, (unsigned char*)crypt_out[index], 16, &akey, zeroiv, AES_ENCRYPT); MEM_FREE(t1f); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/o5logon_fmt_plug.c
#pragma omp parallel for
100
ny_cracked) { memset(cracked, 0, sizeof(*cracked) * count); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char key[24]; unsigned char iv[16]; SHA_CTX ctx; SHA1_Init(&ctx); SHA1_Update(&ctx, saved_key[index], saved_len[index]); SHA1_Update(&ctx, cur_salt->salt, 10); SHA1_Final(key, &ctx); memset(key + 20, 0, 4); if (cur_salt->pw_len) { int i; unsigned char s_secret[48]; unsigned char c_secret[48]; unsigned char combined_sk[24]; unsigned char final_key[32]; unsigned char password[16 + PLAINTEXT_LENGTH + 16]; char *dec_pw = (char*)password + 16; int blen = (saved_len[index] + 15) / 16; MD5_CTX ctx; if (cur_salt->pw_len == blen) { memset(iv, 0, 16); aesDec(cur_salt->ct, s_secret, key, 3, iv); memset(iv, 0, 16); aesDec(cur_salt->csk, c_secret, key, 3, iv); for (i = 0; i < 24; i++) combined_sk[i] = s_secret[16 + i] ^ c_secret[16 + i]; MD5_Init(&ctx); MD5_Update(&ctx, combined_sk, 16); MD5_Final(final_key, &ctx); MD5_Init(&ctx); MD5_Update(&ctx, combined_sk + 16, 8); MD5_Final(final_key + 16, &ctx); memset(iv, 0, 16); aesDec(cur_salt->pw, password, final_key, cur_salt->pw_len + 1, iv); if (!memcmp(dec_pw, saved_key[index], saved_len[index])) { char *p = dec_pw + 16 * blen - 1; int n, pad; int res = 1; n = pad = *p; while (n--) { if (*p-- != pad) { res = 0; break; } } if (res) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } } } else { unsigned char pt[16]; memcpy(iv, cur_salt->ct + 16, 16); aesDec(cur_salt->ct + 32, pt, key, 1, iv); if (!memcmp(pt + 8, "\x08\x08\x08\x08\x08\x08\x08\x08", 8)) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/opencl_diskcryptor_fmt_plug.c
#pragma omp parallel for
100
NULL, multi_profilingEvent[3]), "Copy result back"); if (!ocl_autotune_running) { #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { uint64_t u[8]; unsigned char static_privkey[64]; int j, success; memcpy(u, host_crack[index].hash, 64); for (j = 0; j < 8; j++) u[j] = JOHNSWAP64(u[j]); memcpy(static_privkey, u, 64); success = diskcryptor_decrypt_data(static_privkey, cur_salt); if (success) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/iwork_fmt_plug.c
#pragma omp parallel for
100
= *pcount; int index = 0; memset(cracked, 0, sizeof(cracked[0])*cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char master[MIN_KEYS_PER_CRYPT][16]; int i; #ifdef SIMD_COEF_32 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = master[i]; } pbkdf2_sha1_sse((const unsigned char**)pin, lens, fctx->salt, fctx->salt_length, fctx->iterations, pout, 16, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha1((unsigned char *)saved_key[index+i], strlen(saved_key[index+i]), fctx->salt, fctx->salt_length, fctx->iterations, master[i], 16, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { cracked[index+i] = iwork_decrypt(fctx, master[i], fctx->iv, fctx->blob); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawMD5flat_fmt_plug.c
#pragma omp parallel for
100
= 0; #ifdef SIMD_COEF_32 const int inc = NBKEYS; #else const int inc = 1; #endif #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += inc) { #if SIMD_COEF_32 SIMDmd5body(saved_key[index], crypt_key[index/NBKEYS], NULL, SSEi_FLAT_IN); #else MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], strlen(saved_key[index])); MD5_Final((unsigned char *)crypt_key[index], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/nukedclan_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char pass[40+1]; unsigned char out[80]; int i, k; int idx = 0; MD5_CTX c; SHA_CTX ctx; SHA1_Init(&ctx); SHA1_Update(&ctx, saved_key[index], strlen(saved_key[index])); SHA1_Final(out, &ctx); hex_encode(out, 20, pass); for (i = 0, k=cur_salt->decal; i < 40; ++i, ++k) { out[idx++] = pass[i]; if (k>19) k = 0; out[idx++] = cur_salt->HASHKEY[k]; } MD5_Init(&c); MD5_Update(&c, out, 80); MD5_Final((unsigned char*)crypt_out[index], &c); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rar5_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SSE_GROUP_SZ_SHA256 int lens[SSE_GROUP_SZ_SHA256], i, j; unsigned char PswCheck[SIZE_PSWCHECK], PswCheckValue[SSE_GROUP_SZ_SHA256][SHA256_DIGEST_SIZE]; unsigned char *pin[SSE_GROUP_SZ_SHA256]; union { uint32_t *pout[SSE_GROUP_SZ_SHA256]; unsigned char *poutc; } x; for (i = 0; i < SSE_GROUP_SZ_SHA256; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; x.pout[i] = (uint32_t*)PswCheckValue[i]; } pbkdf2_sha256_sse((const unsigned char **)pin, lens, cur_salt->salt, SIZE_SALT50, cur_salt->iterations+32, &(x.poutc), SHA256_DIGEST_SIZE, 0); // special wtf processing for (j = 0; j < SSE_GROUP_SZ_SHA256; ++j) { memset(PswCheck, 0, sizeof(PswCheck)); for (i = 0; i < SHA256_DIGEST_SIZE; i++) PswCheck[i % SIZE_PSWCHECK] ^= PswCheckValue[j][i]; memcpy((void*)crypt_out[index+j], PswCheck, SIZE_PSWCHECK); } #else unsigned char PswCheckValue[SHA256_DIGEST_SIZE]; unsigned char PswCheck[SIZE_PSWCHECK]; int i; pbkdf2_sha256((unsigned char*)saved_key[index], strlen(saved_key[index]), cur_salt->salt, SIZE_SALT50, cur_salt->iterations+32, PswCheckValue, SHA256_DIGEST_SIZE, 0); // special wtf processing memset(PswCheck, 0, sizeof(PswCheck)); for (i = 0; i < SHA256_DIGEST_SIZE; i++) PswCheck[i % SIZE_PSWCHECK] ^= PswCheckValue[i]; memcpy((void*)crypt_out[index], PswCheck, SIZE_PSWCHECK); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/encdatavault_md5_fmt_plug.c
#pragma omp parallel for
100
0, cracked_size); any_cracked = 0; } nb_keys = 1 << (cur_salt->algo_id - 1); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_MD5_CRYPT) { int i, j; MD5_CTX ctx; buffer_128 kdf_out[MIN_KEYS_PER_MD5_CRYPT][ENC_MAX_KEY_NUM]; buffer_128 hash; buffer_128 tmp; buffer_128 ivs[ENC_MAX_KEY_NUM]; unsigned char result[ENC_KEY_SIZE * ENC_MAX_KEY_NUM] = { 0 }; // Key derivation based on MD5 for (i = 0; i < MIN_KEYS_PER_MD5_CRYPT; ++i) { tmp.u64[0] = 0; tmp.u64[1] = 0; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index + i], strlen(saved_key[index + i])); MD5_Final(hash.u8, &ctx); for (j = 0; j < ENC_MAX_KEY_NUM; j++) { memcpy(kdf_out[i][j].u8, default_salts[j], ENC_SALT_SIZE); } for (j = 1; j < ENC_DEFAULT_MD5_ITERATIONS; j++) { MD5_Init(&ctx); MD5_Update(&ctx, hash.u8, 16); MD5_Final(hash.u8, &ctx); enc_xor_block(tmp.u64, hash.u64); } for (j = 0; j < ENC_MAX_KEY_NUM; j++) { enc_xor_block(kdf_out[i][j].u64, tmp.u64); } } /* AES iterated CTR */ for (i = 0; i < MIN_KEYS_PER_MD5_CRYPT; ++i) { if ((cur_salt->version & 0x0f) == 1) { memcpy(ivs[0].u8, cur_salt->iv, ENC_NONCE_SIZE); for (j = 1; j < nb_keys; j++) { memcpy(ivs[j].u8, cur_salt->iv, ENC_NONCE_SIZE); ivs[j].u64[0] ^= kdf_out[i][j].u64[0]; } // result buffer is used here to hold the decrypted data. enc_aes_ctr_iterated(cur_salt->encrypted_data, result, kdf_out[i][0].u8, ivs, AES_BLOCK_SIZE, nb_keys, 1); if (!memcmp(result + 4, "\xd2\xc3\xb4\xa1\x00\x00", MIN(cur_salt->encrypted_data_length, ENC_SIG_SIZE - 2))) { cracked[index + i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } else { // Decrypt keychain ivs[0].u64[0] = 0; for (j = 1; j < ENC_MAX_KEY_NUM; j++) { ivs[j].u64[0] = kdf_out[i][ENC_MAX_KEY_NUM - j].u64[0]; } // result buffer is used for the decrypted keys from the keychain enc_aes_ctr_iterated(cur_salt->keychain, result, kdf_out[i][0].u8, ivs, ENC_KEYCHAIN_SIZE, ENC_MAX_KEY_NUM, 0); // Decrypt data memcpy(ivs[0].u8, cur_salt->iv, ENC_NONCE_SIZE); for (j = 1; j < nb_keys; j++) { memcpy(ivs[j].u8, cur_salt->iv, ENC_NONCE_SIZE); memcpy(tmp.u8, result + j * 16, ENC_NONCE_SIZE); ivs[j].u64[0] ^= tmp.u64[0]; } // result buffer is reused here to hold the decrypted data. enc_aes_ctr_iterated(cur_salt->encrypted_data, result, result, ivs, AES_BLOCK_SIZE, nb_keys, 1); if (!memcmp(result + 4, "\xd2\xc3\xb4\xa1\x00\x00", MIN(cur_salt->encrypted_data_length, ENC_SIG_SIZE - 2))) { cracked[index + i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/openbsdsoftraid_fmt_plug.c
#pragma omp parallel for
100
ypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { AES_KEY akey; unsigned char mask_key[MIN_KEYS_PER_CRYPT][32]; unsigned char unmasked_keys[OPENBSD_SOFTRAID_KEYLENGTH * OPENBSD_SOFTRAID_KEYS]; unsigned char hashed_mask_key[20]; int i, j; /* derive masking key from password */ if (cur_salt->kdf_type == 1) { #ifdef SSE_GROUP_SZ_SHA1 int lens[SSE_GROUP_SZ_SHA1]; unsigned char *pin[SSE_GROUP_SZ_SHA1], *pout[SSE_GROUP_SZ_SHA1]; for (i = 0; i < SSE_GROUP_SZ_SHA1; ++i) { lens[i] = strlen(key_buffer[index+i]); pin[i] = (unsigned char*)key_buffer[index+i]; pout[i] = mask_key[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, cur_salt->salt, OPENBSD_SOFTRAID_SALTLENGTH, cur_salt->num_iterations, (unsigned char**)pout, 32, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { pbkdf2_sha1((const unsigned char*)(key_buffer[index+i]), strlen(key_buffer[index+i]), cur_salt->salt, OPENBSD_SOFTRAID_SALTLENGTH, cur_salt->num_iterations, mask_key[i], 32, 0); } } else if (cur_salt->kdf_type == 3) { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { bcrypt_pbkdf((const char*)key_buffer[index+i], strlen(key_buffer[index+i]), cur_salt->salt, OPENBSD_SOFTRAID_SALTLENGTH, mask_key[i], 32, cur_salt->num_iterations); } } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { /* decrypt sector keys */ AES_set_decrypt_key(mask_key[i], 256, &akey); for (j = 0; j < (OPENBSD_SOFTRAID_KEYLENGTH * OPENBSD_SOFTRAID_KEYS) / 16; j++) { AES_decrypt(&cur_salt->masked_keys[16*j], &unmasked_keys[16*j], &akey); } /* get SHA1 of mask_key */ SHA_CTX ctx; SHA1_Init(&ctx); SHA1_Update(&ctx, mask_key[i], 32); SHA1_Final(hashed_mask_key, &ctx); hmac_sha1(hashed_mask_key, OPENBSD_SOFTRAID_MACLENGTH, unmasked_keys, OPENBSD_SOFTRAID_KEYLENGTH * OPENBSD_SOFTRAID_KEYS, (unsigned char*)crypt_out[index+i], 20); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/axcrypt_fmt_plug.c
#pragma omp parallel for
100
= 0; if (any_cracked) { memset(cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { /* * NUMBER_AES_BLOCKS = 2 * AES_BLOCK_SIZE = 16 */ unsigned char KEK[32]; AES_KEY akey; int i; if (cur_salt->version == 1) { // See axcrypt/AxCryptCommon/CAes.cpp (CAesWrap::UnWrap) and axcrypt/AxCrypt/CSha1.cpp (CSha1::GetKeyHash) // from AxCrypt-1.7.3180.0-Source.zip file. V1KeyWrap1HeaderBlock.cs, V1KeyWrap1HeaderBlock.cs and // V1AxCryptDocument.cs from https://bitbucket.org/axantum/axcrypt-net are also relevant. union { unsigned char b[16]; uint32_t w[4]; } lsb; union { unsigned char b[16]; uint32_t w[4]; } cipher; for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) { SHA_CTX ctx; int k, j, nb_iterations = cur_salt->key_wrapping_rounds; SHA1_Init(&ctx); SHA1_Update(&ctx, (unsigned char *)saved_key[index+i], strlen(saved_key[index+i])); /* if key-file provided */ if (cur_salt->keyfile != NULL) SHA1_Update(&ctx, (unsigned char *) cur_salt->keyfile, strlen(cur_salt->keyfile)); SHA1_Final(KEK, &ctx); /* hash XOR salt => KEK */ for (k = 0; k < 16; k++) KEK[k] ^= cur_salt->salt[k]; memcpy(lsb.b, cur_salt->wrappedkey + 8, 16); AES_set_decrypt_key(KEK, 128, &akey); /* set msb */ memcpy(cipher.b, cur_salt->wrappedkey, 8); /* custom AES un-wrapping loop */ for (j = nb_iterations - 1; j >= 0; j--) { /* 1st block treatment */ /* MSB XOR (NUMBER_AES_BLOCKS * j + i) */ PUT_64BITS_XOR_MSB(cipher.b, 2 * j + 2); /* R[i] */ cipher.w[2] = lsb.w[2]; cipher.w[3] = lsb.w[3]; /* AES_ECB(KEK, (MSB XOR (NUMBER_AES_BLOCKS * j + i)) | R[i]) */ AES_decrypt(cipher.b, cipher.b, &akey); lsb.w[2] = cipher.w[2]; lsb.w[3] = cipher.w[3]; /* 2nd block treatment */ PUT_64BITS_XOR_MSB(cipher.b, 2 * j + 1); cipher.w[2] = lsb.w[0]; cipher.w[3] = lsb.w[1]; AES_decrypt(cipher.b, cipher.b, &akey); lsb.w[0] = cipher.w[2]; lsb.w[1] = cipher.w[3]; } if (!memcmp(cipher.b, AES_WRAPPING_IV, 8)) { cracked[index+i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } } else if (cur_salt->version == 2) { // See V2AxCryptDocument.cs for internal crypto details unsigned char seed[MIN_KEYS_PER_CRYPT][64]; int i; #ifdef SIMD_COEF_64 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = seed[i]; } pbkdf2_sha512_sse((const unsigned char**)pin, lens, cur_salt->deriv_salt, 32, cur_salt->deriv_iterations, pout, 64, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha512((unsigned char*)saved_key[index+i], strlen(saved_key[index+i]), cur_salt->deriv_salt, 32, cur_salt->deriv_iterations, seed[i], 64, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) { int k, j, nb_iterations = cur_salt->key_wrapping_rounds; int halfblocklen = 16 / 2; int wrappedkeylen = 56 - halfblocklen; unsigned char wrapped[144]; unsigned char block[16]; int t; /* ByteArrayExtensions -> Reduce */ memset(KEK, 0, 32); for (k = 0; k < 64 ; k++) KEK[k % 32] ^= seed[i][k]; /* hash XOR salt => KEK */ for (k = 0; k < 32; k++) KEK[k] = KEK[k] ^ cur_salt->salt[k]; AES_set_decrypt_key(KEK, 256, &akey); memcpy(wrapped, cur_salt->wrappedkey, 56); /* custom AES un-wrapping loop */ for (j = nb_iterations - 1; j >= 0; j--) { for (k = wrappedkeylen / halfblocklen; k >= 1; --k) { t = ((wrappedkeylen / halfblocklen) * j) + k; // MSB(B) = A XOR t memcpy(block, wrapped, halfblocklen); PUT_64BITS_XOR_LSB(block, t); // LSB(B) = R[i] memcpy(block + halfblocklen, wrapped + k * halfblocklen, halfblocklen); // B = AESD(K, X xor t | R[i]) where t = (n * j) + i AES_decrypt(block, block, &akey); // A = MSB(B) memcpy(wrapped, block, halfblocklen); // R[i] = LSB(B) memcpy(wrapped + k * halfblocklen, block + halfblocklen, halfblocklen); } } if (!memcmp(wrapped, AES_WRAPPING_IV, 8)) { cracked[index+i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/kwallet_fmt_plug.c
#pragma omp parallel for
100
pt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char key[MIN_KEYS_PER_CRYPT][56]; /* 56 seems to be the max. key size */ int key_size[MIN_KEYS_PER_CRYPT]; int i; if (cur_salt->kwallet_minor_version == 0) { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { password2hash(saved_key[index+i], key[i], &key_size[i]); cracked[index+i] = !verify_key(key[i], key_size[i]); } } else if (cur_salt->kwallet_minor_version == 1) { #ifdef SIMD_COEF_64 int len[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { len[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = key[i]; } pbkdf2_sha512_sse((const unsigned char **)pin, len, cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, pout, 56, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { pbkdf2_sha512((const unsigned char*)(saved_key[index+i]), strlen(saved_key[index+i]), cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, key[i], 56, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) cracked[index+i] = !verify_key(key[i], 56); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>