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/pkzip_fmt_plug.c
#pragma omp parallel for private(idx)
100
y globbing many tests into a threads working set will flatten out these differences. #ifdef _OPENMP <LOOP-START>for (idx = 0; idx < _count; ++idx) { int cur_hash_count = salt->cnt; int cur_hash_idx = -1; MY_WORD key0, key1, key2; u8 C; const u8 *b; u8 curDecryBuf[256]; #if USE_PKZIP_MAGIC u8 curInfBuf[128]; int k, SigChecked; u16 e, v1, v2; z_stream strm; int ret; /* use the pwkey for each hash. We mangle on the 12 bytes of IV to what was computed in the pwkey load. */ if (dirty) { u8 *p = (u8*)saved_key[idx]; /* load the 'pwkey' one time, put it into the K12 array */ key0.u = 0x12345678UL; key1.u = 0x23456789UL; key2.u = 0x34567890UL; do { key0.u = jtr_crc32 (key0.u, *p++); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); } while (*p); K12[idx*3] = key0.u, K12[idx*3+1] = key1.u, K12[idx*3+2] = key2.u; goto SkipKeyLoadInit; } do { // 2nd, and later times through the loop, AND if keys are not dirty (i.e. multiple salts // for the same key load), we do NOT perform the key compute, but instead load the pre-computed // key data from the array. key0.u = K12[idx*3], key1.u = K12[idx*3+1], key2.u = K12[idx*3+2]; SkipKeyLoadInit:; b = salt->H[++cur_hash_idx].h; k=11; e = salt->H[cur_hash_idx].c; do { C = PKZ_MULT(*b++,key2); key0.u = jtr_crc32 (key0.u, C); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); } while(--k); if (salt->H[cur_hash_idx].type == 2) { u16 e2 = salt->H[cur_hash_idx].c2; if (salt->chk_bytes == 2 && C != (e & 0xff) && C != (e2 & 0xff)) goto Failed_Bailout; C = PKZ_MULT(*b++, key2); if (C != (e >> 8) && C != (e2 >> 8)) goto Failed_Bailout; } else { if (salt->chk_bytes == 2 && C != (e & 0xff)) goto Failed_Bailout; C = PKZ_MULT(*b++, key2); if (C != (e >> 8)) goto Failed_Bailout; } // Now, update the key data (with that last byte. key0.u = jtr_crc32 (key0.u, C); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); // Ok, we now have validated this checksum. We need to 'do some' extra pkzip validation work. // What we do here, is to decrypt a little data (possibly only 1 byte), and perform a single // 'inflate' check (if type is 8). If type is 0 (stored), and we have a signature check, then // we do that here. Also, if the inflate code is a 0 (stored block), and we do sig check, then // we can do that WITHOUT having to call inflate. however, if there IS a sig check, we will have // to call inflate on 'some' data, to get a few bytes (or error code). Also, if this is a type // 2 or 3, then we do the FULL inflate, CRC check here. e = 0; // First, we want to get the inflate CODE byte (the first one). C = PKZ_MULT(*b++,key2); SigChecked = 0; if (salt->H[cur_hash_idx].compType == 0) { // handle a stored file. // We can ONLY deal with these IF we are handling 'magic' testing. #if USE_PKZIP_MAGIC // Ok, if we have a signature, check it here, WITHOUT having to call zLib's inflate. if (salt->H[cur_hash_idx].pSig->max_len) { int len = salt->H[cur_hash_idx].pSig->max_len; if (len > salt->H[cur_hash_idx].datlen-12) len = salt->H[cur_hash_idx].datlen-12; SigChecked = 1; curDecryBuf[0] = C; for (; e < len;) { key0.u = jtr_crc32 (key0.u, curDecryBuf[e]); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); curDecryBuf[++e] = PKZ_MULT(*b++,key2); } if (salt->H[cur_hash_idx].magic == 255) { if (!validate_ascii(&curDecryBuf[5], len-5)) goto Failed_Bailout; } else { if (!CheckSigs(curDecryBuf, len, salt->H[cur_hash_idx].pSig)) goto Failed_Bailout; } } continue; } #if 1 // https://github.com/openwall/john/issues/467 // Ok, if this is a code 3, we are done. // Code moved to after the check for stored type. (FIXED) This check was INVALID for a stored type file. if ((C & 6) == 6) goto Failed_Bailout; if ((C & 6) == 0) { // Check that checksum2 is 0 or 1. If not, I 'think' we can be done if (C > 1) goto Failed_Bailout; // now get 4 bytes. This is the length. It is made up of 2 16 bit values. // these 2 values are checksumed, so it is easy to tell if the data is WRONG. // correct data is u16_1 == (u16_2^0xFFFF) curDecryBuf[0] = C; for (e = 0; e <= 4;) { key0.u = jtr_crc32 (key0.u, curDecryBuf[e]); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); curDecryBuf[++e] = PKZ_MULT(*b++,key2); } v1 = curDecryBuf[1] | (((u16)curDecryBuf[2])<<8); v2 = curDecryBuf[3] | (((u16)curDecryBuf[4])<<8); if (v1 != (v2^0xFFFF)) goto Failed_Bailout; #if USE_PKZIP_MAGIC // Ok, if we have a signature, check it here, WITHOUT having to call zLib's inflate. if (salt->H[cur_hash_idx].pSig->max_len) { int len = salt->H[cur_hash_idx].pSig->max_len + 5; if (len > salt->H[cur_hash_idx].datlen-12) len = salt->H[cur_hash_idx].datlen-12; SigChecked = 1; for (; e < len;) { key0.u = jtr_crc32 (key0.u, curDecryBuf[e]); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); curDecryBuf[++e] = PKZ_MULT(*b++,key2); } if (salt->H[cur_hash_idx].magic == 255) { if (!validate_ascii(&curDecryBuf[5], len-5)) goto Failed_Bailout; } else { if (!CheckSigs(&curDecryBuf[5], len-5, salt->H[cur_hash_idx].pSig)) goto Failed_Bailout; } } } else { // Ok, now we have handled inflate code type 3 and inflate code 0 (50% of 'random' data) // We now have the 2 'hard' ones left (fixed table, and variable table) curDecryBuf[0] = C; if ((C & 6) == 4) { // inflate 'code' 2 (variable table) #if (ZIP_DEBUG==2) static unsigned count, found; ++count; // we need 4 bytes, + 2, + 4 at most. for (; e < 10;) { key0.u = jtr_crc32 (key0.u, curDecryBuf[e]); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); curDecryBuf[++e] = PKZ_MULT(*b++,key2); } if (!check_inflate_CODE2(curDecryBuf)) goto Failed_Bailout; #if (ZIP_DEBUG==2) fprintf(stderr, "CODE2 Pass=%s count = %u, found = %u\n", saved_key[idx], count, ++found); } else { int til; #if (ZIP_DEBUG==2) static unsigned count, found; ++count; til = 36; if (salt->H[cur_hash_idx].datlen-12 < til) til = salt->H[cur_hash_idx].datlen-12; for (; e < til;) { key0.u = jtr_crc32 (key0.u, curDecryBuf[e]); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); curDecryBuf[++e] = PKZ_MULT(*b++,key2); } if (!check_inflate_CODE1(curDecryBuf, til)) goto Failed_Bailout; #if (ZIP_DEBUG==2) fprintf(stderr, "CODE1 Pass=%s count = %u, found = %u\n", saved_key[idx], count, ++found); } } #if USE_PKZIP_MAGIC // Ok, now see if we need to check sigs, or do a FULL inflate/crc check. if (!SigChecked && salt->H[cur_hash_idx].pSig->max_len) { int til = 180; if (salt->H[cur_hash_idx].datlen-12 < til) til = salt->H[cur_hash_idx].datlen-12; for (; e < til;) { key0.u = jtr_crc32 (key0.u, curDecryBuf[e]); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); curDecryBuf[++e] = PKZ_MULT(*b++,key2); } strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.next_in = Z_NULL; strm.avail_in = til; ret = inflateInit2(&strm, -15); /* 'raw', since we do not have gzip header, or gzip crc. .ZIP files are 'raw' implode data. */ if (ret != Z_OK) perror("Error, initializing the libz inflateInit2() system\n"); strm.next_in = curDecryBuf; strm.avail_out = sizeof(curInfBuf); strm.next_out = curInfBuf; ret = inflate(&strm, Z_SYNC_FLUSH); inflateEnd(&strm); if (ret != Z_OK) { // we need to handle zips smaller than sizeof curInfBuf. If we find a zip of this // size, the return is Z_STREAM_END, BUT things are fine. if (ret == Z_STREAM_END && salt->deCompLen == strm.total_out) ; // things are ok. else goto Failed_Bailout; } if (!strm.total_out) goto Failed_Bailout; ret = salt->H[cur_hash_idx].pSig->max_len; if (salt->H[cur_hash_idx].magic == 255) { if (!validate_ascii(curInfBuf, strm.total_out)) goto Failed_Bailout; } else { if (strm.total_out < ret) goto Failed_Bailout; if (!CheckSigs(curInfBuf, strm.total_out, salt->H[cur_hash_idx].pSig)) goto Failed_Bailout; } } if (salt->H[cur_hash_idx].full_zip) { u8 inflateBufTmp[1024]; if (salt->compLen > 240 && salt->H[cur_hash_idx].datlen >= 200) { for (;e < 200;) { key0.u = jtr_crc32 (key0.u, curDecryBuf[e]); key1.u = (key1.u + key0.c[KB1]) * 134775813 + 1; key2.u = jtr_crc32 (key2.u, key1.c[KB2]); curDecryBuf[++e] = PKZ_MULT(*b++,key2); } strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.next_in = Z_NULL; strm.avail_in = e; ret = inflateInit2(&strm, -15); /* 'raw', since we do not have gzip header, or gzip crc. .ZIP files are 'raw' implode data. */ if (ret != Z_OK) perror("Error, initializing the libz inflateInit2() system\n"); strm.next_in = curDecryBuf; strm.avail_out = sizeof(inflateBufTmp); strm.next_out = inflateBufTmp; ret = inflate(&strm, Z_SYNC_FLUSH); inflateEnd(&strm); if (ret != Z_OK) { #if (ZIP_DEBUG==2) fprintf(stderr, "fail=%d fail2=%d tot="LLd"\n", ++FAILED, FAILED2, ((long long)CNT)*_count); goto Failed_Bailout; } } goto KnownSuccess; } } while(--cur_hash_count); /* We got a checksum HIT!!!! All hash checksums matched. */ /* We load the proper checksum value for the gethash */ KnownSuccess: ; chk[idx] = 1; continue; Failed_Bailout: ; /* We load the wrong checksum value for the gethash */ chk[idx] = 0; }<LOOP-END> <OMP-START>#pragma omp parallel for private(idx)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/drupal7_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 unsigned char _IBuf[128*MIN_KEYS_PER_CRYPT+MEM_ALIGN_CACHE], *keys; uint64_t *keys64; unsigned i, j, len; keys = (unsigned char*)mem_align(_IBuf, MEM_ALIGN_CACHE); keys64 = (uint64_t*)keys; memset(keys, 0, 128*MIN_KEYS_PER_CRYPT); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { len = EncKeyLen[index+i]; for (j = 0; j < 8; ++j) keys[GETPOS(j, i)] = cursalt[j]; for (j = 0; j < len; ++j) keys[GETPOS(j+8, i)] = EncKey[index+i][j]; keys[GETPOS(j+8, i)] = 0x80; keys64[15*SIMD_COEF_64+(i&(SIMD_COEF_64-1))+i/SIMD_COEF_64*SHA_BUF_SIZ*SIMD_COEF_64] = (len+8) << 3; } SIMDSHA512body(keys, keys64, NULL, SSEi_MIXED_IN|SSEi_OUTPUT_AS_INP_FMT); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { len = EncKeyLen[index+i]; for (j = 0; j < len; ++j) keys[GETPOS(j+64, i)] = EncKey[index+i][j]; keys[GETPOS(j+64, i)] = 0x80; keys64[15*SIMD_COEF_64+(i&(SIMD_COEF_64-1))+i/SIMD_COEF_64*SHA_BUF_SIZ*SIMD_COEF_64] = (len+64) << 3; } uint64_t Lcount = loopCnt - 1; SIMDSHA512body(keys, keys64, &Lcount, SSEi_MIXED_IN|SSEi_LOOP|SSEi_OUTPUT_AS_INP_FMT); // Last one with FLAT_OUT SIMDSHA512body(keys, (uint64_t*)crypt_key[index], NULL, SSEi_MIXED_IN|SSEi_FLAT_OUT); #else SHA512_CTX ctx; unsigned char tmp[DIGEST_SIZE + PLAINTEXT_LENGTH]; int len = EncKeyLen[index]; unsigned Lcount = loopCnt - 1; SHA512_Init( &ctx ); SHA512_Update( &ctx, cursalt, 8 ); SHA512_Update( &ctx, EncKey[index], len ); memcpy(&tmp[DIGEST_SIZE], (char *)EncKey[index], len); SHA512_Final( tmp, &ctx); len += DIGEST_SIZE; do { SHA512_Init( &ctx ); SHA512_Update( &ctx, tmp, len); SHA512_Final( tmp, &ctx); } while (--Lcount); SHA512_Init( &ctx ); SHA512_Update( &ctx, tmp, len); SHA512_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/rawmd5u_fmt_plug.c
#pragma omp parallel for
100
OCK_LOOPS), // cause it does not scale well. We would need to parallelize set_key() #ifdef _OPENMP <LOOP-START>for (i = 0; i < BLOCK_LOOPS; i++) SIMDmd5body(&saved_key[i*NBKEYS*64], (unsigned int*)&crypt_key[i*NBKEYS*BINARY_SIZE], NULL, SSEi_MIXED_IN); #else SIMDmd5body(saved_key, (unsigned int*)crypt_key, NULL, SSEi_MIXED_IN); #else MD5_Init( &ctx ); MD5_Update(&ctx, (unsigned char*)saved_key, saved_len); MD5_Final((unsigned char*) crypt_key, &ctx); return count; } #define COMMON_GET_HASH_SIMD32 4 #define COMMON_GET_HASH_VAR crypt_key #include "common-get-hash.h" struct fmt_main fmt_rawmd5uthick = { { FORMAT_LABEL, FORMAT_NAME, ALGORITHM_NAME, BENCHMARK_COMMENT, BENCHMARK_LENGTH, 0, PLAINTEXT_LENGTH, BINARY_SIZE, BINARY_ALIGN, SALT_SIZE, SALT_ALIGN, MIN_KEYS_PER_CRYPT, MAX_KEYS_PER_CRYPT, #if (BLOCK_LOOPS > 1) && defined(SSE_MD5_PARA) FMT_OMP | FMT_CASE | FMT_8_BIT | FMT_UNICODE | FMT_ENC | FMT_SPLIT_UNIFIES_CASE, { NULL }, { NULL }, tests }, { init, done, fmt_default_reset, fmt_default_prepare, valid, split, get_binary, fmt_default_salt, { NULL }, fmt_default_source, { fmt_default_binary_hash_0, fmt_default_binary_hash_1, fmt_default_binary_hash_2, fmt_default_binary_hash_3, fmt_default_binary_hash_4, fmt_default_binary_hash_5, fmt_default_binary_hash_6 }, fmt_default_salt_hash, NULL, fmt_default_set_salt, set_key, get_key, fmt_default_clear_keys, crypt_all, { #define COMMON_GET_HASH_LINK #include "common-get-hash.h" }, cmp_all, cmp_one, cmp_exact } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/skein_fmt_plug.c
#pragma omp parallel for
100
nt crypt_256(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_skein256_context ctx; sph_skein256_init(&ctx); sph_skein256(&ctx, saved_key[index], strlen(saved_key[index])); sph_skein256_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/skein_fmt_plug.c
#pragma omp parallel for
100
nt crypt_512(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_skein512_context ctx; sph_skein512_init(&ctx); sph_skein512(&ctx, saved_key[index], strlen(saved_key[index])); sph_skein512_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/bks_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 += MIN_KEYS_PER_CRYPT) { #if !defined(SIMD_COEF_32) if (cur_salt->format == 0) { unsigned char mackey[20]; int mackeylen = cur_salt->hmac_key_size / 8; // mackeylen is only 2 bytes, and this results in lot // of collisions (which work just fine) // // FMT_NOT_EXACT can be turned on for BKS keystores // for finding more possible passwords unsigned char store_hmac_calculated[20]; pkcs12_pbe_derive_key(1, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha1(mackey, mackeylen, cur_salt->store_data, cur_salt->store_data_length, store_hmac_calculated, 20); if (!memcmp(store_hmac_calculated, cur_salt->store_hmac, 20)) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } else if (cur_salt->format == 1) { unsigned char compute_checkum[20]; unsigned char iv[16]; unsigned char key[32]; Twofish_key tkey; int datalen = 0; unsigned char store_data_decrypted[MAX_STORE_DATA_LENGTH]; SHA_CTX ctx; pkcs12_pbe_derive_key(1, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_IV, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, iv, 16); pkcs12_pbe_derive_key(1, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, key, 32); Twofish_prepare_key(key, 32, &tkey); datalen = Twofish_Decrypt(&tkey, cur_salt->store_data, store_data_decrypted, cur_salt->store_data_length, iv); if (datalen < 0) continue; SHA1_Init(&ctx); SHA1_Update(&ctx, store_data_decrypted, datalen - 20); SHA1_Final(compute_checkum, &ctx); if (!memcmp(compute_checkum, store_data_decrypted + datalen - 20, 20)) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } #else size_t lens[SSE_GROUP_SZ_SHA1], j; const unsigned char *keys[SSE_GROUP_SZ_SHA1]; // Load keys, and lengths for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) { lens[j] = saved_len[index+j]; keys[j] = (const unsigned char*)(saved_key[index+j]); } if (cur_salt->format == 0) { unsigned char *mackey[SSE_GROUP_SZ_SHA1], real_keys[SSE_GROUP_SZ_SHA1][20]; int mackeylen = cur_salt->hmac_key_size / 8; // mackeylen is only 2 bytes, and this results in lot // of collisions (which work just fine) // // FMT_NOT_EXACT can be turned on for BKS keystores // for finding more possible passwords unsigned char store_hmac_calculated[20]; for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) mackey[j] = real_keys[j]; pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys, lens, cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) { hmac_sha1(mackey[j], mackeylen, cur_salt->store_data, cur_salt->store_data_length, store_hmac_calculated, 20); if (!memcmp(store_hmac_calculated, cur_salt->store_hmac, 20)) { cracked[index+j] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } } else if (cur_salt->format == 1) { unsigned char iv_[SSE_GROUP_SZ_SHA1][16], *iv[SSE_GROUP_SZ_SHA1]; unsigned char ckey_[SSE_GROUP_SZ_SHA1][32], *ckey[SSE_GROUP_SZ_SHA1]; Twofish_key tkey; int datalen = 0; unsigned char store_data_decrypted[MAX_STORE_DATA_LENGTH]; SHA_CTX ctx; for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) { iv[j] = iv_[j]; ckey[j] = ckey_[j]; } pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_IV, keys, lens, cur_salt->salt, cur_salt->saltlen, iv, 16); // lengths get tromped on, so re-load them for the load keys call. for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) lens[j] = saved_len[index+j]; pkcs12_pbe_derive_key_simd_sha1(cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_KEY, keys, lens, cur_salt->salt, cur_salt->saltlen, ckey, 32); for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) { unsigned char compute_checkum[20]; Twofish_prepare_key(ckey[j], 32, &tkey); datalen = Twofish_Decrypt(&tkey, cur_salt->store_data, store_data_decrypted, cur_salt->store_data_length, iv[j]); if (datalen < 0) continue; SHA1_Init(&ctx); SHA1_Update(&ctx, store_data_decrypted, datalen - 20); SHA1_Final(compute_checkum, &ctx); if (!memcmp(compute_checkum, store_data_decrypted + datalen - 20, 20)) { cracked[index+j] = 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/krb5_db_fmt_plug.c
#pragma omp parallel for
100
l(int *pcount, struct db_salt *_salt) { const int count = *pcount; int index = 0; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char key[32], i; AES_KEY aeskey; int key_size; if (cur_salt->etype == 18 || cur_salt->etype == 17) { #ifdef SSE_GROUP_SZ_SHA1 uint32_t Key[SSE_GROUP_SZ_SHA1][32/4]; int lens[SSE_GROUP_SZ_SHA1]; 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] = Key[i]; } if (cur_salt->etype == 18) { key_size = 32; } else { key_size = 16; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, (const unsigned char*)cur_salt->saved_salt, strlen(cur_salt->saved_salt), 4096, &(x.poutc), key_size, 0); #else if (cur_salt->etype == 18) { key_size = 32; } else { key_size = 16; } pbkdf2_sha1((const unsigned char*)saved_key[index], strlen(saved_key[index]), (const unsigned char*)cur_salt->saved_salt, strlen(cur_salt->saved_salt), 4096, key, key_size, 0); i = 0; #ifdef SSE_GROUP_SZ_SHA1 for (; i < SSE_GROUP_SZ_SHA1; ++i) { memcpy(key, Key[i], key_size); AES_set_encrypt_key(key, key_size * 8, &aeskey); AES_encrypt((unsigned char*)"kerberos{\x9b[+\x93\x13+\x93", (unsigned char*)(crypt_out[index+i]), &aeskey); // the weird constant string comes from "nfold" function AES_encrypt((unsigned char*)(crypt_out[index+i]), (unsigned char*)&crypt_out[index+i][4], &aeskey); #ifdef SSE_GROUP_SZ_SHA1 } } else if (cur_salt->etype == 3) { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { des_string_to_key_shishi(saved_key[index+i], strlen(saved_key[index+i]), cur_salt->saved_salt, strlen(cur_salt->saved_salt), (unsigned char*)(crypt_out[index+i])); } } } return count; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pem_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; #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, cur_salt->salt, SALTLEN, cur_salt->iterations, pout, cur_salt->key_length, 0); #else pbkdf2_sha1((unsigned char *)saved_key[index], strlen(saved_key[index]), cur_salt->salt, SALTLEN, cur_salt->iterations, master[0], cur_salt->key_length, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (pem_decrypt(master[i], cur_salt->iv, cur_salt->ciphertext, cur_salt) == 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/leet_cc_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 += NBKEYS) { sph_whirlpool_context wctx; int i; union { unsigned char buf[BINARY_SIZE]; uint64_t p64[1]; } output1[NBKEYS], output2; #ifdef SIMD_COEF_64 // Not sure why JTR_ALIGN(MEM_ALIGN_SIMD) does n ot work here // but if used, it cores travis-ci, so we use mem_align instead unsigned char _in[8*16*MIN_KEYS_PER_CRYPT+MEM_ALIGN_SIMD]; unsigned char _out[8*8*MIN_KEYS_PER_CRYPT+MEM_ALIGN_SIMD]; uint64_t *in = (uint64_t*)mem_align(_in, MEM_ALIGN_SIMD); uint64_t *out = (uint64_t*)mem_align(_out, MEM_ALIGN_SIMD); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { int x80_off = saved_len[index+i]+cur_salt->saltlen; unsigned char *cp = (unsigned char*)&(in[16*i]); memcpy(cp, saved_key[index+i], saved_len[index+i]); memcpy(&cp[saved_len[index+i]], cur_salt->salt, cur_salt->saltlen); cp[x80_off] = 0x80; memset(&cp[x80_off+1], 0, 120-(x80_off+1)); in[i*16+15] = x80_off<<3; } SIMDSHA512body(in, out, NULL, SSEi_FLAT_IN); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { #if ARCH_LITTLE_ENDIAN==1 output1[i].p64[0] = JOHNSWAP64(out[((i/SIMD_COEF_64)*8*SIMD_COEF_64+i%SIMD_COEF_64)]); #else output1[i].p64[0] = out[((i/SIMD_COEF_64)*8*SIMD_COEF_64+i%SIMD_COEF_64)]; } #else SHA512_CTX sctx; SHA512_Init(&sctx); SHA512_Update(&sctx, saved_key[index], saved_len[index]); SHA512_Update(&sctx, cur_salt->salt, cur_salt->saltlen); SHA512_Final(output1[0].buf, &sctx); for (i = 0; i < NBKEYS; ++i) { sph_whirlpool_init(&wctx); sph_whirlpool(&wctx, cur_salt->salt, cur_salt->saltlen); sph_whirlpool(&wctx, saved_key[index+i], saved_len[index+i]); sph_whirlpool_close(&wctx, output2.buf); crypt_out[index+i][0] = output1[i].p64[0] ^ output2.p64[0]; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/argon2_fmt_plug.c
#pragma omp parallel for
100
crypt_all(int *pcount, struct db_salt *salt) { int i; const int count = *pcount; #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { argon2_hash(saved_salt.t_cost, saved_salt.m_cost, saved_salt.lanes, saved_key[i], saved_len[i], saved_salt.salt, saved_salt.salt_length, crypted[i], saved_salt.hash_size, 0, 0, saved_salt.type, ARGON2_VERSION_NUMBER, memory[THREAD_NUMBER%sc_threads].aligned, pseudo_rands[THREAD_NUMBER%sc_threads]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/pfx_fmt_plug.c
#pragma omp parallel for
100
->mac_algo == 512 || cur_salt->mac_algo == 384) inc = SSE_GROUP_SZ_SHA512; #endif #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += inc) { #if !defined(SIMD_COEF_32) if (cur_salt->mac_algo == 1) { unsigned char mackey[20]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(cur_salt->mac_algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha1(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index], BINARY_SIZE); } else if (cur_salt->mac_algo == 256) { unsigned char mackey[32]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(cur_salt->mac_algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha256(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index], BINARY_SIZE); } else if (cur_salt->mac_algo == 512) { unsigned char mackey[64]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(cur_salt->mac_algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha512(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index], BINARY_SIZE); } else if (cur_salt->mac_algo == 224) { unsigned char mackey[32]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(cur_salt->mac_algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha224(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index], BINARY_SIZE); } else if (cur_salt->mac_algo == 384) { unsigned char mackey[64]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(cur_salt->mac_algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha384(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index], BINARY_SIZE); } #else if (cur_salt->mac_algo == 1) { unsigned char *mackey[SSE_GROUP_SZ_SHA1], real_keys[SSE_GROUP_SZ_SHA1][20]; const unsigned char *keys[SSE_GROUP_SZ_SHA1]; int mackeylen = cur_salt->key_length, j; size_t lens[SSE_GROUP_SZ_SHA1]; for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) { mackey[j] = real_keys[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, cur_salt->saltlen, mackey, mackeylen); for (j = 0; j < SSE_GROUP_SZ_SHA1; ++j) { hmac_sha1(mackey[j], mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index+j], BINARY_SIZE); } } else if (cur_salt->mac_algo == 256) { unsigned char *mackey[SSE_GROUP_SZ_SHA256], real_keys[SSE_GROUP_SZ_SHA256][32]; const unsigned char *keys[SSE_GROUP_SZ_SHA256]; int mackeylen = cur_salt->key_length, j; size_t lens[SSE_GROUP_SZ_SHA256]; for (j = 0; j < SSE_GROUP_SZ_SHA256; ++j) { mackey[j] = real_keys[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, cur_salt->saltlen, mackey, mackeylen); for (j = 0; j < SSE_GROUP_SZ_SHA256; ++j) { hmac_sha256(mackey[j], mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index+j], BINARY_SIZE); } } else if (cur_salt->mac_algo == 512) { #if defined(SIMD_COEF_64) unsigned char *mackey[SSE_GROUP_SZ_SHA512], real_keys[SSE_GROUP_SZ_SHA512][64]; const unsigned char *keys[SSE_GROUP_SZ_SHA512]; int mackeylen = cur_salt->key_length, j; size_t lens[SSE_GROUP_SZ_SHA512]; for (j = 0; j < SSE_GROUP_SZ_SHA512; ++j) { mackey[j] = real_keys[j]; lens[j] = saved_len[index+j]; keys[j] = (const unsigned char*)(saved_key[index+j]); } pkcs12_pbe_derive_key_simd_sha512(cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, keys, lens, cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); for (j = 0; j < SSE_GROUP_SZ_SHA512; ++j) { hmac_sha512(mackey[j], mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index+j], BINARY_SIZE); } #else int j; for (j = 0; j < inc; ++j) { unsigned char mackey[64]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(512, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index+j], saved_len[index+j], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha512(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index+j], BINARY_SIZE); } } else if (cur_salt->mac_algo == 224) { int j; for (j = 0; j < inc; ++j) { unsigned char mackey[32]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(cur_salt->mac_algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index+j], saved_len[index+j], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha224(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index+j], BINARY_SIZE); } } else if (cur_salt->mac_algo == 384) { int j; for (j = 0; j < inc; ++j) { unsigned char mackey[64]; int mackeylen = cur_salt->key_length; pkcs12_pbe_derive_key(cur_salt->mac_algo, cur_salt->iteration_count, MBEDTLS_PKCS12_DERIVE_MAC_KEY, (unsigned char*)saved_key[index+j], saved_len[index+j], cur_salt->salt, cur_salt->saltlen, mackey, mackeylen); hmac_sha384(mackey, mackeylen, cur_salt->data, cur_salt->data_length, (unsigned char*)crypt_out[index+j], BINARY_SIZE); } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/armory_fmt_plug.c
#pragma omp parallel for default(none) private(index) shared(count, failed, cracked, salt, max_threads, memory, saved_key, saved_salt, crypt_out)
100
, struct db_salt *salt) { int failed = 0, cracked = !salt, count = *pcount, index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef _OPENMP int t = omp_get_thread_num(); if (t >= max_threads) { failed = -1; continue; } #else const int t = 0; errno = 0; derived_key dk[MIN_KEYS_PER_CRYPT]; if (derive_keys(&memory[t], index, dk)) { failed = errno ? errno : ENOMEM; #ifndef _OPENMP break; } int subindex; for (subindex = 0; subindex < MIN_KEYS_PER_CRYPT; subindex++) { derive_address(memory, &dk[subindex], crypt_out[index + subindex]); if (salt) { struct db_password *pw = salt->list; do { if (!memcmp(pw->binary, crypt_out[index + subindex], BINARY_SIZE)) cracked = -1; } while ((pw = pw->next)); } } }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(index) shared(count, failed, cracked, salt, max_threads, memory, saved_key, saved_salt, crypt_out)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/bestcrypt_fmt_plug.c
#pragma omp parallel for
100
ount = *pcount; int index; memset(cracked, 0, sizeof(cracked[0])*cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MAX_KEYS_PER_CRYPT) { if (cur_salt->hash_id == bchaWhirlpool512) { unsigned char key[kBCPasswordMaximumKeySize]; int keylen = 0; pbe_format_v5_64* pbe64; unsigned char out[256] = {0}; AES_KEY aes_key; sph_whirlpool_context ctx; unsigned char hash[64]; unsigned char iv[16] = {0}; struct KGEncryptedBlock64 *p; if (cur_salt->mode_id == kBCMode_XTS) keylen = 64; // for AES-256 XTS mode else if (cur_salt->mode_id == kBCMode_CBC) keylen = 32; pkcs12_pbe_derive_key(2, cur_salt->iterations, // 2 is a hack to indicate Whirlpool-512 MBEDTLS_PKCS12_DERIVE_KEY, // key material (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->salt_size, key, keylen); pbe64 = (pbe_format_v5_64*)cur_salt->key; memcpy(iv, pbe64->iv, 8); if (cur_salt->mode_id == kBCMode_XTS) { AES_XTS_decrypt_custom_tweak(key, iv, out, pbe64->keyblock, 256, 256); } if (cur_salt->mode_id == kBCMode_CBC) { // decrypt data stored in encrypted block, AES CBC mode memcpy(iv + 8, pbe64->iv, 8); // isn't BestCrypt great? AES_set_decrypt_key(key, 256, &aes_key); AES_cbc_encrypt(pbe64->keyblock, out, 160, &aes_key, iv, AES_DECRYPT); } sph_whirlpool_init(&ctx); sph_whirlpool(&ctx, out, 90); // only 90 bytes are used, calculate_digest(hash, data, sizeof(*data), digest), sizeof(*data) == 90 sph_whirlpool_close(&ctx, hash); p = (struct KGEncryptedBlock64 *)out; cracked[index] = (0 == memcmp(hash, p->digest, kDigestSize32)); } else if (cur_salt->hash_id == bchaSHA256) { unsigned char key[kBCPasswordMaximumKeySize]; int keylen = 0; pbe_format_v5_32* pbe32; unsigned char out[256] = {0}; AES_KEY aes_key; SHA256_CTX ctx; unsigned char hash[32]; unsigned char iv[16] = {0}; struct KGEncryptedBlock32 *p; if (cur_salt->mode_id == kBCMode_XTS) keylen = 64; else if (cur_salt->mode_id == kBCMode_CBC) keylen = 32; pkcs12_pbe_derive_key(256, cur_salt->iterations, MBEDTLS_PKCS12_DERIVE_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->salt_size, key, keylen); pbe32 = (pbe_format_v5_32*)cur_salt->key; memcpy(iv, pbe32->iv, 8); // iv[8:16] is all zero for XTS mode if (cur_salt->mode_id == kBCMode_XTS) { AES_XTS_decrypt_custom_tweak(key, iv, out, pbe32->keyblock, 256, 256); } else if (cur_salt->mode_id == kBCMode_CBC) { memcpy(iv + 8, pbe32->iv, 8); // iv[8:16] is repeat of iv[0:8] for CBC mode AES_set_decrypt_key(key, 256, &aes_key); AES_cbc_encrypt(pbe32->keyblock, out, 128, &aes_key, iv, AES_DECRYPT); } SHA256_Init(&ctx); SHA256_Update(&ctx, out, 90); SHA256_Final(hash, &ctx); p = (struct KGEncryptedBlock32 *)out; cracked[index] = (0 == memcmp(hash, p->digest, kDigestSize32)); } else if (cur_salt->hash_id == pgphaSHA512) { unsigned char key[kBCPasswordMaximumKeySize]; int keylen = 0; pbe_format_v5_64* pbe64; unsigned char out[256] = {0}; AES_KEY aes_key; SHA512_CTX ctx; unsigned char hash[64]; unsigned char iv[16] = {0}; struct KGEncryptedBlock64 *p; if (cur_salt->mode_id == kBCMode_XTS) keylen = 64; else if (cur_salt->mode_id == kBCMode_CBC) keylen = 32; pkcs12_pbe_derive_key(10, cur_salt->iterations, // 10 is a hack to indicate BestCrypt specific PKCS12 PBE with SHA-512 MBEDTLS_PKCS12_DERIVE_KEY, (unsigned char*)saved_key[index], saved_len[index], cur_salt->salt, cur_salt->salt_size, key, keylen); pbe64 = (pbe_format_v5_64*)cur_salt->key; memcpy(iv, pbe64->iv, 8); if (cur_salt->mode_id == kBCMode_XTS) { AES_XTS_decrypt_custom_tweak(key, iv, out, pbe64->keyblock, 256, 256); } else if (cur_salt->mode_id == kBCMode_CBC) { memcpy(iv + 8, pbe64->iv, 8); AES_set_decrypt_key(key, 256, &aes_key); AES_cbc_encrypt(pbe64->keyblock, out, 160, &aes_key, iv, AES_DECRYPT); } SHA512_Init(&ctx); SHA512_Update(&ctx, out, 90); SHA512_Final(hash, &ctx); p = (struct KGEncryptedBlock64 *)out; cracked[index] = (0 == memcmp(hash, p->digest, kDigestSize32)); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ssh_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 out[N]; // don't do full decryption (except for EC keys) common_crypt_code(saved_key[index], out, 0); if (cur_salt->cipher == 0) { // 3DES cracked[index] = !check_padding_and_structure(out, cur_salt->ctl, 0, 8); } else if (cur_salt->cipher == 1) { cracked[index] = !check_padding_and_structure(out, cur_salt->ctl, 0, 16); } else if (cur_salt->cipher == 2 || cur_salt->cipher == 6) { // new ssh key format handling cracked[index] = !check_structure_bcrypt(out, cur_salt->ctl); } else if (cur_salt->cipher == 3) { // EC keys cracked[index] = !check_padding_and_structure_EC(out, cur_salt->ctl, 0); } else if (cur_salt->cipher == 4) { // AES-192 cracked[index] = !check_padding_and_structure(out, cur_salt->ctl, 0, 16); } else if (cur_salt->cipher == 5) { // AES-256 cracked[index] = !check_padding_and_structure(out, cur_salt->ctl, 0, 16); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/blackberry_ES10_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 /* We use SSEi_HALF_IN, so can halve SHA_BUF_SIZ */ #undef SHA_BUF_SIZ #define SHA_BUF_SIZ 8 unsigned int i; unsigned char _IBuf[8*SHA_BUF_SIZ*MIN_KEYS_PER_CRYPT+MEM_ALIGN_CACHE], *keys; uint64_t *keys64, tmpBuf64[SHA_BUF_SIZ], *p64; 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, saved_key[index+i], strlen(saved_key[index+i])); SHA512_Update(&ctx, cur_salt->salt, strlen((char*)cur_salt->salt)); SHA512_Final((unsigned char *)tmpBuf64, &ctx); p64 = &keys64[i%SIMD_COEF_64+i/SIMD_COEF_64*SHA_BUF_SIZ*SIMD_COEF_64]; for (j = 0; j < 8; ++j) #if ARCH_LITTLE_ENDIAN==1 p64[j*SIMD_COEF_64] = JOHNSWAP64(tmpBuf64[j]); #else p64[j*SIMD_COEF_64] = tmpBuf64[j]; } uint64_t rounds = 98; SIMDSHA512body(keys, keys64, &rounds, SSEi_HALF_IN|SSEi_LOOP); SIMDSHA512body(keys, (uint64_t*)crypt_out[index], NULL, SSEi_HALF_IN|SSEi_FLAT_OUT); #else SHA512_Init(&ctx); SHA512_Update(&ctx, saved_key[index], strlen(saved_key[index])); SHA512_Update(&ctx, cur_salt->salt, strlen((char*)cur_salt->salt)); SHA512_Final((unsigned char *)crypt_out[index], &ctx); /* now "h" (crypt_out[index] becomes our input * total SHA-512 calls => 101 */ for (j = 0; j < 99; j++) { SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, (unsigned char*)crypt_out[index], 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/dragonfly3_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++) { SHA256_CTX ctx; SHA256_Init(&ctx); /* First the password */ SHA256_Update(&ctx, saved_key[index], saved_len[index]); /* Then the salt, including the $3$ magic */ SHA256_Update(&ctx, cur_salt, salt_len); 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/tiger_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_tiger_context ctx; sph_tiger_init(&ctx); sph_tiger(&ctx, saved_key[index], strlen(saved_key[index])); sph_tiger_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/opencl_gpg_fmt_plug.c
#pragma omp parallel for
100
filingEvent[2]), "Copy result back"); if (ocl_autotune_running) return count; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { if (gpg_common_check(outbuffer[index].v, gpg_common_keySize(gpg_common_cur_salt->cipher_algorithm))) { 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/mssql12_fmt_plug.c
#pragma omp parallel for
100
ll(int *pcount, struct db_salt *salt) { const int count = *pcount; int index = 0; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_64 if (new_keys) { int i; for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) { unsigned char *wucp = (unsigned char *)&saved_key[index + i]; int j, len = (saved_key[index + i].u64[15] >> 3) - SALT_SIZE; for (j = 0; j < SALT_SIZE; j++) wucp[len + j] = cursalt[j]; wucp[len + 4] = 0x80; } } SIMDSHA512body(&saved_key[index], &crypt_out[BASE_IDX], NULL, SSEi_REVERSE_STEPS | SSEi_FLAT_IN); #else SHA512_CTX ctx; memcpy(saved_key[index]+saved_len[index], cursalt, SALT_SIZE); SHA512_Init(&ctx ); SHA512_Update(&ctx, saved_key[index], saved_len[index]+SALT_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/dashlane_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 pkey[MIN_KEYS_PER_CRYPT][32]; int i; #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 < MIN_KEYS_PER_CRYPT; ++i) { len[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = pkey[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, len, cur_salt->salt, 32, 10204, pout, 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, 32, 10204, pkey[i], 32, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) { if (dashlane_verify(cur_salt, pkey[i])) 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/rawSHA384_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|SSEi_CRYPT_SHA384); #else SHA512_CTX ctx; SHA384_Init(&ctx); SHA384_Update(&ctx, saved_key[index], saved_len[index]); SHA384_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/phpassMD5_fmt_plug.c
#pragma omp parallel for
100
t loops = 1, index; loops = (count + MIN_KEYS_PER_CRYPT - 1) / MIN_KEYS_PER_CRYPT; #ifdef _OPENMP <LOOP-START>for (index = 0; index < loops; index++) { unsigned Lcount; #ifdef SIMD_COEF_32 SIMDmd5body(cursalt[index], hash_key[index], NULL, SSEi_OUTPUT_AS_INP_FMT); Lcount = loopCnt-1; do { SIMDmd5body(hash_key[index], hash_key[index], NULL, SSEi_OUTPUT_AS_INP_FMT); } while (--Lcount); // last hash goes into crypt_key SIMDmd5body(hash_key[index], crypt_key[index], NULL, 0); #else MD5_CTX ctx; MD5_Init( &ctx ); MD5_Update( &ctx, cursalt, 8 ); MD5_Update( &ctx, saved_key[index], saved_len[index] ); MD5_Final( (unsigned char *) crypt_key[index], &ctx); strcpy(((char*)&(crypt_key[index]))+BINARY_SIZE, saved_key[index]); Lcount = loopCnt; do { MD5_Init( &ctx ); MD5_Update( &ctx, crypt_key[index], BINARY_SIZE+saved_len[index]); MD5_Final( (unsigned char *)&(crypt_key[index]), &ctx); } while (--Lcount); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/NETNTLMv2_fmt_plug.c
#pragma omp parallel for
100
hallenge + 1 + identity_length + 1) << 8) | *(challenge + 1 + identity_length + 2); #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { unsigned char ntlm_v2_hash[16]; HMACMD5Context ctx; if (!keys_prepared) { unsigned char ntlm[16]; int len; /* Generate 16-byte NTLM hash */ len = E_md4hash(saved_plain[i], saved_len[i], ntlm); // We do key setup of the next HMAC_MD5 here (once per salt) hmac_md5_init_K16(ntlm, &saved_ctx[i]); if (len <= 0) saved_plain[i][-len] = 0; // match truncation } /* HMAC-MD5(Username + Domain, NTLM Hash) */ memcpy(&ctx, &saved_ctx[i], sizeof(ctx)); hmac_md5_update((unsigned char *)&challenge[1], identity_length, &ctx); hmac_md5_final(ntlm_v2_hash, &ctx); /* --- Blob Construction --- */ /* The blob consists of the target (from Type 2 message), client nonce and timestamp. This data was provided by the client during authentication and we can use it as is. */ /* --- HMAC #2 Calculations --- */ /* The (server) challenge from the Type 2 message is concatenated with the blob. The HMAC-MD5 message authentication code algorithm is applied to this value using the 16-byte NTLMv2 hash (calculated above) as the key. This results in a 16-byte output value. */ /* Generate 16-byte non-client nonce portion of NTLMv2 Response HMAC-MD5(Challenge + Nonce, NTLMv2 Hash) The length of the challenge was set in get_salt(). We find the server challenge and blob following the identity and challenge size value. challenge -> Identity length, Identity\0, Size (2 bytes), Server Challenge + Client Challenge (Blob) */ hmac_md5(ntlm_v2_hash, challenge + 1 + identity_length + 1 + 2, challenge_size, (unsigned char*)output[i]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/multibit_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++) { unsigned char iv[16]; unsigned char key[32]; unsigned char outbuf[16]; AES_KEY aes_decrypt_key; int len = strlen(saved_key[index]); #ifdef _OPENMP if (cracked[index]) /* avoid false sharing of nearby elements */ cracked[index] = 0; if (cur_salt->type == 1) { unsigned char c; MD5_CTX ctx; // key MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], len); MD5_Update(&ctx, cur_salt->salt, 8); MD5_Final(key, &ctx); // key + 16 MD5_Init(&ctx); MD5_Update(&ctx, key, 16); MD5_Update(&ctx, saved_key[index], len); MD5_Update(&ctx, cur_salt->salt, 8); MD5_Final(key + 16, &ctx); // iv MD5_Init(&ctx); MD5_Update(&ctx, key + 16, 16); MD5_Update(&ctx, saved_key[index], len); MD5_Update(&ctx, cur_salt->salt, 8); MD5_Final(iv, &ctx); AES_set_decrypt_key(key, 256, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->block, outbuf, 16, &aes_decrypt_key, iv, AES_DECRYPT); c = outbuf[0]; if (c == 'L' || c == 'K' || c == '5' || c == 'Q') { // Does it look like a base58 private key (MultiBit, MultiDoge, or oldest-format Android key backup)? (btcrecover) // check if bytes are in base58 set [1-9A-HJ-NP-Za-km-z] if (is_base58(outbuf + 1, 15)) { // decrypt second block AES_cbc_encrypt(cur_salt->block + 16, outbuf, 16, &aes_decrypt_key, iv, AES_DECRYPT); if (is_base58(outbuf, 16)) cracked[index] = 1; } } else if (c == '#') { // Does it look like a KnC for Android key backup? if (memcmp((const char*)outbuf, "# KEEP YOUR PRIV", 8) == 0) // 8 should be enough cracked[index] = 1; } else if (c == '\x0a') { // Does it look like a bitcoinj protobuf (newest Bitcoin for Android backup)? (btcrecover)? if (is_bitcoinj_protobuf_data(outbuf)) cracked[index] = 1; } } else if (cur_salt->type == 2) { UTF16 password[PLAINTEXT_LENGTH * 2 + 1]; len = enc_to_utf16_be(password, PLAINTEXT_LENGTH, (const unsigned char*)saved_key[index], len + 1); if (len < 0) len = strlen16(password); #ifdef _OPENMP int t = omp_get_thread_num(); if (t >= max_threads) { failed = -1; continue; } #else const int t = 0; static const yescrypt_params_t params = { .N = 16384, .r = 8, .p = 1 }; if (yescrypt_kdf(NULL, &local[t], (const uint8_t *)password, (len + 1) * 2, (const uint8_t *)salt_hardcoded, 8, &params, key, 32)) { failed = errno ? errno : EINVAL; #ifndef _OPENMP break; } // 1 AES_set_decrypt_key(key, 128 * 2, &aes_decrypt_key); memcpy(iv, cur_salt->iv, 16); AES_cbc_encrypt(cur_salt->block, outbuf, 16, &aes_decrypt_key, iv, AES_DECRYPT); if (is_bitcoinj_protobuf_data(outbuf)) cracked[index] = 1; else { // 2 AES_set_decrypt_key(key, 128 * 2, &aes_decrypt_key); memcpy(iv, iv_hardcoded, 16); AES_cbc_encrypt(cur_salt->block2, outbuf, 16, &aes_decrypt_key, iv, AES_DECRYPT); if (is_bitcoinj_protobuf_data(outbuf)) cracked[index] = 1; } } else if (cur_salt->type == 3) { UTF16 password[PLAINTEXT_LENGTH * 2 + 1]; len = enc_to_utf16_be(password, PLAINTEXT_LENGTH, (const unsigned char*)saved_key[index], len + 1); if (len < 0) len = strlen16(password); #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 }; if (yescrypt_kdf(NULL, &local[t], (const uint8_t *)password, (len + 1) * 2, (const uint8_t *)cur_salt->salt, 8, &params, key, 32)) { failed = errno ? errno : EINVAL; #ifndef _OPENMP break; } memcpy(iv, cur_salt->block, 16); AES_set_decrypt_key(key, 256, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->block + 16, outbuf, 16, &aes_decrypt_key, iv, AES_DECRYPT); if (!memcmp(outbuf, "\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10", 16)) cracked[index] = 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawSHA1_fmt_plug.c
#pragma omp parallel for
100
int index = 0; #ifdef _OPENMP int loops = (count + MAX_KEYS_PER_CRYPT - 1) / MAX_KEYS_PER_CRYPT; <LOOP-START>for (index = 0; index < loops; ++index) { #if SIMD_COEF_32 SIMDSHA1body(saved_key[index], crypt_key[index], NULL, SSEi_flags); #else SHA_CTX ctx; SHA1_Init( &ctx ); SHA1_Update( &ctx, (unsigned char*) saved_key[index], strlen( saved_key[index] ) ); 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/dpapimk_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 *passwordBuf; int passwordBufSize; unsigned char *sidBuf; int sidBufSize; unsigned char out[MIN_KEYS_PER_CRYPT][KEY_LEN2 + IV_LEN2]; unsigned char out2[MIN_KEYS_PER_CRYPT][KEY_LEN2 + IV_LEN2]; SHA_CTX ctx; MD4_CTX ctx2; int i; int digestlens[MIN_KEYS_PER_CRYPT]; #if defined(SIMD_COEF_64) && defined(SIMD_COEF_32) int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT]; union { unsigned char *pout[MIN_KEYS_PER_CRYPT]; unsigned char *poutc; } x; int sha256loops = MIN_KEYS_PER_CRYPT / SSE_GROUP_SZ_SHA256, loops = MIN_KEYS_PER_CRYPT; if (cur_salt->version == 1) loops = MIN_KEYS_PER_CRYPT / SSE_GROUP_SZ_SHA1; else if (cur_salt->version == 2) loops = MIN_KEYS_PER_CRYPT / SSE_GROUP_SZ_SHA512; for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { digestlens[i] = 16; passwordBuf = (unsigned char*)saved_key[index+i]; passwordBufSize = strlen16((UTF16*)passwordBuf) * 2; /* local credentials */ if (cur_salt->cred_type == 1) { SHA1_Init(&ctx); SHA1_Update(&ctx, passwordBuf, passwordBufSize); SHA1_Final(out[i], &ctx); digestlens[i] = 20; } /* domain credentials */ else if (cur_salt->cred_type == 2 || cur_salt->cred_type == 3) { MD4_Init(&ctx2); MD4_Update(&ctx2, passwordBuf, passwordBufSize); MD4_Final(out[i], &ctx2); digestlens[i] = 16; } } /* 1607+ domain credentials */ /* The key derivation algorithm is hardcoded in NtlmShared.dll!MsvpDeriveSecureCredKey */ if(cur_salt->cred_type == 3) { sidBuf = (unsigned char*)cur_salt->SID; sidBufSize = (strlen16(cur_salt->SID) * 2); #if defined(SIMD_COEF_64) && defined(SIMD_COEF_32) for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = 16; pin[i] = (unsigned char*)out[i]; x.pout[i] = out2[i]; } for (i = 0; i < sha256loops; i++) { pbkdf2_sha256_sse((const unsigned char**)(pin + i * SSE_GROUP_SZ_SHA256), &lens[i * SSE_GROUP_SZ_SHA256], sidBuf, sidBufSize, 10000, x.pout + (i * SSE_GROUP_SZ_SHA256), 32, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = 32; pin[i] = (unsigned char*)out2[i]; x.pout[i] = out[i]; } for (i = 0; i < sha256loops; i++) { pbkdf2_sha256_sse((const unsigned char**)(pin + i * SSE_GROUP_SZ_SHA256), &lens[i * SSE_GROUP_SZ_SHA256], sidBuf, sidBufSize, 1, x.pout + (i * SSE_GROUP_SZ_SHA256), 16, 0); } #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { pbkdf2_sha256(out[i], 16, sidBuf, sidBufSize, 10000, out2[i], 32, 0); pbkdf2_sha256(out2[i], 32, sidBuf, sidBufSize, 1, out[i], 16, 0); } } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { passwordBuf = (unsigned char*)cur_salt->SID; passwordBufSize = (strlen16(cur_salt->SID) + 1) * 2; hmac_sha1(out[i], digestlens[i], passwordBuf, passwordBufSize, out2[i], 20); #if defined(SIMD_COEF_64) && defined(SIMD_COEF_32) lens[i] = 20; pin[i] = (unsigned char*)out2[i]; x.pout[i] = out[i]; } #if defined(SIMD_COEF_64) && defined(SIMD_COEF_32) if (cur_salt->version == 1) 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->iv, MAX_IV_LEN, cur_salt->pbkdf2_iterations, x.pout + (i * SSE_GROUP_SZ_SHA1), KEY_LEN1 + IV_LEN1, 0); else if (cur_salt->version == 2) for (i = 0; i < loops; i++) pbkdf2_sha512_sse((const unsigned char**)(pin + i * SSE_GROUP_SZ_SHA512), &lens[i * SSE_GROUP_SZ_SHA512], cur_salt->iv, MAX_IV_LEN, cur_salt->pbkdf2_iterations, x.pout + (i * SSE_GROUP_SZ_SHA512), KEY_LEN2 + IV_LEN2, 0); #else if (cur_salt->version == 1) pbkdf2_sha1(out2[0], 20, cur_salt->iv, MAX_IV_LEN, cur_salt->pbkdf2_iterations, out[0], KEY_LEN1 + IV_LEN1, 0); else if (cur_salt->version == 2) pbkdf2_sha512(out2[0], 20, cur_salt->iv, MAX_IV_LEN, cur_salt->pbkdf2_iterations, out[0], KEY_LEN2 + IV_LEN2, 0); if (cur_salt->version == 1) { /* decrypt will use 32 bytes, we only initialized 20 so far */ for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { memset(out2[i] + 20, 0, 32 - 20); if (decrypt_v1(out[i], out[i] + KEY_LEN1, out2[i], cur_salt->encrypted) == 0) cracked[index+i] = 1; else cracked[index+i] = 0; } } else if (cur_salt->version == 2) { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (decrypt_v2(out[i], out[i] + KEY_LEN2, out2[i], cur_salt->encrypted) == 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/diskcryptor_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 seed[MIN_KEYS_PER_CRYPT][128]; int i; #ifdef SIMD_COEF_64 int lens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; // kdf #ifdef SIMD_COEF_64 i = 0; do { lens[i] = saved_len[index+i]; pin[i] = (unsigned char*)saved_key[index+i]; pout[i] = seed[i]; ++i; } while (i < MIN_KEYS_PER_CRYPT && index+i < count); for (; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = 0; pin[i] = pin[0]; pout[i] = seed[i]; } pbkdf2_sha512_sse((const unsigned char**)pin, lens, cur_salt->salt, cur_salt->saltlen, 1000, pout, 64, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { pbkdf2_sha512((unsigned char *)saved_key[index+i], saved_len[index+i], cur_salt->salt, cur_salt->saltlen, 1000, seed[i], 64, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { int success = diskcryptor_decrypt_data(seed[i], cur_salt); if (success) { 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/electrum_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 iv[16]; unsigned char key[32]; SHA256_CTX ctx; AES_KEY aes_decrypt_key; int extra; unsigned char static_privkey[MIN_KEYS_PER_CRYPT][64]; int i, j; if (cur_salt->type == 1 || cur_salt->type == 2 || cur_salt->type == 3) { for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) { unsigned char outbuf[48] = { 0 }; SHA256_Init(&ctx); SHA256_Update(&ctx, saved_key[index+i], strlen(saved_key[index+i])); SHA256_Final(key, &ctx); SHA256_Init(&ctx); SHA256_Update(&ctx, key, 32); SHA256_Final(key, &ctx); memcpy(iv, cur_salt->iv, 16); AES_set_decrypt_key(key, 128 * 2, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->seed, outbuf, 16, &aes_decrypt_key, iv, AES_DECRYPT); if (cur_salt->type == 1) { // check if 16 bytes of the encrypted seed are all lower-case hex (btcrecover) outbuf[16] = 0; if (hexlenl((const char*)outbuf, &extra) != 8 * 2 || extra) cracked[index+i] = 0; else cracked[index+i] = 1; } else if (cur_salt->type == 2) { // check if starting 4 bytes are "xprv" or "zprv" if (memcmp(outbuf, "xprv", 4) && memcmp(outbuf, "zprv", 4)) { cracked[index+i] = 0; } else { // check if remaining 12 bytes are in base58 set [1-9A-HJ-NP-Za-km-z] for (j = 0; j < 12; j++) { unsigned char c = outbuf[4 + j]; if ((c > 'z') || (c < '1') || ((c > '9') && (c < 'A')) || ((c > 'Z') && (c < 'a'))) { cracked[index+i] = 0; break; } } if (j == 12) cracked[index+i] = 1; } } else if (cur_salt->type == 3) { unsigned char padbyte = outbuf[15]; // check for valid PKCS7 padding for a 52 or 51 byte "WIF" private key, 64 is the original data size if (padbyte == 12 || padbyte == 13) { if (check_pkcs_pad(outbuf, 16, 16) < 0) cracked[index+i] = 0; else cracked[index+i] = 1; } else { cracked[index+i] = 0; } } } } else if (cur_salt->type == 4 || cur_salt->type == 5) { BIGNUM *p, *q, *r; BN_CTX *ctx; unsigned char shared_pubkey[33]; unsigned char keys[128]; unsigned char cmac[32]; secp256k1_context *sctx; SHA512_CTX md_ctx; int shared_pubkeylen= 33; #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] = static_privkey[i]; } pbkdf2_sha512_sse((const unsigned char **)pin, len, (unsigned char*)"", 0, 1024, 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]), (unsigned char*)"", 0, 1024, static_privkey[i], 64, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) { // do static_privkey % GROUP_ORDER p = BN_bin2bn(static_privkey[i], 64, NULL); q = BN_new(); r = BN_new(); BN_hex2bn(&q, group_order); ctx = BN_CTX_new(); BN_mod(r, p, q, ctx); BN_CTX_free(ctx); BN_free(p); BN_free(q); BN_bn2binpad32(r, static_privkey[i]); BN_free(r); sctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE); // multiply point with a scaler, shared_pubkey is compressed representation secp256k1_mul(sctx, shared_pubkey, &cur_salt->pubkey, static_privkey[i]); secp256k1_context_destroy(sctx); SHA512_Init(&md_ctx); SHA512_Update(&md_ctx, shared_pubkey, shared_pubkeylen); SHA512_Final(keys, &md_ctx); if (cur_salt->type == 4) { // calculate mac of data hmac_sha256(keys + 32, 32, cur_salt->data, cur_salt->datalen, cmac, 32); if (memcmp(&cur_salt->mac, cmac, 16) == 0) cracked[index+i] = 1; else cracked[index+i] = 0; } else if (cur_salt->type == 5) { z_stream z; unsigned char iv[16]; unsigned char out[512] = { 0 }; unsigned char fout[512] = { 0 }; AES_KEY aes_decrypt_key; // common zlib settings z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL; z.avail_in = 512; z.avail_out = 512; z.next_out = fout; memcpy(iv, keys, 16); // fast zlib based rejection test, is this totally safe? AES_set_decrypt_key(keys + 16, 128, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->data, out, 16, &aes_decrypt_key, iv, AES_DECRYPT); if ((memcmp(out, "\x78\x9c", 2) != 0) || (((out[2] & 0x7) != 0x4) && ((out[2] & 0x7) != 0x5))) { cracked[index+i] = 0; } else { AES_set_decrypt_key(keys + 16, 128, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->data + 16, out + 16, 512 - 16, &aes_decrypt_key, iv, AES_DECRYPT); z.next_in = out; inflateInit2(&z, 15); inflate(&z, Z_NO_FLUSH); inflateEnd(&z); if ((memcmp(fout, EXPECTED_BYTES_1, 7) == 0) || (memcmp(fout, EXPECTED_BYTES_2, 8) == 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/IPB2_fmt_plug.c
#pragma omp parallel for
100
truct db_salt *salt) { const int count = *pcount; #ifdef SIMD_COEF_32 #if defined(_OPENMP) int t; <LOOP-START>for (t = 0; t < threads; t++) #define ti (t*NBKEYS+index) #else #define t 0 #define ti index { unsigned int index, i; if (new_salt) for (index = 0; index < NBKEYS; index++) { const uint32_t *sp = cur_salt; #if ARCH_LITTLE_ENDIAN uint32_t *kb = (uint32_t*)&saved_key[GETPOS(0, ti)]; for (i = 0; i < MD5_HEX_SIZE / 4; i++, kb += SIMD_COEF_32) *kb = *sp++; #else uint32_t *kb = (uint32_t*)&saved_key[GETPOS(3, ti)]; for (i = 0; i < MD5_HEX_SIZE / 4; i++, kb += SIMD_COEF_32) *kb = JOHNSWAP(*sp++); } if (new_key) for (index = 0; index < NBKEYS; index++) { const uint32_t *key = (uint32_t*)saved_plain[ti]; int len = 0, temp; #if ARCH_LITTLE_ENDIAN uint32_t *kb = (uint32_t*)&key_buf[GETPOS(0, ti)]; uint32_t *keybuffer = kb; while((unsigned char)(temp = *key++)) { if (!(temp & 0xff00)) { *kb = (unsigned char)temp | (0x80 << 8); len++; goto key_cleaning; } if (!(temp & 0xff0000)) { *kb = (unsigned short)temp | (0x80 << 16); len+=2; goto key_cleaning; } if (!(temp & 0xff000000)) { *kb = temp | (0x80U << 24); len+=3; goto key_cleaning; } *kb = temp; #else uint32_t *kb = (uint32_t*)&key_buf[GETPOS(3, ti)]; uint32_t *keybuffer = kb; while((temp = *key++) & 0xff000000) { if (!(temp & 0xff0000)) { *kb = JOHNSWAP((temp & 0xff000000) | (0x80 << 16)); len++; goto key_cleaning; } if (!(temp & 0xff00)) { *kb = JOHNSWAP((temp & 0xffff0000) | (0x80 << 8)); len+=2; goto key_cleaning; } if (!(temp & 0xff)) { *kb = JOHNSWAP(temp | 0x80U); len+=3; goto key_cleaning; } *kb = JOHNSWAP(temp); len += 4; kb += SIMD_COEF_32; } *kb = 0x00000080; key_cleaning: kb += SIMD_COEF_32; while(*kb) { *kb = 0; kb += SIMD_COEF_32; } keybuffer[14*SIMD_COEF_32] = len << 3; } SIMDmd5body(&key_buf[t*NBKEYS*64], (unsigned int*)&crypt_key[t*NBKEYS*16], NULL, SSEi_MIXED_IN); for (index = 0; index < NBKEYS; index++) { // Somehow when I optimised this it got faster in Valgrind but slower IRL for (i = 0; i < BINARY_SIZE; i++) { unsigned char v = crypt_key[GETOUTPOS(i, ti)]; saved_key[GETPOS(MD5_HEX_SIZE + 2 * i, ti)] = itoa16_shr_04[ARCH_INDEX(v)]; saved_key[GETPOS(MD5_HEX_SIZE + 2 * i + 1, ti)] = itoa16_and_0f[ARCH_INDEX(v)]; } } SIMDmd5body(&saved_key[t*NBKEYS*64], (unsigned int*)&crypt_key[t*NBKEYS*16], NULL, SSEi_MIXED_IN); SIMDmd5body(empty_key, (unsigned int*)&crypt_key[t*NBKEYS*16], (unsigned int*)&crypt_key[t*NBKEYS*16], SSEi_RELOAD|SSEi_MIXED_IN); } //dump_stuff_mmx_msg("\nfinal ", saved_key, 64, count-1); //dump_out_mmx_msg("result", crypt_key, 16, count-1); new_salt = new_key = 0; #else #ifdef _OPENMP int index; #pragma omp parallel for for (index = 0; index < count; index++) #else #define index 0 { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], MD5_HEX_SIZE * 2); MD5_Final((unsigned char*)crypt_key[index], &ctx); } #undef index return count; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/IPB2_fmt_plug.c
#pragma omp parallel for
100
_msg("result", crypt_key, 16, count-1); new_salt = new_key = 0; #else #ifdef _OPENMP int index; <LOOP-START>for (index = 0; index < count; index++) #else #define index 0 { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], MD5_HEX_SIZE * 2); 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/cq_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++) crypt_key[index] = AdProcessPassword(saved_key[index]); return count; } static int cmp_all(void *binary, int count) { int i; for (i = 0; i < count; ++i) if (*(uint32_t *)binary == crypt_key[i]) return 1; return 0; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/hmacSHA1_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 if (new_keys) { SIMDSHA1body(&ipad[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_ipad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN); SIMDSHA1body(&opad[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_opad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN); } SIMDSHA1body(cur_salt, (unsigned int*)&crypt_key[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_ipad[index * BINARY_SIZE], SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT); SIMDSHA1body(&crypt_key[index * SHA_BUF_SIZ * 4], (unsigned int*)&crypt_key[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_opad[index * BINARY_SIZE], SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT); #else SHA_CTX ctx; if (new_keys) { SHA1_Init(&ipad_ctx[index]); SHA1_Update(&ipad_ctx[index], ipad[index], PAD_SIZE); SHA1_Init(&opad_ctx[index]); SHA1_Update(&opad_ctx[index], opad[index], PAD_SIZE); } memcpy(&ctx, &ipad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, cur_salt, strlen((char*)cur_salt)); SHA1_Final((unsigned char*) crypt_key[index], &ctx); memcpy(&ctx, &opad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, crypt_key[index], BINARY_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/cryptosafe_fmt_plug.c
#pragma omp parallel for
100
) { memset(cracked, 0, sizeof(cracked[0]) * cracked_count); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { AES_KEY aes_decrypt_key; unsigned char plain[16], iv[16] = { 0 }; AES_set_decrypt_key((unsigned char*)saved_key[index], 256, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->ciphertext, plain, 16, &aes_decrypt_key, iv, AES_DECRYPT); if (!memcmp(plain, "[{\"coinName\":\"", 14)) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } return count; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rakp_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 if (new_keys) { SIMDSHA1body(&ipad[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_ipad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN); SIMDSHA1body(&opad[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_opad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN); } SIMDSHA1body(cur_salt[0], (unsigned int*)&crypt_key[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_ipad[index * BINARY_SIZE], SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT); SIMDSHA1body(cur_salt[1], (unsigned int*)&crypt_key[index * SHA_BUF_SIZ * 4], (unsigned int*)&crypt_key[index * SHA_BUF_SIZ * 4], SSEi_MIXED_IN|SSEi_RELOAD_INP_FMT|SSEi_OUTPUT_AS_INP_FMT); SIMDSHA1body(&crypt_key[index * SHA_BUF_SIZ * 4], (unsigned int*)&crypt_key[index * SHA_BUF_SIZ * 4], (unsigned int*)&prep_opad[index * BINARY_SIZE], SSEi_MIXED_IN|SSEi_RELOAD|SSEi_OUTPUT_AS_INP_FMT); #else SHA_CTX ctx; if (new_keys) { SHA1_Init(&ipad_ctx[index]); SHA1_Update(&ipad_ctx[index], ipad[index], PAD_SIZE); SHA1_Init(&opad_ctx[index]); SHA1_Update(&opad_ctx[index], opad[index], PAD_SIZE); } memcpy(&ctx, &ipad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, cur_salt.salt, cur_salt.length); SHA1_Final((unsigned char*) crypt_key[index], &ctx); memcpy(&ctx, &opad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, crypt_key[index], BINARY_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/tezos_fmt_plug.c
#pragma omp parallel for
100
endif 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) { union { unsigned char seed[64]; ed25519_secret_key sk; } seed[MIN_KEYS_PER_CRYPT]; char salt[MIN_KEYS_PER_CRYPT][16 + 256 + PLAINTEXT_LENGTH]; int i; #ifdef SIMD_COEF_64 int lens[MIN_KEYS_PER_CRYPT]; int slens[MIN_KEYS_PER_CRYPT]; unsigned char *pin[MIN_KEYS_PER_CRYPT], *pout[MIN_KEYS_PER_CRYPT]; unsigned char *sin[MIN_KEYS_PER_CRYPT]; // create varying salt(s) for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { memcpy(salt[i], "mnemonic", 8); memcpy(salt[i] + 8, cur_salt->email, cur_salt->email_length + 1); strcat(salt[i], saved_key[index+i]); } // kdf #ifdef SIMD_COEF_64 for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { lens[i] = cur_salt->mnemonic_length; pin[i] = (unsigned char*)cur_salt->mnemonic; sin[i] = (unsigned char*)salt[i]; pout[i] = seed[i].seed; slens[i] = strlen(salt[i]); if (!warned && !self_test_running && slens[i] > PBKDF2_64_MAX_SALT_SIZE) { #ifdef _OPENMP #pragma omp critical { warned = 1; fprintf(stderr, "Warning: over-long combination(s) of e-mail address and candidate password\n"); } } } pbkdf2_sha512_sse_varying_salt((const unsigned char**)pin, lens, sin, slens, 2048, pout, 64, 0); #else for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) pbkdf2_sha512((unsigned char*)cur_salt->mnemonic, cur_salt->mnemonic_length, (unsigned char*)salt[i], strlen(salt[i]), 2048, seed[i].seed, 64, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { unsigned char buffer[20]; ed25519_public_key pk; // asymmetric stuff ed25519_publickey(seed[i].sk, pk); blake2b((uint8_t *)buffer, (unsigned char*)pk, NULL, 20, 32, 0); // pk is pkh (pubkey hash) if (!memcmp(cur_salt->raw_address + 2, buffer, 20)) { 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/pgpdisk_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[40]; // multiple of 20 needed for pgpdisk_kdf() if (cur_salt->algorithm == 5 || cur_salt->algorithm == 6 || cur_salt->algorithm == 7) { AES_KEY aes_key; pgpdisk_kdf(saved_key[index], cur_salt->salt, key, 32); // DecryptPassphraseKey in original source code, compute CheckBytes AES_set_encrypt_key(key, 256, &aes_key); AES_ecb_encrypt(key, (unsigned char*)crypt_out[index], &aes_key, AES_ENCRYPT); } else if (cur_salt->algorithm == 4) { Twofish_key tkey; pgpdisk_kdf(saved_key[index], cur_salt->salt, key, 32); Twofish_prepare_key(key, 32, &tkey); Twofish_encrypt(&tkey, key, (unsigned char*)crypt_out[index]); } else if (cur_salt->algorithm == 3) { CAST_KEY ck; pgpdisk_kdf(saved_key[index], cur_salt->salt, key, 16); 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/snmp_fmt_plug.c
#pragma omp parallel for
100
ount = *pcount; int index; memset(cracked, 0, sizeof(cracked[0])*cracked_count); #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { HMACMD5Context ctx; unsigned char authKey[20]; unsigned char out[20]; /* * Missed optimization potential: * This should be re-worked to cache authKey (in global malloc'ed arrays) for * the MD5 and SHA-1 variations of the algorithm if/as they're first computed * and then reuse them for further salts. */ if (cur_salt->authProtocol == 1) { snmp_usm_password_to_key_md5((const uint8_t *)saved_key[index], strlen(saved_key[index]), cur_salt->engineID, cur_salt->engineLength, authKey); hmac_md5_init_rfc2104(authKey, 16, &ctx); hmac_md5_update(cur_salt->salt, cur_salt->salt_length, &ctx); hmac_md5_final(out, &ctx); if (memcmp(out, cur_salt->msgAuthenticationParameters, 12) == 0) cracked[index] = 1; else cracked[index] = 0; } else if (cur_salt->authProtocol == 2) { snmp_usm_password_to_key_sha((const uint8_t *)saved_key[index], strlen(saved_key[index]), cur_salt->engineID, cur_salt->engineLength, authKey); hmac_sha1(authKey, 20, cur_salt->salt, cur_salt->salt_length, out, 12); if (memcmp(out, cur_salt->msgAuthenticationParameters, 12) == 0) cracked[index] = 1; else cracked[index] = 0; } else if (cur_salt->authProtocol == 0) { cracked[index] = 0; snmp_usm_password_to_key_md5((const uint8_t *)saved_key[index], strlen(saved_key[index]), cur_salt->engineID, cur_salt->engineLength, authKey); hmac_md5_init_rfc2104(authKey, 16, &ctx); hmac_md5_update(cur_salt->salt, cur_salt->salt_length, &ctx); hmac_md5_final(out, &ctx); if (memcmp(out, cur_salt->msgAuthenticationParameters, 12) == 0) { cracked[index] = 1; continue; } snmp_usm_password_to_key_sha((const uint8_t *)saved_key[index], strlen(saved_key[index]), cur_salt->engineID, cur_salt->engineLength, authKey); hmac_sha1(authKey, 20, cur_salt->salt, cur_salt->salt_length, out, 12); if (memcmp(out, cur_salt->msgAuthenticationParameters, 12) == 0) cracked[index] = 1; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/bitshares_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++) { SHA512_CTX ctx; unsigned char km[64]; AES_KEY aes_decrypt_key; unsigned char out[MAX_CIPHERTEXT_LENGTH]; unsigned char iv[16] = { 0 }; // does not matter if (cur_salt->type == 0) { SHA512_Init(&ctx); SHA512_Update(&ctx, saved_key[index], saved_len[index]); SHA512_Final(km, &ctx); AES_set_decrypt_key(km, 256, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->ct + cur_salt->ctlen - 32, out, 32, &aes_decrypt_key, iv, AES_DECRYPT); if (memcmp(out + 16, "\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10", 16) == 0) { cracked[index] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 1; } } else { secp256k1_context *ctxs; secp256k1_pubkey pubkey; SHA256_CTX sctx; unsigned char output[128]; size_t outlen = 33; int padbyte; int dlen = cur_salt->ctlen - outlen; SHA256_Init(&sctx); SHA256_Update(&sctx, saved_key[index], saved_len[index]); SHA256_Final(km, &sctx); ctxs = secp256k1_context_create(SECP256K1_CONTEXT_NONE); secp256k1_ec_pubkey_parse(ctxs, &pubkey, cur_salt->ct, 33); secp256k1_ec_pubkey_tweak_mul(ctxs, &pubkey, km); secp256k1_ec_pubkey_serialize(ctxs, output, &outlen, &pubkey, SECP256K1_EC_UNCOMPRESSED); secp256k1_context_destroy(ctxs); SHA512_Init(&ctx); SHA512_Update(&ctx, output + 1, 32); SHA512_Final(km, &ctx); hex_encode(km, 64, output); SHA512_Init(&ctx); SHA512_Update(&ctx, output, 128); SHA512_Final(km, &ctx); AES_set_decrypt_key(km, 256, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->ct + 33, out, dlen, &aes_decrypt_key, km + 32, AES_DECRYPT); padbyte = out[dlen - 1]; if (padbyte <= 16) { // check padding! if (check_pkcs_pad(out, dlen, 16) >= 0) { // check checksum SHA256_Init(&sctx); SHA256_Update(&sctx, out + 4, dlen - 4 - padbyte); SHA256_Final(km, &sctx); if (memcmp(km, out, 4) == 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/sapG_fmt_plug.c
#pragma omp parallel for
100
nst int count = *pcount; #if SIMD_COEF_32 #define ti (t*NBKEYS+index) int t; #if defined(_OPENMP) <LOOP-START>for (t = 0; t < (count-1)/(NBKEYS)+1; t++) { unsigned int index, i, longest; int len; unsigned int crypt_len[NBKEYS]; longest = 0; for (index = 0; index < NBKEYS; index++) { // Store key into vector key buffer if ((len = keyLen[ti]) < 0) { uint32_t *keybuf_word = (uint32_t*)&saved_key[0][GETSTARTPOS(ti)]; #if ARCH_ALLOWS_UNALIGNED const uint32_t *wkey = (uint32_t*)saved_plain[ti]; #else char buf_aligned[UTF8_PLAINTEXT_LENGTH + 1] JTR_ALIGN(4); char *key = (char*)saved_plain[ti]; const uint32_t *wkey = is_aligned(key, 4) ? (uint32_t*)key : (uint32_t*)strcpy(buf_aligned, key); uint32_t temp; len = 0; #if ARCH_LITTLE_ENDIAN while(((unsigned char)(temp = *wkey++))) { if (!(temp & 0xff00)) { *keybuf_word = JOHNSWAP(temp & 0xff); len++; break; } if (!(temp & 0xff0000)) { *keybuf_word = JOHNSWAP(temp & 0xffff); len+=2; break; } *keybuf_word = JOHNSWAP(temp); if (!(temp & 0xff000000)) { len+=3; break; } #else while((temp = *wkey++) & 0xff000000) { if (!(temp & 0xff0000)) { *keybuf_word = (temp & 0xff000000) | (0x80 << 16); len++; break; } if (!(temp & 0xff00)) { *keybuf_word = (temp & 0xffff0000) | (0x80 << 8); len+=2; break; } *keybuf_word = temp; if (!(temp & 0xff)) { *keybuf_word = temp | 0x80U; len+=3; break; } len += 4; if (len & 63) keybuf_word += SIMD_COEF_32; else keybuf_word = (uint32_t*)&saved_key[len>>6][GETSTARTPOS(ti)]; } // Back-out of trailing spaces while(len && saved_plain[ti][len - 1] == ' ') saved_plain[ti][--len] = 0; keyLen[ti] = len; } // 1. we need to SHA1 the password and username for (i = 0; i < cur_salt->l; i++) saved_key[(len+i)>>6][GETPOS((len + i), ti)] = cur_salt->s[i]; len += i; saved_key[len>>6][GETPOS(len, ti)] = 0x80; // Clean rest of this buffer i = len; while (++i & 3) saved_key[i>>6][GETPOS(i, ti)] = 0; for (; i < (((len+8)>>6)+1)*64; i += 4) *(uint32_t*)&saved_key[i>>6][GETWORDPOS(i, ti)] = 0; // This should do good but Valgrind insists it's a waste //if (clean_pos[ti] < i) // clean_pos[ti] = len + 1; if (len > longest) longest = len; ((unsigned int*)saved_key[(len+8)>>6])[15*SIMD_COEF_32 + (ti&(SIMD_COEF_32-1)) + ti/SIMD_COEF_32*SHA_BUF_SIZ*SIMD_COEF_32] = len << 3; crypt_len[index] = len; } SIMDSHA1body(&saved_key[0][t*SHA_BUF_SIZ*4*NBKEYS], (unsigned int*)&crypt_key[t*20*NBKEYS], NULL, SSEi_MIXED_IN); // Do another and possibly a third limb memcpy(&interm_crypt[t*20*NBKEYS], &crypt_key[t*20*NBKEYS], 20*NBKEYS); for (i = 1; i < (((longest + 8) >> 6) + 1); i++) { SIMDSHA1body(&saved_key[i][t*SHA_BUF_SIZ*4*NBKEYS], (unsigned int*)&interm_crypt[t*20*NBKEYS], (unsigned int*)&interm_crypt[t*20*NBKEYS], SSEi_MIXED_IN|SSEi_RELOAD); // Copy any output that is done now for (index = 0; index < NBKEYS; index++) if (((crypt_len[index] + 8) >> 6) == i) crypt_done((unsigned int*)interm_crypt, (unsigned int*)crypt_key, ti); } longest = 0; for (index = 0; index < NBKEYS; index++) { unsigned int offsetMagicArray; unsigned int lengthIntoMagicArray; const unsigned char *p; int i; // If final crypt ends up to be 56-61 bytes (or so), this must be clean for (i = 0; i < LIMB; i++) if (keyLen[ti] < i * 64 + 55) ((unsigned int*)saved_key[i])[15*SIMD_COEF_32 + (ti&(SIMD_COEF_32-1)) + ti/SIMD_COEF_32*SHA_BUF_SIZ*SIMD_COEF_32] = 0; len = keyLen[ti]; lengthIntoMagicArray = extractLengthOfMagicArray(crypt_key, ti); offsetMagicArray = extractOffsetToMagicArray(crypt_key, ti); // 2. now, hash again --> sha1($password+$partOfMagicArray+$username) --> this is CODVNG passcode... i = len - 1; p = &theMagicArray[offsetMagicArray]; // Copy a char at a time until aligned (at destination)... while (++i & 3) saved_key[i>>6][GETPOS(i, ti)] = *p++; // ...then a word at a time. This is a good boost, we are copying between 32 and 82 bytes here. #if ARCH_ALLOWS_UNALIGNED for (;i < lengthIntoMagicArray + len; i += 4, p += 4) #if ARCH_LITTLE_ENDIAN *(uint32_t*)&saved_key[i>>6][GETWORDPOS(i, ti)] = JOHNSWAP(*(uint32_t*)p); #else *(uint32_t*)&saved_key[i>>6][GETWORDPOS(i, ti)] = *(uint32_t*)p; #else for (;i < lengthIntoMagicArray + len; ++i, ++p) { saved_key[i>>6][GETPOS(i, ti)] = *p; } // Now, the salt. This is typically too short for the stunt above. for (i = 0; i < cur_salt->l; i++) saved_key[(len+lengthIntoMagicArray+i)>>6][GETPOS((len + lengthIntoMagicArray + i), ti)] = cur_salt->s[i]; len += lengthIntoMagicArray + cur_salt->l; saved_key[len>>6][GETPOS(len, ti)] = 0x80; crypt_len[index] = len; // Clean the rest of this buffer as needed i = len; while (++i & 3) saved_key[i>>6][GETPOS(i, ti)] = 0; for (; i < clean_pos[ti]; i += 4) *(uint32_t*)&saved_key[i>>6][GETWORDPOS(i, ti)] = 0; clean_pos[ti] = len + 1; if (len > longest) longest = len; ((unsigned int*)saved_key[(len+8)>>6])[15*SIMD_COEF_32 + (ti&(SIMD_COEF_32-1)) + ti/SIMD_COEF_32*SHA_BUF_SIZ*SIMD_COEF_32] = len << 3; } SIMDSHA1body(&saved_key[0][t*SHA_BUF_SIZ*4*NBKEYS], (unsigned int*)&interm_crypt[t*20*NBKEYS], NULL, SSEi_MIXED_IN); // Typically, no or very few crypts are done at this point so this is faster than to memcpy the lot for (index = 0; index < NBKEYS; index++) if (crypt_len[index] < 56) crypt_done((unsigned int*)interm_crypt, (unsigned int*)crypt_key, ti); // Do another and possibly a third, fourth and fifth limb for (i = 1; i < (((longest + 8) >> 6) + 1); i++) { SIMDSHA1body(&saved_key[i][t*SHA_BUF_SIZ*4*NBKEYS], (unsigned int*)&interm_crypt[t*20*NBKEYS], (unsigned int*)&interm_crypt[t*20*NBKEYS], SSEi_MIXED_IN|SSEi_RELOAD); // Copy any output that is done now for (index = 0; index < NBKEYS; index++) if (((crypt_len[index] + 8) >> 6) == i) crypt_done((unsigned int*)interm_crypt, (unsigned int*)crypt_key, ti); } } #undef t #undef ti #else int index; #ifdef _OPENMP #pragma omp parallel for for (index = 0; index < count; index++) { unsigned int offsetMagicArray, lengthIntoMagicArray; unsigned char temp_key[BINARY_SIZE]; unsigned char tempVar[UTF8_PLAINTEXT_LENGTH + MAGIC_ARRAY_SIZE + SALT_LENGTH]; //max size... SHA_CTX ctx; if (keyLen[index] < 0) { keyLen[index] = strlen((char*)saved_key[index]); // Back-out of trailing spaces while (keyLen[index] && saved_key[index][keyLen[index] - 1] == ' ') { saved_key[index][--keyLen[index]] = 0; if (keyLen[index] == 0) break; } } //1. we need to SHA1 the password and username memcpy(tempVar, saved_key[index], keyLen[index]); //first: the password memcpy(tempVar + keyLen[index], cur_salt->s, cur_salt->l); //second: the salt(username) SHA1_Init(&ctx); SHA1_Update(&ctx, tempVar, keyLen[index] + cur_salt->l); SHA1_Final((unsigned char*)temp_key, &ctx); lengthIntoMagicArray = extractLengthOfMagicArray(temp_key); offsetMagicArray = extractOffsetToMagicArray(temp_key); //2. now, hash again --> sha1($password+$partOfMagicArray+$username) --> this is CODVNG passcode... memcpy(tempVar + keyLen[index], &theMagicArray[offsetMagicArray], lengthIntoMagicArray); memcpy(tempVar + keyLen[index] + lengthIntoMagicArray, cur_salt->s, cur_salt->l); SHA1_Init(&ctx); SHA1_Update(&ctx, tempVar, keyLen[index] + lengthIntoMagicArray + cur_salt->l); SHA1_Final((unsigned char*)crypt_key[index], &ctx); } #undef index return count; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sapG_fmt_plug.c
#pragma omp parallel for
100
_crypt, (unsigned int*)crypt_key, ti); } } #undef t #undef ti #else int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned int offsetMagicArray, lengthIntoMagicArray; unsigned char temp_key[BINARY_SIZE]; unsigned char tempVar[UTF8_PLAINTEXT_LENGTH + MAGIC_ARRAY_SIZE + SALT_LENGTH]; //max size... SHA_CTX ctx; if (keyLen[index] < 0) { keyLen[index] = strlen((char*)saved_key[index]); // Back-out of trailing spaces while (keyLen[index] && saved_key[index][keyLen[index] - 1] == ' ') { saved_key[index][--keyLen[index]] = 0; if (keyLen[index] == 0) break; } } //1. we need to SHA1 the password and username memcpy(tempVar, saved_key[index], keyLen[index]); //first: the password memcpy(tempVar + keyLen[index], cur_salt->s, cur_salt->l); //second: the salt(username) SHA1_Init(&ctx); SHA1_Update(&ctx, tempVar, keyLen[index] + cur_salt->l); SHA1_Final((unsigned char*)temp_key, &ctx); lengthIntoMagicArray = extractLengthOfMagicArray(temp_key); offsetMagicArray = extractOffsetToMagicArray(temp_key); //2. now, hash again --> sha1($password+$partOfMagicArray+$username) --> this is CODVNG passcode... memcpy(tempVar + keyLen[index], &theMagicArray[offsetMagicArray], lengthIntoMagicArray); memcpy(tempVar + keyLen[index] + lengthIntoMagicArray, cur_salt->s, cur_salt->l); SHA1_Init(&ctx); SHA1_Update(&ctx, tempVar, keyLen[index] + lengthIntoMagicArray + cur_salt->l); 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/blockchain_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 char master[MIN_KEYS_PER_CRYPT][32]; int lens[MIN_KEYS_PER_CRYPT], i; 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] = master[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, cur_salt->data, 16, cur_salt->iter, pout, 32, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (blockchain_decrypt(master[i], cur_salt->data) == 0) cracked[i+index] = 1; else cracked[i+index] = 0; } #else unsigned char master[32]; pbkdf2_sha1((unsigned char *)saved_key[index], strlen(saved_key[index]), cur_salt->data, 16, cur_salt->iter, master, 32, 0); if (blockchain_decrypt(master, cur_salt->data) == 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/sapB_fmt_plug.c
#pragma omp parallel for
100
, struct db_salt *salt) { const int count = *pcount; #if SIMD_COEF_32 #if defined(_OPENMP) int t; <LOOP-START>for (t = 0; t < threads; t++) #define ti (t*NBKEYS+index) #else #define t 0 #define ti index { unsigned int index, i; for (index = 0; index < NBKEYS; index++) { int len; if ((len = keyLen[ti]) < 0) { unsigned char *key; // Load key into vector buffer len = 0; key = (unsigned char*)saved_plain[ti]; while (*key) { saved_key[GETPOS(len, ti)] = transtable[*key++]; len++; } // Back-out of trailing spaces while(len && *--key == ' ') { len--; saved_key[GETPOS(len, ti)] = 0; } keyLen[ti] = len; } // Prepend the salt for (i = 0; i < cur_salt->l; i++) saved_key[GETPOS((len + i), ti)] = cur_salt->s[i]; saved_key[GETPOS((len + i), ti)] = 0x80; ((unsigned int *)saved_key)[14*SIMD_COEF_32 + (ti&(SIMD_COEF_32-1)) + (unsigned int)ti/SIMD_COEF_32*16*SIMD_COEF_32] = (len + i) << 3; // Clean rest of buffer for (i = i + len + 1; i <= clean_pos[ti]; i++) saved_key[GETPOS(i, ti)] = 0; clean_pos[ti] = len + cur_salt->l; } SIMDmd5body(&saved_key[t*NBKEYS*64], (unsigned int*)&crypt_key[t*NBKEYS*16], NULL, SSEi_MIXED_IN); for (i = 0; i < SIMD_PARA_MD5; i++) memset(&interm_key[t*64*NBKEYS+i*64*SIMD_COEF_32+32*SIMD_COEF_32], 0, 32*SIMD_COEF_32); for (index = 0; index < NBKEYS; index++) { unsigned int sum20; // note, without the union (just type casting to uint32_t*) was causing weird problems // compiling for ppc64 (BE). This was seen for other things, where typecasting caused // problems. Using a union, solved the problem fully. union { unsigned char temp_key[BINARY_SIZE*2]; uint32_t temp_keyw[BINARY_SIZE/2]; } x; uint32_t destArray[TEMP_ARRAY_SIZE / 4]; const unsigned int *sw; unsigned int *dw; // Temporary flat copy of crypt sw = (unsigned int*)&crypt_key[GETOUTPOS(0, ti)]; for (i = 0; i < 4; i++, sw += SIMD_COEF_32) #if ARCH_LITTLE_ENDIAN x.temp_keyw[i] = *sw; #else x.temp_keyw[i] = JOHNSWAP(*sw); //now: walld0rf-magic [tm], (c), <g> sum20 = walld0rf_magic(ti, x.temp_key, (unsigned char*)destArray); // Vectorize a word at a time #if ARCH_LITTLE_ENDIAN dw = (unsigned int*)&interm_key[GETPOS(0, ti)]; for (i = 0;i <= sum20; i += 4, dw += SIMD_COEF_32) *dw = destArray[i >> 2]; #else dw = (unsigned int*)&interm_key[GETPOS(3, ti)]; for (i = 0;i <= sum20; i += 4, dw += SIMD_COEF_32) *dw = JOHNSWAP(destArray[i >> 2]); ((unsigned int *)interm_key)[14*SIMD_COEF_32 + (ti&(SIMD_COEF_32-1)) + (unsigned int)ti/SIMD_COEF_32*16*SIMD_COEF_32] = sum20 << 3; } SIMDmd5body(&interm_key[t*NBKEYS*64], (unsigned int*)&crypt_key[t*NBKEYS*16], NULL, SSEi_MIXED_IN); for (index = 0; index < NBKEYS; index++) { *(uint32_t*)&crypt_key[GETOUTPOS(0, ti)] ^= *(uint32_t*)&crypt_key[GETOUTPOS(8, ti)]; *(uint32_t*)&crypt_key[GETOUTPOS(4, ti)] ^= *(uint32_t*)&crypt_key[GETOUTPOS(12, ti)]; } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sapB_fmt_plug.c
#pragma omp parallel for
100
TOUTPOS(4, ti)] ^= *(uint32_t*)&crypt_key[GETOUTPOS(12, ti)]; } } #else #ifdef _OPENMP int t; <LOOP-START>for (t = 0; t < count; t++) #else #define t 0 { unsigned char temp_key[BINARY_SIZE*2]; unsigned char final_key[BINARY_SIZE*2]; unsigned int i; unsigned int sum20; unsigned char destArray[TEMP_ARRAY_SIZE]; MD5_CTX ctx; if (keyLen[t] < 0) { keyLen[t] = strlen(saved_plain[t]); // Back-out of trailing spaces while ( keyLen[t] && saved_plain[t][keyLen[t] - 1] == ' ' ) { if (keyLen[t] == 0) break; saved_plain[t][--keyLen[t]] = 0; } for (i = 0; i < keyLen[t]; i++) saved_key[t][i] = transtable[ARCH_INDEX(saved_plain[t][i])]; } MD5_Init(&ctx); MD5_Update(&ctx, saved_key[t], keyLen[t]); MD5_Update(&ctx, cur_salt->s, cur_salt->l); MD5_Final(temp_key,&ctx); //now: walld0rf-magic [tm], (c), <g> sum20 = walld0rf_magic(t, temp_key, destArray); MD5_Init(&ctx); MD5_Update(&ctx, destArray, sum20); MD5_Final(final_key, &ctx); for (i = 0; i < 8; i++) ((char*)crypt_key[t])[i] = final_key[i + 8] ^ final_key[i]; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/lastpass_cli_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]; int i; if (cur_salt->iterations != 1) { #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); } } else { for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, cur_salt->salt, cur_salt->salt_length); SHA256_Update(&ctx, saved_key[i+index], strlen(saved_key[i+index])); SHA256_Final((unsigned char*)key[i], &ctx); } } for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { unsigned char iv[16]; AES_KEY akey; memcpy(iv, cur_salt->iv, 16); AES_set_encrypt_key((unsigned char*)key[i], 256, &akey); AES_cbc_encrypt((const unsigned char*)AGENT_VERIFICATION_STRING, (unsigned char*)crypt_out[i+index], BINARY_SIZE, &akey, iv, AES_ENCRYPT); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/EPI_fmt_plug.c
#pragma omp parallel for private(i) shared(global_salt, saved_key, key_len, crypt_out)
100
crypt_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int i=0; #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; ++i) { SHA_CTX ctx; SHA1_Init(&ctx); SHA1_Update(&ctx, (unsigned char*)global_salt, SALT_LENGTH-1); SHA1_Update(&ctx, saved_key[i], key_len[i]); SHA1_Final((unsigned char*)crypt_out[i], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for private(i) shared(global_salt, saved_key, key_len, crypt_out)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/gost_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++) { gost_ctx ctx; if (is_cryptopro) john_gost_cryptopro_init(&ctx); else john_gost_init(&ctx); john_gost_update(&ctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); john_gost_final(&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/lotus85_fmt_plug.c
#pragma omp parallel for
100
= *pcount; int index = 0; /* Compute digest for all given plaintext passwords */ #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { unsigned char user_key[8], deciphered_userid[LOTUS85_MAX_BLOB_SIZE]; memset(lotus85_last_binary_hash1[index], 0, BINARY_LENGTH); memset(lotus85_last_binary_hash2[index], 0, BINARY_LENGTH); memset(user_key, 0, sizeof(user_key)); memset(deciphered_userid, 0, sizeof(deciphered_userid)); /* Derive password and retrieve RC2 key */ get_user_id_secret_key(lotus85_saved_passwords[index], user_key); /* Deciphered user blob stored in user.id file */ decipher_userid_blob(cur_salt->lotus85_user_blob, cur_salt->lotus85_user_blob_len, user_key, deciphered_userid); /* Store first deciphered digest */ memcpy(lotus85_last_binary_hash1[index], deciphered_userid + cur_salt->lotus85_user_blob_len - BINARY_LENGTH, BINARY_LENGTH); /* Compute digest of deciphered message */ compute_msg_mac(deciphered_userid, cur_salt->lotus85_user_blob_len - BINARY_LENGTH, lotus85_last_binary_hash2[index]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/MD5_std.c
#pragma omp parallel for default(none) private(t) shared(n, salt_changed, saved_salt)
100
crypt(int count) { #if MD5_std_mt int t, n = (count + (MD5_N - 1)) / MD5_N; #endif #ifdef _OPENMP <LOOP-START>for_each_t(n) { /* * We could move the salt_changed check out of the parallel region (and have * two specialized parallel regions instead), but MD5_std_crypt_for_thread() * does so much work that the salt_changed check is negligible. */ if (salt_changed) MD5_std_set_salt_for_thread(t, saved_salt); MD5_std_crypt_for_thread(t); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(t) shared(n, salt_changed, saved_salt)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/FGT_fmt_plug.c
#pragma omp parallel for default(none) private(i) shared(ctx_salt, count, saved_key, saved_key_len, crypt_key, cp)
100
, struct db_salt *salt) { int count = *pcount; int i=0; char *cp=FORTINET_MAGIC; #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_key_len[i]); SHA1_Update(&ctx, cp, FORTINET_MAGIC_LENGTH); SHA1_Final((unsigned char*)crypt_key[i], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(ctx_salt, count, saved_key, saved_key_len, crypt_key, cp)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/oldoffice_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 i; if (oo_cur_salt->type < 3) { MD5_CTX ctx; unsigned char hashBuf[21 * 16]; unsigned char key_hash[16]; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], saved_len[index]); MD5_Final(key_hash, &ctx); for (i = 0; i < 16; i++) { memcpy(hashBuf + i * 21, key_hash, 5); memcpy(hashBuf + i * 21 + 5, oo_cur_salt->salt, 16); } MD5_Init(&ctx); MD5_Update(&ctx, hashBuf, 21 * 16); MD5_Final(mitm_key[index], &ctx); memset(&mitm_key[index][5], 0, 11); // Truncate to 40 bits MD5_Init(&ctx); MD5_Update(&ctx, mitm_key[index], 9); MD5_Final(rc4_key[index], &ctx); } else { SHA_CTX ctx; unsigned char H0[24]; unsigned char key_hash[20]; SHA1_Init(&ctx); SHA1_Update(&ctx, oo_cur_salt->salt, 16); SHA1_Update(&ctx, saved_key[index], saved_len[index]); SHA1_Final(H0, &ctx); memset(&H0[20], 0, 4); SHA1_Init(&ctx); SHA1_Update(&ctx, H0, 24); SHA1_Final(key_hash, &ctx); if (oo_cur_salt->type < 4) { memcpy(mitm_key[index], key_hash, 5); memset(&mitm_key[index][5], 0, 11); // Truncate to 40 bits } else if (oo_cur_salt->type == 5) { memcpy(mitm_key[index], key_hash, 7); memset(&mitm_key[index][7], 0, 9); // Truncate to 56 bits } else memcpy(mitm_key[index], key_hash, 16); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/oldoffice_fmt_plug.c
#pragma omp parallel for
100
; if (any_cracked) { memset(oo_cracked, 0, cracked_size); any_cracked = 0; } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { RC4_KEY key; if (oo_cur_salt->type < 3) { MD5_CTX ctx; unsigned char pwdHash[16]; unsigned char hashBuf[32]; if (cur_binary->has_mitm && memcmp(cur_binary->mitm, mitm_key[index], 5)) continue; RC4_set_key(&key, 16, rc4_key[index]); /* rc4Key */ RC4(&key, 16, cur_binary->verifier, hashBuf); /* encryptedVerifier */ RC4(&key, 16, cur_binary->verifierHash, hashBuf + 16); /* encryptedVerifierHash */ /* hash the decrypted verifier */ MD5_Init(&ctx); MD5_Update(&ctx, hashBuf, 16); MD5_Final(pwdHash, &ctx); if (!memcmp(pwdHash, hashBuf + 16, 16)) #ifdef _OPENMP #pragma omp critical { any_cracked = oo_cracked[index] = 1; cur_binary->has_mitm = 1; memcpy(cur_binary->mitm, mitm_key[index], 5); } } else { SHA_CTX ctx; unsigned char Hfinal[20]; unsigned char DecryptedVerifier[16]; unsigned char DecryptedVerifierHash[20]; if (oo_cur_salt->type == 3 && !cur_binary->has_extra && cur_binary->has_mitm && memcmp(cur_binary->mitm, mitm_key[index], 5)) continue; RC4_set_key(&key, 16, mitm_key[index]); /* dek */ RC4(&key, 16, cur_binary->verifier, DecryptedVerifier); RC4(&key, 16, cur_binary->verifierHash, DecryptedVerifierHash); SHA1_Init(&ctx); SHA1_Update(&ctx, DecryptedVerifier, 16); SHA1_Final(Hfinal, &ctx); if (memcmp(Hfinal, DecryptedVerifierHash, 16)) continue; if (oo_cur_salt->type == 3 && cur_binary->has_extra) { SHA_CTX ctx; unsigned char H0[24]; unsigned char key_hash[20]; uint8_t data[32]; int i, num_zero = 0; SHA1_Init(&ctx); SHA1_Update(&ctx, oo_cur_salt->salt, 16); SHA1_Update(&ctx, saved_key[index], saved_len[index]); SHA1_Final(H0, &ctx); memcpy(&H0[20], "\1\0\0\0", 4); SHA1_Init(&ctx); SHA1_Update(&ctx, H0, 24); SHA1_Final(key_hash, &ctx); memset(key_hash + 40/8, 0, sizeof(key_hash) - 40/8); RC4_set_key(&key, 16, key_hash); RC4(&key, 32, cur_binary->extra, data); for (i = 0; i < 32; i++) if (data[i] == 0) num_zero++; if (num_zero < 10) continue; } /* If we got here, looks like we have a candidate */ #ifdef _OPENMP #pragma omp critical { any_cracked = oo_cracked[index] = 1; if (oo_cur_salt->type < 4) { cur_binary->has_mitm = 1; memcpy(cur_binary->mitm, mitm_key[index], 5); } } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/rawMD5_fmt_plug.c
#pragma omp parallel for
100
t; 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 SIMDmd5body(saved_key[index], crypt_key[index], NULL, SSEi_REVERSE_STEPS | SSEi_MIXED_IN); #else MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], saved_len[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/nsec3_fmt_plug.c
#pragma omp parallel for private(i)
100
ic int crypt_all(int *pcount, struct db_salt *salt) { int count = *pcount; int i; #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; ++i) { uint16_t iterations = saved_salt.iterations; SHA_CTX ctx; SHA1_Init(&ctx); if (saved_key_length[i] > 0) { unsigned char label_wf[PLAINTEXT_LENGTH + 2]; labels_to_wireformat(saved_key[i], saved_key_length[i], label_wf); SHA1_Update(&ctx, label_wf, saved_key_length[i] + 1); } /* Minor optimization potential: the above can be performed in set_key() */ /* Major optimization potential: use SIMD */ SHA1_Update(&ctx, saved_salt.zone_wf, saved_salt.zone_wf_length); SHA1_Update(&ctx, saved_salt.salt, saved_salt.salt_length); SHA1_Final((unsigned char *)crypt_out[i], &ctx); while (iterations--) { SHA1_Init(&ctx); SHA1_Update(&ctx, crypt_out[i], BINARY_SIZE); SHA1_Update(&ctx, saved_salt.salt, saved_salt.salt_length); SHA1_Final((unsigned char *)crypt_out[i], &ctx); } }<LOOP-END> <OMP-START>#pragma omp parallel for private(i)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/MSCHAPv2_bs_fmt_plug.c
#pragma omp parallel for
100
struct db_salt *salt) { const int count = *pcount; int i; if (!keys_prepared) { #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { int len; /* Generate 16-byte NTLM hash */ len = E_md4hash((uchar *) saved_plain[i], saved_len[i], saved_key[i]); if (len <= 0) saved_plain[i][-len] = 0; // match truncation /* NULL-padding the 16-byte hash to 21-bytes is made in cmp_exact if needed */ setup_des_key(saved_key[i], i); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/ripemd_fmt_plug.c
#pragma omp parallel for
100
nt crypt_160(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_ripemd160_context ctx; sph_ripemd160_init(&ctx); sph_ripemd160(&ctx, saved_key[index], strlen(saved_key[index])); sph_ripemd160_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/ripemd_fmt_plug.c
#pragma omp parallel for
100
nt crypt_128(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_ripemd128_context ctx; sph_ripemd128_init(&ctx); sph_ripemd128(&ctx, saved_key[index], strlen(saved_key[index])); sph_ripemd128_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/krb5pa-sha1_fmt_plug.c
#pragma omp parallel for
100
unt = *pcount; const int key_size = (cur_salt->etype == 17) ? 16 : 32; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { unsigned char tkey[MIN_KEYS_PER_CRYPT][32]; unsigned char base_key[32]; unsigned char Ke[32]; unsigned char plaintext[TIMESTAMP_SIZE]; int i; int len[MIN_KEYS_PER_CRYPT]; #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, cur_salt->salt,strlen((char*)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[0], cur_salt->salt,strlen((char*)cur_salt->salt), 4096, tkey[0], key_size, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { // generate 128 bits from 40 bits of "kerberos" string // This is precomputed in init() //nfold(8 * 8, (unsigned char*)"kerberos", 128, constant); dk(base_key, tkey[i], key_size, constant, 16); /* The "well-known constant" used for the DK function is the key usage number, * expressed as four octets in big-endian order, followed by one octet indicated below. * Kc = DK(base-key, usage | 0x99); * Ke = DK(base-key, usage | 0xAA); * Ki = DK(base-key, usage | 0x55); */ // derive Ke for decryption/encryption // This is precomputed in init() //memset(usage, 0, sizeof(usage)); //usage[3] = 0x01; // key number in big-endian format //usage[4] = 0xAA; // used to derive Ke //nfold(sizeof(usage) * 8, usage, sizeof(ke_input) * 8, ke_input); dk(Ke, base_key, key_size, ke_input, 16); // decrypt the AS-REQ timestamp encrypted with 256-bit AES // here is enough to check the string, further computation below is required // to fully verify the checksum krb_decrypt(cur_salt->ct, TIMESTAMP_SIZE, plaintext, Ke, key_size); // Check a couple bytes from known plain (YYYYMMDDHHMMSSZ) and // bail out if we are out of luck. if (plaintext[22] == '2' && plaintext[23] == '0' && plaintext[36] == 'Z') { unsigned char Ki[32]; unsigned char checksum[20]; // derive Ki used in HMAC-SHA-1 checksum // This is precomputed in init() //memset(usage, 0, sizeof(usage)); //usage[3] = 0x01; // key number in big-endian format //usage[4] = 0x55; // used to derive Ki //nfold(sizeof(usage) * 8, usage, sizeof(ki_input) * 8, ki_input); dk(Ki, base_key, key_size, ki_input, 16); // derive checksum of plaintext hmac_sha1(Ki, key_size, plaintext, TIMESTAMP_SIZE, checksum, 20); memcpy(crypt_out[index+i], checksum, BINARY_SIZE); } else { memset(crypt_out[index+i], 0, BINARY_SIZE); } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sha3_512_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++) { Keccak_HashInstance hash; Keccak_HashInitialize(&hash, 576, 1024, 512, 0x06); 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/clipperz_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) { SHA256_CTX ctx; unsigned char Tmp[32]; unsigned char TmpHex[64]; memset(crypt_out[j], 0, sizeof(crypt_out[j])); SHA256_Init(&ctx); SHA256_Update(&ctx, saved_key[j], strlen(saved_key[j])); SHA256_Update(&ctx, cur_salt->user_id, strlen((char*)cur_salt->user_id)); SHA256_Final(Tmp, &ctx); SHA256_Init(&ctx); SHA256_Update(&ctx, Tmp, 32); SHA256_Final(Tmp, &ctx); SHA256_Init(&ctx); SHA256_Update(&ctx, cur_salt->saved_salt, strlen((char*)cur_salt->saved_salt)); hex_encode(Tmp, 32, TmpHex); SHA256_Update(&ctx, TmpHex, 64); SHA256_Final(Tmp, &ctx); SHA256_Init(&ctx); SHA256_Update(&ctx, Tmp, 32); SHA256_Final(Tmp, &ctx); #ifdef HAVE_LIBGMP { unsigned char HashStr[80], *p; int i, todo; p = HashStr; for (i = 0; i < 32; ++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; } } #else // using oSSL's BN to do expmod. pSRP_CTX[j].z_exp = BN_bin2bn(Tmp,32,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])); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/sspr_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++) { uint32_t c; SHA_CTX ctx; SHA256_CTX sctx; SHA512_CTX sctx2; MD5_CTX mctx; unsigned char buf[64]; if (cur_salt->fmt == 0) { MD5_Init(&mctx); MD5_Update(&mctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); MD5_Final(buf, &mctx); for (c = 1; c < cur_salt->iterations; c++) { MD5_Init(&mctx); MD5_Update(&mctx, buf, 16); MD5_Final(buf, &mctx); } } else if (cur_salt->fmt == 1) { SHA1_Init(&ctx); SHA1_Update(&ctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); SHA1_Final(buf, &ctx); for (c = 1; c < cur_salt->iterations; c++) { SHA1_Init(&ctx); SHA1_Update(&ctx, buf, 20); SHA1_Final(buf, &ctx); } } else if (cur_salt->fmt == 2) { SHA1_Init(&ctx); SHA1_Update(&ctx, cur_salt->salt, cur_salt->saltlen); SHA1_Update(&ctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); SHA1_Final(buf, &ctx); for (c = 1; c < cur_salt->iterations; c++) { SHA1_Init(&ctx); SHA1_Update(&ctx, buf, 20); SHA1_Final(buf, &ctx); } } else if (cur_salt->fmt == 3) { SHA256_Init(&sctx); SHA256_Update(&sctx, cur_salt->salt, cur_salt->saltlen); SHA256_Update(&sctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); SHA256_Final(buf, &sctx); for (c = 1; c < cur_salt->iterations; c++) { SHA256_Init(&sctx); SHA256_Update(&sctx, buf, 32); SHA256_Final(buf, &sctx); } } else if (cur_salt->fmt == 4) { SHA512_Init(&sctx2); SHA512_Update(&sctx2, cur_salt->salt, cur_salt->saltlen); SHA512_Update(&sctx2, (const unsigned char*)saved_key[index], strlen(saved_key[index])); SHA512_Final(buf, &sctx2); for (c = 1; c < cur_salt->iterations; c++) { SHA512_Init(&sctx2); SHA512_Update(&sctx2, buf, 64); SHA512_Final(buf, &sctx2); } } memcpy(crypt_out[index], buf, BINARY_SIZE_MIN); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/mysql_fmt_plug.c
#pragma omp parallel for default(none) private(i) shared(count, binary, crypt_key, retval)
100
ndex][0]; } static int cmp_all(void* binary, int count) { int i; #ifdef _OPENMP int retval = 0; <LOOP-START>for (i = 0; i < count; i++) if (*(uint32_t *)binary == crypt_key[i][0]) #pragma omp atomic retval |= 1; return retval; #else for (i = 0; i < count; i++) if (*(uint32_t *)binary == crypt_key[i][0]) return 1; return 0; } static int cmp_exact(char* source, int index) { uint32_t *binary = get_binary_size(source, 8); register uint32_t nr = 1345345333, add = 7, nr2 = 0x12345671; register uint32_t tmp; unsigned char *p; p = (unsigned char *)saved_key[index]; for (; *p; p++) { if (*p == ' ' || *p == '\t') continue; tmp = (uint32_t)*p; nr ^= (((nr & 63) + add) * tmp) + (nr << 8); nr2 += (nr2 << 8) ^ nr; add += tmp; } return binary[0] == (nr & (((uint32_t)1 << 31) - 1)) && binary[1] == (nr2 & (((uint32_t)1 << 31) - 1)); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, binary, crypt_key, retval)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/mysql_fmt_plug.c
#pragma omp parallel for default(none) private(i) shared(count, saved_key, crypt_key)
100
ic int crypt_all(int *pcount, struct db_salt *salt) { int count = *pcount; int i; #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { unsigned char *p = (unsigned char *)saved_key[i]; if (*p) { uint32_t nr, add; uint32_t tmp; while (*p == ' ' || *p == '\t') p++; tmp = (uint32_t) (unsigned char) *p++; nr = 1345345333 ^ ((((1345345333 & 63) + 7) * tmp) + (1345345333U << 8)); add = 7 + tmp; for (; *p; p++) { if (*p == ' ' || *p == '\t') continue; tmp = (uint32_t) (unsigned char) *p; nr ^= (((nr & 63) + add) * tmp) + (nr << 8); add += tmp; } crypt_key[i][0] = (nr & (((uint32_t)1 << 31) - 1)); continue; } crypt_key[i][0] = (1345345333 & (((uint32_t)1 << 31) - 1)); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, saved_key, crypt_key)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/keplr_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++) { uint8_t key[32]; int len = strlen(saved_key[index]); #ifdef _OPENMP if (cracked[index]) /* avoid false sharing of nearby elements */ cracked[index] = 0; #ifdef _OPENMP int t = omp_get_thread_num(); if (t >= max_threads) { failed = -1; continue; } #else const int t = 0; // Scrypt part yescrypt_params_t params = { .N = 131072, .r = 8, .p = 1 }; if (yescrypt_kdf(NULL, &local[t], (const uint8_t *)saved_key[index], len, (const uint8_t *)cur_salt->salt, 32, &params, key, 32)) { failed = errno ? errno : EINVAL; #ifndef _OPENMP break; } // Sha256 part SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, key + 16, 16); SHA256_Update(&ctx, cur_salt->ciphertext, cur_salt->ciphertext_size); SHA256_Final(key, &ctx); // Comparison part if (!memcmp(key, cur_salt->mac, 32)) cracked[index] = 1; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/bitwarden_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) { 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, 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], 32, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (bitwarden_decrypt(cur_salt, master[i])) { 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/SybasePROP_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++) { generate_hash((unsigned char*)saved_key[index], saved_salt, (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/o10glogon_fmt_plug.c
#pragma omp parallel for
100
ORACLE dump_stuff_msg("cur_salt ", buf, cur_salt->userlen+key_length); #endif #ifdef _OPENMP <LOOP-START>for (idx = 0; idx < count; idx++) { unsigned char buf[256], buf1[256]; unsigned int l; uint32_t iv[2]; DES_key_schedule desschedule2; l = cur_salt->userlen + cur_key_len[idx]; memcpy(buf, cur_salt->user, cur_salt->userlen); memcpy(buf + cur_salt->userlen, cur_key[idx], cur_key_len[idx]); iv[0] = iv[1] = 0; DES_ncbc_encrypt((unsigned char *)buf, buf1, l, &desschedule1, (DES_cblock *) iv, DES_ENCRYPT); DES_set_key_unchecked((DES_cblock *)iv, &desschedule2); iv[0] = iv[1] = 0; DES_ncbc_encrypt((unsigned char *)buf, buf1, l, &desschedule2, (DES_cblock *) iv, DES_ENCRYPT); #ifdef DEBUG_ORACLE dump_stuff_msg(" iv (the hash key) ", (unsigned char*)&iv[0], 8); ORACLE_TNS_Decrypt_Password_10g ((unsigned char*)iv, cur_salt->auth_sesskey, cur_salt->auth_sesskey_c, cur_salt->auth_pass, cur_salt->auth_pass_len, buf); if (!strncmp((char*)buf, plain_key[idx], strlen(plain_key[idx]))) { cracked[idx] = 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/NETNTLM_bs_fmt_plug.c
#pragma omp parallel for
100
struct db_salt *salt) { const int count = *pcount; int i; if (!keys_prepared) { #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { int len; /* Generate 16-byte NTLM hash */ len = E_md4hash((uchar *) saved_plain[i], saved_len[i], saved_key[i]); if (len <= 0) saved_plain[i][-len] = 0; // match truncation /* NULL-padding the 16-byte hash to 21-bytes is made in cmp_exact if needed */ setup_des_key(saved_key[i], i); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/krb5_tgsrep_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 += MIN_KEYS_PER_CRYPT) { unsigned char tkey[MIN_KEYS_PER_CRYPT][32]; int i; #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 < 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) { pbkdf2_sha1((const unsigned char*)saved_key[index], strlen(saved_key[index+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]; 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/racf_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 (dirty) { DES_cblock des_key; int i; /* process key */ for (i = 0; saved_key[index][i]; i++) des_key[i] = a2e_precomputed[ARCH_INDEX(saved_key[index][i])]; /* replace missing characters in userid by (EBCDIC space (0x40) XOR 0x55) << 1 */ while(i < 8) des_key[i++] = 0x2a; DES_set_key_unchecked(&des_key, &schedules[index]); } /* do encryption */ DES_ecb_encrypt((const_DES_cblock*)cur_salt->userid, (DES_cblock*)crypt_out[index], &schedules[index], DES_ENCRYPT); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/cloudkeychain_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_SHA512 int lens[SSE_GROUP_SZ_SHA512], i; unsigned char *pin[SSE_GROUP_SZ_SHA512]; uint64_t key[SSE_GROUP_SZ_SHA512][8]; union { uint32_t *pout[SSE_GROUP_SZ_SHA512]; unsigned char *poutc; } x; for (i = 0; i < SSE_GROUP_SZ_SHA512; ++i) { lens[i] = strlen(saved_key[index+i]); pin[i] = (unsigned char*)saved_key[index+i]; x.pout[i] = (uint32_t*)(key[i]); } pbkdf2_sha512_sse((const unsigned char **)pin, lens, cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, &(x.poutc), HASH_LENGTH, 0); for (i = 0; i < SSE_GROUP_SZ_SHA512; ++i) cracked[index+i] = ckcdecrypt((unsigned char*)(key[i])); #else uint64_t key[8]; pbkdf2_sha512((const unsigned char*)(saved_key[index]), strlen(saved_key[index]), cur_salt->salt, cur_salt->saltlen, cur_salt->iterations, (unsigned char*)key, HASH_LENGTH, 0); cracked[index] = ckcdecrypt((unsigned char*)key); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/androidbackup_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 pkey[MIN_KEYS_PER_CRYPT][32]; int i; #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 < MIN_KEYS_PER_CRYPT; ++i) { len[i] = strlen(saved_key[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = pkey[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, len, cur_salt->user_salt, cur_salt->user_salt_length, cur_salt->iterations, pout, 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->user_salt, cur_salt->user_salt_length, cur_salt->iterations, pkey[i], 32, 0); } for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) { if (check_password(pkey[i], cur_salt)) { cracked[index+i] = 1; #ifdef _OPENMP #pragma omp atomic any_cracked |= 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/net_md5_fmt_plug.c
#pragma omp parallel for
100
ur_salt->magic != MAGIC) { return pDynamicFmt->methods.crypt_all(pcount, salt); } #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, cur_salt->salt, cur_salt->length); MD5_Update(&ctx, saved_key[index], PLAINTEXT_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/vdi_fmt_plug.c
#pragma omp parallel for
100
crypt_all(int *pcount, struct db_salt *salt) { int i; const int count = *pcount; #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i += MIN_KEYS_PER_CRYPT) { unsigned char key[MAX_KEY_LEN]; #if SSE_GROUP_SZ_SHA256 unsigned char Keys[SSE_GROUP_SZ_SHA256][MAX_KEY_LEN]; unsigned char Decr[SSE_GROUP_SZ_SHA256][MAX_KEY_LEN]; #else unsigned char Decr[1][MAX_KEY_LEN]; int ksz = strlen((char *)key_buffer[i]); int j; #if SSE_GROUP_SZ_SHA256 int lens[SSE_GROUP_SZ_SHA256]; unsigned char *pin[SSE_GROUP_SZ_SHA256]; union { unsigned char *pout[SSE_GROUP_SZ_SHA256]; unsigned char *poutc; } x; for (j = 0; j < SSE_GROUP_SZ_SHA256; ++j) { lens[j] = strlen((char*)(key_buffer[i+j])); pin[j] = key_buffer[i+j]; x.pout[j] = Keys[j]; } pbkdf2_sha256_sse((const unsigned char **)pin, lens, psalt->salt1, psalt->saltlen, psalt->rounds1, &(x.poutc), psalt->keylen, 0); #else pbkdf2_sha256((const unsigned char*)key_buffer[i], ksz, psalt->salt1, psalt->saltlen, psalt->rounds1, key, psalt->keylen, 0); for (j = 0; j < MIN_KEYS_PER_CRYPT; ++j) { #if SSE_GROUP_SZ_SHA256 memcpy(key, Keys[j], sizeof(key)); // Try to decrypt using AES AES_XTS_decrypt(key, Decr[j], psalt->encr, psalt->keylen, psalt->evp_type); } #if SSE_GROUP_SZ_SHA256 for (j = 0; j < SSE_GROUP_SZ_SHA256; ++j) { lens[j] = psalt->keylen; pin[j] = Decr[j]; x.pout[j] = crypt_out[i+j]; } pbkdf2_sha256_sse((const unsigned char **)pin, lens, psalt->salt2, psalt->saltlen, psalt->rounds2, &(x.poutc), psalt->saltlen, 0); #else pbkdf2_sha256(Decr[0], psalt->keylen, psalt->salt2, psalt->saltlen, psalt->rounds2, crypt_out[i], psalt->saltlen, 0); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/agilekeychain_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 += MAX_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_32 unsigned char master[MAX_KEYS_PER_CRYPT][32]; int lens[MAX_KEYS_PER_CRYPT], i; 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[i+index]); pin[i] = (unsigned char*)saved_key[i+index]; pout[i] = master[i]; } pbkdf2_sha1_sse((const unsigned char **)pin, lens, cur_salt->salt[0], cur_salt->saltlen[0], cur_salt->iterations[0], pout, 16, 0); for (i = 0; i < MAX_KEYS_PER_CRYPT; ++i) { if (akcdecrypt(master[i], cur_salt->ct[0]) == 0) cracked[i+index] = 1; else cracked[i+index] = 0; } #else unsigned char master[32]; pbkdf2_sha1((unsigned char *)saved_key[index], strlen(saved_key[index]), cur_salt->salt[0], cur_salt->saltlen[0], cur_salt->iterations[0], master, 16, 0); if (akcdecrypt(master, cur_salt->ct[0]) == 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/stribog_fmt_plug.c
#pragma omp parallel for
100
pt_256(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { /* GOST34112012Context ctx; GOST34112012Init(&ctx, 256); GOST34112012Update(&ctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); GOST34112012Final(&ctx, (unsigned char*)crypt_out[index]); */ GOST34112012Context ctx[2]; // alignment stuff stribog256_init((void *)ctx); stribog_update(&ctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); stribog_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/stribog_fmt_plug.c
#pragma omp parallel for
100
ypt_512(int *pcount, struct db_salt *salt) { const int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { GOST34112012Context ctx[2]; // alignment stuff stribog512_init((void *)ctx); stribog_update(&ctx, (const unsigned char*)saved_key[index], strlen(saved_key[index])); stribog_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/snefru_fmt_plug.c
#pragma omp parallel for
100
nt crypt_256(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { snefru_ctx ctx;; rhash_snefru256_init(&ctx); rhash_snefru_update(&ctx, (unsigned char*)saved_key[index], strlen(saved_key[index])); rhash_snefru_final(&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/snefru_fmt_plug.c
#pragma omp parallel for
100
nt crypt_128(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { snefru_ctx ctx;; rhash_snefru128_init(&ctx); rhash_snefru_update(&ctx, (unsigned char*)saved_key[index], strlen(saved_key[index])); rhash_snefru_final(&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/dragonfly4_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++) { SHA512_CTX ctx; SHA512_Init(&ctx); /* First the password */ SHA512_Update(&ctx, saved_key[index], saved_len[index]); /* Then the salt, including the $4$ magic */ SHA512_Update(&ctx, cur_salt, salt_len); 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/radmin_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; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], sizeof(saved_key[index])); 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/MD5_fmt.c
#pragma omp parallel for
100
nt, struct db_salt *salt) { const int count = *pcount; #ifdef SIMD_PARA_MD5 #ifdef _OPENMP int t; <LOOP-START>for (t = 0; t < omp_para; t++) md5cryptsse((unsigned char *)(&saved_key[t*MD5_N]), cursalt, (char *)(&sout[t*MD5_N*BINARY_SIZE/sizeof(MD5_word)]), CryptType); #else md5cryptsse((unsigned char *)saved_key, cursalt, (char *)sout, CryptType); #else MD5_std_crypt(count); return count; } static int cmp_all(void *binary, int count) { #ifdef SIMD_PARA_MD5 unsigned int x,y; for (y=0;y<SIMD_PARA_MD5*omp_para;y++) for (x=0;x<SIMD_COEF_32;x++) { if ( ((MD5_word *)binary)[0] == ((MD5_word *)sout)[x+y*SIMD_COEF_32*4] ) return 1; } return 0; #else #if MD5_std_mt int t, n = (count + (MD5_N - 1)) / MD5_N; for_each_t(n) { #if MD5_X2 if (*(MD5_word *)binary == MD5_out[0][0] || *(MD5_word *)binary == MD5_out[1][0]) return 1; #else if (*(MD5_word *)binary == MD5_out[0][0]) return 1; } return 0; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/o3logon_fmt_plug.c
#pragma omp parallel for
100
ORACLE dump_stuff_msg("cur_salt ", buf, cur_salt->userlen+key_length); #endif #ifdef _OPENMP <LOOP-START>for (idx = 0; idx < count; idx++) { unsigned char buf[256], buf1[256]; unsigned int l; uint32_t iv[2]; DES_key_schedule desschedule2; l = cur_salt->userlen + cur_key_len[idx]; memcpy(buf, cur_salt->user, cur_salt->userlen); memcpy(buf + cur_salt->userlen, cur_key[idx], cur_key_len[idx]); iv[0] = iv[1] = 0; DES_ncbc_encrypt((unsigned char *)buf, buf1, l, &desschedule1, (DES_cblock *) iv, DES_ENCRYPT); DES_set_key_unchecked((DES_cblock *)iv, &desschedule2); iv[0] = iv[1] = 0; DES_ncbc_encrypt((unsigned char *)buf, buf1, l, &desschedule2, (DES_cblock *) iv, DES_ENCRYPT); #ifdef DEBUG_ORACLE dump_stuff_msg(" iv (the hash key) ", (unsigned char*)&iv[0], 8); ORACLE_TNS_Decrypt_Password_9i ((unsigned char*)iv, cur_salt->auth_sesskey, 16, cur_salt->auth_pass, cur_salt->auth_pass_len, buf); if (!strncmp((char*)buf, plain_key[idx], strlen(plain_key[idx]))) { cracked[idx] = 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/timeroast_fmt_plug.c
#pragma omp parallel for default(none) private(i) shared(count, ms_buffer1x, crypt_out, last)
100
output1x[4 * index] & PH_MASK_6; } static void nt_hash(int count) { int i; #if defined(_OPENMP) <LOOP-START>for (i = 0; i < count; i++) { unsigned int a; unsigned int b; unsigned int c; unsigned int d; /* Round 1 */ a = 0xFFFFFFFF + ms_buffer1x[16 * i + 0];a = (a << 3 ) | (a >> 29); d = INIT_D + (INIT_C ^ (a & 0x77777777)) + ms_buffer1x[16 * i + 1];d = (d << 7 ) | (d >> 25); c = INIT_C + (INIT_B ^ (d & (a ^ INIT_B)))+ ms_buffer1x[16 * i + 2];c = (c << 11) | (c >> 21); b = INIT_B + (a ^ (c & (d ^ a))) + ms_buffer1x[16 * i + 3];b = (b << 19) | (b >> 13); a += (d ^ (b & (c ^ d))) + ms_buffer1x[16 * i + 4] ;a = (a << 3 ) | (a >> 29); d += (c ^ (a & (b ^ c))) + ms_buffer1x[16 * i + 5] ;d = (d << 7 ) | (d >> 25); c += (b ^ (d & (a ^ b))) + ms_buffer1x[16 * i + 6] ;c = (c << 11) | (c >> 21); b += (a ^ (c & (d ^ a))) + ms_buffer1x[16 * i + 7] ;b = (b << 19) | (b >> 13); a += (d ^ (b & (c ^ d))) + ms_buffer1x[16 * i + 8] ;a = (a << 3 ) | (a >> 29); d += (c ^ (a & (b ^ c))) + ms_buffer1x[16 * i + 9] ;d = (d << 7 ) | (d >> 25); c += (b ^ (d & (a ^ b))) + ms_buffer1x[16 * i + 10] ;c = (c << 11) | (c >> 21); b += (a ^ (c & (d ^ a))) + ms_buffer1x[16 * i + 11] ;b = (b << 19) | (b >> 13); a += (d ^ (b & (c ^ d))) + ms_buffer1x[16 * i + 12] ;a = (a << 3 ) | (a >> 29); d += (c ^ (a & (b ^ c))) + ms_buffer1x[16 * i + 13] ;d = (d << 7 ) | (d >> 25); c += (b ^ (d & (a ^ b))) + ms_buffer1x[16 * i + 14] ;c = (c << 11) | (c >> 21); b += (a ^ (c & (d ^ a)))/*+ms_buffer1x[16 * i + 15]*/;b = (b << 19) | (b >> 13); /* Round 2 */ a += ((b & (c | d)) | (c & d)) + ms_buffer1x[16 * i + 0] + SQRT_2; a = (a << 3 ) | (a >> 29); d += ((a & (b | c)) | (b & c)) + ms_buffer1x[16 * i + 4] + SQRT_2; d = (d << 5 ) | (d >> 27); c += ((d & (a | b)) | (a & b)) + ms_buffer1x[16 * i + 8] + SQRT_2; c = (c << 9 ) | (c >> 23); b += ((c & (d | a)) | (d & a)) + ms_buffer1x[16 * i + 12] + SQRT_2; b = (b << 13) | (b >> 19); a += ((b & (c | d)) | (c & d)) + ms_buffer1x[16 * i + 1] + SQRT_2; a = (a << 3 ) | (a >> 29); d += ((a & (b | c)) | (b & c)) + ms_buffer1x[16 * i + 5] + SQRT_2; d = (d << 5 ) | (d >> 27); c += ((d & (a | b)) | (a & b)) + ms_buffer1x[16 * i + 9] + SQRT_2; c = (c << 9 ) | (c >> 23); b += ((c & (d | a)) | (d & a)) + ms_buffer1x[16 * i + 13] + SQRT_2; b = (b << 13) | (b >> 19); a += ((b & (c | d)) | (c & d)) + ms_buffer1x[16 * i + 2] + SQRT_2; a = (a << 3 ) | (a >> 29); d += ((a & (b | c)) | (b & c)) + ms_buffer1x[16 * i + 6] + SQRT_2; d = (d << 5 ) | (d >> 27); c += ((d & (a | b)) | (a & b)) + ms_buffer1x[16 * i + 10] + SQRT_2; c = (c << 9 ) | (c >> 23); b += ((c & (d | a)) | (d & a)) + ms_buffer1x[16 * i + 14] + SQRT_2; b = (b << 13) | (b >> 19); a += ((b & (c | d)) | (c & d)) + ms_buffer1x[16 * i + 3] + SQRT_2; a = (a << 3 ) | (a >> 29); d += ((a & (b | c)) | (b & c)) + ms_buffer1x[16 * i + 7] + SQRT_2; d = (d << 5 ) | (d >> 27); c += ((d & (a | b)) | (a & b)) + ms_buffer1x[16 * i + 11] + SQRT_2; c = (c << 9 ) | (c >> 23); b += ((c & (d | a)) | (d & a))/*+ms_buffer1x[16 * i + 15]*/+SQRT_2; b = (b << 13) | (b >> 19); /* Round 3 */ a += (b ^ c ^ d) + ms_buffer1x[16 * i + 0] + SQRT_3; a = (a << 3 ) | (a >> 29); d += (a ^ b ^ c) + ms_buffer1x[16 * i + 8] + SQRT_3; d = (d << 9 ) | (d >> 23); c += (d ^ a ^ b) + ms_buffer1x[16 * i + 4] + SQRT_3; c = (c << 11) | (c >> 21); b += (c ^ d ^ a) + ms_buffer1x[16 * i + 12] + SQRT_3; b = (b << 15) | (b >> 17); a += (b ^ c ^ d) + ms_buffer1x[16 * i + 2] + SQRT_3; a = (a << 3 ) | (a >> 29); d += (a ^ b ^ c) + ms_buffer1x[16 * i + 10] + SQRT_3; d = (d << 9 ) | (d >> 23); c += (d ^ a ^ b) + ms_buffer1x[16 * i + 6] + SQRT_3; c = (c << 11) | (c >> 21); b += (c ^ d ^ a) + ms_buffer1x[16 * i + 14] + SQRT_3; b = (b << 15) | (b >> 17); a += (b ^ c ^ d) + ms_buffer1x[16 * i + 1] + SQRT_3; a = (a << 3 ) | (a >> 29); d += (a ^ b ^ c) + ms_buffer1x[16 * i + 9] + SQRT_3; d = (d << 9 ) | (d >> 23); c += (d ^ a ^ b) + ms_buffer1x[16 * i + 5] + SQRT_3; c = (c << 11) | (c >> 21); b += (c ^ d ^ a) + ms_buffer1x[16 * i + 13] + SQRT_3; b = (b << 15) | (b >> 17); a += (b ^ c ^ d) + ms_buffer1x[16 * i + 3] + SQRT_3; a = (a << 3 ) | (a >> 29); d += (a ^ b ^ c) + ms_buffer1x[16 * i + 11] + SQRT_3; d = (d << 9 ) | (d >> 23); c += (d ^ a ^ b) + ms_buffer1x[16 * i + 7] + SQRT_3; c = (c << 11) | (c >> 21); b += (c ^ d ^ a) /*+ ms_buffer1x[16 * i + 15] */+ SQRT_3; b = (b << 15) | (b >> 17); last[4 * i + 0] = a + INIT_A; last[4 * i + 1] = b + INIT_B; last[4 * i + 2] = c + INIT_C; last[4 * i + 3] = d + INIT_D; }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, ms_buffer1x, crypt_out, last)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/timeroast_fmt_plug.c
#pragma omp parallel for
100
t); #if !ARCH_LITTLE_ENDIAN swap(last, count * 4); #endif new_key = 0; } #if defined(_OPENMP) <LOOP-START>for (i = 0; i < count; i++) { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, &((unsigned char*)last)[16 * i], 16); MD5_Update(&ctx, salt_buffer, SALT_SIZE); MD5_Final(&((unsigned char*)output1x)[16 * i], &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/tcp_md5_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; MD5_Init(&ctx); MD5_Update(&ctx, cur_salt->salt, cur_salt->length); MD5_Update(&ctx, saved_key[index], saved_len[index]); 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/DOMINOSEC_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 += 3) { int i, j; if (keys_changed) { char *k0 = saved_key[index]; char *k1 = saved_key[index + 1]; char *k2 = saved_key[index + 2]; unsigned char digest16[3][16]; domino_big_md_3((unsigned char *)k0, strlen(k0), (unsigned char *)k1, strlen(k1), (unsigned char *)k2, strlen(k2), digest16[0], digest16[1], digest16[2]); /* Not (++i < 16) ! * Domino will do hash of first 34 bytes ignoring The Fact that now * there is a salt at a beginning of buffer. This means that last 5 * bytes "EEFF)" of password digest are meaningless. */ for (i = 0, j = 6; i < 14; i++, j += 2) { const char *hex2 = hex_table[ARCH_INDEX(digest16[0][i])]; digest34[index][j] = hex2[0]; digest34[index][j + 1] = hex2[1]; hex2 = hex_table[ARCH_INDEX(digest16[1][i])]; digest34[index + 1][j] = hex2[0]; digest34[index + 1][j + 1] = hex2[1]; hex2 = hex_table[ARCH_INDEX(digest16[2][i])]; digest34[index + 2][j] = hex2[0]; digest34[index + 2][j + 1] = hex2[1]; } } if (salt_changed) { digest34[index + 2][0] = digest34[index + 1][0] = digest34[index][0] = saved_salt[0]; digest34[index + 2][1] = digest34[index + 1][1] = digest34[index][1] = saved_salt[1]; digest34[index + 2][2] = digest34[index + 1][2] = digest34[index][2] = saved_salt[2]; digest34[index + 2][3] = digest34[index + 1][3] = digest34[index][3] = saved_salt[3]; digest34[index + 2][4] = digest34[index + 1][4] = digest34[index][4] = saved_salt[4]; digest34[index + 2][5] = digest34[index + 1][5] = digest34[index][5] = '('; } domino_big_md_3_34(digest34[index], digest34[index + 1], digest34[index + 2], (unsigned char *)crypt_out[index], (unsigned char *)crypt_out[index + 1], (unsigned char *)crypt_out[index + 2]); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/oracle_fmt_plug.c
#pragma omp parallel for
100
_all(int *pcount, struct db_salt *salt) { const int count = *pcount; int idx = 0; #ifdef _OPENMP <LOOP-START>for (idx = 0; idx < count; idx++) { unsigned char buf[sizeof(cur_salt)]; unsigned char buf2[SALT_SIZE + PLAINTEXT_LENGTH*2]; DES_key_schedule sched_local; unsigned int l; l = salt_length + key_length[idx]; memcpy(buf2, cur_salt, salt_length); memcpy(buf2 + salt_length, cur_key[idx], key_length[idx]); #ifdef DEBUG_ORACLE dump_stuff_msg("cur_salt ", buf2, salt_length+key_length[idx]); crypt_key[idx][0] = 0; crypt_key[idx][1] = 0; DES_ncbc_encrypt(buf2, buf, l, &desschedule_static, (DES_cblock *) crypt_key[idx], DES_ENCRYPT); DES_set_key_unchecked((DES_cblock *)crypt_key[idx], &sched_local); crypt_key[idx][0] = 0; crypt_key[idx][1] = 0; DES_ncbc_encrypt(buf2, buf, l, &sched_local, (DES_cblock *) crypt_key[idx], DES_ENCRYPT); #ifdef DEBUG_ORACLE dump_stuff_msg(" crypt_key ", (unsigned char*)&crypt_key[idx][0], 8); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/wpapsk.h
#pragma omp parallel for default(none) private(i) shared(count, outbuffer, msg, mic)
100
"PMK Name"; memcpy(msg + 8, hccap->mac1, 6); memcpy(msg + 14, hccap->mac2, 6); #ifdef _OPENMP <LOOP-START>/* Create "keymic" that is actually PMKID */ for (i = 0; i < count; i++) { hmac_sha1((unsigned char*)outbuffer[i].v, 32, msg, 20, mic[i].keymic, 16); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, outbuffer, msg, mic)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/wpapsk.h
#pragma omp parallel for default(none) private(i) shared(count, outbuffer, data, hccap, mic)
100
t_mac(hccap, data); insert_nonce(hccap, data + 12); } if (hccap->keyver == 1) { #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { union { uint32_t u32[20/4]; unsigned char uc[20]; uint64_t dummy; /* alignment for hmac_md5_init_K16() */ } prf; HMACMD5Context ctx; prf_512(outbuffer[i].v, data, prf.u32); // PTK hmac_md5_init_K16(prf.uc, &ctx); hmac_md5_update(hccap->eapol, hccap->eapol_size, &ctx); hmac_md5_final(mic[i].keymic, &ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, outbuffer, data, hccap, mic)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/wpapsk.h
#pragma omp parallel for default(none) private(i) shared(count, outbuffer, data, hccap, mic)
100
&ctx); hmac_md5_final(mic[i].keymic, &ctx); } } else if (hccap->keyver == 2) { #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { uint32_t prf[20/4]; prf_512(outbuffer[i].v, data, prf); // PTK hmac_sha1((unsigned char*)prf, 16, hccap->eapol, hccap->eapol_size, mic[i].keymic, 16); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, outbuffer, data, hccap, mic)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/wpapsk.h
#pragma omp parallel for default(none) private(i) shared(count, outbuffer, data, hccap, mic)
100
#if HAVE_OPENSSL_CMAC_H } else if (hccap->keyver == 3) { // 802.11w, WPA-PSK-SHA256 #ifdef _OPENMP <LOOP-START>for (i = 0; i < count; i++) { unsigned char ptk[48]; unsigned char cmic[16]; size_t miclen; CMAC_CTX *ctx; sha256_prf_bits((unsigned char*)outbuffer[i].v, 32, "Pairwise key expansion", data, 76, ptk, 48 * 8); // PTK // Compute MIC ctx = CMAC_CTX_new(); CMAC_Init(ctx, ptk, 16, EVP_aes_128_cbc(), 0); CMAC_Update(ctx, hccap->eapol, hccap->eapol_size); CMAC_Final(ctx, cmic, &miclen); memcpy(mic[i].keymic, cmic, 16); CMAC_CTX_free(ctx); }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) private(i) shared(count, outbuffer, data, hccap, mic)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/openwall/john/src/hmacSHA256_fmt_plug.c
#pragma omp parallel for
100
LAGS #else const int B_LEN #endif ) { const int count = *pcount; int index = 0; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) { #ifdef SIMD_COEF_32 unsigned int i, *pclear; if (new_keys) { SIMDSHA256body(&ipad[index * PAD_SIZE], (unsigned int*)&prep_ipad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN|EX_FLAGS); SIMDSHA256body(&opad[index * PAD_SIZE], (unsigned int*)&prep_opad[index * BINARY_SIZE], NULL, SSEi_MIXED_IN|EX_FLAGS); } SIMDSHA256body(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|EX_FLAGS); for (i = 1; i <= (cur_salt->salt_len + 8) / PAD_SIZE; i++) SIMDSHA256body(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|EX_FLAGS); if (EX_FLAGS) { // NOTE, SSESHA224 will output 32 bytes. We need the first 28 (plus the 0x80 padding). // so we are forced to 'clean' this crap up, before using the crypt as the input. pclear = (unsigned int*)&crypt_key[(unsigned int)index/SIMD_COEF_32*PAD_SIZE_W*SIMD_COEF_32*4]; for (i = 0; i < MIN_KEYS_PER_CRYPT; i++) pclear[28/4*SIMD_COEF_32+(i&(SIMD_COEF_32-1))+i/SIMD_COEF_32*PAD_SIZE_W*SIMD_COEF_32] = 0x80000000; } SIMDSHA256body(&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|EX_FLAGS); #else SHA256_CTX ctx; // Note, for oSSL, we really only need SHA256_Init and SHA224_Init. From that point // on, SHA256_Update/SHA256_Final can be used. Also, jtr internal sha2.c file works // like that. BUT I am not sure every hash engine works that way, so we are keeping // the 'full' block. if (B_LEN == BINARY_SIZE) { if (new_keys) { SHA256_Init(&ipad_ctx[index]); SHA256_Update(&ipad_ctx[index], ipad[index], PAD_SIZE); SHA256_Init(&opad_ctx[index]); SHA256_Update(&opad_ctx[index], opad[index], PAD_SIZE); } memcpy(&ctx, &ipad_ctx[index], sizeof(ctx)); SHA256_Update( &ctx, cur_salt, strlen( (char*) cur_salt) ); SHA256_Final( (unsigned char*) crypt_key[index], &ctx); memcpy(&ctx, &opad_ctx[index], sizeof(ctx)); SHA256_Update( &ctx, crypt_key[index], B_LEN); SHA256_Final( (unsigned char*) crypt_key[index], &ctx); } else { if (new_keys) { SHA224_Init(&ipad_ctx[index]); SHA224_Update(&ipad_ctx[index], ipad[index], PAD_SIZE); SHA224_Init(&opad_ctx[index]); SHA224_Update(&opad_ctx[index], opad[index], PAD_SIZE); } memcpy(&ctx, &ipad_ctx[index], sizeof(ctx)); SHA224_Update( &ctx, cur_salt, strlen( (char*) cur_salt) ); SHA224_Final( (unsigned char*) crypt_key[index], &ctx); memcpy(&ctx, &opad_ctx[index], sizeof(ctx)); SHA224_Update( &ctx, crypt_key[index], B_LEN); SHA224_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/siemens-s7_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[20]; SHA_CTX ctx; if (new_keys) { unsigned char pad[20]; int i; SHA1_Init(&ctx); SHA1_Update(&ctx, saved_key[index], strlen(saved_key[index])); SHA1_Final(buf, &ctx); for (i = 0; i < 20; ++i) { pad[i] = buf[i] ^ 0x36; } SHA1_Init(&ipad_ctx[index]); SHA1_Update(&ipad_ctx[index], pad, 20); SHA1_Update(&ipad_ctx[index], "\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36\x36", 44); for (i = 0; i < 20; ++i) { pad[i] = buf[i] ^ 0x5C; } SHA1_Init(&opad_ctx[index]); SHA1_Update(&opad_ctx[index], pad, 20); SHA1_Update(&opad_ctx[index], "\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C", 44); } memcpy(&ctx, &ipad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, challenge, 20); SHA1_Final(buf, &ctx); memcpy(&ctx, &opad_ctx[index], sizeof(ctx)); SHA1_Update(&ctx, buf, 20); 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/postgres_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; unsigned char out[32]; MD5_Init(&ctx); MD5_Update(&ctx, saved_key[index], strlen(saved_key[index])); MD5_Update(&ctx, cur_salt->user, strlen((char*)cur_salt->user)); MD5_Final((unsigned char*)crypt_out[index], &ctx); hex_encode((unsigned char*)crypt_out[index], 16, out); MD5_Init(&ctx); MD5_Update(&ctx, out, 32); MD5_Update(&ctx, cur_salt->salt, 4); 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/haval_fmt_plug.c
#pragma omp parallel for
100
crypt_256_3(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_haval256_3_context ctx; sph_haval256_3_init(&ctx); sph_haval256_3(&ctx, saved_key[index], strlen(saved_key[index])); sph_haval256_3_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/haval_fmt_plug.c
#pragma omp parallel for
100
crypt_128_4(int *pcount, struct db_salt *salt) { int count = *pcount; int index; #ifdef _OPENMP <LOOP-START>for (index = 0; index < count; index++) { sph_haval128_4_context ctx; sph_haval128_4_init(&ctx); sph_haval128_4(&ctx, saved_key[index], strlen(saved_key[index])); sph_haval128_4_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/mdc2_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++) { JtR_MDC2_CTX ctx; JtR_MDC2_Init(&ctx); JtR_MDC2_Update(&ctx, (unsigned char*)saved_key[index], saved_len[index]); JtR_MDC2_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/strip_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]; unsigned char output[24]; unsigned char *iv_in; unsigned char iv_out[16]; int size,i; int page_sz = 1008; /* 1024 - strlen(SQLITE_FILE_HEADER) */ int reserve_sz = 16; /* for HMAC off case */ AES_KEY akey; #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 < MIN_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, cur_salt->salt, 16, ITERATIONS, pout, 32, 0); #else pbkdf2_sha1((unsigned char *)saved_key[index], strlen(saved_key[index]), cur_salt->salt, 16, ITERATIONS, master[0], 32, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { // memcpy(output, SQLITE_FILE_HEADER, FILE_HEADER_SZ); size = page_sz - reserve_sz; iv_in = cur_salt->data + size + 16; 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 (strip_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/keychain_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_sha1_sse((const unsigned char**)pin, lens, cur_salt->salt, SALTLEN, 1000, pout, 24, 0); #else pbkdf2_sha1((unsigned char *)saved_key[index], strlen(saved_key[index]), cur_salt->salt, SALTLEN, 1000, master[0], 24, 0); for (i = 0; i < MIN_KEYS_PER_CRYPT; ++i) { if (kcdecrypt(master[i], cur_salt->iv, cur_salt->ct) == 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/opencl_electrum_modern_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++) { BIGNUM *p, *q, *r; BN_CTX *ctx; uint64_t u[8]; unsigned char static_privkey[64]; unsigned char shared_pubkey[33]; unsigned char keys[128]; unsigned char cmac[32]; secp256k1_context *sctx; SHA512_CTX md_ctx; int shared_pubkeylen= 33; int j; memcpy(u, host_crack[index].hash, 64); for (j = 0; j < 8; j++) u[j] = JOHNSWAP64(u[j]); memcpy(static_privkey, u, 64); // do static_privkey % GROUP_ORDER p = BN_bin2bn(static_privkey, 64, NULL); q = BN_new(); r = BN_new(); BN_hex2bn(&q, group_order); ctx = BN_CTX_new(); BN_mod(r, p, q, ctx); BN_CTX_free(ctx); BN_free(p); BN_free(q); BN_bn2binpad32(r, static_privkey); BN_free(r); sctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE); // multiply point with a scaler, shared_pubkey is compressed representation secp256k1_mul(sctx, shared_pubkey, &cur_salt->pubkey, static_privkey); secp256k1_context_destroy(sctx); SHA512_Init(&md_ctx); SHA512_Update(&md_ctx, shared_pubkey, shared_pubkeylen); SHA512_Final(keys, &md_ctx); if (cur_salt->type == 4) { // calculate mac of data hmac_sha256(keys + 32, 32, cur_salt->data, cur_salt->datalen, cmac, 32); memcpy(crypt_out[index], cmac, BINARY_SIZE); } else if (cur_salt->type == 5) { z_stream z; unsigned char iv[16]; unsigned char out[512] = { 0 }; unsigned char fout[512] = { 0 }; AES_KEY aes_decrypt_key; // common zlib settings z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL; z.avail_in = 512; z.avail_out = 512; z.next_out = fout; memcpy(iv, keys, 16); memset(crypt_out[index], 0, BINARY_SIZE); // fast zlib based rejection test, is this totally safe? AES_set_decrypt_key(keys + 16, 128, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->data, out, 16, &aes_decrypt_key, iv, AES_DECRYPT); if ((memcmp(out, "\x78\x9c", 2) != 0) || (((out[2] & 0x7) != 0x4) && ((out[2] & 0x7) != 0x5))) { } else { AES_set_decrypt_key(keys + 16, 128, &aes_decrypt_key); AES_cbc_encrypt(cur_salt->data + 16, out + 16, 512 - 16, &aes_decrypt_key, iv, AES_DECRYPT); z.next_in = out; inflateInit2(&z, 15); inflate(&z, Z_NO_FLUSH); inflateEnd(&z); if ((memcmp(fout, EXPECTED_BYTES_1, 7) == 0) || (memcmp(fout, EXPECTED_BYTES_2, 8) == 0)) memcpy(crypt_out[index], cur_salt->mac, BINARY_SIZE); // dirty hack! } } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>