čištění a další upravy
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
chmod 777 output/licenceGenerator
|
chmod 777 output/licenceGenerator
|
||||||
|
|
||||||
#./output/licenceGenerator -cid=9f5449534443495461457815de0164a9 -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
#./output/licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
||||||
|
|
||||||
cd output
|
cd output
|
||||||
./licenceGenerator -cid=9f5449534443495461457815de0164a9 -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
./licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
||||||
@@ -106,6 +106,10 @@ struct LicenceIdentification
|
|||||||
uint8_t licCompatibility = 1; // identikator hlavního ELC
|
uint8_t licCompatibility = 1; // identikator hlavního ELC
|
||||||
|
|
||||||
uint16_t licItemsCount = 0;
|
uint16_t licItemsCount = 0;
|
||||||
|
|
||||||
|
string cid_cds_path = "";
|
||||||
|
string licenceFilePath = "";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LicData
|
struct LicData
|
||||||
@@ -165,17 +169,14 @@ struct LicenceInfo11
|
|||||||
class LicenceException : public std::exception
|
class LicenceException : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Constructor with int and string parameters
|
|
||||||
LicenceException(int errorCode, const std::string &errorMessage)
|
LicenceException(int errorCode, const std::string &errorMessage)
|
||||||
: errorCode_(errorCode), errorMessage_(errorMessage) {}
|
: errorCode_(errorCode), errorMessage_(errorMessage) {}
|
||||||
|
|
||||||
// Override the what() function to provide a description of the exception
|
|
||||||
const char *what() const noexcept override
|
const char *what() const noexcept override
|
||||||
{
|
{
|
||||||
return errorMessage_.c_str();
|
return errorMessage_.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getter functions for the exception members
|
|
||||||
int getErrorCode() const
|
int getErrorCode() const
|
||||||
{
|
{
|
||||||
return errorCode_;
|
return errorCode_;
|
||||||
|
|||||||
@@ -230,8 +230,7 @@ class LicenceELC11
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SDCard sdCard;
|
SDCard sdCard;
|
||||||
const string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/
|
|
||||||
const string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\";
|
|
||||||
string cidString = "";
|
string cidString = "";
|
||||||
char cid[32] = {};
|
char cid[32] = {};
|
||||||
string csdString = "";
|
string csdString = "";
|
||||||
@@ -266,6 +265,8 @@ public:
|
|||||||
|
|
||||||
string operationErrors = "";
|
string operationErrors = "";
|
||||||
ErrorMessage errorMessage;
|
ErrorMessage errorMessage;
|
||||||
|
string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/
|
||||||
|
string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\";
|
||||||
|
|
||||||
LicenceELC11();
|
LicenceELC11();
|
||||||
~LicenceELC11();
|
~LicenceELC11();
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ using namespace std;
|
|||||||
|
|
||||||
class LicenceELC21
|
class LicenceELC21
|
||||||
{
|
{
|
||||||
const string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/
|
|
||||||
const string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\";
|
|
||||||
|
|
||||||
enum class Error21
|
enum class Error21
|
||||||
{
|
{
|
||||||
@@ -88,6 +87,7 @@ class LicenceELC21
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int licItemCount = 0;
|
int licItemCount = 0;
|
||||||
LicenceBody licBody;
|
LicenceBody licBody;
|
||||||
LicenceIdentification lIdentification;
|
LicenceIdentification lIdentification;
|
||||||
@@ -107,6 +107,8 @@ class LicenceELC21
|
|||||||
|
|
||||||
ErrorMessage errorMessage;
|
ErrorMessage errorMessage;
|
||||||
LicenceInfo21 licenceInfo;
|
LicenceInfo21 licenceInfo;
|
||||||
|
string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/
|
||||||
|
string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\";
|
||||||
|
|
||||||
LicenceELC21();
|
LicenceELC21();
|
||||||
~LicenceELC21();
|
~LicenceELC21();
|
||||||
|
|||||||
@@ -26,13 +26,12 @@ using namespace std;
|
|||||||
int licenceIndex = 0;
|
int licenceIndex = 0;
|
||||||
int compatibility = 0;
|
int compatibility = 0;
|
||||||
string licenceFilePath = "";
|
string licenceFilePath = "";
|
||||||
|
string cid_csd_filePath = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
class LicenceGenerator
|
class LicenceGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int elcSwitchType;
|
int elcSwitchType;
|
||||||
string operationErrors = "";
|
string operationErrors = "";
|
||||||
|
|||||||
32
licData.xml
Normal file
32
licData.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<licence elc="1" xmlVersion="1" revision="1" compatibility="1">
|
||||||
|
<licenceType licenceVersion="1" licenceIndex="0">EOV_OSV</licenceType>
|
||||||
|
<plcType>WAGO</plcType>
|
||||||
|
<licenceName>Licence pro EOV_OSV</licenceName>
|
||||||
|
<station>start.cz</station>
|
||||||
|
<distributor>teco</distributor>
|
||||||
|
<project>Projekt XXX stanice YYY</project>
|
||||||
|
<items>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 1</name>
|
||||||
|
<protoId>666</protoId>
|
||||||
|
<dataPointsCount>100</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 2</name>
|
||||||
|
<protoId>777</protoId>
|
||||||
|
<dataPointsCount>200</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 3</name>
|
||||||
|
<protoId>888</protoId>
|
||||||
|
<dataPointsCount>300</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 3</name>
|
||||||
|
<protoId>999</protoId>
|
||||||
|
<dataPointsCount>1600</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
</items>
|
||||||
|
|
||||||
|
</licence>
|
||||||
@@ -4,5 +4,5 @@
|
|||||||
<licenceType version="1">EOV_OSV</licenceType>
|
<licenceType version="1">EOV_OSV</licenceType>
|
||||||
<licenceName>Licence pro EOV_OSV</licenceName>
|
<licenceName>Licence pro EOV_OSV</licenceName>
|
||||||
<station>start.cz</station>
|
<station>start.cz</station>
|
||||||
<distributor>wago</distributor>
|
<distributor>teco</distributor>
|
||||||
</data>
|
</data>
|
||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
9f5449534443495461457815de0164a9
|
0353445355313647801b1a9f6600c747
|
||||||
6 . x4 <20><><EFBFBD> .. nt$6 &<26> manfid 6 <20><><EFBFBD>
|
6 . x4 <20><><EFBFBD> .. nt$6 &<26> manfid 6 <20><><EFBFBD>
|
||||||
cid "6 <10> fwrev 6 Jm<4A> csd ,6 gEd$
|
cid "6 <10> fwrev 6 Jm<4A> csd ,6 gEd$
|
||||||
subsystem 46 <20><><EFBFBD>%
|
subsystem 46 <20><><EFBFBD>%
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
400e00325b5900003a0d7f800a40008d
|
400e00325b59000076b27f800a404013
|
||||||
|
|
||||||
BIN
output/ezlic_eovosv0_cbheemcjsii.lic
Normal file
BIN
output/ezlic_eovosv0_cbheemcjsii.lic
Normal file
Binary file not shown.
BIN
output/ezlic_eovosv0_jbyabqatxji.lic
Normal file
BIN
output/ezlic_eovosv0_jbyabqatxji.lic
Normal file
Binary file not shown.
BIN
output/ezlic_eovosv0_jjbaxgatxab.lic
Normal file
BIN
output/ezlic_eovosv0_jjbaxgatxab.lic
Normal file
Binary file not shown.
Binary file not shown.
BIN
output/ezlic_eovosv0_vdyeygcjeca.lic
Normal file
BIN
output/ezlic_eovosv0_vdyeygcjeca.lic
Normal file
Binary file not shown.
Binary file not shown.
@@ -3,8 +3,8 @@
|
|||||||
<licenceType licenceVersion="1" licenceIndex="0">EOV_OSV</licenceType>
|
<licenceType licenceVersion="1" licenceIndex="0">EOV_OSV</licenceType>
|
||||||
<plcType>WAGO</plcType>
|
<plcType>WAGO</plcType>
|
||||||
<licenceName>Licence pro EOV_OSV</licenceName>
|
<licenceName>Licence pro EOV_OSV</licenceName>
|
||||||
<station>start.cz</station>
|
<station>eov.ceskatrebova.ddts.cz</station>
|
||||||
<distributor>wago</distributor>
|
<distributor>eov2</distributor>
|
||||||
<project>Projekt XXX stanice YYY</project>
|
<project>Projekt XXX stanice YYY</project>
|
||||||
<items>
|
<items>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Binary file not shown.
@@ -1,29 +1,69 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "plcLicence.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <filesystem>
|
#include "licenceGenerator.h"
|
||||||
|
#include "licenceCommon.h"
|
||||||
|
|
||||||
#define FILEBUFFER 300
|
|
||||||
#define TWO_HOURSE_SECONDS 7200
|
|
||||||
|
|
||||||
/// @brief hlavní funkce
|
/// @brief hlavní funkce
|
||||||
/// @param argc
|
/// @param argc
|
||||||
/// @param argv parametry pro generování licence
|
/// @param argv parametry pro generování licence
|
||||||
/// 1-cid, 2-csd, 3-stanice 4-rozvadec 5-typ licence
|
|
||||||
/// @return
|
/// @return
|
||||||
int main5(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
unordered_map<string, string> arguments = getArguments(argc, argv);
|
unordered_map<string, string> arguments = getArguments(argc, argv);
|
||||||
|
LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]);
|
||||||
|
generatorOld.createLicenceFile();
|
||||||
|
return SUCCES;
|
||||||
|
|
||||||
|
LicenceGenerator licenceGenerator = LicenceGenerator();
|
||||||
|
|
||||||
PlcLicence plcWriteLicence = PlcLicence(arguments["-cid"], arguments["-csd"], arguments["-outputType"], arguments["-configFileName"]);
|
InitStructure initStructure;
|
||||||
if (plcWriteLicence.CreateLicence() == false)
|
initStructure.elcType = 2;
|
||||||
|
initStructure.licenceType = (int)LicenceType::EOS_EOV;
|
||||||
|
initStructure.licenceVersion = 1;
|
||||||
|
initStructure.licenceIndex = 0;
|
||||||
|
initStructure.compatibility = 1;
|
||||||
|
initStructure.licenceFilePath = "";
|
||||||
|
initStructure.cid_csd_filePath = "";
|
||||||
|
|
||||||
|
// //verze #1: načtení kompletní licence a zobrazení
|
||||||
|
// if (licenceGenerator.init(initStructure))
|
||||||
|
// {
|
||||||
|
// LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||||
|
// int protocolId = 345;
|
||||||
|
// if (licenceGenerator.getLicenceInfo(protocolId, &info))
|
||||||
|
// {
|
||||||
|
// std::cout << "Počet licenčních bodů pro : " << protocolId << ": " << info.reqDataPointsCount << std::endl;
|
||||||
|
// if (info.licences.count(protocolId) > 0) cout << "počet z vectoru pro : " << protocolId << info.licences.at(888) << endl;
|
||||||
|
// cout << "všechny licenční body: " << endl;
|
||||||
|
// for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//verze #2 : iterace pro kazdý bod zvlášť
|
||||||
|
if (licenceGenerator.initread(initStructure))
|
||||||
{
|
{
|
||||||
cerr << "Licence creation failed";
|
int protocolId = 888;
|
||||||
|
|
||||||
|
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||||
|
|
||||||
|
if (licenceGenerator.getLicenceItemInfo(protocolId, &info))
|
||||||
|
{
|
||||||
|
std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
system("pause");
|
||||||
|
return SUCCES;
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ bool LicenceELC11::createEosEovLicence()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dataToFile.header.licCount = 1;
|
dataToFile.header.licCount = 1;
|
||||||
dataToFile.items[1].licCount = 999;//65535;
|
dataToFile.items[1].licCount = 65535; // 65535;
|
||||||
dataToFile.items[1].protoId = cEzLic_p78ou3_CheckLicNumberId_EOV1;
|
dataToFile.items[1].protoId = cEzLic_p78ou3_CheckLicNumberId_EOV1;
|
||||||
dataToFile.items[1].data1 = cEzLic_p78ou3_CheckLicNumber_EOV1;
|
dataToFile.items[1].data1 = cEzLic_p78ou3_CheckLicNumber_EOV1;
|
||||||
}
|
}
|
||||||
@@ -680,6 +680,9 @@ bool LicenceELC11::readLicence(LicenceInfoGeneral *licences)
|
|||||||
fileNameCh[i] = licFilePath[i];
|
fileNameCh[i] = licFilePath[i];
|
||||||
|
|
||||||
licenceFile = fopen(fileNameCh, "rb"); // read mode
|
licenceFile = fopen(fileNameCh, "rb"); // read mode
|
||||||
|
|
||||||
|
if (licenceFile == nullptr) throw LicenceException((int)Error11::LicenceReadError, "Licence read error: " + licFilePath);
|
||||||
|
|
||||||
fseek(licenceFile, 0, SEEK_END); // seek to end of file
|
fseek(licenceFile, 0, SEEK_END); // seek to end of file
|
||||||
const int size = ftell(licenceFile); // get current file pointer
|
const int size = ftell(licenceFile); // get current file pointer
|
||||||
fseek(licenceFile, 0, SEEK_SET);
|
fseek(licenceFile, 0, SEEK_SET);
|
||||||
@@ -728,10 +731,10 @@ bool LicenceELC11::readLicence(LicenceInfoGeneral *licences)
|
|||||||
// CryptData cryptData = initCrypto(sdData, licIdent.licIDType);
|
// CryptData cryptData = initCrypto(sdData, licIdent.licIDType);
|
||||||
unsigned char decrypted[2000] = {};
|
unsigned char decrypted[2000] = {};
|
||||||
int decrypted_len = decrypt(encryptedData, sizeof(encryptedData), cryptData.aesKey, cryptData.aesInitVector, decrypted);
|
int decrypted_len = decrypt(encryptedData, sizeof(encryptedData), cryptData.aesKey, cryptData.aesInitVector, decrypted);
|
||||||
#ifdef DEB
|
#ifdef DEB
|
||||||
cout << "sizeof(licEncryptedData: " << sizeof(licEncryptedData) << endl;
|
cout << "sizeof(licEncryptedData: " << sizeof(licEncryptedData) << endl;
|
||||||
cout << "decrypted_len: " << decrypted_len << endl;
|
cout << "decrypted_len: " << decrypted_len << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sizeof(licEncryptedData) != decrypted_len)
|
if (sizeof(licEncryptedData) != decrypted_len)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ bool LicenceGenerator::initread(InitStructure &initStructure)
|
|||||||
case 11:
|
case 11:
|
||||||
{ // old eoseov
|
{ // old eoseov
|
||||||
LicenceELC11 licence = LicenceELC11(this->licIdentification);
|
LicenceELC11 licence = LicenceELC11(this->licIdentification);
|
||||||
|
licence.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||||
|
licence.licenceFilePath = initStructure.licenceFilePath;;
|
||||||
licence.readLicence(&this->licenceInfo);
|
licence.readLicence(&this->licenceInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -99,6 +101,8 @@ bool LicenceGenerator::initread(InitStructure &initStructure)
|
|||||||
{
|
{
|
||||||
LicenceELC21 licence = LicenceELC21(this->licIdentification);
|
LicenceELC21 licence = LicenceELC21(this->licIdentification);
|
||||||
this->licence21 = &licence;
|
this->licence21 = &licence;
|
||||||
|
licence.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||||
|
licence.licenceFilePath = initStructure.licenceFilePath;;
|
||||||
this->licence21->readLicence(&this->licenceInfo);
|
this->licence21->readLicence(&this->licenceInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
|
#define NEW =1
|
||||||
|
|
||||||
|
#ifdef NEW
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "licenceGenerator.h"
|
#include "licenceGenerator.h"
|
||||||
#include "licenceCommon.h"
|
#include "licenceCommon.h"
|
||||||
|
|
||||||
|
#define FILEBUFFER 300
|
||||||
|
#define TWO_HOURSE_SECONDS 7200
|
||||||
|
|
||||||
|
|
||||||
/// @brief hlavní funkce
|
/// @brief hlavní funkce
|
||||||
/// @param argc
|
/// @param argc
|
||||||
/// @param argv parametry pro generování licence
|
/// @param argv parametry pro generování licence
|
||||||
/// @return
|
/// @return
|
||||||
int main(int argc, char *argv[])
|
int main5(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// cout << "test" << endl;
|
cout << "test" << endl;
|
||||||
// unordered_map<string, string> arguments = getArguments(argc, argv);
|
unordered_map<string, string> arguments = getArguments(argc, argv);
|
||||||
// LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]);
|
LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]);
|
||||||
// generatorOld.createLicenceFile();
|
generatorOld.createLicenceFile();
|
||||||
// return 0;
|
return 0;
|
||||||
//cout << "Reading Test" << endl;
|
|
||||||
LicenceGenerator licenceGenerator = LicenceGenerator();
|
LicenceGenerator licenceGenerator = LicenceGenerator();
|
||||||
|
|
||||||
InitStructure initStructure;
|
InitStructure initStructure;
|
||||||
@@ -23,21 +30,20 @@ int main(int argc, char *argv[])
|
|||||||
initStructure.licenceVersion = 1;
|
initStructure.licenceVersion = 1;
|
||||||
initStructure.licenceIndex = 0;
|
initStructure.licenceIndex = 0;
|
||||||
initStructure.compatibility = 1;
|
initStructure.compatibility = 1;
|
||||||
initStructure.licenceFilePath = "";
|
initStructure.licenceFilePath = "test";
|
||||||
|
initStructure.cid_csd_filePath = "test";
|
||||||
|
|
||||||
// if (licenceGenerator.init(initStructure))
|
// if (licenceGenerator.init(initStructure))
|
||||||
// {
|
// {
|
||||||
// LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
// LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||||
|
|
||||||
// if (licenceGenerator.getLicenceInfo(888, &info))
|
// if (licenceGenerator.getLicenceInfo(888, &info))
|
||||||
// {
|
// {
|
||||||
// std::cout << "Počet licenčních bodů pro 888: " << info.reqDataPointsCount << std::endl;
|
// std::cout << "Počet licenčních bodů pro 888: " << info.reqDataPointsCount << std::endl;
|
||||||
// if (info.licences.count(888) > 0) cout << "počet z vectoru pro 888: " << info.licences.at(888) << endl;
|
// if (info.licences.count(888) > 0)
|
||||||
|
// cout << "počet z vectoru pro 888: " << info.licences.at(888) << endl;
|
||||||
// cout << "všechny licenční body: " << endl;
|
// cout << "všechny licenční body: " << endl;
|
||||||
|
// //for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; }
|
||||||
// for (const auto& pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
// cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
@@ -46,24 +52,56 @@ int main(int argc, char *argv[])
|
|||||||
// {
|
// {
|
||||||
// cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
// cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (licenceGenerator.initread(initStructure))
|
if (licenceGenerator.initread(initStructure))
|
||||||
{
|
{
|
||||||
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||||
|
|
||||||
if (licenceGenerator.getLicenceItemInfo(777, &info))
|
if (licenceGenerator.getLicenceItemInfo(777, &info))
|
||||||
{
|
{
|
||||||
std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
|
std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
|
||||||
//for (const auto& pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl;
|
// for (const auto& pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl;
|
||||||
}
|
}
|
||||||
else cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
else
|
||||||
|
cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
cerr << "Došlo k chybě: " << licenceGenerator.error.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
system("pause");
|
system("pause");
|
||||||
|
return 0;
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEW
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "plcLicence.h"
|
||||||
|
// #include "licenceGenerator.h"
|
||||||
|
// #include "licenceCommon.h"
|
||||||
|
|
||||||
|
#define FILEBUFFER 300
|
||||||
|
#define TWO_HOURSE_SECONDS 7200
|
||||||
|
|
||||||
|
|
||||||
|
/// @brief hlavní funkce
|
||||||
|
/// @param argc
|
||||||
|
/// @param argv parametry pro generování licence
|
||||||
|
/// @return
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
unordered_map<string, string> arguments = getArguments(argc, argv);
|
||||||
|
PlcLicence plcWriteLicence = PlcLicence(arguments["-cid"], arguments["-csd"], arguments["-outputType"], arguments["-configFileName"]);
|
||||||
|
if (plcWriteLicence.CreateLicence() == false)
|
||||||
|
{
|
||||||
|
cerr << "Licence creation failed";
|
||||||
|
}
|
||||||
|
// cout << "Reading Test" << endl;
|
||||||
|
system("pause");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -330,6 +330,8 @@ bool PlcLicence::CreateEosEovLicence()
|
|||||||
dataToFile.id.version = 10;
|
dataToFile.id.version = 10;
|
||||||
dataToFile.id.cardSize = this->sdData.cardSize;
|
dataToFile.id.cardSize = this->sdData.cardSize;
|
||||||
|
|
||||||
|
cout << "cardSize: " << this->sdData.cardSize << endl;
|
||||||
|
|
||||||
switch (licIdent.licIDType)
|
switch (licIdent.licIDType)
|
||||||
{
|
{
|
||||||
case cEzLic_p78ou3_IDType_DDTS:
|
case cEzLic_p78ou3_IDType_DDTS:
|
||||||
@@ -348,6 +350,9 @@ bool PlcLicence::CreateEosEovLicence()
|
|||||||
dataToFile.header.licVersion = 10;
|
dataToFile.header.licVersion = 10;
|
||||||
dataToFile.header.licType = licIdent.licIDType;
|
dataToFile.header.licType = licIdent.licIDType;
|
||||||
dataToFile.header.licDate = getLicDate(); // 1692230400; //getLicDate(); //1692144000;// getLicDate();
|
dataToFile.header.licDate = getLicDate(); // 1692230400; //getLicDate(); //1692144000;// getLicDate();
|
||||||
|
|
||||||
|
cout << "date:" << dataToFile.header.licDate << endl;
|
||||||
|
|
||||||
mainLicDescription += dataToFile.header.licDescription1;
|
mainLicDescription += dataToFile.header.licDescription1;
|
||||||
mainLicDescription += " [";
|
mainLicDescription += " [";
|
||||||
mainLicDescription += dataToFile.header.licDescription2;
|
mainLicDescription += dataToFile.header.licDescription2;
|
||||||
@@ -380,6 +385,10 @@ bool PlcLicence::CreateEosEovLicence()
|
|||||||
|
|
||||||
memcpy(byteArray, &dataToFile, sizeof(dataToFile));
|
memcpy(byteArray, &dataToFile, sizeof(dataToFile));
|
||||||
|
|
||||||
|
cout << endl;
|
||||||
|
for (auto x : byteArray) cout << (int)x << "-";
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
int finalEncryptedLength = encrypt(byteArray, sizeof(dataToFile), this->cryptData.aesKey, this->cryptData.aesInitVector, encrypted);
|
int finalEncryptedLength = encrypt(byteArray, sizeof(dataToFile), this->cryptData.aesKey, this->cryptData.aesInitVector, encrypted);
|
||||||
|
|
||||||
if (licIdent.licPrefixType == cEzLic_p78ou3_LicPrefixType_ELC1) // typ1 = pouze zasifrovani dat
|
if (licIdent.licPrefixType == cEzLic_p78ou3_LicPrefixType_ELC1) // typ1 = pouze zasifrovani dat
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ bool LicenceELC21::createLicence()
|
|||||||
privateContent.push_back(crcComplete & 0xFF);
|
privateContent.push_back(crcComplete & 0xFF);
|
||||||
privateContent.push_back((crcComplete >> 8) & 0xFF);
|
privateContent.push_back((crcComplete >> 8) & 0xFF);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
privateContentEncrypted = cryptPrivateContent(privateContent);
|
privateContentEncrypted = cryptPrivateContent(privateContent);
|
||||||
|
|
||||||
#ifdef DEB
|
#ifdef DEB
|
||||||
@@ -162,22 +164,19 @@ bool LicenceELC21::createLicence()
|
|||||||
|
|
||||||
bool LicenceELC21::readLicence(LicenceInfoGeneral * licences)
|
bool LicenceELC21::readLicence(LicenceInfoGeneral * licences)
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
// sdCard = SDCard("9f544930303030300000000b47015423", "400e00325b5900003a0d7f800a40008d");
|
// sdCard = SDCard("9f544930303030300000000b47015423", "400e00325b5900003a0d7f800a40008d");
|
||||||
sdCard = SDCard(this->cid_cdsPath);
|
sdCard = SDCard(this->cid_cdsPath);
|
||||||
if (sdCard.isLoaded == false)
|
if (sdCard.isLoaded == false) throw LicenceException((int)Error21::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath);
|
||||||
throw LicenceException((int)Error21::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath);
|
|
||||||
|
|
||||||
string licFileName = getLicenceName();
|
string licFileName = getLicenceName();
|
||||||
string licFilePath = this->licenceFilePath+licFileName;
|
string licFilePath = this->licenceFilePath+licFileName;
|
||||||
|
|
||||||
|
|
||||||
// Create an unsigned char vector to store the file data
|
// Create an unsigned char vector to store the file data
|
||||||
vector<char> content;
|
vector<char> content;
|
||||||
if (readFile(licFilePath, content) == false)
|
if (readFile(licFilePath, content) == false)
|
||||||
{
|
{
|
||||||
throw LicenceException((int)GeneralError::FileOpenError, "Chyba otevření souboru licence.");
|
throw LicenceException((int)GeneralError::FileOpenError, "Chyba otevření souboru licence: " + licFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->licBody.licId.licIdent[0] = content[0];
|
this->licBody.licId.licIdent[0] = content[0];
|
||||||
@@ -266,15 +265,6 @@ bool LicenceELC21::readLicence(LicenceInfoGeneral * licences)
|
|||||||
this->licenceInfo.licences.insert(pair<int, int>(item.protoId, item.licCount));
|
this->licenceInfo.licences.insert(pair<int, int>(item.protoId, item.licCount));
|
||||||
licences->licences.insert(pair<int, int>(item.protoId, item.licCount));
|
licences->licences.insert(pair<int, int>(item.protoId, item.licCount));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
catch (const LicenceException &ex)
|
|
||||||
{
|
|
||||||
errorMessage.code = ex.getErrorCode();
|
|
||||||
errorMessage.message = ex.getErrorMessage();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
102
src/notes.txt
102
src/notes.txt
@@ -1,3 +1,105 @@
|
|||||||
|
10
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-79
|
||||||
|
-58
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-2
|
||||||
|
-0
|
||||||
|
-10
|
||||||
|
-0
|
||||||
|
-128
|
||||||
|
-92
|
||||||
|
-114
|
||||||
|
-101
|
||||||
|
-115
|
||||||
|
-116
|
||||||
|
-97
|
||||||
|
-114
|
||||||
|
-116
|
||||||
|
-46
|
||||||
|
-99
|
||||||
|
-122
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-116
|
||||||
|
-101
|
||||||
|
-99
|
||||||
|
-111
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-1
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-0
|
||||||
|
-1
|
||||||
|
-0
|
||||||
|
-255
|
||||||
|
-255
|
||||||
|
-21
|
||||||
|
-17
|
||||||
|
-97
|
||||||
|
-225
|
||||||
|
-0
|
||||||
|
-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0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0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-37-59-
|
||||||
|
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<data version="1">
|
<data version="1">
|
||||||
<plcType>WAGO</type>
|
<plcType>WAGO</type>
|
||||||
|
|||||||
@@ -960,8 +960,8 @@ string readFileToString(const std::string &filename, std::size_t sizeS)
|
|||||||
bool readFile(string fileName, vector<char> &output)
|
bool readFile(string fileName, vector<char> &output)
|
||||||
{
|
{
|
||||||
std::ifstream file(fileName, std::ios::in | std::ios::binary);
|
std::ifstream file(fileName, std::ios::in | std::ios::binary);
|
||||||
|
|
||||||
if (!file.is_open())
|
if (file.is_open() != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -973,6 +973,7 @@ bool readFile(string fileName, vector<char> &output)
|
|||||||
output.push_back(byte);
|
output.push_back(byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
|
||||||
// Get the size of the file
|
// Get the size of the file
|
||||||
// file.seekg(0, std::ios::end);
|
// file.seekg(0, std::ios::end);
|
||||||
|
|||||||
Reference in New Issue
Block a user