1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 #define SHA256_DIGEST_SIZE (256 / 8)
20 #define SHA256_BLOCK_SIZE (512 / 8)
22 /** Query a hash algorithm's name
26 * cout << "Using hash algorithm: " << HashNameRequest(this, HashModule).response;
29 struct HashNameRequest : public Request
32 HashNameRequest(Module* Me, Module* Target) : Request(Me, Target, "NAME")
38 /** Send this class to the hashing module to HashSUM a std::string.
42 * // Get the Hash sum of the string 'doodads'.
43 * std::string result = HashRequest(this, HashModule, "doodads").result;
46 struct HashRequest : public Request
48 const std::string data;
49 std::string binresult;
50 /** Initialize HashSumRequest for sending.
51 * @param Me A pointer to the sending module
52 * @param Target A pointer to the hashing module
53 * @param data The data to be hashed
55 HashRequest(Module* Me, Module* Target, const std::string &sdata)
56 : Request(Me, Target, "HASH"), data(sdata)
60 inline std::string hex()
62 return BinToHex(binresult);
66 /** Allows the IVs for the hash to be specified. As the choice of initial IV is
67 * important for the security of a hash, this should not be used except to
68 * maintain backwards compatability. This also allows you to change the hex
69 * sequence from its default of "0123456789abcdef", which does not improve the
70 * strength of the output, but helps confuse those attempting to implement it.
72 * Only m_md5 implements this request; only m_cloaking should use it.
76 * unsigned int iv[] = { 0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0xCCCCCCCC };
77 * std::string result = HashRequestIV(this, HashModule, iv, "0123456789abcdef", "data").result;
80 struct HashRequestIV : public Request
85 const std::string data;
86 HashRequestIV(Module* Me, Module* Target, unsigned int* IV, const char* HexMap, const std::string &sdata)
87 : Request(Me, Target, "HASH-IV"), iv(IV), map(HexMap), data(sdata)