iw4x-client/src/Components/Modules/Auth.hpp

61 lines
1.3 KiB
C++
Raw Normal View History

2016-02-21 13:57:56 -05:00
namespace Components
{
class Auth : public Component
{
public:
Auth();
~Auth();
const char* GetName() { return "Auth"; };
2016-02-22 17:35:53 -05:00
static void StoreKey();
static void LoadKey(bool force = false);
static unsigned int GetKeyHash();
static uint32_t GetSecurityLevel();
2016-02-22 20:03:05 -05:00
static void IncreaseSecurityLevel(uint32_t level, std::string command = "");
2016-02-22 17:35:53 -05:00
static uint32_t GetZeroBits(Utils::Cryptography::Token token, std::string publicKey);
2016-02-23 07:39:38 -05:00
static void IncrementToken(Utils::Cryptography::Token& token, std::string publicKey, uint32_t zeroBits, bool* cancel = nullptr, uint64_t* count = nullptr);
2016-02-22 17:35:53 -05:00
2016-02-21 13:57:56 -05:00
private:
enum AuthState
{
STATE_UNKNOWN,
STATE_NEGOTIATING,
STATE_VALID,
STATE_INVALID,
};
struct AuthInfo
{
Utils::Cryptography::ECDSA::Key publicKey;
std::string challenge;
AuthState state;
int time;
};
2016-02-22 20:03:05 -05:00
struct TokenIncrementing
{
bool cancel;
bool generating;
std::thread* thread;
uint32_t targetLevel;
int startTime;
std::string command;
2016-02-23 07:39:38 -05:00
uint64_t hashes;
2016-02-22 20:03:05 -05:00
};
2016-02-21 13:57:56 -05:00
static AuthInfo ClientAuthInfo[18];
2016-02-22 20:03:05 -05:00
static TokenIncrementing TokenContainer;
2016-02-21 13:57:56 -05:00
2016-02-22 17:35:53 -05:00
static Utils::Cryptography::Token GuidToken;
static Utils::Cryptography::ECDSA::Key GuidKey;
2016-02-21 13:57:56 -05:00
static void Frame();
static void RegisterClient(int clientNum);
static void RegisterClientStub();
};
}