]> git.sesse.net Git - freerainbowtables/blob - Common/rt api/ChainWalkContext.h
UINT4 -> uint32
[freerainbowtables] / Common / rt api / ChainWalkContext.h
1 /*
2  * freerainbowtables is a project for generating, distributing, and using
3  * perfect rainbow tables
4  *
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>
8  *
9  * This file is part of freerainbowtables.
10  *
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.
15  *
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.
20  *
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/>.
23  */
24
25 #ifndef _CHAINWALKCONTEXT_H
26 #define _CHAINWALKCONTEXT_H
27
28 #include "HashRoutine.h"
29 #include "Public.h"
30
31 typedef struct 
32 {
33         unsigned char m_PlainCharset[255];
34         unsigned int m_nPlainCharsetLen;
35         int m_nPlainLenMin;
36         int m_nPlainLenMax;
37         string m_sPlainCharsetName;
38         string m_sPlainCharsetContent;
39 } stCharset;
40 class CChainWalkContext 
41 {
42 public:
43         CChainWalkContext();
44         virtual ~CChainWalkContext();
45
46 //private:
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_nPlainSpaceTotal;                                                       // Performance consideration
55         static uint64 m_nPlainSpaceUpToX[MAX_PLAIN_LEN + 1];            // Performance consideration
56         static int m_nHybridCharset;
57         static int m_nRainbowTableIndex;                                                        // Configuration
58         static uint64 m_nReduceOffset;                                                          // Performance consideration
59
60         // Context
61         uint64 m_nIndex;
62         unsigned char m_Plain[MAX_PLAIN_LEN];
63         int m_nPlainLen;
64         unsigned char m_Hash[MAX_HASH_LEN];
65         static unsigned char m_Salt[MAX_SALT_LEN];
66         static int m_nSaltLen;
67 private:
68         static bool LoadCharset(string sCharset);
69
70 public:
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();
84         static void Dump();
85         static bool isOldFormat();
86         static bool isRti2Format();
87
88         void SetIndex(uint64 nIndex);
89         void SetHash(unsigned char* pHash);             // The length should be m_nHashLen
90
91         void IndexToPlain();
92         void PlainToHash();
93         void HashToIndex(int nPos);
94
95         uint64 GetIndex();
96         const uint64* GetIndexPtr();
97         string GetPlain();
98         string GetBinary();
99 //      string GetPlainBinary();
100         string GetHash();
101         bool CheckHash(unsigned char* pHash);   // The length should be m_nHashLen
102 };
103
104 #endif