This function checks username and password against -rpcauth entries from config file.
| 61 | //This function checks username and password against -rpcauth |
| 62 | //entries from config file. |
| 63 | static bool CheckUserAuthorized(std::string_view user, std::string_view pass) |
| 64 | { |
| 65 | for (const auto& fields : g_rpcauth) { |
| 66 | if (!TimingResistantEqual(std::string_view(fields[0]), user)) { |
| 67 | continue; |
| 68 | } |
| 69 | |
| 70 | const std::string& salt = fields[1]; |
| 71 | const std::string& hash = fields[2]; |
| 72 | |
| 73 | std::array<unsigned char, CHMAC_SHA256::OUTPUT_SIZE> out; |
| 74 | CHMAC_SHA256(UCharCast(salt.data()), salt.size()).Write(UCharCast(pass.data()), pass.size()).Finalize(out.data()); |
| 75 | std::string hash_from_pass = HexStr(out); |
| 76 | |
| 77 | if (TimingResistantEqual(hash_from_pass, hash)) { |
| 78 | return true; |
| 79 | } |
| 80 | } |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUsernameOut) |
| 85 | { |
no test coverage detected