diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-05 20:48:54 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-05 20:48:54 +0000 |
commit | 060887d2828b9153351e74362604548af08e9d79 (patch) | |
tree | 43a28b71642cc2952a40833fa44ca0406a260911 /src | |
parent | c3a7fb47d62c2f701782809a987747edd7bc7818 (diff) |
Allow for querying the hash modules for the hashing algorithm name
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5868 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_hash.h | 39 | ||||
-rw-r--r-- | src/modules/m_md5.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_sha256.cpp | 4 |
3 files changed, 37 insertions, 10 deletions
diff --git a/src/modules/m_hash.h b/src/modules/m_hash.h index 0c9eecdca..5dd528e6e 100644 --- a/src/modules/m_hash.h +++ b/src/modules/m_hash.h @@ -37,7 +37,7 @@ class HashRequest : public Request std::string tohash; public: /** Initialize HashRequest as an Hash_RESET message */ - HashRequest(Module* Me, Module* Target) : Request(Me, Target, "RESET") + HashRequest(const char* req, Module* Me, Module* Target) : Request(Me, Target, req) { } @@ -75,7 +75,26 @@ class HashRequest : public Request } }; -/** Send this class to hashing.so to reset the Hash module to a known state. +/** Send this class to the hashing module to query for its name. + * + * Example: + * \code + * cout << "Using hash algorithm: " << HashNameRequest(this, HashModule).Send(); + * \endcode + */ +class HashNameRequest : public HashRequest +{ + public: + /** Initialize HashNameRequest for sending. + * @param Me A pointer to the sending module + * @param Target A pointer to the hashing module + */ + HashNameRequest(Module* Me, Module* Target) : HashRequest("NAME", Me, Target) + { + } +} + +/** Send this class to the hashing module to reset the Hash module to a known state. * This will reset the IV to the defaults specified by the Hash spec, * and reset the hex sequence to "0123456789abcdef". It should be sent before * ANY other Request types. @@ -91,14 +110,14 @@ class HashResetRequest : public HashRequest public: /** Initialize HashResetRequest for sending. * @param Me A pointer to the sending module - * @param Target A pointer to the hashing.so module + * @param Target A pointer to the hashing module */ - HashResetRequest(Module* Me, Module* Target) : HashRequest(Me, Target) + HashResetRequest(Module* Me, Module* Target) : HashRequest("RESET", Me, Target) { } }; -/** Send this class to hashing.so to HashSUM a std::string. +/** Send this class to the hashing module to HashSUM a std::string. * You should make sure you know the state of the module before you send this * class, e.g. by first sending an HashResetRequest class. The hash will be * returned when you call Send(). @@ -116,7 +135,7 @@ class HashSumRequest : public HashRequest public: /** Initialize HashSumRequest for sending. * @param Me A pointer to the sending module - * @param Target A pointer to the hashing.so module + * @param Target A pointer to the hashing module * @param data The data to be hashed */ HashSumRequest(Module* Me, Module* Target, const std::string &data) : HashRequest(Me, Target, data) @@ -124,7 +143,7 @@ class HashSumRequest : public HashRequest } }; -/** Send this class to hashing.so to change the IVs (keys) to use for hashing. +/** Send this class to hashing module to change the IVs (keys) to use for hashing. * You should make sure you know the state of the module before you send this * class, e.g. by first sending an HashResetRequest class. The default values for * the IV's are those specified in the Hash specification. Only in very special @@ -141,7 +160,7 @@ class HashKeyRequest : public HashRequest public: /** Initialize HashKeyRequest for sending. * @param Me A pointer to the sending module - * @param Target A pointer to the hashing.so module + * @param Target A pointer to the hashing module * @param data The new IV's. This should be an array of exactly four 32 bit values. * On 64-bit architectures, the upper 32 bits of the values will be discarded. */ @@ -150,7 +169,7 @@ class HashKeyRequest : public HashRequest } }; -/** Send this class to hashing.so to change the hex sequence to use for generating the returned value. +/** Send this class to the hashing module to change the hex sequence to use for generating the returned value. * You should make sure you know the state of the module before you send this * class, e.g. by first sending an HashResetRequest class. The default value for * the hex sequence is "0123456789abcdef". Only in very special circumstances should @@ -167,7 +186,7 @@ class HashHexRequest : public HashRequest public: /** Initialize HashHexRequest for sending. * @param Me A pointer to the sending module - * @param Target A pointer to the hashing.so module + * @param Target A pointer to the hashing module * @param data The hex sequence to use. This should contain exactly 16 ASCII characters, * terminated by a NULL char. */ diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index a42ccbb7e..d256b0f1c 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -310,6 +310,10 @@ class ModuleMD5 : public Module GenHash((const char*)MD5->GetHashData(), data, chars ? chars : "0123456789abcdef", key); return data; } + else if (strcmp("NAME", request->GetId()) == 0) + { + return "MD5"; + } else if (strcmp("RESET", request->GetId()) == 0) { ServerInstance->Log(DEBUG,"MD5 RESET!"); diff --git a/src/modules/m_sha256.cpp b/src/modules/m_sha256.cpp index c5df2aad3..68b7ad3d9 100644 --- a/src/modules/m_sha256.cpp +++ b/src/modules/m_sha256.cpp @@ -279,6 +279,10 @@ class ModuleSHA256 : public Module SHA256((const char*)SHA->GetHashData(), data, strlen(SHA->GetHashData()), chars ? chars : "0123456789abcdef", key); return data; } + else if (strcmp("SUM", request->GetId()) == 0) + { + return "SHA256"; + } else if (strcmp("RESET", request->GetId()) == 0) { this->chars = NULL; |