- rounds++;
- }
- if (!item.empty())
- {
- /* Send the Hash module a different hex table for each octet group's Hash sum */
- HashHexRequest(Sender, HashProvider, xtab[(key1+rounds) % 4]).Send();
- hashies.push_back(std::string(HashSumRequest(Sender, HashProvider, item).Send()).substr(0,8));
- item.clear();
- }
- /* Stick them all together */
- return irc::stringjoiner(":", hashies, 0, hashies.size() - 1).GetJoined();
- }
-
- void DoRehash()
- {
- ConfigReader Conf(ServerInstance);
- bool lowercase;
-
- /* These are *not* using the need_positive parameter of ReadInteger -
- * that will limit the valid values to only the positive values in a
- * signed int. Instead, accept any value that fits into an int and
- * cast it to an unsigned int. That will, a bit oddly, give us the full
- * spectrum of an unsigned integer. - Special */
- key1 = key2 = key3 = key4 = 0;
- key1 = (unsigned int) Conf.ReadInteger("cloak","key1",0,false);
- key2 = (unsigned int) Conf.ReadInteger("cloak","key2",0,false);
- key3 = (unsigned int) Conf.ReadInteger("cloak","key3",0,false);
- key4 = (unsigned int) Conf.ReadInteger("cloak","key4",0,false);
- prefix = Conf.ReadValue("cloak","prefix",0);
- ipalways = Conf.ReadFlag("cloak", "ipalways", 0);
- lowercase = Conf.ReadFlag("cloak", "lowercase", 0);
-
- if (!lowercase)
- {
- xtab[0] = "F92E45D871BCA630";
- xtab[1] = "A1B9D80C72E653F4";
- xtab[2] = "1ABC078934DEF562";
- xtab[3] = "ABCDEF5678901234";
- }
- else
- {
- xtab[0] = "f92e45d871bca630";
- xtab[1] = "a1b9d80c72e653f4";
- xtab[2] = "1abc078934def562";
- xtab[3] = "abcdef5678901234";
- }
-
- if (prefix.empty())
- prefix = ServerInstance->Config->Network;
-
- if (!key1 || !key2 || !key3 || !key4)
- {
- std::string detail;
- if (!key1)
- detail = "<cloak:key1> is not valid, it may be set to a too high/low value, or it may not exist.";
- else if (!key2)
- detail = "<cloak:key2> is not valid, it may be set to a too high/low value, or it may not exist.";
- else if (!key3)
- detail = "<cloak:key3> is not valid, it may be set to a too high/low value, or it may not exist.";
- else if (!key4)
- detail = "<cloak:key4> is not valid, it may be set to a too high/low value, or it may not exist.";
-
- throw ModuleException("You have not defined cloak keys for m_cloaking!!! THIS IS INSECURE AND SHOULD BE CHECKED! - " + detail);