diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt index 5b33077..ab0ba17 100644 --- a/src/net/CMakeLists.txt +++ b/src/net/CMakeLists.txt @@ -1,4 +1,4 @@ -file(GLOB PRIVATE_SOURCES "*.cpp" "connection/*.cpp" "grunt/*.cpp" "login/*.cpp") +file(GLOB PRIVATE_SOURCES "*.cpp" "connection/*.cpp" "grunt/*.cpp" "login/*.cpp" "srp/*.cpp") add_library(net STATIC ${PRIVATE_SOURCES} diff --git a/src/net/grunt/ClientLink.cpp b/src/net/grunt/ClientLink.cpp index c4417c1..bf63393 100644 --- a/src/net/grunt/ClientLink.cpp +++ b/src/net/grunt/ClientLink.cpp @@ -82,7 +82,7 @@ void Grunt::ClientLink::LogonNewSession(const Grunt::ClientLink::Logon& logon) { *decoration = '\0'; } - // TODO SRP6_Client::BeginAuthentication + this->m_srpClient.BeginAuthentication(accountNameUnDecorated, password); CDataStoreCache<1024> clientChallenge; diff --git a/src/net/grunt/ClientLink.hpp b/src/net/grunt/ClientLink.hpp index 206eada..c405e0d 100644 --- a/src/net/grunt/ClientLink.hpp +++ b/src/net/grunt/ClientLink.hpp @@ -5,6 +5,7 @@ #include "net/connection/WowConnectionResponse.hpp" #include "net/grunt/Pending.hpp" #include "net/grunt/Timer.hpp" +#include "net/srp/SRP6_Client.hpp" #include "net/Types.hpp" #include @@ -31,6 +32,7 @@ class Grunt::ClientLink : public WowConnectionResponse, Grunt::Pending, Grunt::T Grunt::Timer m_timer; uint32_t m_clientIP = 0; int32_t m_state; + SRP6_Client m_srpClient; SCritSect m_critSect; WowConnection* m_connection = nullptr; ClientResponse* m_clientResponse; diff --git a/src/net/srp/SRP6_Client.cpp b/src/net/srp/SRP6_Client.cpp new file mode 100644 index 0000000..f01b5da --- /dev/null +++ b/src/net/srp/SRP6_Client.cpp @@ -0,0 +1,24 @@ +#include "net/srp/SRP6_Client.hpp" +#include + +int32_t SRP6_Client::BeginAuthentication(const char* accountName, const char* password) { + if (!accountName || !password) { + return -1; + } + + SHA1_Init(&this->ctx); + + SHA1_CONTEXT ctx; + + SHA1_Init(&ctx); + SHA1_Update(&ctx, reinterpret_cast(accountName), strlen(accountName)); + SHA1_Final(this->accountNameDigest, &ctx); + + SHA1_Init(&ctx); + SHA1_Update(&ctx, reinterpret_cast(accountName), strlen(accountName)); + SHA1_Update(&ctx, reinterpret_cast(":"), 1u); + SHA1_Update(&ctx, reinterpret_cast(password), strlen(password)); + SHA1_Final(this->interimDigest, &ctx); + + return 0; +} diff --git a/src/net/srp/SRP6_Client.hpp b/src/net/srp/SRP6_Client.hpp new file mode 100644 index 0000000..fd07453 --- /dev/null +++ b/src/net/srp/SRP6_Client.hpp @@ -0,0 +1,17 @@ +#ifndef NET_SRP_SRP6_CLIENT_HPP +#define NET_SRP_SRP6_CLIENT_HPP + +#include + +class SRP6_Client { + public: + // Member variables + uint8_t accountNameDigest[SHA1_DIGEST_SIZE]; + uint8_t interimDigest[SHA1_DIGEST_SIZE]; + SHA1_CONTEXT ctx; + + // Member functions + int32_t BeginAuthentication(const char* accountName, const char* password); +}; + +#endif