diff --git a/Makefile b/Makefile index 0dfe1f8..09b396d 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ CXX = g++ # define any compile-time flags # CXXFLAGS := -std=c++17 -Wall -Wextra -g -lssl -lcrypto -w -CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto +CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto -std=c++11 # define library paths in addition to /usr/lib # if I wanted to include libraries not in /usr/lib I'd specify @@ -16,10 +16,10 @@ CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto LFLAGS = # define output directory -OUTPUT := output +OUTPUT:= output # define source directory -SRC := src src/common src/reader src/generator +SRC := src src/common src/reader src/generator # define include directory INCLUDE := include include/common include/reader include/generator diff --git a/docker/Makefile b/docker/Makefile index 98318a5..56fb700 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -8,7 +8,7 @@ CXX = g++ # define any compile-time flags # CXXFLAGS := -std=c++17 -Wall -Wextra -g -lssl -lcrypto -CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto -std=c++11 +CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto -w -std=c++11 # define library paths in addition to /usr/lib # if I wanted to include libraries not in /usr/lib I'd specify diff --git a/output/createnew.bat b/output/createnew.bat index 2025a9f..2843714 100644 --- a/output/createnew.bat +++ b/output/createnew.bat @@ -1 +1 @@ -licenceGenerator.exe -uid=9a2314bcee131834715adcabc506724c -cid=9f54495344434954615ad803c50171bf -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml +licenceGenerator.exe -uid=a3395d1b898b4fdbbd563f9c75b3e885.a433 -cid=9f54495344434954615ad803c50171bf -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml diff --git a/output/ezlic_drt0_yfavdwbbxbg.lic b/output/ezlic_drt0_xxbxdjhxyhc.lic similarity index 62% rename from output/ezlic_drt0_yfavdwbbxbg.lic rename to output/ezlic_drt0_xxbxdjhxyhc.lic index f8aa693..fb8b19f 100644 Binary files a/output/ezlic_drt0_yfavdwbbxbg.lic and b/output/ezlic_drt0_xxbxdjhxyhc.lic differ diff --git a/output/licData.xml b/output/licData.xml index 9bcb75d..ff346fa 100644 --- a/output/licData.xml +++ b/output/licData.xml @@ -3,7 +3,7 @@ DRT wago Licence pro EOV_OSV -Zdenda Test CRC4 +Licence ELC3 pt_Ez_interHW @@ -33,7 +33,7 @@ pt_Ez_iec61850c 7 -30777 +77 \ No newline at end of file diff --git a/output/machine-id b/output/machine-id index da26398..382e210 100644 --- a/output/machine-id +++ b/output/machine-id @@ -1 +1 @@ -9a2314bcee131834715adcabc506724c \ No newline at end of file +a3395d1b898b4fdbbd563f9c75b3e885 diff --git a/src/CreateLicence.cpp b/src/CreateLicence.cpp index 5d98fed..424d0fd 100644 --- a/src/CreateLicence.cpp +++ b/src/CreateLicence.cpp @@ -1,6 +1,6 @@ #ifndef EZ_APPLICATION_LICENCE_DISABLE -// #define LINUX 1 -#define WINDOWS 1 +#define LINUX 1 +//#define WINDOWS 1 #define READ 1 #include @@ -11,7 +11,7 @@ /// @param argc /// @param argv parametry pro generování licence /// @return -int main(int argc, char *argv[]) +int main8(int argc, char *argv[]) { unordered_map arguments = getArguments(argc, argv); try diff --git a/src/ReadLicence.cpp b/src/ReadLicence.cpp index b073686..5689d87 100644 --- a/src/ReadLicence.cpp +++ b/src/ReadLicence.cpp @@ -1,7 +1,7 @@ #ifndef EZ_APPLICATION_LICENCE_DISABLE -//#define LINUX 1 -#define WINDOWS 1 +#define LINUX 1 +//#define WINDOWS 1 #include "licenceReader.h" @@ -9,7 +9,7 @@ /// @param argc /// @param argv parametry pro generování licence /// @return -int main8() +int main() { // buffer,850client,104client, 104server, web // kouknout na unikatní klíc pro linux (native uid, i openssl neco má) @@ -32,12 +32,10 @@ int main8() LicenceReader licenceReaderELC3{}; if (licenceReaderELC3.initread(3, initStructure)) // iniciacni nacteni { - LicenceELC3Item info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) + LicenceELC3Item info; // podle ELC a kompatibility určit strukuru (LicenceInfo1, LicenceInfo2, LicenceInfo3) // if () int protocolId = 4; - cout << "název licenčního souboru: " << licenceReaderELC3.licInfo.licenceFileName << "\n"; - cout << "cesta k licenčnímu souboru: " << licenceReaderELC3.licInfo.licenceFilePath << "\n"; - + if (licenceReaderELC3.getLicenceItemInfo(protocolId, &info)) { cout << "Pocet licencních bodu pro " << info.protocolId << ": " << info.dataPointsCount << std::endl; diff --git a/src/common/licenceELC3.cpp b/src/common/licenceELC3.cpp index 1128f8b..3870a8b 100644 --- a/src/common/licenceELC3.cpp +++ b/src/common/licenceELC3.cpp @@ -110,7 +110,7 @@ vector LicenceELC3::decryptPrivateContent(const std::vectoruid.length(); i++) uidb[i] = uid[i]; CryptInitVector vec1 = {uidb[10], diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 92b657d..cdfccb2 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -1,6 +1,7 @@ #ifndef EZ_APPLICATION_LICENCE_DISABLE -#define WINDOWS 1 +//#define WINDOWS 1 +#define LINUX 1 #include #include /* core library */ diff --git a/src/generator/LicenceGenerator.cpp b/src/generator/LicenceGenerator.cpp index 41448b1..450737d 100644 --- a/src/generator/LicenceGenerator.cpp +++ b/src/generator/LicenceGenerator.cpp @@ -20,7 +20,7 @@ LicenceGenerator::LicenceGenerator(string uid, string cid, string csd, string da if (uid.empty() == false) { - if (uid.length() != 32) throw LicenceException((int)GeneralError::IvanlidParam, "UID incorrect size"); + if (uid.length() < 32) throw LicenceException((int)GeneralError::IvanlidParam, "UID incorrect size"); this->licData.uid = uid; } else diff --git a/src/reader/LicenceReader.cpp b/src/reader/LicenceReader.cpp index 8b1465c..4917cc9 100644 --- a/src/reader/LicenceReader.cpp +++ b/src/reader/LicenceReader.cpp @@ -112,6 +112,7 @@ bool LicenceReader::initread(int elcType, InitStructure &initStructure) { Reader::Licence3 licenceELC3 = Reader::Licence3(this->licIdentification); this->licence3 = &licenceELC3; + this->licence3->uid_path = initStructure.uid_filePath; licenceELC3.licenceFilePath = initStructure.licenceFilePath; this->licence3->readLicence(&this->licencesInfo); this->licInfo.licenceFileName = this->licence3->licFileName; diff --git a/src/reader/licReaderELC3.cpp b/src/reader/licReaderELC3.cpp index dd531d6..001dba5 100644 --- a/src/reader/licReaderELC3.cpp +++ b/src/reader/licReaderELC3.cpp @@ -20,8 +20,8 @@ namespace Reader bool Licence3::readLicence(LicenceInfoGeneral *licences) { - //uid load if (getUID() == false) throw LicenceException((int)GeneralError::UIDReadError, "Nepodařilo se načíst UID: " + uid_path); + if (this->uid.length() < UID_LENGTH) throw LicenceException((int)GeneralError::UIDReadError, "UID nemá požadovanou velikost: " + uid_path); string licFileName = getLicenceName(); string licFilePath = this->licenceFilePath + licFileName; @@ -35,8 +35,6 @@ namespace Reader throw LicenceException((int)GeneralError::FileOpenError, "Chyba otevření souboru licence: " + licFilePath); } - - #ifdef SHOW cout << "Celý vstup zašifrovaný: \n"; for (const auto &x : content) @@ -192,6 +190,7 @@ namespace Reader this->uid = string(content.begin(), content.end()); + return true; }