1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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 class HashProvider : public DataProvider
25 HashProvider(Module* mod, const std::string& Name) : DataProvider(mod, Name) {}
26 virtual std::string sum(const std::string& data) = 0;
27 inline std::string hexsum(const std::string& data)
29 return BinToHex(sum(data));
32 /** Allows the IVs for the hash to be specified. As the choice of initial IV is
33 * important for the security of a hash, this should not be used except to
34 * maintain backwards compatability. This also allows you to change the hex
35 * sequence from its default of "0123456789abcdef", which does not improve the
36 * strength of the output, but helps confuse those attempting to implement it.
38 * Only m_md5 implements this request; only m_cloaking should use it.
42 * unsigned int iv[] = { 0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0xCCCCCCCC };
43 * std::string result = Hash.sumIV(iv, "0123456789abcdef", "data");
46 virtual std::string sumIV(unsigned int* IV, const char* HexMap, const std::string &sdata) = 0;