diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-04-08 17:54:46 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-04-08 17:54:46 +0000 |
commit | 683ca5965e69d1780d957ab6f59b704c612852fa (patch) | |
tree | d1f089a434184304ef952ecae80d379431a0846a /protocols/Steam | |
parent | 78dc54f9e392b45492a2b726d6268c41f594eb41 (diff) |
Steam:
- added options
- removed OpenSSL dependencies
- cleaned project files
git-svn-id: http://svn.miranda-ng.org/main/trunk@8893 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam')
-rw-r--r-- | protocols/Steam/Steam_10.vcxproj | 26 | ||||
-rw-r--r-- | protocols/Steam/Steam_12.vcxproj | 28 | ||||
-rw-r--r-- | protocols/Steam/res/Resource.rc | 6 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/authorization.h | 15 | ||||
-rw-r--r-- | protocols/Steam/src/resource.h | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_account.cpp | 264 | ||||
-rw-r--r-- | protocols/Steam/src/steam_dialogs.cpp | 3 | ||||
-rw-r--r-- | protocols/Steam/src/steam_events.cpp | 12 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.h | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_thread.cpp | 4 |
11 files changed, 152 insertions, 214 deletions
diff --git a/protocols/Steam/Steam_10.vcxproj b/protocols/Steam/Steam_10.vcxproj index 4e0d8649f9..3660f2db5c 100644 --- a/protocols/Steam/Steam_10.vcxproj +++ b/protocols/Steam/Steam_10.vcxproj @@ -90,7 +90,7 @@ <Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win32\lib\VC</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -106,21 +106,21 @@ <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\..\OpenSSL\Win64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<StringPooling>false</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>skype.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalDependencies>comctl32.lib;libeay64MDd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalOptions>/PDBALTPATH:%_PDB% %(AdditionalOptions)</AdditionalOptions>
</Link>
@@ -136,11 +136,11 @@ <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\OpenSSL\Win32\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>skype.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -149,8 +149,8 @@ <OptimizeReferences>true</OptimizeReferences>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
- <AdditionalDependencies>comctl32.lib;libeay32MD.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win32\lib\VC</AdditionalLibraryDirectories>
+ <AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
</Link>
<ResourceCompile>
@@ -165,11 +165,11 @@ <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\OpenSSL\Win64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>skype.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -178,8 +178,8 @@ <OptimizeReferences>true</OptimizeReferences>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
- <AdditionalDependencies>comctl32.lib;libeay64MD.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories>
+ <AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
</Link>
<ResourceCompile>
diff --git a/protocols/Steam/Steam_12.vcxproj b/protocols/Steam/Steam_12.vcxproj index 19c0828fe6..c4cbfb26de 100644 --- a/protocols/Steam/Steam_12.vcxproj +++ b/protocols/Steam/Steam_12.vcxproj @@ -82,7 +82,7 @@ <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\..\OpenSSL\Win32\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<StringPooling>false</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -94,9 +94,9 @@ <Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win32\lib\VC</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalDependencies>comctl32.lib;libeay32MDd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalOptions>/PDBALTPATH:%_PDB% %(AdditionalOptions)</AdditionalOptions>
</Link>
@@ -110,21 +110,21 @@ <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\..\OpenSSL\Win64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<StringPooling>false</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>skype.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalDependencies>comctl32.lib;libeay64MDd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalOptions>/PDBALTPATH:%_PDB% %(AdditionalOptions)</AdditionalOptions>
</Link>
@@ -140,11 +140,11 @@ <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\OpenSSL\Win32\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>skype.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -153,8 +153,8 @@ <OptimizeReferences>true</OptimizeReferences>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
- <AdditionalDependencies>comctl32.lib;libeay32MD.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win32\lib\VC</AdditionalLibraryDirectories>
+ <AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
</Link>
<ResourceCompile>
@@ -169,11 +169,11 @@ <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\OpenSSL\Win64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>skype.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -182,8 +182,8 @@ <OptimizeReferences>true</OptimizeReferences>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
- <AdditionalDependencies>comctl32.lib;libeay64MD.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;$(ProfileDir)..\..\..\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories>
+ <AdditionalDependencies>crypt32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
</Link>
<ResourceCompile>
diff --git a/protocols/Steam/res/Resource.rc b/protocols/Steam/res/Resource.rc index 5dcc1e5c57..8a57ceff64 100644 --- a/protocols/Steam/res/Resource.rc +++ b/protocols/Steam/res/Resource.rc @@ -97,13 +97,13 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- GROUPBOX "Account",-1,7,7,291,61
+ GROUPBOX "Account",-1,7,7,291,44
LTEXT "Username:",-1,15,19,69,8
EDITTEXT IDC_USERNAME,90,17,201,13,ES_AUTOHSCROLL
LTEXT "Password:",-1,15,35,69,8
EDITTEXT IDC_PASSWORD,90,33,201,13,ES_PASSWORD | ES_AUTOHSCROLL
- EDITTEXT IDC_GROUP,90,50,201,14,ES_AUTOHSCROLL
- LTEXT "Default group:",-1,15,52,69,8
+ EDITTEXT IDC_GROUP,90,59,201,14,ES_AUTOHSCROLL
+ LTEXT "Default group:",-1,15,61,69,8
END
IDD_CAPTCHA DIALOGEX 0, 0, 274, 91
diff --git a/protocols/Steam/src/Steam/authorization.h b/protocols/Steam/src/Steam/authorization.h index 17aa3410d6..f7fa0444ee 100644 --- a/protocols/Steam/src/Steam/authorization.h +++ b/protocols/Steam/src/Steam/authorization.h @@ -14,6 +14,7 @@ namespace SteamWebApi private:
std::string steamid;
std::string token;
+ std::string cookie;
std::string emailauth;
std::string emaildomain;
@@ -39,6 +40,7 @@ namespace SteamWebApi bool IsEmailAuthNeeded() const { return emailauth_needed; }
const char *GetSteamid() const { return steamid.c_str(); }
const char *GetToken() const { return token.c_str(); }
+ const char *GetCookie() const { return cookie.c_str(); }
const char *GetAuthId() const { return emailauth.c_str(); }
const char *GetAuthCode() const { return emailsteamid.c_str(); }
const char *GetEmailDomain() const { return emaildomain.c_str(); }
@@ -64,16 +66,6 @@ namespace SteamWebApi ptrA base64Username(mir_urlEncode(ptrA(mir_utf8encodeW(username))));
- /*CryptoApi::RsaKey rsaKey;
- CryptoApi::GetRsaKey(hConnection, base64Username, &rsaKey);
- if (!rsaKey.IsSuccess()) return;
-
- int size = rsaKey.GetEncryptedSize();
- BYTE *rsaEncryptedPassword = (BYTE*)mir_alloc(size);
- rsaKey.Encrypt((unsigned char*)password, strlen(password), rsaEncryptedPassword);
- ptrA base64RsaEncryptedPassword(mir_base64_encode(rsaEncryptedPassword, size));
- mir_free(rsaEncryptedPassword);*/
-
CMStringA data;
data.AppendFormat("username=%s", base64Username);
data.AppendFormat("&password=%s", ptrA(mir_urlEncode(password)));
@@ -142,6 +134,9 @@ namespace SteamWebApi node = json_get(root, "oauth_token");
authResult->token = ptrA(mir_u2a(json_as_string(node)));
+ node = json_get(root, "webcookie");
+ authResult->cookie = ptrA(mir_u2a(json_as_string(node)));
+
authResult->success = true;
authResult->captcha_needed = false;
authResult->emailauth_needed = false;
diff --git a/protocols/Steam/src/resource.h b/protocols/Steam/src/resource.h index 648047d1bc..3432481021 100644 --- a/protocols/Steam/src/resource.h +++ b/protocols/Steam/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by d:\Projects\CPlusPlus\MirandaNG\protocols\Steam\res\Resource.rc
+// Used by e:\Projects\C++\MirandaNG\protocols\Steam\res\Resource.rc
//
#define IDD_ACCMGR 9
#define IDD_OPT_MAIN 10
diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index 61469a02a1..133ddd068c 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -90,186 +90,118 @@ void CSteamProto::Authorize(SteamWebApi::AuthorizationApi::AuthResult *authResul ptrW username(getWStringA("Username"));
ptrA base64RsaEncryptedPassword;
- DBVARIANT dbv;
- CMStringA timestamp;
- DWORD encryptedSize = 0;
- BYTE *encryptedPassword = NULL;
- db_get(NULL, this->m_szModuleName, "EncryptedPassword", &dbv);
- if (dbv.type == DBVT_BLOB && dbv.pbVal && dbv.cpbVal > 0)
- {
- encryptedSize = dbv.cpbVal;
- encryptedPassword = (BYTE*)mir_alloc(dbv.cpbVal);
- memcpy(encryptedPassword, dbv.pbVal, dbv.cpbVal);
-
- timestamp = getStringA("RsaTimestamp");
- }
- else
- {
- // get rsa public key
- SteamWebApi::RsaKeyApi::RsaKey rsaKey;
- SteamWebApi::RsaKeyApi::GetRsaKey(m_hNetlibUser, username, &rsaKey);
- if (!rsaKey.IsSuccess())
- {
- db_free(&dbv);
- return;
- }
-
- timestamp = rsaKey.GetTimestamp();
- setString("RsaTimestamp", timestamp);
-
- ptrA password(getStringA("Password"));
-
- // OpenSSL rsa is depricated
- /*BIGNUM *n = BN_new();
- if (!BN_hex2bn(&n, rsaKey.GetModulus()))
- {
- BN_free(n);
- return;
- }
-
- BIGNUM *e = BN_new();
- if (!BN_hex2bn(&e, rsaKey.GetExponent()))
- {
- BN_free(e);
- return;
- }
-
- RSA *rsa = RSA_new();
- rsa->n = n;
- rsa->e = e;
-
- encryptedSize = RSA_size(rsa);
- encryptedPassword = (BYTE*)mir_alloc(encryptedSize);
- if (RSA_public_encrypt(strlen(password), (unsigned char*)(char*)password, encryptedPassword, rsa, RSA_PKCS1_PADDING) < 0)
- {
- RSA_free(rsa);
- return;
- }
+ // get rsa public key
+ SteamWebApi::RsaKeyApi::RsaKey rsaKey;
+ SteamWebApi::RsaKeyApi::GetRsaKey(m_hNetlibUser, username, &rsaKey);
+ if (!rsaKey.IsSuccess())
+ return;
- BN_free(e);
- BN_free(n);
- RSA_free(rsa);*/
+ ptrA password(getStringA("Password"));
- const char *pszModulus = rsaKey.GetModulus();
- DWORD cchModulus = strlen(pszModulus);
+ const char *pszModulus = rsaKey.GetModulus();
+ DWORD cchModulus = strlen(pszModulus);
- // convert hex string to byte array
- DWORD cbLen = 0, dwSkip = 0, dwFlags = 0;
- if (!CryptStringToBinaryA(pszModulus, cchModulus, CRYPT_STRING_HEX, NULL, &cbLen, &dwSkip, &dwFlags))
- {
- DWORD dwResult = GetLastError();
- int i = 0;
- }
+ // convert hex string to byte array
+ DWORD cbLen = 0, dwSkip = 0, dwFlags = 0;
+ if (!CryptStringToBinaryA(pszModulus, cchModulus, CRYPT_STRING_HEX, NULL, &cbLen, &dwSkip, &dwFlags))
+ {
+ debugLogA("CSteamProto::Authorize: Cannot get size of rsa modulus in binary (%lu)", GetLastError());
+ return;
+ }
- // Allocate a new buffer.
- BYTE *pbBuffer = (BYTE*)malloc(cbLen);
- if (!CryptStringToBinaryA(pszModulus, cchModulus, CRYPT_STRING_HEX, pbBuffer, &cbLen, &dwSkip, &dwFlags))
- {
- DWORD dwResult = GetLastError();
- int i = 0;
- }
+ // Allocate a new buffer.
+ BYTE *pbBuffer = (BYTE*)malloc(cbLen);
+ if (!CryptStringToBinaryA(pszModulus, cchModulus, CRYPT_STRING_HEX, pbBuffer, &cbLen, &dwSkip, &dwFlags))
+ {
+ debugLogA("CSteamProto::Authorize: Cannot convert rsa modulus to binary (%lu)", GetLastError());
+ return;
+ }
- // reverse byte array, because of microsoft
- for (int i = 0; i < cbLen / 2; ++i)
- {
- BYTE temp = pbBuffer[cbLen - i - 1];
- pbBuffer[cbLen - i - 1] = pbBuffer[i];
- pbBuffer[i] = temp;
- }
+ // reverse byte array, because of microsoft
+ for (int i = 0; i < cbLen / 2; ++i)
+ {
+ BYTE temp = pbBuffer[cbLen - i - 1];
+ pbBuffer[cbLen - i - 1] = pbBuffer[i];
+ pbBuffer[i] = temp;
+ }
- HCRYPTPROV hCSP = 0;
- if (!CryptAcquireContext(&hCSP, NULL, NULL, PROV_RSA_AES, CRYPT_SILENT) ||
- !CryptAcquireContext(&hCSP, NULL, NULL, PROV_RSA_AES, CRYPT_SILENT | CRYPT_NEWKEYSET))
- {
- DWORD dwResult = GetLastError();
- int i = 0;
- }
+ HCRYPTPROV hCSP = 0;
+ if (!CryptAcquireContext(&hCSP, NULL, NULL, PROV_RSA_AES, CRYPT_SILENT) &&
+ !CryptAcquireContext(&hCSP, NULL, NULL, PROV_RSA_AES, CRYPT_SILENT | CRYPT_NEWKEYSET))
+ {
+ debugLogA("CSteamProto::Authorize: Cannot create rsa context (%lu)", GetLastError());
+ return;
+ }
- // Move the key into the key container.
- DWORD cbKeyBlob = sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY) + cbLen;
- BYTE *pKeyBlob = (BYTE*)malloc(cbKeyBlob);
-
- // Fill in the data.
- PUBLICKEYSTRUC *pPublicKey = (PUBLICKEYSTRUC*)pKeyBlob;
- pPublicKey->bType = PUBLICKEYBLOB;
- pPublicKey->bVersion = CUR_BLOB_VERSION; // Always use this value.
- pPublicKey->reserved = 0; // Must be zero.
- pPublicKey->aiKeyAlg = CALG_RSA_KEYX; // RSA public-key key exchange.
-
- // The next block of data is the RSAPUBKEY structure.
- 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.
-
- // Copy the modulus into the blob. Put the modulus directly after the
- // RSAPUBKEY structure in the blob.
- BYTE *pKey = (BYTE*)(((BYTE *)pRsaPubKey) + sizeof(RSAPUBKEY));
- //pKeyBlob + sizeof(BLOBHEADER)+ sizeof(RSAPUBKEY);
- memcpy(pKey, pbBuffer, cbLen);
-
- // Now import public key
- HCRYPTKEY phKey = 0;
- if (!CryptImportKey(hCSP, pKeyBlob, cbKeyBlob, 0, 0, &phKey))
- {
- DWORD err = GetLastError();
- int i = 0;
- }
+ // Move the key into the key container.
+ DWORD cbKeyBlob = sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY) + cbLen;
+ BYTE *pKeyBlob = (BYTE*)malloc(cbKeyBlob);
+
+ // Fill in the data.
+ PUBLICKEYSTRUC *pPublicKey = (PUBLICKEYSTRUC*)pKeyBlob;
+ pPublicKey->bType = PUBLICKEYBLOB;
+ pPublicKey->bVersion = CUR_BLOB_VERSION; // Always use this value.
+ pPublicKey->reserved = 0; // Must be zero.
+ pPublicKey->aiKeyAlg = CALG_RSA_KEYX; // RSA public-key key exchange.
+
+ // The next block of data is the RSAPUBKEY structure.
+ 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.
+
+ // Copy the modulus into the blob. Put the modulus directly after the
+ // RSAPUBKEY structure in the blob.
+ BYTE *pKey = (BYTE*)(((BYTE *)pRsaPubKey) + sizeof(RSAPUBKEY));
+ //pKeyBlob + sizeof(BLOBHEADER)+ sizeof(RSAPUBKEY);
+ memcpy(pKey, pbBuffer, cbLen);
+
+ // Now import public key
+ HCRYPTKEY phKey = 0;
+ if (!CryptImportKey(hCSP, pKeyBlob, cbKeyBlob, 0, 0, &phKey))
+ {
+ debugLogA("CSteamProto::Authorize: Cannot import rsa key to context (%lu)", GetLastError());
+ return;
+ }
- // encrypt password
- DWORD pwdLength = strlen(password);
- if (!CryptEncrypt(phKey, 0, TRUE, 0, NULL, &encryptedSize, pwdLength))
- {
- DWORD err = GetLastError();
- int i = 0;
- }
+ // encrypt password
+ DWORD encryptedSize = 0;
+ DWORD pwdLength = strlen(password);
+ if (!CryptEncrypt(phKey, 0, TRUE, 0, NULL, &encryptedSize, pwdLength))
+ {
+ debugLogA("CSteamProto::Authorize: Cannot get rsa encrypt length (%lu)", GetLastError());
+ return;
+ }
- encryptedPassword = (BYTE*)mir_calloc(encryptedSize);
- memcpy(encryptedPassword, password, pwdLength);
- if (!CryptEncrypt(phKey, 0, TRUE, 0, encryptedPassword, &pwdLength, encryptedSize))
- {
- DWORD err = GetLastError();
- int i = 0;
- }
+ BYTE *encryptedPassword = (BYTE*)mir_calloc(encryptedSize);
+ memcpy(encryptedPassword, password, pwdLength);
+ if (!CryptEncrypt(phKey, 0, TRUE, 0, encryptedPassword, &pwdLength, encryptedSize))
+ {
+ debugLogA("CSteamProto::Authorize: Cannot rsa encrypt password (%lu)", GetLastError());
+ return;
+ }
- // reverse byte array again
- for (int i = 0; i < encryptedSize / 2; ++i)
- {
- BYTE temp = encryptedPassword[encryptedSize - i - 1];
- encryptedPassword[encryptedSize - i - 1] = encryptedPassword[i];
- encryptedPassword[i] = temp;
- }
+ // reverse byte array again
+ for (int i = 0; i < encryptedSize / 2; ++i)
+ {
+ BYTE temp = encryptedPassword[encryptedSize - i - 1];
+ encryptedPassword[encryptedSize - i - 1] = encryptedPassword[i];
+ encryptedPassword[i] = temp;
+ }
- // save rsa encrypted password to db
- db_set_blob(NULL, this->m_szModuleName, "EncryptedPassword", encryptedPassword, encryptedSize);
+ // save rsa encrypted password to db
+ db_set_blob(NULL, this->m_szModuleName, "EncryptedPassword", encryptedPassword, encryptedSize);
- CryptDestroyKey(phKey);
- free(pKeyBlob);
- CryptReleaseContext(hCSP, 0);
- free(pbBuffer);
- }
- db_free(&dbv);
-
- //DWORD cbLen = 0, dwSkip = 0, dwFlags = 0;
- //if (!CryptBinaryToStringA(encryptedPassword, encryptedSize, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &cbLen))
- //{
- // DWORD dwResult = GetLastError();
- // int i = 0;
- //}
-
- //// Allocate a new buffer.
- //char *pbBuffer = (char*)malloc(cbLen);
- //if (!CryptBinaryToStringA(encryptedPassword, encryptedSize, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, pbBuffer, &cbLen))
- //{
- // DWORD dwResult = GetLastError();
- // int i = 0;
- //}
+ CryptDestroyKey(phKey);
+ free(pKeyBlob);
+ CryptReleaseContext(hCSP, 0);
+ free(pbBuffer);
base64RsaEncryptedPassword = mir_base64_encode(encryptedPassword, encryptedSize);
mir_free(encryptedPassword);
// try to authorize
- SteamWebApi::AuthorizationApi::Authorize(m_hNetlibUser, username, base64RsaEncryptedPassword, timestamp, authResult);
+ SteamWebApi::AuthorizationApi::Authorize(m_hNetlibUser, username, base64RsaEncryptedPassword, rsaKey.GetTimestamp(), authResult);
if (authResult->IsEmailAuthNeeded() || authResult->IsCaptchaNeeded())
{
do
@@ -297,7 +229,7 @@ void CSteamProto::Authorize(SteamWebApi::AuthorizationApi::AuthResult *authResul }
// try to authorize with emailauthcode or captcha taxt
- SteamWebApi::AuthorizationApi::Authorize(m_hNetlibUser, username, base64RsaEncryptedPassword, timestamp, authResult);
+ SteamWebApi::AuthorizationApi::Authorize(m_hNetlibUser, username, base64RsaEncryptedPassword, rsaKey.GetTimestamp(), authResult);
} while (authResult->IsEmailAuthNeeded() || authResult->IsCaptchaNeeded());
}
}
@@ -317,6 +249,8 @@ void CSteamProto::LogInThread(void* param) {
// todo: dosplay error message from authResult.GetMessage()
//ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
+ debugLogA("CSteamProto::Authorize: Error (%s)", authResult.GetMessage());
+
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE);
return;
@@ -324,6 +258,7 @@ void CSteamProto::LogInThread(void* param) token = authResult.GetToken();
setString("TokenSecret", token);
+ setString("Cookie", authResult.GetCookie());
setString("SteamID", authResult.GetSteamid());
}
@@ -332,6 +267,7 @@ void CSteamProto::LogInThread(void* param) // if some error
if (!loginResult.IsSuccess())
{
+ debugLogA("CSteamProto::login: Error");
// set status to offline
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE);
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp index d7ec5c1f77..a03114f6c8 100644 --- a/protocols/Steam/src/steam_dialogs.cpp +++ b/protocols/Steam/src/steam_dialogs.cpp @@ -170,6 +170,8 @@ INT_PTR CALLBACK CSteamProto::MainOptionsProc(HWND hwnd, UINT message, WPARAM wP {
if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
proto->delSetting("SteamID");
+ proto->delSetting("Cookies");
+ proto->delSetting("TokenSecret");
wchar_t username[128];
GetDlgItemText(hwnd, IDC_USERNAME, username, SIZEOF(username));
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
@@ -179,6 +181,7 @@ INT_PTR CALLBACK CSteamProto::MainOptionsProc(HWND hwnd, UINT message, WPARAM wP case IDC_PASSWORD:
{
if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
+ proto->delSetting("Cookie");
proto->delSetting("TokenSecret");
char password[128];
GetDlgItemTextA(hwnd, IDC_PASSWORD, password, SIZEOF(password));
diff --git a/protocols/Steam/src/steam_events.cpp b/protocols/Steam/src/steam_events.cpp index 0099f43456..27e63951b7 100644 --- a/protocols/Steam/src/steam_events.cpp +++ b/protocols/Steam/src/steam_events.cpp @@ -2,6 +2,8 @@ int CSteamProto::OnModulesLoaded(WPARAM, LPARAM)
{
+ HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, this);
+
TCHAR name[128];
mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), m_tszUserName);
@@ -24,7 +26,7 @@ int CSteamProto::OnPreShutdown(WPARAM, LPARAM) return 0;
}
-INT_PTR __cdecl CSteamProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam)
+INT_PTR CSteamProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam)
{
return (int)CreateDialogParam(
g_hInstance,
@@ -34,14 +36,16 @@ INT_PTR __cdecl CSteamProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam) (LPARAM)this);
}
-int __cdecl CSteamProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
+int CSteamProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam)
{
- char *title = mir_t2a(this->m_tszUserName);
+ CSteamProto *instance = (CSteamProto*)obj;
+
+ char *title = mir_t2a(instance->m_tszUserName);
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = g_hInstance;
odp.pszTitle = title;
- odp.dwInitParam = LPARAM(this);
+ odp.dwInitParam = LPARAM(obj);
odp.flags = ODPF_BOLDGROUPS;
odp.pszGroup = LPGEN("Network");
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 6fe6ac82e9..2684818880 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -254,8 +254,8 @@ int __cdecl CSteamProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM case EV_PROTO_ONEXIT:
return this->OnPreShutdown(wParam, lParam);
- case EV_PROTO_ONOPTIONS:
- return this->OnOptionsInit(wParam, lParam);
+ /*case EV_PROTO_ONOPTIONS:
+ return this->OnOptionsInit(wParam, lParam);*/
/*case EV_PROTO_ONCONTACTDELETED:
return this->OnContactDeleted(wParam, lParam);*/
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index d6e579a2fb..28ef2f853a 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -124,7 +124,7 @@ protected: int OnModulesLoaded(WPARAM, LPARAM);
int OnPreShutdown(WPARAM, LPARAM);
INT_PTR __cdecl OnAccountManagerInit(WPARAM wParam, LPARAM lParam);
- int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam);
+ static int __cdecl OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam);
//options
static INT_PTR CALLBACK GuardProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
diff --git a/protocols/Steam/src/steam_thread.cpp b/protocols/Steam/src/steam_thread.cpp index 3249ef629e..ef6cb813b0 100644 --- a/protocols/Steam/src/steam_thread.cpp +++ b/protocols/Steam/src/steam_thread.cpp @@ -67,7 +67,7 @@ void CSteamProto::PollStatus(const char *token, const char *sessionId, UINT32 me if (IsMe(steamId))
{
const wchar_t *oldNickname = getWStringA("Nick");
- if (lstrcmp(oldNickname, nickname))
+ if (lstrcmp(oldNickname, nickname) && lstrlen(nickname))
setWString("Nick", nickname);
SetStatus(status);
@@ -78,7 +78,7 @@ void CSteamProto::PollStatus(const char *token, const char *sessionId, UINT32 me if (hContact)
{
const wchar_t *oldNickname = getWStringA(hContact, "Nick");
- if (lstrcmp(oldNickname, nickname))
+ if (lstrcmp(oldNickname, nickname) && lstrlen(nickname))
setWString(hContact, "Nick", nickname);
SetContactStatus(hContact, status);
|