2 * freerainbowtables is a project for generating, distributing, and using
3 * perfect rainbow tables
5 * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
6 * Copyright 2009, 2010 Daniƫl Niggebrugge <niggebrugge@fox-it.com>
7 * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
9 * This file is part of freerainbowtables.
11 * freerainbowtables is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or
14 * (at your option) any later version.
16 * freerainbowtables is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with freerainbowtables. If not, see <http://www.gnu.org/licenses/>.
25 #ifndef _CHAINWALKCONTEXT_H
26 #define _CHAINWALKCONTEXT_H
28 #include "HashRoutine.h"
33 unsigned char m_PlainCharset[255];
34 unsigned int m_nPlainCharsetLen;
37 string m_sPlainCharsetName;
38 string m_sPlainCharsetContent;
40 class CChainWalkContext
44 virtual ~CChainWalkContext();
47 static string m_sHashRoutineName;
48 static HASHROUTINE m_pHashRoutine; // Configuration
49 static int m_nHashLen; // Configuration
50 static bool isOldRtFormat;
51 static bool isRti2RtFormat;
52 static vector<stCharset> m_vCharset;
53 static int m_nPlainLenMinTotal, m_nPlainLenMaxTotal;
54 static uint64 m_nPlainSpaceUpToX[MAX_PLAIN_LEN + 1]; // Performance consideration
55 static uint64 m_nPlainSpaceTotal; // Performance consideration
56 static int m_nHybridCharset;
57 static int m_nRainbowTableIndex; // Configuration
58 static uint64 m_nReduceOffset; // Performance consideration
62 unsigned char m_Plain[MAX_PLAIN_LEN];
64 unsigned char m_Hash[MAX_HASH_LEN];
65 static unsigned char m_Salt[MAX_SALT_LEN];
66 static int m_nSaltLen;
68 static bool LoadCharset(string sCharset);
71 static bool SetHashRoutine(string sHashRoutineName); // Configuration
72 static bool SetPlainCharset(string sCharsetName, int nPlainLenMin, int nPlainLenMax); // Configuration
73 static bool SetRainbowTableIndex(int nRainbowTableIndex);
74 static bool SetSalt(unsigned char *Salt, int nSaltLength);// Configuration
75 static bool SetupWithPathName(string sPathName, int& nRainbowChainLen, int& nRainbowChainCount); // Wrapper
76 static string GetHashRoutineName();
77 static int GetHashLen();
78 static string GetPlainCharsetName();
79 static string GetPlainCharsetContent();
80 static int GetPlainLenMin();
81 static int GetPlainLenMax();
82 static uint64 GetPlainSpaceTotal();
83 static int GetRainbowTableIndex();
85 static bool isOldFormat();
86 static bool isRti2Format();
88 void SetIndex(uint64 nIndex);
89 void SetHash(unsigned char* pHash); // The length should be m_nHashLen
93 void HashToIndex(int nPos);
96 const uint64* GetIndexPtr();
100 bool CheckHash(unsigned char* pHash); // The length should be m_nHashLen