auth.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. Minetest
  3. Copyright (C) 2015, 2016 est31 <MTest31@outlook.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. /// Gets the base64 encoded legacy password db entry.
  18. std::string translate_password(const std::string &name,
  19. const std::string &password);
  20. /// Creates a verification key with given salt and password.
  21. std::string generate_srp_verifier(const std::string &name,
  22. const std::string &password, const std::string &salt);
  23. /// Creates a verification key and salt with given password.
  24. void generate_srp_verifier_and_salt(const std::string &name,
  25. const std::string &password, std::string *verifier,
  26. std::string *salt);
  27. /// Gets an SRP verifier, generating a salt,
  28. /// and encodes it as DB-ready string.
  29. std::string get_encoded_srp_verifier(const std::string &name,
  30. const std::string &password);
  31. /// Converts the passed SRP verifier into a DB-ready format.
  32. std::string encode_srp_verifier(const std::string &verifier,
  33. const std::string &salt);
  34. /// Reads the DB-formatted SRP verifier and gets the verifier
  35. /// and salt components.
  36. bool decode_srp_verifier_and_salt(const std::string &encoded,
  37. std::string *verifier, std::string *salt);