]> git.sesse.net Git - freerainbowtables/blob - Common/rt api/HashRoutine.cpp
Merge branch 'origin/rti2'
[freerainbowtables] / Common / rt api / HashRoutine.cpp
1 /*
2    RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
3
4    Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
5 */
6
7 #ifdef _WIN32
8         #pragma warning(disable : 4786)
9 #endif
10
11 #include "HashRoutine.h"
12 #include "HashAlgorithm.h"
13
14 //////////////////////////////////////////////////////////////////////
15
16 CHashRoutine::CHashRoutine()
17 {
18         // Notice: MIN_HASH_LEN <= nHashLen <= MAX_HASH_LEN
19
20
21         AddHashRoutine("lm",   HashLM,   8);
22         AddHashRoutine("ntlm", HashNTLM, 16);
23 //      AddHashRoutine("md2",  HashMD2,  16);
24         AddHashRoutine("md4",  HashMD4,  16);
25         AddHashRoutine("md5",  HashMD5,  16);
26         AddHashRoutine("doublemd5",  HashDoubleMD5,  16);
27 /*      AddHashRoutine("sha1", HashSHA1, 20);
28         AddHashRoutine("ripemd160", HashRIPEMD160, 20);
29         AddHashRoutine("mysql323", HashMySQL323, 8);
30         AddHashRoutine("mysqlsha1", HashMySQLSHA1, 20);
31         AddHashRoutine("ciscopix", HashPIX, 16);*/
32 //      AddHashRoutine("mscache", HashMSCACHE, 16);
33         AddHashRoutine("halflmchall", HashHALFLMCHALL, 8);
34
35         // Added from mao
36         AddHashRoutine("lmchall", HashLMCHALL, 24);
37         AddHashRoutine("ntlmchall", HashNTLMCHALL, 24);
38 //      AddHashRoutine("oracle", HashORACLE, 8);
39
40 }
41
42 CHashRoutine::~CHashRoutine()
43 {
44 }
45
46 void CHashRoutine::AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRoutine, int nHashLen)
47 {
48         vHashRoutineName.push_back(sHashRoutineName);
49         vHashRoutine.push_back(pHashRoutine);
50         vHashLen.push_back(nHashLen);
51 }
52
53 string CHashRoutine::GetAllHashRoutineName()
54 {
55         string sRet;
56         uint32 i;
57         for (i = 0; i < vHashRoutineName.size(); i++)
58                 sRet += vHashRoutineName[i] + " ";
59
60         return sRet;
61 }
62
63 void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen)
64 {
65         uint32 i;
66         for (i = 0; i < vHashRoutineName.size(); i++)
67         {
68                 if (sHashRoutineName == vHashRoutineName[i])
69                 {
70                         pHashRoutine = vHashRoutine[i];
71                         nHashLen = vHashLen[i];
72                         return;
73                 }
74         }
75
76         pHashRoutine = NULL;
77         nHashLen = 0;
78 }