summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2017-12-05 22:48:07 +0100
committerRobert Pösel <robyer@seznam.cz>2017-12-05 22:48:31 +0100
commit0a8dbb91b0f505da3ce617fa5284719b8356cdac (patch)
tree428fec080c21abd172b27ffdde15c52a86c9c7dd /protocols/Steam/src
parentdd604b30c3153903bef1d40d4ebaa62f14671177 (diff)
Steam: For RsaEncryption use exponent received from server
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/steam_login.cpp8
-rw-r--r--protocols/Steam/src/steam_proto.h2
-rw-r--r--protocols/Steam/src/steam_utils.cpp4
3 files changed, 7 insertions, 7 deletions
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp
index c1ef9b09f0..d91acaba6d 100644
--- a/protocols/Steam/src/steam_login.cpp
+++ b/protocols/Steam/src/steam_login.cpp
@@ -64,8 +64,8 @@ void CSteamProto::OnGotRsaKey(const HttpResponse *response)
return;
std::string modulus = root["publickey_mod"].as_string();
- // exponent "010001" is used as constant in CSteamProto::RsaEncrypt
- //std::string exponent = root["publickey_exp"].as_string();
+ std::string exp = root["publickey_exp"].as_string();
+ DWORD exponent = strtoul(exp.c_str(), nullptr, 16); // default "010001" = 0x10001
std::string timestamp = root["timestamp"].as_string();
@@ -75,14 +75,14 @@ void CSteamProto::OnGotRsaKey(const HttpResponse *response)
DWORD error = 0;
DWORD encryptedSize = 0;
- if ((error = RsaEncrypt(modulus.c_str(), szPassword, nullptr, encryptedSize)) != 0)
+ if ((error = RsaEncrypt(modulus.c_str(), exponent, szPassword, nullptr, encryptedSize)) != 0)
{
debugLogA("CSteamProto::OnGotRsaKey: encryption error (%lu)", error);
return;
}
BYTE *encryptedPassword = (BYTE*)mir_calloc(encryptedSize);
- if ((error = RsaEncrypt(modulus.c_str(), szPassword, encryptedPassword, encryptedSize)) != 0)
+ if ((error = RsaEncrypt(modulus.c_str(), exponent, szPassword, encryptedPassword, encryptedSize)) != 0)
{
debugLogA("CSteamProto::OnGotRsaKey: encryption error (%lu)", error);
return;
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 4a2aff8d47..dab65cccce 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -220,7 +220,7 @@ protected:
static WORD SteamToMirandaStatus(int state);
static int MirandaToSteamState(int status);
- static int RsaEncrypt(const char *pszModulus, const char *data, BYTE *encrypted, DWORD &encryptedSize);
+ static int RsaEncrypt(const char *pszModulus, DWORD &exponent, const char *data, BYTE *encrypted, DWORD &encryptedSize);
static void CSteamProto::ShowNotification(const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
static void CSteamProto::ShowNotification(const wchar_t *caption, const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
diff --git a/protocols/Steam/src/steam_utils.cpp b/protocols/Steam/src/steam_utils.cpp
index 4723eb7fd9..409ce4276a 100644
--- a/protocols/Steam/src/steam_utils.cpp
+++ b/protocols/Steam/src/steam_utils.cpp
@@ -48,7 +48,7 @@ int CSteamProto::MirandaToSteamState(int status)
}
}
-int CSteamProto::RsaEncrypt(const char *pszModulus, const char *data, BYTE *encryptedData, DWORD &encryptedSize)
+int CSteamProto::RsaEncrypt(const char *pszModulus, DWORD &exponent, const char *data, BYTE *encryptedData, DWORD &encryptedSize)
{
DWORD cchModulus = (DWORD)mir_strlen(pszModulus);
int result = 0;
@@ -103,7 +103,7 @@ int CSteamProto::RsaEncrypt(const char *pszModulus, const char *data, BYTE *encr
RSAPUBKEY *pRsaPubKey = (RSAPUBKEY*)(pKeyBlob + sizeof(PUBLICKEYSTRUC));
pRsaPubKey->magic = 0x31415352; // RSA1 // Use public key
pRsaPubKey->bitlen = cbLen * 8; // Number of bits in the modulus.
- pRsaPubKey->pubexp = 0x10001; // "010001" // Exponent.
+ pRsaPubKey->pubexp = exponent; // Exponent.
// Copy the modulus into the blob. Put the modulus directly after the
// RSAPUBKEY structure in the blob.