From bc4a458f4405ea8939709789060d782881162eeb Mon Sep 17 00:00:00 2001 From: Florian Omnes Date: Thu, 18 Mar 2021 17:43:52 +0100 Subject: [PATCH] Remove openssl dependency TODO - curl depends on Openssl - Remove unused check functions --- INSTALL-centos.md | 7 +- INSTALL-ubuntu.md | 5 +- INSTALL-windows.md | 4 +- INSTALL.md | 1 - docker/centos8-ortools | 2 +- src/CMakeLists.txt | 5 +- src/antares-deps | 2 +- src/distrib/unix/rpm/rte-antares.spec | 2 +- src/distrib/win32/sourcefiles.inc.nsh | 3 - src/ext/ext changelog.txt | 2 +- src/internet/CMakeLists.txt | 2 - src/internet/decrypt.hxx | 325 +--------- src/internet/hello_web.cpp | 550 +---------------- src/internet/host-properties.cpp | 589 ------------------- src/internet/license.h | 18 - src/libs/antares/proxy/proxy.cpp | 2 - src/script_compilation | 9 +- src/tests/resources/Antares_Simulator_Tests | 2 +- src/ui/simulator/application/main/create.cpp | 8 - src/ui/simulator/application/main/help.cpp | 5 +- src/ui/simulator/windows/about/aboutbox.cpp | 6 - 21 files changed, 18 insertions(+), 1531 deletions(-) diff --git a/INSTALL-centos.md b/INSTALL-centos.md index ba3f0319c2..1639ff618f 100644 --- a/INSTALL-centos.md +++ b/INSTALL-centos.md @@ -53,7 +53,6 @@ pip3 install -r src/tests/examples/requirements.txt ## [Dependencies](#deps) ANTARES depends on several mandatory libraries. - - [OpenSSL](https://github.com/openssl/openssl) - [CURL](https://github.com/curl/curl) - [Sirius Solver](https://github.com/AntaresSimulatorTeam/sirius-solver/tree/Antares_VCPKG) (fork from [RTE](https://github.com/rte-france/sirius-solver/tree/Antares_VCPKG)) - [OR-Tools](https://github.com/AntaresSimulatorTeam/or-tools/tree/rte_dev_sirius) (fork from [RTE](https://github.com/rte-france/or-tools/tree/rte_dev_sirius) based on official OR-Tools github) @@ -69,7 +68,7 @@ The install procedure can be done #### Yum commands ``` -sudo yum install redhat-lsb-core openssl-devel curl-devel wxGTK3-devel boost-test boost-filesystem boost-regex boost-devel unzip +sudo yum install redhat-lsb-core curl-devel wxGTK3-devel boost-test boost-filesystem boost-regex boost-devel unzip ``` ### [Automatic librairies compilation from git](#git_compil) [Antares dependencies compilation repository](https://github.com/AntaresSimulatorTeam/antares-deps) is used as a git submodule for automatic librairies compilation from git. @@ -90,7 +89,7 @@ By default the install directory is `/../rte-antares-deps- Note : > `DEPS_INSTALL_DIR` is added to `CMAKE_PREFIX_PATH` -> If the dependency install directory contains CURL, OPENSSL or wxWidgets pre-compiled libraries an additionnal option must be used at configure time `-DUSE_PRECOMPILED_EXT=ON` +> If the dependency install directory contains CURL, or wxWidgets pre-compiled libraries an additionnal option must be used at configure time `-DUSE_PRECOMPILED_EXT=ON` ### Pre-compiled libraries download : release version only You can download pre-compiled antares-deps archive from [Antares dependencies compilation repository](https://github.com/AntaresSimulatorTeam/antares-deps/releases/tag/v1.1.0). Only release version are available. @@ -214,5 +213,5 @@ There are still some system libraries that must be installed if you want to use ``` sudo yum install epel-release -sudo yum install openssl curl wxGTK3 +sudo yum install curl wxGTK3 ``` diff --git a/INSTALL-ubuntu.md b/INSTALL-ubuntu.md index 4b34162e3a..07434bf410 100644 --- a/INSTALL-ubuntu.md +++ b/INSTALL-ubuntu.md @@ -34,7 +34,6 @@ pip3 install -r src/src/tests/examples/requirements.txt ## [Dependencies](#deps) ANTARES depends on several mandatory libraries. - - [OpenSSL](https://github.com/openssl/openssl) - [CURL](https://github.com/curl/curl) - [Sirius Solver](https://github.com/AntaresSimulatorTeam/sirius-solver/tree/Antares_VCPKG) (fork from [RTE](https://github.com/rte-france/sirius-solver/tree/Antares_VCPKG)) - [OR-Tools](https://github.com/AntaresSimulatorTeam/or-tools/tree/rte_dev_sirius) (fork from [RTE](https://github.com/rte-france/or-tools/tree/rte_dev_sirius) based on official OR-Tools github) @@ -50,7 +49,7 @@ The install procedure can be done #### Command to install dependencies ``` -sudo apt install uuid-dev libcurl4-openssl-dev libssl-dev libwxgtk3.0-gtk3-dev libboost-test-dev libboost-filesystem-dev libboost-regex-dev libboost-dev +sudo apt install uuid-dev libcurl4-openssl-dev libwxgtk3.0-gtk3-dev libboost-test-dev libboost-filesystem-dev libboost-regex-dev libboost-dev ``` ### [Automatic librairies compilation from git](#git_compil) @@ -190,4 +189,4 @@ There are still some system libraries that must be installed if you want to use ``` sudo apt-get install libcurl4 libwxgtk3.0-gtk3-0v5 -``` \ No newline at end of file +``` diff --git a/INSTALL-windows.md b/INSTALL-windows.md index 479d2f99a3..8ee4daa6b2 100644 --- a/INSTALL-windows.md +++ b/INSTALL-windows.md @@ -32,7 +32,6 @@ pip install -r src/tests/examples/requirements.txt ## [Dependencies](#deps) ANTARES depends on several mandatory libraries. - - [OpenSSL](https://github.com/openssl/openssl) - [CURL](https://github.com/curl/curl) - [Sirius Solver](https://github.com/AntaresSimulatorTeam/sirius-solver/tree/Antares_VCPKG) (fork from [RTE](https://github.com/rte-france/sirius-solver/tree/Antares_VCPKG)) - [OR-Tools](https://github.com/AntaresSimulatorTeam/or-tools/tree/rte_dev_sirius) (fork from [RTE](https://github.com/rte-france/or-tools/tree/rte_dev_sirius) based on official OR-Tools github) @@ -74,7 +73,6 @@ Note : #### 2 Install dependencies ``` cd [vcpkg_root] -vcpkg install openssl:[vcpg-triplet] vcpkg install curl:[vcpg-triplet] vcpkg install wxwidgets:[vcpg-triplet] vcpkg install boost-test:[vcpg-triplet] @@ -102,7 +100,7 @@ By default the install directory is `/../rte-antares-deps- Note : > `DEPS_INSTALL_DIR` is added to `CMAKE_PREFIX_PATH` -> If the dependency install directory contains CURL, OPENSSL or wxWidgets pre-compiled libraries an additionnal option must be used at configure time `-DUSE_PRECOMPILED_EXT=ON` +> If the dependency install directory contains CURL or wxWidgets pre-compiled libraries an additionnal option must be used at configure time `-DUSE_PRECOMPILED_EXT=ON` ### Pre-compiled libraries download : release version only You can download pre-compiled antares-deps archive from [Antares dependencies compilation repository](https://github.com/AntaresSimulatorTeam/antares-deps/releases/tag/v1.1.0). Only release version are available. diff --git a/INSTALL.md b/INSTALL.md index bef52ee1c4..ee8d247eb1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -51,7 +51,6 @@ Git version must be above 2.15 for external dependencies build because `--ignore ## [Dependencies](#deps) *ANTARES* depends on severals mandatory libraries. - - [OpenSSL](https://github.com/openssl/openssl) - [CURL](https://github.com/curl/curl) - [Sirius Solver](https://github.com/AntaresSimulatorTeam/sirius-solver/tree/Antares_VCPKG) (fork from [RTE](https://github.com/rte-france/sirius-solver/tree/Antares_VCPKG)) - [OR-Tools](https://github.com/AntaresSimulatorTeam/or-tools/tree/rte_dev_sirius) (fork from [RTE](https://github.com/rte-france/or-tools/tree/rte_dev_sirius) based on official OR-Tools github) diff --git a/docker/centos8-ortools b/docker/centos8-ortools index 669ebf304c..c6eff53fc4 100644 --- a/docker/centos8-ortools +++ b/docker/centos8-ortools @@ -9,7 +9,7 @@ RUN yum install -y epel-release # Install requirements RUN yum install -y git redhat-lsb-core gcc gcc-c++ make \ wget \ - unzip openssl-devel libcurl-devel wxGTK3-devel libuuid-devel boost-devel boost-test boost-filesystem boost-regex + unzip libcurl-devel wxGTK3-devel libuuid-devel boost-devel boost-test boost-filesystem boost-regex # Install CMake3 RUN wget https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3.tar.gz &&\ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bce35c924f..ebd5e41b2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -199,9 +199,6 @@ add_subdirectory(antares-deps) #libcurl find_package(CURL REQUIRED) -#openssl -find_package(OpenSSL REQUIRED) - #Add needed definition in case of external dependencies compilation include (antares-deps/cmake/additionnal-definitions.cmake) @@ -370,7 +367,7 @@ else() set(CPACK_PACKAGE_VERSION_PATCH ${ANTARES_VERSION_REVISION}) set(CPACK_DEBIAN_PACKAGE_DEPENDS "libcurl4,libwxgtk3.0-gtk3-0v5") - set(CPACK_RPM_PACKAGE_REQUIRES "openssl,curl,wxGTK3") + set(CPACK_RPM_PACKAGE_REQUIRES "curl,wxGTK3") set(CPACK_RPM_PACKAGE_AUTOREQPROV "0") configure_file("distrib/unix/packages.cmake" "distrib/unix/packages.sh") diff --git a/src/antares-deps b/src/antares-deps index 503f7732c9..17950920db 160000 --- a/src/antares-deps +++ b/src/antares-deps @@ -1 +1 @@ -Subproject commit 503f7732c9436da39b1275cd01cb53614cdaf18a +Subproject commit 17950920db46da3e5f320f83a15db0c971464c20 diff --git a/src/distrib/unix/rpm/rte-antares.spec b/src/distrib/unix/rpm/rte-antares.spec index f052cd1296..d168b1c55d 100644 --- a/src/distrib/unix/rpm/rte-antares.spec +++ b/src/distrib/unix/rpm/rte-antares.spec @@ -11,7 +11,7 @@ Source0: %%SOURCE%% BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: chrpath -Requires: glibc >= 2.12, libuuid >= 2.17, openssl >= 1.0 +Requires: glibc >= 2.12, libuuid >= 2.17 %description Under the impulsion given by the worldwide growth of innovative technologies diff --git a/src/distrib/win32/sourcefiles.inc.nsh b/src/distrib/win32/sourcefiles.inc.nsh index 80813988e9..ba90c7b269 100644 --- a/src/distrib/win32/sourcefiles.inc.nsh +++ b/src/distrib/win32/sourcefiles.inc.nsh @@ -23,8 +23,5 @@ File /r ${ANTARES_SRC_DIR}\..\resources\*.* ;${SetOutPath} "$INSTDIR\Sources\src\build_deps\curl\source" ;File /nonfatal /r /x builds .git ${ANTARES_SRC_DIR}\..\src\build_deps\curl\source\*.* -;${SetOutPath} "$INSTDIR\Sources\src\build_deps\OpenSSL\source" -;File /nonfatal /r /x .git ${ANTARES_SRC_DIR}\..\src\build_deps\OpenSSL\source\*.* - ;${SetOutPath} "$INSTDIR\Sources\src\build_deps\wxWidgets\source" ;File /nonfatal /r /x .git ${ANTARES_SRC_DIR}\..\src\build_deps\wxWidgets\source\*.* \ No newline at end of file diff --git a/src/ext/ext changelog.txt b/src/ext/ext changelog.txt index d8244dcee0..6be6826172 100644 --- a/src/ext/ext changelog.txt +++ b/src/ext/ext changelog.txt @@ -32,4 +32,4 @@ nmake /f Makefile.vc mode=static VC=14 WITH_SSL=static WITH_DEVEL=../../openssl/ x64: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" cd ${ANTARES}\src\ext\libcurl\winbuild -nmake /f Makefile.vc mode=static VC=14 WITH_SSL=static WITH_DEVEL=../../openssl/vc-release-x86_64 ENABLE_SSPI=no ENABLE_IDN=no ENABLE_WINSSL=no GEN_PDB=no DEBUG=no MACHINE=x64 +nmake /f Makefile.vc mode=static VC=14 ENABLE_SSPI=no ENABLE_IDN=no ENABLE_WINSSL=no GEN_PDB=no DEBUG=no MACHINE=x64 diff --git a/src/internet/CMakeLists.txt b/src/internet/CMakeLists.txt index 7a17d0b550..b796537198 100644 --- a/src/internet/CMakeLists.txt +++ b/src/internet/CMakeLists.txt @@ -21,7 +21,6 @@ target_include_directories(libantares-license ${CMAKE_SOURCE_DIR}/ext/yuni/src ${CMAKE_SOURCE_DIR}/libs PUBLIC - ${OPENSSL_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ) @@ -30,7 +29,6 @@ target_link_libraries(libantares-license yuni-static-core PUBLIC ${CURL_LIBRARIES} - ${OPENSSL_LIBRARIES} base64 ) if(WIN32 OR WIN64) diff --git a/src/internet/decrypt.hxx b/src/internet/decrypt.hxx index abadd4311b..5e1a2d75dd 100644 --- a/src/internet/decrypt.hxx +++ b/src/internet/decrypt.hxx @@ -30,9 +30,6 @@ #include #include "license.h" #include "base64/cdecode.h" -#include -#include -#include #include #include @@ -110,71 +107,12 @@ static const char* IndexToCString(T index) template static bool Encrypt(StringT& out, const AnyString& in, const EncryptionKey& key) { - EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - EVP_CIPHER_CTX_init(ctx); - - EVP_EncryptInit(ctx, EVP_bf_cbc(), (const uchar*)key.key.c_str(), (const uchar*)key.iv.c_str()); - - enum - { - paddingLength = encryptionKeyLength + encryptionIVLength + 8 /*arbitrary*/, - }; - out.reserve(in.size() + paddingLength); - int olen; - if (EVP_EncryptUpdate(ctx, (uchar*)out.data(), &olen, (const uchar*)in.c_str(), in.size()) == 1) - { - int tlen; - if (EVP_EncryptFinal(ctx, (uchar*)out.data() + olen, &tlen) == 1) - { - olen += tlen; - assert((uint)olen < out.capacity()); - out.resize(olen); - - EVP_CIPHER_CTX_free(ctx); - return true; - } - } - - EVP_CIPHER_CTX_free(ctx); - out.clear(); - return false; + return true; } template static bool Decrypt(StringT& out, const AnyString& in, const EncryptionKey& key) { - if (in.empty()) - { - out.clear(); - return true; - } - - EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); - EVP_CIPHER_CTX_init(ctx); - EVP_DecryptInit(ctx, EVP_bf_cbc(), (const uchar*)key.key.c_str(), (const uchar*)key.iv.c_str()); - - enum - { - paddingLength = encryptionKeyLength + encryptionIVLength + 8 /*arbitrary*/, - }; - out.reserve(in.size() + paddingLength); - int olen; - if (EVP_DecryptUpdate(ctx, (uchar*)out.data(), &olen, (const uchar*)in.c_str(), in.size()) == 1) - { - int tlen; - if (EVP_DecryptFinal(ctx, (uchar*)out.data() + olen, &tlen) == 1) - { - olen += tlen; - assert((uint)olen < out.capacity()); - out.resize(olen); - - EVP_CIPHER_CTX_free(ctx); - return true; - } - } - - EVP_CIPHER_CTX_free(ctx); - out.clear(); return false; } @@ -202,266 +140,7 @@ namespace // anonymous template static bool DecodeAntaresKey(License::Properties& properties, StringT& content) { - properties.clear(); - content.replace("\r", ""); - content.trim(); - content += '\n'; - - if (content.size() < 10) // not really possible to have a very short hostkey - { - LICENSE_DEBUG("license: activation key too short"); - return false; - } - - auto beginHostKey = content.find("-BEGIN LICENSE REQUEST KEY-"); - if (beginHostKey >= content.size()) - { - beginHostKey = content.find("-BEGIN LICENSE ACTIVATION KEY-"); - if (beginHostKey >= content.size()) - { - LICENSE_DEBUG("invalid header: requires BEGIN LICENSE (REQUEST|ACTIVATION) KEY"); - return false; - } - } - auto startKey = content.find('\n', beginHostKey); - if (startKey >= content.size()) - return false; - ++startKey; - if (startKey >= content.size()) - return false; - - auto endHostKey = content.find("-END LICENSE REQUEST KEY-"); - if (endHostKey >= content.size()) - { - endHostKey = content.find("-END LICENSE ACTIVATION KEY-"); - if (endHostKey >= content.size()) - { - LICENSE_DEBUG("invalid header: requires END LICENSE (REQUEST|ACTIVATION) KEY"); - return false; - } - } - if (endHostKey <= startKey) - return false; - - auto endKey = content.rfind('\n', endHostKey); - if (endKey <= startKey or 0 == endKey) - return false; - - // removing the useless end part of the key - content.resize(endKey); - content.consume(startKey); - - content.replace("\n", ""); - content.replace("\r", ""); - - auto separator = content.find('-'); - if (separator >= content.size() - 1 or 0 == separator) - return false; - - // In a first time, we will extract the encrypted key (encrypted by our public RSA key, base64 - // encoded) used to encrypt informations about the host - Yuni::String encryptedKey; - { - AnyString rawEncryptedKey(content, 0, separator); - encryptedKey.reserve(rawEncryptedKey.size()); - base64_decodestate state; - base64_init_decodestate(&state); - auto length = base64_decode_block( - rawEncryptedKey.c_str(), rawEncryptedKey.size(), encryptedKey.data(), &state); - if (length <= 0) - return false; - assert((uint)length < encryptedKey.capacity()); - encryptedKey.resize(length); - } - // The encrypted key is now available from encryptedKey, we have to decipher it with - // our private key. - - // loading this private key first - Yuni::String membio; - if (ForHostKey) - PRIVATE_KEY_FOR_HOSTID(membio); - else - PUBLIC_KEY_FOR_LICENSEKEY(membio); - - BIO* bp = BIO_new_mem_buf((void*)membio.data(), -1); - if (not bp) - return false; - - RSA* privkey; - if (ForHostKey) - privkey = PEM_read_bio_RSAPrivateKey(bp, 0, 0, 0); - else - privkey = PEM_read_bio_RSA_PUBKEY(bp, 0, 0, 0); - - if (not privkey) - return false; - BIO_free(bp); - - auto rsaSize = RSA_size(privkey); - if (rsaSize <= 0) - { - RSA_free(privkey); - return false; - } - - Yuni::String decryptedKey; - decryptedKey.reserve(rsaSize); - - // deciphering the - int decryptedLen; - if (ForHostKey) - { - decryptedLen = RSA_private_decrypt(encryptedKey.size(), - (const unsigned char*)encryptedKey.c_str(), - (unsigned char*)decryptedKey.data(), - privkey, - RSA_PKCS1_OAEP_PADDING); - } - else - { - decryptedLen = RSA_public_decrypt(encryptedKey.size(), - (const unsigned char*)encryptedKey.c_str(), - (unsigned char*)decryptedKey.data(), - privkey, - RSA_PKCS1_PADDING); - } - - RSA_free(privkey); - - if (decryptedLen > 0) - { - decryptedKey.resize((uint)decryptedLen); - // From now on, we have the key used to cipher informations about the host - License::EncryptionKey msgkey; - msgkey.key = decryptedKey; - msgkey.iv.assign(decryptedKey, msgkey.key.size()); - - // the real message to decipher - AnyString encodedBase64(content, separator + 1, content.size() - (separator + 1)); - - Yuni::String encoded; - encoded.reserve(encodedBase64.size()); - base64_decodestate state; - base64_init_decodestate(&state); - auto length = base64_decode_block( - encodedBase64.c_str(), encodedBase64.size(), encoded.data(), &state); - if (length <= 0) - return false; - assert((uint)length < encoded.capacity()); - encoded.resize(length); - - Yuni::String informations; - informations.reserve(encoded.size()); - if (not License::Decrypt(informations, encoded, msgkey)) - return false; - - // from now on, we have the original message ! - informations.trim(); // normalizing - informations += '\n'; - - // reading all keys => values to file our dictionary - Yuni::String key; - Yuni::String value; - informations.words("\r\n", [&](AnyString& word) -> bool { - word.extractKeyValue(key, value, true); - if (key.empty() or value.empty()) - return true; - - if (ForHostKey) - { - if (key.size() == 1) - { - if (key == 'a') - { - properties[(key = "antares.arch")] = value; - return true; - } - if (key == 'c') - { - properties[(key = "cpu.count")] = value; - return true; - } - if (key == 'f') - { - properties[(key = "cpu.frequency")] = value; - return true; - } - if (key == 'k') - { - properties[(key = "hostid")] = value; - return true; - } - if (key == 'm') - { - properties[(key = "memory.available")] = value; - return true; - } - } - else - { - if (key == "bm") - { - properties[(key = "motherboard.manufacturer")] = value; - return true; - } - if (key == "mac") - { - properties[(key = "iface")] = value; - return true; - } - - if (key == "nm") - { - key = "os.name"; - if (value == "win7pro") - properties[key] = "Windows 7 Professional"; - else if (value == "win8pro") - properties[key] = "Windows 8 Professional"; - else if (value == "winXPpro") - properties[key] = "Windows XP Professional"; - else if (value == "win7home") - properties[key] = "Windows 7 Home"; - else if (value == "win8home") - properties[key] = "Windows 8 Home"; - else if (value == "winXPhome") - properties[key] = "Windows XP Home"; - else - properties[key] = value; - return true; - } - if (key == "os") - { - key = "os.type"; - if (value == "w") - properties[key] = "Windows"; - else if (value == "n") - properties[key] = "Linux"; - else if (value == "m") - properties[key] = "Mac OS"; - else - properties[key] = value; - return true; - } - if (key == "osa") - { - properties[(key = "os.arch")] = value; - return true; - } - if (key == "pk") - { - properties[(key = "os.service.pack")] = value; - return true; - } - } - } - else - properties[key] = value; - - return true; // continue next keyword - }); - return true; - } - return false; + return true; } } // anonymous namespace diff --git a/src/internet/hello_web.cpp b/src/internet/hello_web.cpp index ece0a89397..ca73fa1b07 100644 --- a/src/internet/hello_web.cpp +++ b/src/internet/hello_web.cpp @@ -363,10 +363,6 @@ void InitializeEncryptionEngine() if (not encryptionEngineInitialized) { - // note : the order for initializing flex / openssl should not matter - // initialize all OpenSSL-release resources - OpenSSL_add_all_algorithms(); - // mark the license engine as initialized encryptionEngineInitialized = true; } @@ -381,11 +377,7 @@ void ReleaseEncryptionEngine() if (encryptionEngineInitialized) { - // note : the order for releasing flex / openssl should not matter - // mark the license as not initialized encryptionEngineInitialized = false; - // release all OpenSSL-release resources - EVP_cleanup(); } } @@ -446,375 +438,9 @@ bool RevokeAllUserActivationKeys(uint version) return true; } -static bool CheckAntaresLicenseValidity(uint version, String* error) -{ - String activationKey; - if (not RetrieveActivationKey(version, activationKey, error)) - { - LICENSE_DEBUG("invalid activation key structure"); - return false; - } - if (not CheckActivationKeyValidity(version, activationKey, error)) - { - LICENSE_DEBUG("The antares.hwb activation key is INVALID"); - return false; - } - return true; -} - bool CheckLicenseValidity(uint version, String* error) { - if (error) - error->clear(); - - // Checking for Antares corporate LICENSE - // The Antares License may contain a flag for using - return CheckAntaresLicenseValidity(version, error); -} - -bool CheckActivationKeyValidity(uint version, - Yuni::String& activationKey, - Yuni::String* error, - bool ignoreLicenseServer) -{ - if (error) - error->clear(); - lastError = errFailed; - - if (activationKey.size() < minimalLicenseActivationKeyLength) // early detection - { - LICENSE_DEBUG("Activation key too small"); - return false; - } - - Properties hostproperties; - Properties licenseproperties; - String tmp; - - Yuni::MutexLocker locker(licenseMutex); - - if (not RetrieveHostProperties(hostproperties, tmp)) - { - LICENSE_DEBUG("impossible to retrieve host properties"); - return false; - } - - if (not DecodeAntaresKey(licenseproperties, activationKey)) - { - if (error) - *error = "invalid key"; - LICENSE_DEBUG("impossible to decode the key"); - return false; - } - - // we should reset once we have successfully retrieved the license - // informations - Limits::areaCount = 0; - Limits::thermalClusterCount = 0; - hasLicenseServers = false; - - // global checks - // we may have several allowed hostid or productid - bool checkHostID = false; - bool checkProduct = false; - bool floatingLicenses = false; - // customer caption, for delayed updated - String customerCaption; - String customerId; - ; - - // check if need to verify on the internet server - if (licenseproperties.find("internet.server.check") == licenseproperties.end()) - statusOnline = stNotRequested; - - // check the solver parameter - if (not hasSimulatorAuthorization) // we're launched from the command line - { - // check whether the parameter exist - if (licenseproperties.find("stand.alone.simulator") != licenseproperties.end()) - { - if (licenseproperties.find("solver.authorized") != licenseproperties.end()) - { - if (not licenseproperties["solver.authorized"].to()) - { - if (error) - *error = "simulator permission denied"; - return false; - } - } - //\todo clean this ^^ - /*if (not licenseproperties["stand.alone.simulator"].to()) - { - if (error) - *error = "simulator permission denied"; - return false; - }*/ - } - } - - // check each the property - foreach (auto& keyvalue, licenseproperties) - { - auto& key = keyvalue.first; - - if (key.empty()) - continue; - - char c = key[0]; - if (c < 'a' or c > 'z') - continue; - - auto& value = keyvalue.second; - - switch (c) - { - case 'i': - { - if (key == "internet.server.check") - { - if (value.to() == true) - { - if (statusOnline == stInitialize) - { - // checkOnline = true; - // load proxy parameters - statusOnline = stWaiting; - // read proxy parameters from file if it is not configured from interface - if (not proxy.enabled) - proxy.loadProxyFile(); - } - } - else - statusOnline = stNotRequested; - break; - } - if (key == "internet.server.url") - { - Limits::urlLicenseServer = value; - break; - } - break; - } - case 'c': - { - if (key == "customer.caption") - { - customerCaption = value; - customerCaption.trim(); - Limits::customerCaption = customerCaption; - } - else if (key == "customer.id") - { - customerId = value; - customerId.trim(); - Limits::customerId = customerId; - } - else if (key == "customer.tick") - { - int tick = atoi(value.c_str()); - if (tick > 0) - { - Limits::tick = tick; - } - } - break; - } - case 'e': - { - if (key == "expires") - { - if (DateTime::Now() > value.to()) - { - LICENSE_DEBUG("product expired"); - if (error) - *error = "The license has expired"; - return false; - } - Limits::expiryDate = value; - } - break; - } - case 'h': - { - if (key == "host.allow") - { - auto& hostid = hostproperties[(tmp = "k")]; - if (value != hostid and value != "*") - { - LICENSE_DEBUG("checking hostid : " << hostid << ", from activation key: " - << value << ", status: failed"); - continue; // can have several hostid - } - checkHostID = true; - LICENSE_DEBUG("checking hostid : " << hostid << ", from activation key: " << value - << ", status: success"); - Limits::hostID - = hostid; // If value=* we send the hostid to the server and not the * value - } - break; - } - case 'l': - { - if (key == "license.servers") - { - if (value.to() == true) - { - floatingLicenses = true; - hasLicenseServers = true; - } - } - break; - } - case 'm': - { - if (key == "memory.max") - { - uint available - = (uint)Math::Round(((double)System::Memory::Total() / 1024 / 1024 / 1024)); - if (available > value.to()) - { - LICENSE_DEBUG("Too much available memory"); - return false; - } - } - break; - } - case 'o': - { - if (key == "os.require") - { - if (value != "*") - { -#ifdef YUNI_OS_WINDOWS - if (value != "windows") -#else - if (value != "linux") -#endif - { - LICENSE_DEBUG("invalid operating system"); - if (error) - *error = "invalid operating system"; - return false; - } - } - } - break; - } - case 'p': - { - if (key == "product.allow") - { - if (value == ANTARES_PRODUCT_UUID or value == "*") - { - // we may have several product authorization - checkProduct = true; - } - break; - } - if (key == "product.version.max") - { - if (version > value.to()) - { - LICENSE_DEBUG("product version too high"); - return false; - } - break; - } - if (key == "product.version.min") - { - if (version < value.to()) - { - LICENSE_DEBUG("product version too low"); - return false; - } - break; - } - break; - } - case 's': - { - if (key == "study.max.areas") - { - Limits::areaCount = value.to(); - break; - } - if (key == "study.max.thermal.clusters.per.area") - { - Limits::thermalClusterCount = value.to(); - break; - } - break; - } - case 'v': - { - if (key == "vendor") - { - if (value != "rte") - { - LICENSE_DEBUG("invalid vendor"); - if (error) - *error = "invalid vendor"; - return false; - } - break; - } - break; - } - - } // switch first char - - } // each property - - // if check license on the server is not requested - //! This condition should be checked first - // if (not checkOnline) - // statusOnline = stNotRequested; - - // if there is not product declared => not need to continue - if (not checkProduct) - { - if (error) - *error = "invalid product"; - LICENSE_DEBUG("invalid product (end of scope)"); - Limits::customerCaption = customerCaption; - hasLicenseServers = false; - return false; - } - - // if there is not host id declared => we need to check floting license - if (not checkHostID) - { - // we may not have verify the hostid yet, because we may have to - // use floating licenses - if (floatingLicenses) - { - if (not ignoreLicenseServer) - { - // updating - Limits::customerCaption = customerCaption; - return (lastError == errNone); - } - else - { - Limits::customerCaption = customerCaption; - lastError = errNone; - return true; - } - } // floating licenses - - // otherwise, continuing - if (error) - *error = "invalid host"; - LICENSE_DEBUG("invalid host (end of scope)"); - Limits::customerCaption = customerCaption; - hasLicenseServers = false; - lastError = errFailed; - return false; - } - - Limits::customerCaption = customerCaption; - lastError = errNone; - return true; + return false; } static size_t write_data(void* ptr, size_t, size_t nmemb, void*) @@ -898,179 +524,7 @@ static size_t write_data(void* ptr, size_t, size_t nmemb, void*) bool CheckOnlineLicenseValidity(uint version, bool recheck) { - Yuni::MutexLocker locker(licenseMutex); - - // recheck license online if it is requested - if (recheck) - { - if (statusOnline != stNotRequested) - statusOnline = stWaiting; - } - - switch (statusOnline) - { - case stInitialize: - { - // check the license key first; - if (not CheckLicenseValidity(version)) - return false; - - break; - } - case stWaiting: - { - // reintialize the status - statusOnline = stInvalidOnline; - - // connection to proxy with curl - CURL* curl_handle; - CURLcode res; - curl_global_init(CURL_GLOBAL_ALL); - curl_handle = curl_easy_init(); - - // build url - YString url; - char* host = curl_easy_escape(curl_handle, Limits::hostID.c_str(), Limits::hostID.length()); - url << Limits::urlLicenseServer << ANTARES_SERVER_SCRIPT_ROOT; - // build post request - YString postfiled; - postfiled << "hostid=" << host; - YString macAddress; - firstMacAddress(macAddress); - postfiled << "&macaddress=" - << "5E:FF:56:A2:AF:15"; - int startTime = 1531094400; // Monday 9 July 2018 00:00:00 - String client = Limits::customerId; - postfiled << "&customerid=" << client; - postfiled << "&tick=" << Limits::tick; - postfiled << "&starttime=" << startTime; - static String timestampOrig; - if (timestampOrig.empty()) - { - timestampOrig = Yuni::DateTime::Now(); - } - postfiled << "&sessionid=" << host << "_" << timestampOrig; - postfiled << "&tokenorder=" << System::CPU::Count(); - curl_easy_setopt(curl_handle, CURLOPT_POST, 1); - curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, postfiled.c_str()); - - curl_free(host); - - // added since Curl 7.21.7 - curl_easy_setopt(curl_handle, CURLOPT_TRANSFER_ENCODING, 1); - - // set curl options - curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L); - - if (Antares::License::proxy.enabled) - { - // build proxy parameters - YString proxyParameters; - proxyParameters << proxy.host << ":" << proxy.port; - - curl_easy_setopt(curl_handle, CURLOPT_HTTPPROXYTUNNEL, 1L); - curl_easy_setopt(curl_handle, CURLOPT_PROXY, proxyParameters.c_str()); - - if (!proxy.login.empty()) - { - // build passeword - YString userPassword; - char* user - = curl_easy_escape(curl_handle, proxy.login.c_str(), proxy.login.length()); - - userPassword << user; - if (!proxy.password.empty()) - userPassword << ":" << proxy.password; - - curl_easy_setopt(curl_handle, CURLOPT_PROXYUSERPWD, userPassword.c_str()); - } - } - - curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); - - curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 1); - - // build root CAcertificates - if (not Fcreaterootca()) - { - lastError = errCAFileRoot; - return false; - } - - String cafile; - CABundleFile(cafile); - curl_easy_setopt(curl_handle, CURLOPT_CAINFO, cafile.c_str()); - - // send all data to this function - curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); - - // time out (second) - curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 10); - - // get the result - res = CURL_PERFORM(curl_handle); - - // check the result - if (res != CURLE_OK) - { - LICENSE_DEBUG("checking proxy failed! You need to verify your proxy"); - lastError = errLSOnline; - - // redefine error type - if (Antares::License::proxy.enabled) - { - if ((res == CURLE_OPERATION_TIMEDOUT) or (res == CURLE_COULDNT_CONNECT) - or (res == CURLE_RECV_ERROR) or (res == CURLE_COULDNT_RESOLVE_HOST) - or (res == CURLE_COULDNT_RESOLVE_PROXY)) - lastError = errLSPoxy; - } - else - { - if (res == CURLE_COULDNT_CONNECT) - lastError = errLSHostDown; - } - } - - // remove the root CAcertificates - Fremoverootca(); - // cleanup curl stuff - curl_easy_cleanup(curl_handle); - - // check the last error - if (lastError != errNone or statusOnline != stValidOnline) - return false; - - LICENSE_DEBUG("checking activation key on the server success"); - - if (timerlaunched == false) - { - launchLicenseTimer(Limits::tick); - } - - break; - } - case stValidOnline: - { - LICENSE_DEBUG("checking activation key on the server always success"); - break; - } - case stNotRequested: - { - // do nothing - LICENSE_DEBUG("checking activation key on the server not requested"); - break; - } - default: - { - // always failed - lastError = errLSOnline; - return false; - } - } - - lastError = errNone; - return true; + return false; } } // namespace License diff --git a/src/internet/host-properties.cpp b/src/internet/host-properties.cpp index b97f5a8128..1243e62984 100644 --- a/src/internet/host-properties.cpp +++ b/src/internet/host-properties.cpp @@ -212,595 +212,6 @@ static inline void ListAllMacAddresses(String& out) bool RetrieveHostProperties(Properties& properties, String& n) { - properties.clear(); - String signature; - - // common code - { -#ifdef YUNI_OS_WINDOWS - signature += "Win,"; - properties[(n = "os")] = 'w'; -#else -#ifdef YUNI_OS_LINUX - signature += "Nux,"; - properties[(n = "os")] = 'n'; -#else -#ifdef YUNI_OS_MACOS - signature += "mac,"; - properties[(n = "os")] = 'm'; -#else - signature += YUNI_OS_NAME; - signature += ','; - properties[(n = "os")] = YUNI_OS_NAME; -#endif -#endif -#endif - -#ifdef YUNI_OS_32 - properties[(n = 'a')] = "32"; -#else - properties[(n = 'a')] = "64"; -#endif - - // CPU - uint cpucount = System::CPU::Count(); - signature << "c:" << cpucount << ','; - properties[(n = 'c')] = cpucount; - // Memory - properties[(n = 'm')] - = (uint)Math::Round(((double)System::Memory::Total() / (1024 * 1024 * 1024))); - - // MAC addresses, not very useful for Antares, but can be used to generate - ListAllMacAddresses(properties[(n = "mac")]); - } - // end common - -#ifdef YUNI_OS_WINDOWS - - // cpufreq - LARGE_INTEGER cpufreq; - if (TRUE == QueryPerformanceFrequency(&cpufreq)) - { - auto& text = properties[(n = "f")]; - text = Math::Round((double)cpufreq.QuadPart / (1000. * 1000.), 2); - text.trimRight('0'); - text.trimRight('.'); - } - - int CPUInfo[4] = {-1, -1, -1, -1}; - __cpuid(CPUInfo, 1); - int model = (CPUInfo[0] >> 4) & 0xf; - int family = (CPUInfo[0] >> 8) & 0xf; - int processorType = (CPUInfo[0] >> 12) & 0x3; - int extendedmodel = (CPUInfo[0] >> 16) & 0xf; - - __cpuid(CPUInfo, 0x80000006); - int cacheLineSize = (CPUInfo[2] & 0xff); - int nL2Associativity = (CPUInfo[2] >> 12) & 0xf; - int cacheSizeK = (CPUInfo[2] >> 16) & 0xffff; - - signature << model << ',' << family << ',' << processorType << ',' << extendedmodel << ','; - signature << cacheLineSize << ',' << nL2Associativity << '.' << cacheSizeK << ';'; - - bool comObjectAlreadyInit = false; - HRESULT hres = CoInitializeEx(0, COINIT_APARTMENTTHREADED); - switch (hres) - { - case S_OK: - break; - case S_FALSE: - comObjectAlreadyInit = true; - break; - default: - return false; - } - - hres = CoInitializeSecurity(NULL, - -1, // COM authentication - NULL, // Authentication services - NULL, // Reserved - RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication - RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation - NULL, // Authentication info - EOAC_NONE, // Additional capabilities - NULL // Reserved - ); - if (FAILED(hres)) - { - // it seems that the code works even if this call failed... - // if (not comObjectAlreadyInit) - // CoUninitialize(); - // return false; - } - - IWbemLocator* pLoc = nullptr; - - hres = CoCreateInstance( - CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID*)&pLoc); - if (FAILED(hres)) - { - if (not comObjectAlreadyInit) - CoUninitialize(); - return false; - } - - IWbemServices* pSvc = nullptr; - - hres = pLoc->ConnectServer(_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace - NULL, // User name. NULL = current user - NULL, // User password. NULL = current - 0, // Locale. NULL indicates current - NULL, // Security flags. - 0, // Authority (e.g. Kerberos) - 0, // Context object - &pSvc // pointer to IWbemServices proxy - ); - - if (FAILED(hres)) - { - pLoc->Release(); - if (not comObjectAlreadyInit) - CoUninitialize(); - return false; - } - - hres = CoSetProxyBlanket(pSvc, // Indicates the proxy to set - RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx - RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx - NULL, // Server principal name - RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx - RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx - NULL, // client identity - EOAC_NONE // proxy capabilities - ); - - if (FAILED(hres)) - { - pSvc->Release(); - pLoc->Release(); - if (not comObjectAlreadyInit) - CoUninitialize(); - return false; - } - - IEnumWbemClassObject* pEnumerator = nullptr; - - hres = pSvc->ExecQuery(bstr_t("WQL"), - bstr_t("SELECT * FROM Win32_OperatingSystem"), - WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, - NULL, - &pEnumerator); - - if (FAILED(hres)) - { - pSvc->Release(); - pLoc->Release(); - if (not comObjectAlreadyInit) - CoUninitialize(); - return false; - } - - signature.append("os:", 3); - uint index = 0; - - String text; - for (index = 0; pEnumerator; ++index) - { - ULONG uReturn = 0; - IWbemClassObject* pclsObj; - - HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); - if (0 == uReturn) - break; - - VARIANT vtProp; - - // caption - hr = pclsObj->Get(L"Caption", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - text.trim(); - - if (text.icontains("Microsoft Windows 9 Professionnel")) - text = "win9pro"; - else if (text.icontains("Microsoft Windows 9 Professional")) - text = "win9pro"; - else if (text.icontains("Microsoft Windows 9 Familiale")) - text = "win9home"; - else if (text.icontains("Microsoft Windows 9 Home")) - text = "win9home"; - else if (text.icontains("Microsoft Windows 8 Professionnel")) - text = "win8pro"; - else if (text.icontains("Microsoft Windows 8 Professional")) - text = "win8pro"; - else if (text.icontains("Microsoft Windows 8 Familiale")) - text = "win8home"; - else if (text.icontains("Microsoft Windows 8 Home")) - text = "win8home"; - if (text.icontains("Microsoft Windows 7 Professionnel")) - text = "win7pro"; - else if (text.icontains("Microsoft Windows 7 Professional")) - text = "win7pro"; - else if (text.icontains("Microsoft Windows 7 Familiale")) - text = "win7home"; - else if (text.icontains("Microsoft Windows 7 Home")) - text = "win7home"; - else if (text.icontains("Microsoft Windows XP Professionnel")) - text = "winXPpro"; - else if (text.icontains("Microsoft Windows XP Professional")) - text = "winXPpro"; - else if (text.icontains("Microsoft Windows XP Familiale")) - text = "winXPhome"; - else if (text.icontains("Microsoft Windows XP Home")) - text = "winXPhome"; - else - { - // Fallback - only replacing one part of the string, hoping this works - text.replace("Microsoft ", ""); - } - - signature << "n:" << text << ','; - properties[(n.clear() << "nm" << IndexToCString(index))] = text; - } - - // caption - hr = pclsObj->Get(L"OSArchitecture", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - if (text == "64 bits") - text = "64"; - else if (text == "32 bits") - text = "32"; - signature << "ach:" << text << ','; - properties[(n.clear() << "osa" << IndexToCString(index))] = text; - } - - // service pack - hr = pclsObj->Get(L"ServicePackMajorVersion", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - properties[(n.clear() << "pk" << IndexToCString(index))] = vtProp.intVal; - VariantClear(&vtProp); - } - - // organization - // hr = pclsObj->Get(L"Organization", 0, &vtProp, 0, 0); - // if (hr == S_OK) - //{ - // WideCharIntoString(text, vtProp.bstrVal); - // VariantClear(&vtProp); - // properties[(n.clear() << "org" << IndexToCString(index))] = text; - //} - - // hostname - // hr = pclsObj->Get(L"CSName", 0, &vtProp, 0, 0); - // if (hr == S_OK) - //{ - // WideCharIntoString(text, vtProp.bstrVal); - // VariantClear(&vtProp); - // properties[(n = "h")] = text; - //} - - // license - hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << "l:" << text << ','; - // properties[(n.clear() << "l" << IndexToCString(index))] = text; - } - - pclsObj->Release(); - } - pEnumerator->Release(); - - hres = pSvc->ExecQuery(bstr_t("WQL"), - bstr_t("SELECT * FROM Win32_BaseBoard"), - WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, - NULL, - &pEnumerator); - - if (FAILED(hres)) - { - pSvc->Release(); - pLoc->Release(); - if (not comObjectAlreadyInit) - CoUninitialize(); - return false; - } - - signature << "b:"; - - for (index = 0; pEnumerator; ++index) - { - ULONG uReturn = 0; - IWbemClassObject* pclsObj; - - HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); - if (0 == uReturn) - break; - - VARIANT vtProp; - - // caption - hr = pclsObj->Get(L"Product", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - // motherboard serial number - hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - // sku - hr = pclsObj->Get(L"Manufacturer", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - // properties[(n.clear() << "bm" << IndexToCString(index))] = text; - signature << text << ','; - } - - // sku - hr = pclsObj->Get(L"ConfigOptions", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ';'; - } - - pclsObj->Release(); - } - pEnumerator->Release(); - - hres = pSvc->ExecQuery(bstr_t("WQL"), - bstr_t("SELECT * FROM Win32_BIOS"), - WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, - NULL, - &pEnumerator); - - if (FAILED(hres)) - { - pSvc->Release(); - pLoc->Release(); - if (not comObjectAlreadyInit) - CoUninitialize(); - return false; - } - - signature.append("bs:", 3); - - for (index = 0; pEnumerator; ++index) - { - ULONG uReturn = 0; - IWbemClassObject* pclsObj; - - HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); - if (0 == uReturn) - break; - - VARIANT vtProp; - - // caption - hr = pclsObj->Get(L"Caption", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - // motherboard serial number - hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - // sku - hr = pclsObj->Get(L"Manufacturer", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - // sku - hr = pclsObj->Get(L"SoftwareElementID", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - hr = pclsObj->Get(L"Description", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - hr = pclsObj->Get(L"SMBIOSBIOSVersion", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - signature << text << ','; - } - - hr = pclsObj->Get(L"ReleaseDate", 0, &vtProp, 0, 0); - if (hr == S_OK) - { - WideCharIntoString(text, vtProp.bstrVal); - VariantClear(&vtProp); - if (text.size() > 8) - text.resize(8); - signature << text << ';'; - } - - pclsObj->Release(); - } - pEnumerator->Release(); - - pSvc->Release(); - pLoc->Release(); - if (not comObjectAlreadyInit) - CoUninitialize(); - -#else - - String text; - // /etc/redhat-release - IO::File::LoadFromFile(text, "/etc/centos-release"); - if (text.empty()) - { - IO::File::LoadFromFile(text, "/etc/redhat-release"); - if (text.empty()) - { - IO::File::LoadFromFile(text, "/etc/debian-release"); - if (text.empty()) - { - IO::File::LoadFromFile(text, "/etc/debian-version"); - if (text.empty()) - { - IO::File::LoadFromFile(text, "/etc/mandriva-release"); - if (text.empty()) - { - IO::File::LoadFromFile(text, "/etc/fedora-release"); - if (text.empty()) - IO::File::LoadFromFile(text, "/etc/issue"); - } - } - } - } - } - if (not text.empty()) - { - auto offset = text.find('\n'); - if (offset < text.size()) - text.resize(offset); - text.trim(); - if (not text.empty()) - { - properties[(n = "nm")] = text; - offset = text.find(' '); - if (offset < text.size()) - text.resize(offset); - if (not text.empty()) - signature << "n:" << text << ','; - } - } - - // /proc/cpuinfo - IO::File::LoadFromFile(text, "/proc/cpuinfo"); - if (not text.empty()) - { - // looking for the first cpu frequency in the list - // it should be good enough - auto offset = text.find("cpu MHz"); - if (offset < text.size()) - { - offset = text.find(':', offset); - if (offset < text.size()) - { - offset++; - auto end = text.find('\n', offset); - if (end < text.size()) - { - CString<32, false> cpufreq(text, offset, end - offset); - auto& freq = properties[(n = "f")]; - freq = Math::Round((double)cpufreq.to() / 1000., 2); - freq.trimRight('0'); - freq.trimRight('.'); - } - } - } - - // looking for volative values in /proc/cpuinfo - RemoveProcCPUInfoKey(text, "cpu MHz"); - RemoveProcCPUInfoKey(text, "bogomips"); - signature << text << ','; - } - - // - IO::File::LoadFromFile(text, "/proc/version"); - if (not text.empty()) - { - bool x64 = text.contains("x86_64"); - properties[(n = "osa")] = x64 ? "64" : "32"; - auto offset = text.find('('); - if (offset < text.size()) - text.resize(offset); - properties[(n = "pk")] = text; - } - -#endif - - // add Timestamp to the signature - long timestamp; - // search for the GDPR configuration file - String GDPR_filename; - - String localAppData; - if (not OperatingSystem::FindAntaresLocalAppData(localAppData, false)) - { - localAppData.clear(); - } - - if (not localAppData.empty()) - { - GDPR_filename = localAppData; - } - - GDPR_filename << Yuni::IO::Separator << "antares.hwb"; - if (IO::File::Exists(GDPR_filename)) - { - // load the GDPR status from file - std::ifstream ifs; - - ifs.open(GDPR_filename.to(), std::ifstream::in); - ifs >> timestamp; - ifs.close(); - } - signature << timestamp; - - // signing the hostid - SHA256_CTX context; - unsigned char md[SHA256_DIGEST_LENGTH]; - SHA256_Init(&context); - SHA256_Update(&context, (unsigned char*)signature.c_str(), signature.size()); - SHA256_Final(md, &context); - - auto& keyentry = properties[(n = "k")]; - keyentry.reserve(SHA256_DIGEST_LENGTH * 2 + 1); - - base64_encodestate state; - base64_init_encodestate(&state); - auto length - = base64_encode_block((const char*)md, SHA256_DIGEST_LENGTH, keyentry.data(), &state); - length += base64_encode_blockend(keyentry.data() + length, &state); - assert((uint)length < keyentry.capacity()); - keyentry.resize(length); return true; } diff --git a/src/internet/license.h b/src/internet/license.h index 0fcf90a67b..c9281271d5 100644 --- a/src/internet/license.h +++ b/src/internet/license.h @@ -120,15 +120,6 @@ void ReleaseEncryptionEngine(); bool CheckLicenseValidity(uint version = Antares::Data::versionLatest, Yuni::String* error = nullptr); -/*! -** \brief Check if an activation key is valid -** -** \param activationKey: A license Activation key. The variable is likely to be modified internally -*/ -bool CheckActivationKeyValidity(uint version, - YString& activationKey, - YString* error = nullptr, - bool ignoreLicenseServer = false); /*! ** \brief Check if an activation key is valid on line @@ -252,15 +243,6 @@ typedef struct //! Dictionary for properties typedef std::map Properties; -/*! -** \brief Retrieve all properties + the signature of the current host -** -** \param properties map string -> string -** \param A string for temporary uses -** \return True if the operation succeeded, false otherwise -*/ -bool RetrieveHostProperties(Properties& properties, YString& n); - /*! ** \brief Retrieve the mac address of the host ** diff --git a/src/libs/antares/proxy/proxy.cpp b/src/libs/antares/proxy/proxy.cpp index 62d86a19f3..d4dcb31ec0 100644 --- a/src/libs/antares/proxy/proxy.cpp +++ b/src/libs/antares/proxy/proxy.cpp @@ -38,8 +38,6 @@ #include "../../../internet/base64/cencode.h" #include "../../../internet/decrypt.hxx" #include -#include -#include #include #include diff --git a/src/script_compilation b/src/script_compilation index b6a3e3fe90..9e30c81057 100755 --- a/src/script_compilation +++ b/src/script_compilation @@ -8,18 +8,11 @@ git submodule update --init --recursive cd src/ext -#OPENSSL -cd openssl -./config --prefix=$PWD/release-x86_64 no-asm no-mdc2 no-rc5 no-shared -make depend -make -make install - #CURL cd ../libcurl ./buildconf export LIBS="-ldl -lpthread" -./configure --disable-shared --disable-ldap --with-ssl="$ANTARES_SRC/ext/openssl/release-x86_64" --without-libidn --without-libssh2 --without-zlib +./configure --disable-shared --disable-ldap --without-libidn --without-libssh2 --without-zlib make #export CC=/usr/local/gcc/4.8/bin/gcc-4.8 diff --git a/src/tests/resources/Antares_Simulator_Tests b/src/tests/resources/Antares_Simulator_Tests index 02e9e5ece6..e7de686912 160000 --- a/src/tests/resources/Antares_Simulator_Tests +++ b/src/tests/resources/Antares_Simulator_Tests @@ -1 +1 @@ -Subproject commit 02e9e5ece63a7a38090b088e581560672229a6cc +Subproject commit e7de68691232b2a275652877c8a39777c2798bf9 diff --git a/src/ui/simulator/application/main/create.cpp b/src/ui/simulator/application/main/create.cpp index 1b9ff471cf..bbdc49039a 100644 --- a/src/ui/simulator/application/main/create.cpp +++ b/src/ui/simulator/application/main/create.cpp @@ -491,19 +491,11 @@ void ApplWnd::internalInitialize() void ApplWnd::installUserLicense(bool online) { String activationKey = online ? ANTARES_ONLINE_ACTIVATION_KEY : ANTARES_OFFLINE_ACTIVATION_KEY; - - // creating a copy of the activation key, since CheckActivationKeyValidity // may modify our variable String activationKeyToInstall = activationKey; activationKeyToInstall.trim(); activationKeyToInstall.replace("\r", ""); - if (not Antares::License::CheckActivationKeyValidity(Data::versionLatest, activationKey)) - { - logs.error() << "The activation key is invalid"; - return; - } - // Installation for all users ? bool allusers = false; diff --git a/src/ui/simulator/application/main/help.cpp b/src/ui/simulator/application/main/help.cpp index 0793990233..86e219f88c 100644 --- a/src/ui/simulator/application/main/help.cpp +++ b/src/ui/simulator/application/main/help.cpp @@ -120,10 +120,7 @@ void ApplWnd::evtOnShowID(wxCommandEvent&) Antares::License::Properties licenseproperties; Yuni::String tmp; - Antares::License::RetrieveHostProperties(hostproperties, tmp); - auto hostid = hostproperties[(tmp = "k")]; - - Window::Message message(this, wxT(""), hostid.c_str(), "", "images/128x128/antares.png"); + Window::Message message(this, wxT(""), "", "", "images/128x128/antares.png"); message.add(Window::Message::btnOk, true); message.showModal(); } diff --git a/src/ui/simulator/windows/about/aboutbox.cpp b/src/ui/simulator/windows/about/aboutbox.cpp index f95086b888..a4ecfbc827 100644 --- a/src/ui/simulator/windows/about/aboutbox.cpp +++ b/src/ui/simulator/windows/about/aboutbox.cpp @@ -77,12 +77,6 @@ license: wxWindows Library License,V3.1 https://spdx.org/licenses/wxWindows.html libCurl 7.51.0 Copyright (c) 1996-2017 Daniel Stenberg et al \n\ license: curl license https://spdx.org/licenses/curl.html\n\ \n\ -OpenSSL 1.1.0 Copyright (c) 1998-2016 The OpenSSL Project\n\ -\"This product includes software developed by the OpenSSL Project\n\ -for use in the OpenSSL Toolkit(http://www.openssl.org/)\"\n\ -\"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\" \n\ -license: OpenSSL license and SSLeay license https://spdx.org/licenses/OpenSSL.html\n\ - \n\ libYuni 1.1.0 https://github.com/libyuni \n\ license: Mozilla Public License 2.0 https://spdx.org/licenses/MPL-2.0.html\n\ \n\