2 #pragma warning(disable : 4786 4267 4018)
5 #include "rcrackiThread.h"
7 // create job for pre-calculation
8 rcrackiThread::rcrackiThread(unsigned char* TargetHash, int thread_id, int nRainbowChainLen, int thread_count, uint64* pStartPosIndexE)
10 t_TargetHash = TargetHash;
11 t_nRainbowChainLen = nRainbowChainLen;
13 t_count = thread_count;
14 t_pStartPosIndexE = pStartPosIndexE;
16 falseAlarmChecker = false;
17 falseAlarmCheckerO = false;
20 // create job for false alarm checking
21 rcrackiThread::rcrackiThread(unsigned char* pHash)
23 falseAlarmChecker = true;
24 falseAlarmCheckerO = false;
25 t_pChainsFound.clear();
26 t_nGuessedPoss.clear();
28 t_nChainWalkStepDueToFalseAlarm = 0;
33 // create job for false alarm checking OLD format
34 rcrackiThread::rcrackiThread(unsigned char* pHash, bool oldFormat)
36 falseAlarmChecker = true;
37 falseAlarmCheckerO = true;
38 t_pChainsFoundO.clear();
39 t_nGuessedPoss.clear();
41 t_nChainWalkStepDueToFalseAlarm = 0;
47 void rcrackiThread::AddAlarmCheck(RainbowChain* pChain, int nGuessedPos)
49 t_pChainsFound.push_back(pChain);
50 t_nGuessedPoss.push_back(nGuessedPos);
53 void rcrackiThread::AddAlarmCheckO(RainbowChainO* pChain, int nGuessedPos)
55 t_pChainsFoundO.push_back(pChain);
56 t_nGuessedPoss.push_back(nGuessedPos);
59 // Windows (beginthreadex) way of threads
60 //unsigned __stdcall rcrackiThread::rcrackiThreadStaticEntryPoint(void * pThis)
62 // rcrackiThread* pTT = (rcrackiThread*)pThis;
63 // pTT->rcrackiThreadEntryPoint();
68 // entry point for the posix thread
69 void * rcrackiThread::rcrackiThreadStaticEntryPointPthread(void * pThis)
71 rcrackiThread* pTT = (rcrackiThread*)pThis;
72 pTT->rcrackiThreadEntryPoint();
77 // start processing of jobs
78 void rcrackiThread::rcrackiThreadEntryPoint()
80 if (falseAlarmChecker) {
81 if (falseAlarmCheckerO) {
93 uint64 rcrackiThread::GetIndex(int nPos)
95 uint64 t_index = t_vStartPosIndexE[nPos - t_ID];
99 int rcrackiThread::GetChainWalkStep()
101 return t_nChainWalkStep;
104 int rcrackiThread::GetIndexCount()
106 return t_vStartPosIndexE.size();
109 rcrackiThread::~rcrackiThread(void)
113 void rcrackiThread::PreCalculate()
115 for (t_nPos = t_nRainbowChainLen - 2 - t_ID; t_nPos >= 0; t_nPos -= t_count)
117 t_cwc.SetHash(t_TargetHash);
118 t_cwc.HashToIndex(t_nPos);
120 for (i = t_nPos + 1; i <= t_nRainbowChainLen - 2; i++)
121 //for (i = t_nPos + 1; i <= 10; i++)
123 t_cwc.IndexToPlain();
125 t_cwc.HashToIndex(i);
127 t_pStartPosIndexE[t_nPos] = t_cwc.GetIndex();
128 t_nChainWalkStep += t_nRainbowChainLen - 2 - t_nPos;
132 void rcrackiThread::CheckAlarm()
135 for (i = 0; i < t_pChainsFound.size(); i++)
137 RainbowChain* t_pChain = t_pChainsFound[i];
138 int t_nGuessedPos = t_nGuessedPoss[i];
140 CChainWalkContext cwc;
141 //uint64 nIndexS = t_pChain->nIndexS & 0x0000FFFFFFFFFFFF; // for first 6 bytes
142 //uint64 nIndexS = t_pChain->nIndexS >> 16;
143 uint64 nIndexS = t_pChain->nIndexS & 0x0000FFFFFFFFFFFFULL; // for first 6 bytes
144 cwc.SetIndex(nIndexS);
145 //cwc.SetIndex(t_pChain->nIndexS);
147 for (nPos = 0; nPos < t_nGuessedPos; nPos++)
151 cwc.HashToIndex(nPos);
155 if (cwc.CheckHash(t_pHash))
157 t_Hash = cwc.GetHash();
158 t_Plain = cwc.GetPlain();
159 t_Binary = cwc.GetBinary();
166 t_nChainWalkStepDueToFalseAlarm += t_nGuessedPos + 1;
172 void rcrackiThread::CheckAlarmO()
175 for (i = 0; i < t_pChainsFoundO.size(); i++)
177 RainbowChainO* t_pChain = t_pChainsFoundO[i];
178 int t_nGuessedPos = t_nGuessedPoss[i];
180 CChainWalkContext cwc;
182 uint64 nIndexS = t_pChain->nIndexS;
183 cwc.SetIndex(nIndexS);
186 for (nPos = 0; nPos < t_nGuessedPos; nPos++)
190 cwc.HashToIndex(nPos);
194 if (cwc.CheckHash(t_pHash))
196 t_Hash = cwc.GetHash();
197 t_Plain = cwc.GetPlain();
198 t_Binary = cwc.GetBinary();
205 t_nChainWalkStepDueToFalseAlarm += t_nGuessedPos + 1;
211 bool rcrackiThread::FoundHash()
216 int rcrackiThread::GetChainWalkStepDueToFalseAlarm()
218 return t_nChainWalkStepDueToFalseAlarm;
221 int rcrackiThread::GetnFalseAlarm()
223 return t_nFalseAlarm;
226 string rcrackiThread::GetHash()
231 string rcrackiThread::GetPlain()
236 string rcrackiThread::GetBinary()