- /* Lets see if they gave us an algorithm which has been implemented */
- hashymodules::iterator x = hashers.find(algo);
- if (x != hashers.end())
+ if (!algo.compare(0, 5, "hmac-", 5))
+ {
+ std::string type(algo, 5);
+ HashProvider* hp = ServerInstance->Modules->FindDataService<HashProvider>("hash/" + type);
+ if (!hp)
+ {
+ user->WriteNotice("Unknown hash type");
+ return;
+ }
+
+ if (hp->IsKDF())
+ {
+ user->WriteNotice(type + " does not support HMAC");
+ return;
+ }
+
+ std::string salt = ServerInstance->GenRandomStr(hp->out_size, false);
+ std::string target = hp->hmac(salt, stuff);
+ std::string str = BinToBase64(salt) + "$" + BinToBase64(target, NULL, 0);
+
+ user->WriteNotice(algo + " hashed password for " + stuff + " is " + str);
+ return;
+ }
+ HashProvider* hp = ServerInstance->Modules->FindDataService<HashProvider>("hash/" + algo);
+ if (hp)