LoginBlob.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <cstdint> // for uint8_t, uint32_t
  3. #include <map> // for map
  4. #include <memory> // for unique_ptr
  5. #include <string> // for string
  6. #include <vector> // for vector
  7. #include "Crypto.h" // for CryptoMbedTLS, Crypto
  8. namespace cspot {
  9. class LoginBlob {
  10. private:
  11. int blobSkipPosition = 0;
  12. std::unique_ptr<Crypto> crypto;
  13. std::string name, deviceId;
  14. uint32_t readBlobInt(const std::vector<uint8_t>& loginData);
  15. std::vector<uint8_t> decodeBlob(const std::vector<uint8_t>& blob,
  16. const std::vector<uint8_t>& sharedKey);
  17. std::vector<uint8_t> decodeBlobSecondary(const std::vector<uint8_t>& blob,
  18. const std::string& username,
  19. const std::string& deviceId);
  20. public:
  21. LoginBlob(std::string name);
  22. std::vector<uint8_t> authData;
  23. std::string username = "";
  24. int authType;
  25. // Loading
  26. void loadZeroconfQuery(std::map<std::string, std::string>& queryParams);
  27. void loadZeroconf(const std::vector<uint8_t>& blob,
  28. const std::vector<uint8_t>& sharedKey,
  29. const std::string& deviceId, const std::string& username);
  30. void loadUserPass(const std::string& username, const std::string& password);
  31. void loadJson(const std::string& json);
  32. std::string buildZeroconfInfo();
  33. std::string getDeviceId();
  34. std::string getDeviceName();
  35. std::string getUserName();
  36. std::string toJson();
  37. };
  38. } // namespace cspot