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_sha256.cpp | |
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_sha256.cpp')
-rw-r--r-- | src/modules/m_sha256.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/modules/m_sha256.cpp b/src/modules/m_sha256.cpp index 7856b296b..8c2b00eea 100644 --- a/src/modules/m_sha256.cpp +++ b/src/modules/m_sha256.cpp @@ -132,7 +132,7 @@ uint32_t sha256_k[64] = 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; -class ModuleSHA256 : public Module +class HashSHA256 : public HashProvider { void SHA256Init(SHA256Context *ctx, const unsigned int* ikey) { @@ -245,35 +245,33 @@ class ModuleSHA256 : public Module } public: - ModuleSHA256() + std::string sum(const std::string& data) { - ServerInstance->Modules->PublishInterface("HashRequest", this); + unsigned char bytes[SHA256_DIGEST_SIZE]; + SHA256(data.data(), bytes, data.length()); + return std::string((char*)bytes, SHA256_DIGEST_SIZE); } - virtual ~ModuleSHA256() + std::string sumIV(unsigned int* IV, const char* HexMap, const std::string &sdata) { - ServerInstance->Modules->UnpublishInterface("HashRequest", this); + return ""; } + HashSHA256(Module* parent) : HashProvider(parent, "hash/sha256") {} +}; - void OnRequest(Request& request) +class ModuleSHA256 : public Module +{ + HashSHA256 sha; + public: + ModuleSHA256() : sha(this) { - if (strcmp("HASH", request.id) == 0) - { - unsigned char bytes[SHA256_DIGEST_SIZE]; - HashRequest& req = static_cast<HashRequest&>(request); - SHA256(req.data.data(), bytes, req.data.length()); - req.binresult.assign((char*)bytes, SHA256_DIGEST_SIZE); - } - else if (strcmp("NAME", request.id) == 0) - { - static_cast<HashNameRequest&>(request).response = "sha256"; - } + ServerInstance->Modules->AddService(sha); } Version GetVersion() { - return Version("Allows for SHA-256 encrypted oper passwords", VF_VENDOR); + return Version("Implements SHA-256 hashing", VF_VENDOR); } }; |