diff --git a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj
index 58a6afae4db..94e895c802e 100644
--- a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj
+++ b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj
@@ -565,10 +565,6 @@
-
- {fa169092-ea3e-40c1-8e5a-a2b575700fe8}
- false
-
{a0f7d1fb-59a7-4717-a7e4-96f37e91998e}
false
diff --git a/src/engine.sln b/src/engine.sln
index 8649fa11e1a..0404ac93059 100644
--- a/src/engine.sln
+++ b/src/engine.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.40629.0
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utils", "utils", "{89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B}"
EndProject
@@ -109,15 +109,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Maya_Export_2009", "plugins
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Maya_Material_2009", "plugins\Maya\Maya_Material2009.vcxproj", "{FFDF27A8-C198-49ED-BA13-4DA9054266C6}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crypto", "3rd party\crypto\crypto.vcxproj", "{FA169092-EA3E-40C1-8E5A-A2B575700FE8}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrRender_R4", "Layers\xrRenderPC_R4\xrRender_R4.vcxproj", "{AC9B12ED-A2D7-4337-A981-5BD8430E96D8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp_screenshots_info", "utils\mp_screenshots_info\mp_screenshots_info.vcxproj", "{032A10AB-E44C-4751-A290-001EF99E664A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp_configs_verifyer", "utils\mp_configs_verifyer\mp_configs_verifyer.vcxproj", "{1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxImage", "3rd party\CxImage\cximage.vcxproj", "{880CD250-BA77-4DAF-A8D4-552F12DD3AE4}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxImage", "3rd party\cximage\cximage.vcxproj", "{880CD250-BA77-4DAF-A8D4-552F12DD3AE4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NVTT", "3rd party\NVTT\NVTT.vcxproj", "{0EB257DC-5CFC-44B0-82C9-CE6B158BE473}"
EndProject
@@ -1040,27 +1038,6 @@ Global
{FFDF27A8-C198-49ED-BA13-4DA9054266C6}.Release|Mixed Platforms.Build.0 = Release|Win32
{FFDF27A8-C198-49ED-BA13-4DA9054266C6}.Release|Win32.ActiveCfg = Release|Win32
{FFDF27A8-C198-49ED-BA13-4DA9054266C6}.Release|Win32.Build.0 = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Debug_Dedicated|Mixed Platforms.ActiveCfg = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Debug_Dedicated|Mixed Platforms.Build.0 = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Debug_Dedicated|Win32.ActiveCfg = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Debug|Mixed Platforms.Build.0 = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Debug|Win32.ActiveCfg = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Debug|Win32.Build.0 = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Mixed_Dedicated|Mixed Platforms.ActiveCfg = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Mixed_Dedicated|Mixed Platforms.Build.0 = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Mixed_Dedicated|Win32.ActiveCfg = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Mixed|Mixed Platforms.ActiveCfg = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Mixed|Mixed Platforms.Build.0 = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Mixed|Win32.ActiveCfg = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Mixed|Win32.Build.0 = Debug|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Release_Dedicated|Mixed Platforms.ActiveCfg = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Release_Dedicated|Mixed Platforms.Build.0 = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Release_Dedicated|Win32.ActiveCfg = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Release|Mixed Platforms.ActiveCfg = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Release|Mixed Platforms.Build.0 = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Release|Win32.ActiveCfg = Release|Win32
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8}.Release|Win32.Build.0 = Release|Win32
{AC9B12ED-A2D7-4337-A981-5BD8430E96D8}.Debug_Dedicated|Mixed Platforms.ActiveCfg = Debug|Win32
{AC9B12ED-A2D7-4337-A981-5BD8430E96D8}.Debug_Dedicated|Mixed Platforms.Build.0 = Debug|Win32
{AC9B12ED-A2D7-4337-A981-5BD8430E96D8}.Debug_Dedicated|Win32.ActiveCfg = Debug|Win32
@@ -1375,7 +1352,6 @@ Global
{EC924B9B-4991-4931-8623-E1DB9AE005CA} = {89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B}
{E5F40F9E-C01B-4B97-9BD5-FC24308D8022} = {68CB7CEC-F907-47AD-B624-B8432F53AAE3}
{FFDF27A8-C198-49ED-BA13-4DA9054266C6} = {68CB7CEC-F907-47AD-B624-B8432F53AAE3}
- {FA169092-EA3E-40C1-8E5A-A2B575700FE8} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348}
{032A10AB-E44C-4751-A290-001EF99E664A} = {89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B}
{1924EF23-A05E-40E5-93F2-6CCD64BE1F8B} = {89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B}
{880CD250-BA77-4DAF-A8D4-552F12DD3AE4} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348}
diff --git a/src/utils/mp_configs_verifyer/configs_common.h b/src/utils/mp_configs_verifyer/configs_common.h
index 475b429a7aa..442c2563bbf 100644
--- a/src/utils/mp_configs_verifyer/configs_common.h
+++ b/src/utils/mp_configs_verifyer/configs_common.h
@@ -1,7 +1,7 @@
#ifndef CONFIGS_COMMON_INCLUDED
#define CONFIGS_COMMON_INCLUDED
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
namespace mp_anticheat
{
diff --git a/src/utils/mp_configs_verifyer/entry_point.cpp b/src/utils/mp_configs_verifyer/entry_point.cpp
index 21c7478794f..68bf60df47f 100644
--- a/src/utils/mp_configs_verifyer/entry_point.cpp
+++ b/src/utils/mp_configs_verifyer/entry_point.cpp
@@ -2,7 +2,6 @@
#include "configs_dump_verifyer.h"
#pragma comment(lib, "xrCore.lib")
-#pragma comment(lib, "crypto.lib")
static char const * help_msg =
"Format: mp_configs_verifyer.exe [--file | --unpack | --io_filter | --help] [file name]\n"
diff --git a/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj b/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj
index 6b33245a6e9..f8c56e490ab 100644
--- a/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj
+++ b/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj
@@ -110,10 +110,6 @@
-
- {fa169092-ea3e-40c1-8e5a-a2b575700fe8}
- false
-
{a0f7d1fb-59a7-4717-a7e4-96f37e91998e}
false
diff --git a/src/utils/mp_configs_verifyer/pch.h b/src/utils/mp_configs_verifyer/pch.h
index 0b301749ec6..95792f70195 100644
--- a/src/utils/mp_configs_verifyer/pch.h
+++ b/src/utils/mp_configs_verifyer/pch.h
@@ -4,7 +4,7 @@
#include "xrCore/xrCore.h"
#include "xrCore/LocatorAPI.h"
#include "xrCore/ppmd_compressor.h"
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
#include
diff --git a/src/utils/mp_configs_verifyer/xr_dsa_verifyer.h b/src/utils/mp_configs_verifyer/xr_dsa_verifyer.h
index c440bbde2f6..7be30b36a95 100644
--- a/src/utils/mp_configs_verifyer/xr_dsa_verifyer.h
+++ b/src/utils/mp_configs_verifyer/xr_dsa_verifyer.h
@@ -1,7 +1,7 @@
#ifndef XR_DSA_VERIFYER_INCLUDED
#define XR_DSA_VERIFYER_INCLUDED
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
class xr_dsa_verifyer
{
diff --git a/src/utils/mp_screenshots_info/entry_point.cpp b/src/utils/mp_screenshots_info/entry_point.cpp
index 8add8e83185..fe14679407e 100644
--- a/src/utils/mp_screenshots_info/entry_point.cpp
+++ b/src/utils/mp_screenshots_info/entry_point.cpp
@@ -3,7 +3,6 @@
#include "screenshots_reader.h"
#pragma comment(lib, "xrCore.lib")
-#pragma comment(lib, "crypto.lib")
void print_format()
{
diff --git a/src/utils/mp_screenshots_info/mp_screenshots_info.vcxproj b/src/utils/mp_screenshots_info/mp_screenshots_info.vcxproj
index bf948f01cc5..14d6a95a08c 100644
--- a/src/utils/mp_screenshots_info/mp_screenshots_info.vcxproj
+++ b/src/utils/mp_screenshots_info/mp_screenshots_info.vcxproj
@@ -127,10 +127,6 @@
-
- {fa169092-ea3e-40c1-8e5a-a2b575700fe8}
- false
-
{a0f7d1fb-59a7-4717-a7e4-96f37e91998e}
false
diff --git a/src/utils/mp_screenshots_info/pch.h b/src/utils/mp_screenshots_info/pch.h
index e8f3afb08d6..0e7d211123c 100644
--- a/src/utils/mp_screenshots_info/pch.h
+++ b/src/utils/mp_screenshots_info/pch.h
@@ -3,7 +3,7 @@
#include "xrCore/xrCore.h"
#include "xrCore/LocatorAPI.h"
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
#include
#include
diff --git a/src/utils/mp_screenshots_info/xr_dsa_signer.h b/src/utils/mp_screenshots_info/xr_dsa_signer.h
index 40339cc5e6a..c5b7ae724b5 100644
--- a/src/utils/mp_screenshots_info/xr_dsa_signer.h
+++ b/src/utils/mp_screenshots_info/xr_dsa_signer.h
@@ -1,7 +1,7 @@
#ifndef XR_DSA_SIGNER_INCLUDED
#define XR_DSA_SIGNER_INCLUDED
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
typedef fastdelegate::FastDelegate1< long > sha_process_yielder;
diff --git a/src/xrCore/crypto/crypto.cpp b/src/xrCore/crypto/crypto.cpp
new file mode 100644
index 00000000000..136102d8ea0
--- /dev/null
+++ b/src/xrCore/crypto/crypto.cpp
@@ -0,0 +1,36 @@
+#include "stdafx.h"
+#include "crypto.h"
+#include
+#include
+#include
+
+
+namespace crypto
+{
+
+static void unsafe_xr_free(void* ptr)
+{
+ xr_free(ptr);
+};
+
+static unsigned char rnd_seed[] = "S.T.A.L.K.E.R. 4ever Rulezz !!!";
+
+CRYPTO_API void xr_crypto_init ()
+{
+ string256 random_string;
+ xr_sprintf (random_string, "%I64d_%s", CPU::QPC(), rnd_seed);
+ //sprintf_s (random_string, "%s", rnd_seed);
+ CRYPTO_set_mem_functions (xr_malloc, xr_realloc, unsafe_xr_free);
+ RAND_seed (random_string, xr_strlen(random_string));
+ //unsigned int siglen;
+ //tmp_dsa_params->flags |= DSA_FLAG_NO_EXP_CONSTTIME;
+ //ZeroMemory(sig, sizeof(sig));
+ //DSA_sign(0, digest, sizeof(digest), sig, &siglen, tmp_dsa_params);
+ //DSA_verify(0, digest, sizeof(digest), sig, siglen, tmp_dsa_params);
+/*#ifdef DEBUG
+ CRYPTO_dbg_set_options (V_CRYPTO_MDEBUG_ALL);
+ CRYPTO_mem_ctrl (CRYPTO_MEM_CHECK_ON);
+#endif*/
+}
+
+} //namespace crypto
\ No newline at end of file
diff --git a/src/xrCore/crypto/crypto.h b/src/xrCore/crypto/crypto.h
new file mode 100644
index 00000000000..74c629907c2
--- /dev/null
+++ b/src/xrCore/crypto/crypto.h
@@ -0,0 +1,15 @@
+#ifndef CRYPTO_INCLUDED
+#define CRYPTO_INCLUDED
+
+#include "xrCore/xrCore.h"
+#include "xr_dsa.h"
+#include "xr_sha.h"
+
+namespace crypto
+{
+
+CRYPTO_API void xr_crypto_init ();
+
+} //namespace crypto
+
+#endif
\ No newline at end of file
diff --git a/src/xrCore/crypto/crypto_api_def.h b/src/xrCore/crypto/crypto_api_def.h
new file mode 100644
index 00000000000..18cda6a5422
--- /dev/null
+++ b/src/xrCore/crypto/crypto_api_def.h
@@ -0,0 +1,10 @@
+#ifndef CRYPTO_API_DEF_INCLUDED
+#define CRYPTO_API_DEF_INCLUDED
+
+# ifdef CRYPTO_BUILD
+# define CRYPTO_API __declspec(dllexport)
+# else
+# define CRYPTO_API __declspec(dllimport)
+# endif //#ifdef CRYPTO_BUILD
+
+#endif //#ifndef CRYPTO_API_DEF_INCLUDED
\ No newline at end of file
diff --git a/src/xrCore/crypto/xr_dsa.cpp b/src/xrCore/crypto/xr_dsa.cpp
new file mode 100644
index 00000000000..e0ca278b687
--- /dev/null
+++ b/src/xrCore/crypto/xr_dsa.cpp
@@ -0,0 +1,189 @@
+#include "stdafx.h"
+#include "xr_dsa.h"
+#include "crypto.h"
+#include
+
+namespace crypto
+{
+
+xr_dsa::xr_dsa(u8 const p[public_key_length],
+ u8 const q[private_key_length],
+ u8 const g[public_key_length])
+{
+ m_dsa = DSA_new();
+ m_dsa->p = BN_new();
+ m_dsa->q = BN_new();
+ m_dsa->g = BN_new();
+ m_dsa->priv_key = BN_new();
+ m_dsa->pub_key = BN_new();
+
+ BN_bin2bn(p, public_key_length, m_dsa->p);
+ BN_bin2bn(q, private_key_length, m_dsa->q);
+ BN_bin2bn(g, public_key_length, m_dsa->g);
+}
+
+xr_dsa::~xr_dsa()
+{
+ DSA_free (m_dsa);
+}
+
+shared_str const xr_dsa::sign (private_key_t const & priv_key,
+ u8 const* data,
+ u32 const data_size)
+{
+ BN_bin2bn(priv_key.m_value, sizeof(priv_key.m_value), m_dsa->priv_key);
+
+ unsigned int sign_size = DSA_size(m_dsa);
+ u8* sign_dest = static_cast(
+ _alloca(sign_size));
+
+ BIGNUM tmp_sign_res_bn;
+ BN_init (&tmp_sign_res_bn);
+
+ DSA_sign (0, data, data_size, sign_dest, &sign_size, m_dsa);
+ BN_bin2bn (sign_dest, sign_size, &tmp_sign_res_bn);
+
+ return shared_str(BN_bn2hex(&tmp_sign_res_bn));
+}
+
+bool xr_dsa::verify (public_key_t const & pub_key,
+ u8 const * data,
+ u32 const data_size,
+ shared_str const & dsign)
+{
+ BN_bin2bn(pub_key.m_value, sizeof(pub_key.m_value), m_dsa->pub_key);
+
+ BIGNUM* tmp_bn = NULL;
+ BN_hex2bn (&tmp_bn, dsign.c_str());
+ int sig_size = tmp_bn->top * sizeof(unsigned long);
+ u8* sig_buff = static_cast(_alloca(sig_size));
+ VERIFY (sig_size == DSA_size(m_dsa));
+ BN_bn2bin (tmp_bn, sig_buff);
+
+ bool ret = DSA_verify (0, data, data_size, sig_buff, sig_size, m_dsa) == 1 ? true : false;
+ BN_free(tmp_bn);
+ return ret;
+}
+
+
+
+#ifdef DEBUG
+
+static void dsa_genparams_cb(int p, int n, void *arg)
+{
+ Msg("* dsa genparams cb(%d, %d)", p, n);
+}
+
+static unsigned char rnd_seed[] = "S.T.A.L.K.E.R. 4ever Rulezz !!!";
+void print_big_number(BIGNUM* big_num, u32 max_columns = 8)
+{
+ u8 bin_buff[xr_dsa::public_key_length];//public_key_length is the max
+ int bin_size = 0;
+
+ string4096 result_buffer;
+ string16 tmp_buff;
+
+ ZeroMemory (bin_buff, sizeof(bin_buff));
+ BN_bn2bin (big_num, bin_buff);
+ bin_size = big_num->top * sizeof(unsigned long);
+
+ result_buffer[0] = 0;
+ xr_strcat(result_buffer, "\t");
+ for (int i = 0; i < bin_size; ++i)
+ {
+ if (((i % max_columns) == 0) && (i > 0))
+ {
+ xr_strcat(result_buffer, "\n\t");
+ }
+ xr_sprintf(tmp_buff, "0x%02x, ", bin_buff[i]);
+ xr_strcat(result_buffer, tmp_buff);
+ }
+ Msg(result_buffer);
+};
+
+void xr_dsa::generate_params()
+{
+ int counter;
+ unsigned long long_ret;
+ string256 random_string;
+ xr_sprintf (random_string, "%I64d_%s", CPU::QPC(), rnd_seed);
+ //sprintf_s (random_string, "%s", rnd_seed);
+ unsigned char* rnd_seed = static_cast((void*)random_string);
+ unsigned int rnd_ssize = xr_strlen(random_string);
+ DSA* tmp_dsa_params = DSA_generate_parameters(
+ key_bit_length,
+ rnd_seed,
+ rnd_ssize,
+ &counter,
+ &long_ret,
+ dsa_genparams_cb,
+ NULL
+ );
+ DSA_generate_key (tmp_dsa_params);
+
+ VERIFY (tmp_dsa_params->p->top * sizeof(u32) == public_key_length);
+ VERIFY (tmp_dsa_params->q->top * sizeof(u32) == private_key_length);
+ VERIFY (tmp_dsa_params->g->top * sizeof(u32) == public_key_length);
+ VERIFY (tmp_dsa_params->pub_key->top * sizeof(u32) == public_key_length);
+ VERIFY (tmp_dsa_params->priv_key->top * sizeof(u32)== private_key_length);
+
+ Msg("// DSA params ");
+
+ Msg("u8 const p_number[crypto::xr_dsa::public_key_length] = {");
+ print_big_number (tmp_dsa_params->p);
+ Msg("};//p_number");
+
+
+ Msg("u8 const q_number[crypto::xr_dsa::private_key_length] = {");
+ print_big_number (tmp_dsa_params->q);
+ Msg("};//q_number");
+
+
+ Msg("u8 const g_number[crypto::xr_dsa::public_key_length] = {");
+ print_big_number (tmp_dsa_params->g);
+ Msg("};//g_number");
+
+ Msg("u8 const public_key[crypto::xr_dsa::public_key_length] = {");
+ print_big_number (tmp_dsa_params->pub_key);
+ Msg("};//public_key");
+
+
+ u8 priv_bin[private_key_length];
+ BN_bn2bin (tmp_dsa_params->priv_key, priv_bin);
+ Msg("// Private key:");
+ for (int i = 0; i < private_key_length; ++i)
+ {
+ Msg(" m_private_key.m_value[%d] = 0x%02x;", i, priv_bin[i]);
+ }
+
+ u8 debug_digest[] = "this is a test";
+ u8 debug_bad_digest[] = "this as a test";
+
+ u32 siglen = DSA_size(tmp_dsa_params);
+ u8* sig = static_cast(_alloca(siglen));
+
+ BIGNUM bn_sign;
+ BN_init (&bn_sign);
+
+ VERIFY (DSA_sign(0, debug_digest, sizeof(debug_digest), sig, &siglen, tmp_dsa_params) == 1);
+
+ BN_bin2bn (sig, siglen, &bn_sign);
+ shared_str sig_str = BN_bn2hex(&bn_sign);
+
+ BIGNUM* bn_rsing = NULL;
+ ZeroMemory (sig, siglen);
+ BN_hex2bn (&bn_rsing, sig_str.c_str());
+ BN_bn2bin (bn_rsing, sig);
+ BN_free (bn_rsing);
+
+ VERIFY (DSA_verify(0, debug_digest, sizeof(debug_digest), sig, siglen, tmp_dsa_params) == 1);
+
+ VERIFY (DSA_verify(0, debug_bad_digest, sizeof(debug_bad_digest), sig, siglen, tmp_dsa_params) == 0);
+
+ DSA_free(tmp_dsa_params);
+}
+
+#endif //#ifdef DEBUG
+
+
+} //namespace crypto
\ No newline at end of file
diff --git a/src/xrCore/crypto/xr_dsa.h b/src/xrCore/crypto/xr_dsa.h
new file mode 100644
index 00000000000..c59dd0c0ecd
--- /dev/null
+++ b/src/xrCore/crypto/xr_dsa.h
@@ -0,0 +1,49 @@
+#ifndef XR_DSA_INCLUDED
+#define XR_DSA_INCLUDED
+
+#include "crypto_api_def.h"
+#include "xrCore/xrCore.h"
+
+struct dsa_st;
+
+namespace crypto
+{
+
+class CRYPTO_API xr_dsa
+{
+public:
+ static int const key_bit_length = 1024;
+ static int const public_key_length = key_bit_length / 8;
+ static int const private_key_length = 20;
+
+ xr_dsa (u8 const p[public_key_length],
+ u8 const q[private_key_length],
+ u8 const g[public_key_length]);
+ ~xr_dsa ();
+
+ struct private_key_t
+ {
+ u8 m_value[private_key_length];
+ };//struct private_key_t
+
+ struct public_key_t
+ {
+ u8 m_value[public_key_length];
+ };//struct public_key_t
+
+ shared_str const sign (private_key_t const & priv_key,
+ u8 const * data, u32 const data_size);
+ bool verify (public_key_t const & pub_key,
+ u8 const * data, u32 const data_size, shared_str const & dsign);
+
+#ifdef DEBUG
+ static void generate_params ();
+#endif
+
+private:
+ dsa_st* m_dsa;
+};//class xr_dsa
+
+} //namespace crypto
+
+#endif //#ifndef XR_DSA_INCLUDED
\ No newline at end of file
diff --git a/src/xrCore/crypto/xr_sha.cpp b/src/xrCore/crypto/xr_sha.cpp
new file mode 100644
index 00000000000..857988f7ccc
--- /dev/null
+++ b/src/xrCore/crypto/xr_sha.cpp
@@ -0,0 +1,44 @@
+#include "stdafx.h"
+#include "xr_sha.h"
+#include
+
+namespace crypto
+{
+
+xr_sha256::xr_sha256()
+{
+ m_sha_ctx = xr_new();
+}
+
+xr_sha256::~xr_sha256()
+{
+ xr_delete (m_sha_ctx);
+}
+
+void xr_sha256::start_calculate (u8 const * data, u32 data_size)
+{
+ SHA_Init (m_sha_ctx);
+ ZeroMemory (m_result, sizeof(m_result));
+ VERIFY (data_size);
+ m_data_src = data;
+ m_data_size = data_size;
+}
+
+bool xr_sha256::continue_calculate ()
+{
+ u32 const to_calc = m_data_size >= calc_chunk_size ? calc_chunk_size : m_data_size;
+
+ SHA_Update (m_sha_ctx, m_data_src, to_calc);
+
+ m_data_src += to_calc;
+ m_data_size -= to_calc;
+
+ if (!m_data_size)
+ {
+ SHA_Final(m_result, m_sha_ctx);
+ return true;
+ }
+ return false;
+}
+
+} //namespace crypto
diff --git a/src/xrCore/crypto/xr_sha.h b/src/xrCore/crypto/xr_sha.h
new file mode 100644
index 00000000000..041a87a1ae2
--- /dev/null
+++ b/src/xrCore/crypto/xr_sha.h
@@ -0,0 +1,36 @@
+#ifndef XR_SHA_INCLUDED
+#define XR_SHA_INCLUDED
+
+#include "crypto_api_def.h"
+#include "xrCore/xrCore.h"
+
+struct SHAstate_st;
+
+namespace crypto
+{
+
+class CRYPTO_API xr_sha256
+{
+public:
+ static u32 const digest_length = 20; //SHA_DIGEST_LENGTH
+
+ xr_sha256 ();
+ ~xr_sha256 ();
+
+ void start_calculate (u8 const * data, u32 data_size);
+ bool continue_calculate ();
+
+ u8 const * pointer () const { return m_result; };
+private:
+ static u32 const calc_chunk_size = 512;
+
+ u8 const * m_data_src;
+ u32 m_data_size;
+
+ u8 m_result[digest_length];
+ SHAstate_st* m_sha_ctx;
+}; //xr_sha256
+
+} //namespace crypto
+
+#endif //#ifndef XR_SHA_INCLUDED
\ No newline at end of file
diff --git a/src/xrCore/xrCore.vcxproj b/src/xrCore/xrCore.vcxproj
index e229464ab4c..d124fc9c1da 100644
--- a/src/xrCore/xrCore.vcxproj
+++ b/src/xrCore/xrCore.vcxproj
@@ -76,8 +76,8 @@
Disabled
- .;$(SolutionDir);$(DXSDK_DIR)Include;$(XRAY_16X_LIBS);$(xrSdkDir)include;%(AdditionalIncludeDirectories)
- WIN32;DEBUG;_WINDOWS;_USRDLL;XRCORE_EXPORTS;_SECURE_SCL=0;%(PreprocessorDefinitions)
+ .;$(SolutionDir);$(DXSDK_DIR)Include;$(XRAY_16X_LIBS);$(xrSdkDir)include;$(XRAY_16X_LIBS)openssl\include;%(AdditionalIncludeDirectories)
+ WIN32;DEBUG;_WINDOWS;_USRDLL;XRCORE_EXPORTS;_SECURE_SCL=0;%(PreprocessorDefinitions);CRYPTO_BUILD
false
true
Sync
@@ -96,7 +96,7 @@
true
- $(xrSdkDir)libraries;$(DXSDK_DIR)Lib\x86;$(XRAY_16X_LIBS)BugTrap\Bin;$(xrLibDir);%(AdditionalLibraryDirectories)
+ $(xrSdkDir)libraries;$(DXSDK_DIR)Lib\x86;$(XRAY_16X_LIBS)BugTrap\Bin;$(xrLibDir);$(XRAY_16X_LIBS)openssl\lib;%(AdditionalLibraryDirectories)
true
false
Windows
@@ -105,7 +105,7 @@
$(xrLibDir)$(TargetName).lib
MachineX86
- xrAPI.lib;%(AdditionalDependencies)
+ xrAPI.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
@@ -117,8 +117,8 @@
true
true
true
- .;$(SolutionDir);$(DXSDK_DIR)Include;$(XRAY_16X_LIBS);$(xrSdkDir)include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;_USRDLL;XRCORE_EXPORTS;_SECURE_SCL=0;%(PreprocessorDefinitions)
+ .;$(SolutionDir);$(DXSDK_DIR)Include;$(XRAY_16X_LIBS);$(xrSdkDir)include;$(XRAY_16X_LIBS)openssl\include;%(AdditionalIncludeDirectories)
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;XRCORE_EXPORTS;_SECURE_SCL=0;%(PreprocessorDefinitions);CRYPTO_BUILD
true
MultiThreadedDLL
@@ -134,7 +134,7 @@
ProgramDatabase
- $(xrSdkDir)libraries;$(DXSDK_DIR)Lib\x86;$(XRAY_16X_LIBS)BugTrap\Bin;$(xrLibDir);%(AdditionalLibraryDirectories)
+ $(xrSdkDir)libraries;$(DXSDK_DIR)Lib\x86;$(XRAY_16X_LIBS)BugTrap\Bin;$(xrLibDir);$(XRAY_16X_LIBS)openssl\lib;%(AdditionalLibraryDirectories)
true
NotSet
true
@@ -145,7 +145,7 @@
$(xrLibDir)$(TargetName).lib
NotSet
- xrAPI.lib;%(AdditionalDependencies)
+ xrAPI.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
@@ -156,8 +156,8 @@
Speed
false
true
- .;$(SolutionDir);$(DXSDK_DIR)Include;$(XRAY_16X_LIBS);$(xrSdkDir)include;%(AdditionalIncludeDirectories)
- MIXED;WIN32;DEBUG;_WINDOWS;_USRDLL;XRCORE_EXPORTS;_SECURE_SCL=0;%(PreprocessorDefinitions)
+ .;$(SolutionDir);$(DXSDK_DIR)Include;$(XRAY_16X_LIBS);$(xrSdkDir)include;$(XRAY_16X_LIBS)openssl\include;%(AdditionalIncludeDirectories)
+ MIXED;WIN32;DEBUG;_WINDOWS;_USRDLL;XRCORE_EXPORTS;_SECURE_SCL=0;%(PreprocessorDefinitions);CRYPTO_BUILD
true
MultiThreadedDLL
true
@@ -171,7 +171,7 @@
ProgramDatabase
- $(xrSdkDir)libraries;$(DXSDK_DIR)Lib\x86;$(XRAY_16X_LIBS)BugTrap\Bin;$(xrLibDir);%(AdditionalLibraryDirectories)
+ $(xrSdkDir)libraries;$(DXSDK_DIR)Lib\x86;$(XRAY_16X_LIBS)BugTrap\Bin;$(xrLibDir);$(XRAY_16X_LIBS)openssl\lib;%(AdditionalLibraryDirectories)
true
Windows
true
@@ -179,7 +179,7 @@
$(xrLibDir)$(TargetName).lib
NotSet
- xrAPI.lib;%(AdditionalDependencies)
+ xrAPI.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
@@ -292,6 +292,9 @@
+
+
+
@@ -436,6 +439,10 @@
+
+
+
+
CppHeader
diff --git a/src/xrCore/xrCore.vcxproj.filters b/src/xrCore/xrCore.vcxproj.filters
index 039f63aed52..b9bf9c4dd6d 100644
--- a/src/xrCore/xrCore.vcxproj.filters
+++ b/src/xrCore/xrCore.vcxproj.filters
@@ -118,6 +118,9 @@
{0a558484-bd93-4e59-90eb-227898f999f9}
+
+ {c56e1246-919c-4516-ad31-b9d3b4dadbc4}
+
@@ -369,6 +372,15 @@
Debug core\DxErr
+
+ crypto
+
+
+ crypto
+
+
+ crypto
+
@@ -779,6 +791,18 @@
Kernel\Common
+
+ crypto
+
+
+ crypto
+
+
+ crypto
+
+
+ crypto
+
diff --git a/src/xrGame/configs_common.h b/src/xrGame/configs_common.h
index 475b429a7aa..442c2563bbf 100644
--- a/src/xrGame/configs_common.h
+++ b/src/xrGame/configs_common.h
@@ -1,7 +1,7 @@
#ifndef CONFIGS_COMMON_INCLUDED
#define CONFIGS_COMMON_INCLUDED
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
namespace mp_anticheat
{
diff --git a/src/xrGame/game_cl_mp.cpp b/src/xrGame/game_cl_mp.cpp
index f61dd18b21b..dc1f81f7dea 100644
--- a/src/xrGame/game_cl_mp.cpp
+++ b/src/xrGame/game_cl_mp.cpp
@@ -35,7 +35,7 @@
#include "xrCore/ppmd_compressor.h"
#include "xrCore/rt_compressor.h"
#include "game_cl_mp_snd_messages.h"
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
#include "reward_event_generator.h"
#include "game_cl_base_weapon_usage_statistic.h"
@@ -56,7 +56,6 @@
BOOL g_draw_downloads = FALSE;
-#pragma comment(lib, "crypto.lib")
game_cl_mp::game_cl_mp()
{
diff --git a/src/xrGame/screenshots_common.h b/src/xrGame/screenshots_common.h
index 9836c68173a..4bd89b47b18 100644
--- a/src/xrGame/screenshots_common.h
+++ b/src/xrGame/screenshots_common.h
@@ -1,7 +1,7 @@
#ifndef SCREENSHOTS_COMMON_INCLUDED
#define SCREENSHOTS_COMMON_INCLUDED
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
namespace screenshots
{
diff --git a/src/xrGame/stats_submitter.h b/src/xrGame/stats_submitter.h
index e765dfc9c20..b8a97732eab 100644
--- a/src/xrGame/stats_submitter.h
+++ b/src/xrGame/stats_submitter.h
@@ -5,7 +5,7 @@
#include "gamespy/GameSpy_ATLAS.h"
#include "profile_data_types.h"
#include "gsc_dsigned_ltx.h"
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
class CGameSpy_Full;
diff --git a/src/xrGame/xrGame.vcxproj b/src/xrGame/xrGame.vcxproj
index c79f815cc27..467733ca1d6 100644
--- a/src/xrGame/xrGame.vcxproj
+++ b/src/xrGame/xrGame.vcxproj
@@ -4024,10 +4024,6 @@
-
- {fa169092-ea3e-40c1-8e5a-a2b575700fe8}
- false
-
{cc52e0b3-cc35-4934-9302-035b748f3f2c}
false
diff --git a/src/xrGame/xr_dsa_signer.h b/src/xrGame/xr_dsa_signer.h
index d4765f35619..ffd89b11d28 100644
--- a/src/xrGame/xr_dsa_signer.h
+++ b/src/xrGame/xr_dsa_signer.h
@@ -1,7 +1,7 @@
#ifndef XR_DSA_SIGNER_INCLUDED
#define XR_DSA_SIGNER_INCLUDED
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
typedef fastdelegate::FastDelegate1< long > sha_process_yielder;
diff --git a/src/xrGame/xr_dsa_verifyer.h b/src/xrGame/xr_dsa_verifyer.h
index c440bbde2f6..7be30b36a95 100644
--- a/src/xrGame/xr_dsa_verifyer.h
+++ b/src/xrGame/xr_dsa_verifyer.h
@@ -1,7 +1,7 @@
#ifndef XR_DSA_VERIFYER_INCLUDED
#define XR_DSA_VERIFYER_INCLUDED
-#include "3rd party/crypto/crypto.h"
+#include "xrCore/crypto/crypto.h"
class xr_dsa_verifyer
{