diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-16 17:59:06 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-16 17:59:06 +0000 |
commit | 54fb0cd5aa7d090d5c3da5ab54988c86ba8a2e8e (patch) | |
tree | bc20ce6dca41b2d16349ae4c8212861c10e3685e /src/modules/m_hash.h | |
parent | 3bfd0db65ff01c026e968af4de074cc1155a4061 (diff) |
Use ServiceProvider for inter-module dependencies
This will stop dependency chains from preventing module reloads when
it is not actually needed; however, it removes some failsafes that will
need to be reimplemented in order to avoid unmapped vtables.
This deprecates Request as an inter-module signaling mechanism, although
SQL still uses it.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12140 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_hash.h')
-rw-r--r-- | src/modules/m_hash.h | 84 |
1 files changed, 20 insertions, 64 deletions
diff --git a/src/modules/m_hash.h b/src/modules/m_hash.h index 08a24eb85..385fff95e 100644 --- a/src/modules/m_hash.h +++ b/src/modules/m_hash.h @@ -19,75 +19,31 @@ #define SHA256_DIGEST_SIZE (256 / 8) #define SHA256_BLOCK_SIZE (512 / 8) -/** Query a hash algorithm's name - * - * Example: - * \code - * cout << "Using hash algorithm: " << HashNameRequest(this, HashModule).response; - * \endcode - */ -struct HashNameRequest : public Request +class HashProvider : public DataProvider { - std::string response; - HashNameRequest(Module* Me, Module* Target) : Request(Me, Target, "NAME") + public: + HashProvider(Module* mod, const std::string& Name) : DataProvider(mod, Name) {} + virtual std::string sum(const std::string& data) = 0; + inline std::string hexsum(const std::string& data) { - Send(); + return BinToHex(sum(data)); } -}; -/** Send this class to the hashing module to HashSUM a std::string. - * - * Example: - * \code - * // Get the Hash sum of the string 'doodads'. - * std::string result = HashRequest(this, HashModule, "doodads").result; - * \endcode - */ -struct HashRequest : public Request -{ - const std::string data; - std::string binresult; - /** Initialize HashSumRequest for sending. - * @param Me A pointer to the sending module - * @param Target A pointer to the hashing module - * @param data The data to be hashed + /** Allows the IVs for the hash to be specified. As the choice of initial IV is + * important for the security of a hash, this should not be used except to + * maintain backwards compatability. This also allows you to change the hex + * sequence from its default of "0123456789abcdef", which does not improve the + * strength of the output, but helps confuse those attempting to implement it. + * + * Only m_md5 implements this request; only m_cloaking should use it. + * + * Example: + * \code + * unsigned int iv[] = { 0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0xCCCCCCCC }; + * std::string result = Hash.sumIV(iv, "0123456789abcdef", "data"); + * \endcode */ - HashRequest(Module* Me, Module* Target, const std::string &sdata) - : Request(Me, Target, "HASH"), data(sdata) - { - Send(); - } - inline std::string hex() - { - return BinToHex(binresult); - } -}; - -/** Allows the IVs for the hash to be specified. As the choice of initial IV is - * important for the security of a hash, this should not be used except to - * maintain backwards compatability. This also allows you to change the hex - * sequence from its default of "0123456789abcdef", which does not improve the - * strength of the output, but helps confuse those attempting to implement it. - * - * Only m_md5 implements this request; only m_cloaking should use it. - * - * Example: - * \code - * unsigned int iv[] = { 0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0xCCCCCCCC }; - * std::string result = HashRequestIV(this, HashModule, iv, "0123456789abcdef", "data").result; - * \endcode - */ -struct HashRequestIV : public Request -{ - unsigned int* iv; - const char* map; - std::string result; - const std::string data; - HashRequestIV(Module* Me, Module* Target, unsigned int* IV, const char* HexMap, const std::string &sdata) - : Request(Me, Target, "HASH-IV"), iv(IV), map(HexMap), data(sdata) - { - Send(); - } + virtual std::string sumIV(unsigned int* IV, const char* HexMap, const std::string &sdata) = 0; }; #endif |