Compare commits
2 Commits
c0b36e9068
...
37d02abd3f
| Author | SHA1 | Date | |
|---|---|---|---|
| 37d02abd3f | |||
| 5229f16c9d |
2
Makefile
2
Makefile
@@ -8,7 +8,7 @@ CXX = g++
|
|||||||
|
|
||||||
# define any compile-time flags
|
# define any compile-time flags
|
||||||
# CXXFLAGS := -std=c++17 -Wall -Wextra -g -lssl -lcrypto -w
|
# CXXFLAGS := -std=c++17 -Wall -Wextra -g -lssl -lcrypto -w
|
||||||
CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto -w
|
CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto
|
||||||
|
|
||||||
# define library paths in addition to /usr/lib
|
# define library paths in addition to /usr/lib
|
||||||
# if I wanted to include libraries not in /usr/lib I'd specify
|
# if I wanted to include libraries not in /usr/lib I'd specify
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ void LicenceELC11::initCrypto()
|
|||||||
memcpy(&this->cryptData.aesKey[24], &this->cryptData.aesKey[12], 8);
|
memcpy(&this->cryptData.aesKey[24], &this->cryptData.aesKey[12], 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string LicenceELC11::getLicenceName()
|
string LicenceELC11::getLicenceName()
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
@@ -11,6 +11,12 @@ RUN chmod 755 /app/start.sh
|
|||||||
COPY ./startok.sh /app/
|
COPY ./startok.sh /app/
|
||||||
RUN chmod 755 /app/startok.sh
|
RUN chmod 755 /app/startok.sh
|
||||||
|
|
||||||
|
COPY ./lread.sh /app/
|
||||||
|
RUN chmod 755 /app/lread.sh
|
||||||
|
|
||||||
|
COPY ./lgen.sh /app/
|
||||||
|
RUN chmod 755 /app/lgen.sh
|
||||||
|
|
||||||
COPY ./Makefile /app/
|
COPY ./Makefile /app/
|
||||||
|
|
||||||
ENTRYPOINT ["tail"]
|
ENTRYPOINT ["tail"]
|
||||||
|
|||||||
7
docker/lgen.sh
Normal file
7
docker/lgen.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
chmod 777 output/generate
|
||||||
|
|
||||||
|
#./output/generate -cid=9f54495344434954615ad803c50171bf -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml
|
||||||
|
|
||||||
|
cd output
|
||||||
|
./generate -cid=9f54495344434954615ad803c50171bf -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml
|
||||||
7
docker/lread.sh
Normal file
7
docker/lread.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
chmod 777 output/read
|
||||||
|
|
||||||
|
#./output/read -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||||
|
|
||||||
|
cd output
|
||||||
|
./read -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
chmod 777 output/licenceGenerator
|
chmod 777 output/licenceGenerator
|
||||||
|
|
||||||
#./output/licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
#./output/licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||||
|
|
||||||
cd output
|
cd output
|
||||||
./licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
./licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -46,15 +47,6 @@ enum class GeneralError
|
|||||||
ItemsCountMismatch = 61
|
ItemsCountMismatch = 61
|
||||||
};
|
};
|
||||||
|
|
||||||
// unordered_map<GeneralError, string> mapGeneralErrors = {
|
|
||||||
// {GeneralError::SDCardReadError, "Nepodařilo se načíst SD kartu."},
|
|
||||||
// {GeneralError::ItemsCountMismatch, "Nesouhlasí počet položek licence."},
|
|
||||||
// {GeneralError::LicenceSizeMismatch, "Nesouhlasí velikost souboru licence."},
|
|
||||||
// {GeneralError::LicenceSizeCardMismatch, "Nesouhlasí velikost SD karty."},
|
|
||||||
// {GeneralError::LicenceMismatch, "Nesouhlasí licence."},
|
|
||||||
// {GeneralError::ItemsCountMismatch, "Nesouhlasí počet položek licence."}
|
|
||||||
// };
|
|
||||||
|
|
||||||
enum class ELCType
|
enum class ELCType
|
||||||
{
|
{
|
||||||
ELC1 = 1,
|
ELC1 = 1,
|
||||||
@@ -119,14 +111,19 @@ struct LicenceIdentification
|
|||||||
uint8_t licenceVersion = 1; // verze licence, určuje kodování, pojmenování souborů
|
uint8_t licenceVersion = 1; // verze licence, určuje kodování, pojmenování souborů
|
||||||
uint8_t licenceIndex = 0;
|
uint8_t licenceIndex = 0;
|
||||||
uint8_t revision;
|
uint8_t revision;
|
||||||
uint8_t licCompatibility = 1; // identikator hlavního ELC
|
uint8_t licCompatibility = 0; // identikator hlavního ELC. 0 = nedefinová a vrací se defaultní k danému ELC
|
||||||
|
|
||||||
uint16_t licItemsCount = 0;
|
uint16_t licItemsCount = 0;
|
||||||
|
|
||||||
string cid_cds_path = "";
|
string cid_cds_path = "";
|
||||||
string licenceFilePath = "";
|
string licenceFilePath = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief obecná struktura pro reader
|
||||||
|
struct LicenceInfoGeneral
|
||||||
|
{
|
||||||
|
int reqDataPointsCount = 0;
|
||||||
|
unordered_map<int, int> licences = {};
|
||||||
|
};
|
||||||
|
|
||||||
/// @brief obecná struktura polozky licence, defaultní kompatibilita
|
/// @brief obecná struktura polozky licence, defaultní kompatibilita
|
||||||
struct LicenceItem
|
struct LicenceItem
|
||||||
{
|
{
|
||||||
@@ -134,97 +131,53 @@ struct LicenceItem
|
|||||||
int dataPointsCount = 0;
|
int dataPointsCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief struktura polozky licence, kompatibilita 1
|
/* struktury pro ELC 1 */
|
||||||
struct LicenceItemCompatibility1
|
//defaultní struktura pro ELC 1
|
||||||
|
struct LicenceELC1Info
|
||||||
{
|
{
|
||||||
int protocolId = -1;
|
bool isValid {false};
|
||||||
int dataPointsCount = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief struktura polozky licence, kompatibilita 2
|
//struktura ELC1, kompatibilita 1
|
||||||
struct LicenceItemCompatibility2
|
struct LicenceELC1Info_1
|
||||||
{
|
{
|
||||||
int protocolId = -1;
|
unordered_map<int, int> licences = {};
|
||||||
int dataPointsCount = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief struktura polozky licence, kompatibilita 3
|
//defaultni struktura polozky licence ELC 1
|
||||||
struct LicenceItemCompatibility3
|
struct LicenceELC1Item
|
||||||
{
|
{
|
||||||
int protocolId = -1;
|
int protocolId = -1;
|
||||||
int dataPointsCount = 0;
|
int dataPointsCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct LicenceItem11
|
/* struktury pro ELC 2 */
|
||||||
|
//defaultní struktura pro ELC 2
|
||||||
|
struct LicenceELC2Info
|
||||||
|
{
|
||||||
|
unordered_map<int, int> licences = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LicenceELC2Info_1
|
||||||
|
{
|
||||||
|
unordered_map<int, int> licences = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
//defaultni struktura polozky ELC 2
|
||||||
|
struct LicenceELC2Item
|
||||||
{
|
{
|
||||||
int protocolId = -1;
|
int protocolId = -1;
|
||||||
int dataPointsCount = 0;
|
int dataPointsCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LicenceItem21
|
//struktura polozky ELC 2,
|
||||||
|
struct LicenceELC2Item_1
|
||||||
{
|
{
|
||||||
int protocolId = -1;
|
int protocolId = -1;
|
||||||
int dataPointsCount = 0;
|
int dataPointsCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LicenceItem31
|
|
||||||
{
|
|
||||||
int protocolId = -1;
|
|
||||||
int dataPointsCount = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief základní struktura, seznam polozek licencí
|
|
||||||
struct LicenceInfo
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief základní struktura, seznam polozek licencí, kompatibilita 1
|
|
||||||
struct LicenceInfoCompatibility1
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief základní struktura, seznam polozek licencí, kompatibilita 1
|
|
||||||
struct LicenceInfoCompatibility2
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief základní struktura, seznam polozek licencí, kompatibilita 3
|
|
||||||
struct LicenceInfoCompatibility3
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LicenceInfo11
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LicenceInfo21
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LicenceInfo31
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LicenceInfoGeneral
|
|
||||||
{
|
|
||||||
int reqDataPointsCount = 0;
|
|
||||||
map<int, int> licences = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class LicenceException : public std::exception
|
class LicenceException : public std::exception
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
//#define LINUX 1
|
|
||||||
#define WINDOWS 1
|
|
||||||
|
|
||||||
#ifndef UTILS_H_
|
#ifndef UTILS_H_
|
||||||
#define UTILS_H_
|
#define UTILS_H_
|
||||||
|
|
||||||
@@ -12,6 +9,7 @@
|
|||||||
#include <format>
|
#include <format>
|
||||||
#include <libgen.h> // dirname
|
#include <libgen.h> // dirname
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
typedef uint8_t BYTE;
|
typedef uint8_t BYTE;
|
||||||
typedef uint16_t WORD;
|
typedef uint16_t WORD;
|
||||||
@@ -40,11 +38,8 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
|||||||
string convertToString(char* a, int size);
|
string convertToString(char* a, int size);
|
||||||
string base64_encode_ai(const std::string &input);
|
string base64_encode_ai(const std::string &input);
|
||||||
unordered_map<string, string> getArguments(int argc, char *argv[]);
|
unordered_map<string, string> getArguments(int argc, char *argv[]);
|
||||||
char* getCharArray(string source);
|
|
||||||
void getCharsFromString1(string source, char *charArray);
|
|
||||||
void getCharsFromString(string& source, char *charArray, size_t length);
|
void getCharsFromString(string& source, char *charArray, size_t length);
|
||||||
string getCompletePath(string fileName);
|
string getCompletePath(string fileName);
|
||||||
char* getFileContent(string fileName);
|
|
||||||
void appendStringToVector(const std::string& str, std::vector<unsigned char>& charVector);
|
void appendStringToVector(const std::string& str, std::vector<unsigned char>& charVector);
|
||||||
uint16_t calculateCRC16(std::vector<unsigned char>& charVector);
|
uint16_t calculateCRC16(std::vector<unsigned char>& charVector);
|
||||||
uint32_t bytesToDword(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4);
|
uint32_t bytesToDword(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "pugixml.hpp"
|
#include "pugixml.hpp"
|
||||||
#include "licenceCommon.h"
|
#include "licenceCommon.h"
|
||||||
#include "licenceELC11.h"
|
// #include "licenceELC11.h"
|
||||||
#include "licenceELC21.h"
|
// #include "licenceELC21.h"
|
||||||
#include "licenceELC31.h"
|
// #include "licenceELC31.h"
|
||||||
|
|
||||||
#include "licGenELC1.h"
|
#include "licGenELC1.h"
|
||||||
#include "licGenELC2.h"
|
#include "licGenELC2.h"
|
||||||
@@ -20,6 +20,7 @@ using namespace std;
|
|||||||
class LicenceGenerator
|
class LicenceGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
struct LicData
|
struct LicData
|
||||||
{
|
{
|
||||||
string station = "";
|
string station = "";
|
||||||
@@ -32,31 +33,27 @@ class LicenceGenerator
|
|||||||
pugi::xml_document *doc;
|
pugi::xml_document *doc;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
LicData licData;
|
||||||
int elcSwitchType;
|
int elcSwitchType;
|
||||||
string operationErrors = "";
|
string operationErrors = "";
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
bool argumentsCorrect = false;
|
bool argumentsCorrect = false;
|
||||||
ErrorMessage error;
|
ErrorMessage error;
|
||||||
LicenceELC11 *licence11;
|
// LicenceELC11 *licence11;
|
||||||
LicenceELC21 *licence21;
|
// LicenceELC21 *licence21;
|
||||||
LicenceELC31 *licence31;
|
// LicenceELC31 *licence31;
|
||||||
Mapping mapping;
|
Mapping mapping;
|
||||||
|
|
||||||
|
|
||||||
LicenceGenerator();
|
LicenceGenerator();
|
||||||
~LicenceGenerator();
|
~LicenceGenerator();
|
||||||
LicenceGenerator(string uid, string cid, string csd, string dataFileName);
|
LicenceGenerator(string uid, string cid, string csd, string dataFileName);
|
||||||
|
|
||||||
void createLicenceFile();
|
void createLicenceFile();
|
||||||
|
|
||||||
|
|
||||||
LicenceInfoGeneral licenceInfo;
|
LicenceInfoGeneral licenceInfo;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LicenceIdentification licIdentification;
|
LicenceIdentification licIdentification;
|
||||||
LicData licData;
|
|
||||||
string configFileName = "";
|
string configFileName = "";
|
||||||
|
|
||||||
void *licence = nullptr;
|
void *licence = nullptr;
|
||||||
@@ -66,7 +63,6 @@ private:
|
|||||||
void createLicenceELC1();
|
void createLicenceELC1();
|
||||||
void createLicenceELC2();
|
void createLicenceELC2();
|
||||||
void createLicenceELC3();
|
void createLicenceELC3();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -944,13 +944,17 @@ namespace pugi
|
|||||||
char _memory[192];
|
char _memory[192];
|
||||||
|
|
||||||
// Non-copyable semantics
|
// Non-copyable semantics
|
||||||
xml_document(const xml_document&);
|
// xml_document(const xml_document&);
|
||||||
xml_document& operator=(const xml_document&);
|
// xml_document& operator=(const xml_document&);
|
||||||
|
|
||||||
void create();
|
void create();
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
xml_document(const xml_document&);
|
||||||
|
xml_document& operator=(const xml_document&);
|
||||||
|
|
||||||
// Default constructor, makes empty document
|
// Default constructor, makes empty document
|
||||||
xml_document();
|
xml_document();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,31 @@
|
|||||||
#ifndef ELC1_READER__H
|
#ifndef ELC1_READER__H
|
||||||
#define ELC1_READER__H
|
#define ELC1_READER__H
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "licenceCommon.h"
|
||||||
|
#include "licenceELC1.h"
|
||||||
|
#include "SDCard.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
namespace Reader
|
namespace Reader
|
||||||
{
|
{
|
||||||
|
class Licence1 : public LicenceELC1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
LicenceELC1Info licenceInfo;
|
||||||
|
|
||||||
|
Licence1();
|
||||||
|
~Licence1();
|
||||||
|
Licence1(LicenceIdentification &licIdentification);
|
||||||
|
|
||||||
|
bool readLicence(LicenceInfoGeneral *licences);
|
||||||
|
bool getLicenceInfo(void *ptr);
|
||||||
|
bool getLicenceItemInfo(int protocolId, void *returnItemStructure);
|
||||||
|
void getLicenceItems();
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -13,15 +13,13 @@ namespace Reader
|
|||||||
class Licence2 : public LicenceELC2
|
class Licence2 : public LicenceELC2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LicenceInfo21 licenceInfo;
|
LicenceELC2Info licenceInfo;
|
||||||
|
|
||||||
|
|
||||||
Licence2();
|
Licence2();
|
||||||
~Licence2();
|
~Licence2();
|
||||||
Licence2(LicenceIdentification &licIdentification);
|
Licence2(LicenceIdentification &licIdentification);
|
||||||
|
|
||||||
bool readLicence(LicenceInfoGeneral *licences);
|
bool readLicence(LicenceInfoGeneral *licences);
|
||||||
int getDataPointsCount(int protocolId);
|
|
||||||
bool getLicenceInfo(void *ptr);
|
bool getLicenceInfo(void *ptr);
|
||||||
bool getLicenceItemInfo(int protocolId, void *returnItemStructure);
|
bool getLicenceItemInfo(int protocolId, void *returnItemStructure);
|
||||||
void getLicenceItems();
|
void getLicenceItems();
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
#define LICENCE_READER_H_
|
#define LICENCE_READER_H_
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "licenceELC11.h"
|
|
||||||
#include "licenceELC31.h"
|
|
||||||
|
|
||||||
#include "licReaderELC1.h"
|
#include "licReaderELC1.h"
|
||||||
#include "licReaderELC2.h"
|
#include "licReaderELC2.h"
|
||||||
@@ -31,9 +29,9 @@ public:
|
|||||||
string operationErrors = "";
|
string operationErrors = "";
|
||||||
bool argumentsCorrect = false;
|
bool argumentsCorrect = false;
|
||||||
ErrorMessage error;
|
ErrorMessage error;
|
||||||
LicenceELC11 *licence11;
|
|
||||||
LicenceELC31 *licence31;
|
|
||||||
Licence2 *licence2;
|
Licence2 *licence2;
|
||||||
|
Licence1 *licence1;
|
||||||
|
|
||||||
|
|
||||||
LicenceReader();
|
LicenceReader();
|
||||||
~LicenceReader();
|
~LicenceReader();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
0353445355313647801b1a9f6600c747
|
9f54495344434954615ad803c50171bf
|
||||||
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 @@
|
|||||||
400e00325b59000076b27f800a404013
|
400e00325b5900003be77f800a400043
|
||||||
|
|
||||||
Binary file not shown.
BIN
output/ezlic_eovosv0_jjacdgpdxpb.lic
Normal file
BIN
output/ezlic_eovosv0_jjacdgpdxpb.lic
Normal file
Binary file not shown.
BIN
output/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
BIN
output/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
Binary file not shown.
BIN
output/generate
Normal file
BIN
output/generate
Normal file
Binary file not shown.
5
output/lcis/cis
Normal file
5
output/lcis/cis
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
0353445355313647801b1a9f6600c747
|
||||||
|
6 . x4 <20><><EFBFBD> .. nt$6 &<26> manfid 6 <20><><EFBFBD>
|
||||||
|
cid "6 <10> fwrev 6 Jm<4A> csd ,6 gEd$
|
||||||
|
subsystem 46 <20><><EFBFBD>%
|
||||||
|
driver (6 <20><><EFBFBD>- ocr -6 <20><><EFBFBD>? power *6 <>4L type 6 <20>1M date #6 <20>rTP hwrev )6 n<>yR dsr '6 <20>` serial 6 NN<4E>m erase_size <20>6 <20>6<EFBFBD>m block 6 <20><><EFBFBD>n uevent 6 <18><>o ssr 6 <1E>q scr &6 &<26><>y oemid !6 <20><><EFBFBD>y ( preferred_erase_size %6 <20><><EFBFBD> name
|
||||||
2
output/lcis/csd
Normal file
2
output/lcis/csd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
400e00325b59000076b27f800a404013
|
||||||
|
|
||||||
BIN
output/lcis/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
BIN
output/lcis/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
Binary file not shown.
37
output/lcis/licData.xml
Normal file
37
output/lcis/licData.xml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<licence elc="2" xmlVersion="1" revision="1" compatibility="1">
|
||||||
|
<licenceType licenceVersion="1" licenceIndex="0">EOV_OSV</licenceType>
|
||||||
|
<plcType>WAGO</plcType>
|
||||||
|
<licenceName>Licence pro EOV_OSV</licenceName>
|
||||||
|
<station>eov.ceskatrebova.ddts.cz</station>
|
||||||
|
<distributor>eov2</distributor>
|
||||||
|
<project>Projekt XXX stanice YYY</project>
|
||||||
|
<items>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 1</name>
|
||||||
|
<protoId>111</protoId>
|
||||||
|
<dataPointsCount>100</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 2</name>
|
||||||
|
<protoId>222</protoId>
|
||||||
|
<dataPointsCount>200</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 3</name>
|
||||||
|
<protoId>333</protoId>
|
||||||
|
<dataPointsCount>300</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 4</name>
|
||||||
|
<protoId>555</protoId>
|
||||||
|
<dataPointsCount>666</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<name>Položka licence 5</name>
|
||||||
|
<protoId>666</protoId>
|
||||||
|
<dataPointsCount>9998</dataPointsCount>
|
||||||
|
</item>
|
||||||
|
</items>
|
||||||
|
|
||||||
|
</licence>
|
||||||
BIN
output/lcis/temp/ezlic_eovosv0_cbheemcjsii.lic
Normal file
BIN
output/lcis/temp/ezlic_eovosv0_cbheemcjsii.lic
Normal file
Binary file not shown.
BIN
output/lcis/temp/ezlic_eovosv0_xjxvxgalxab.lic
Normal file
BIN
output/lcis/temp/ezlic_eovosv0_xjxvxgalxab.lic
Normal file
Binary file not shown.
@@ -1,36 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<licence elc="1" xmlVersion="1" revision="1" compatibility="1">
|
<licence elc="2" xmlVersion="1" revision="1" compatibility="1">
|
||||||
<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>eov.ceskatrebova.ddts.cz</station>
|
<station>odb.zaluzi.drt.cz</station>
|
||||||
<distributor>eov2</distributor>
|
<distributor>POZ8</distributor>
|
||||||
<project>Projekt XXX stanice YYY</project>
|
<project>Projekt XXX stanice YYY</project>
|
||||||
<items>
|
<items>
|
||||||
<item>
|
<item>
|
||||||
<name>Položka licence 1</name>
|
<name>Položka licence 1</name>
|
||||||
<protoId>111</protoId>
|
<protoId>111</protoId>
|
||||||
<dataPointsCount>100</dataPointsCount>
|
<dataPointsCount>7454</dataPointsCount>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<name>Položka licence 2</name>
|
<name>Položka licence 2</name>
|
||||||
<protoId>222</protoId>
|
<protoId>222</protoId>
|
||||||
<dataPointsCount>200</dataPointsCount>
|
<dataPointsCount>6477</dataPointsCount>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<name>Položka licence 3</name>
|
<name>Položka licence 3</name>
|
||||||
<protoId>333</protoId>
|
<protoId>333</protoId>
|
||||||
<dataPointsCount>300</dataPointsCount>
|
<dataPointsCount>7844</dataPointsCount>
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<name>Položka licence 3</name>
|
|
||||||
<protoId>444</protoId>
|
|
||||||
<dataPointsCount>1600</dataPointsCount>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<name>Položka licence 4</name>
|
|
||||||
<protoId>555</protoId>
|
|
||||||
<dataPointsCount>666</dataPointsCount>
|
|
||||||
</item>
|
</item>
|
||||||
</items>
|
</items>
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
BIN
output/read
Normal file
BIN
output/read
Normal file
Binary file not shown.
@@ -1,3 +1,6 @@
|
|||||||
|
#define LINUX 1
|
||||||
|
//#define WINDOWS 1
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "licenceGenerator.h"
|
#include "licenceGenerator.h"
|
||||||
|
|
||||||
@@ -5,7 +8,7 @@
|
|||||||
/// @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 main6(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
unordered_map<string, string> arguments = getArguments(argc, argv);
|
unordered_map<string, string> arguments = getArguments(argc, argv);
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,92 +1,115 @@
|
|||||||
#include <stdio.h>
|
#define LINUX 1
|
||||||
#include "utils.h"
|
// #define WINDOWS 1
|
||||||
#include "licenceReader.h"
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "licenceReader.h"
|
||||||
|
|
||||||
/// @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 main5()
|
int main()
|
||||||
{
|
{
|
||||||
// unordered_map<string, string> arguments = getArguments(argc, argv);
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// unordered_map<string, string> arguments = getArguments(argc, argv);
|
|
||||||
// LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]);
|
|
||||||
// generatorOld.createLicenceFile();
|
|
||||||
// system("pause");
|
|
||||||
// return SUCCES;
|
|
||||||
// }
|
|
||||||
// catch (...)
|
|
||||||
// {
|
|
||||||
// cerr << "Obecná chyba\n";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// system("pause");
|
|
||||||
// return SUCCES;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
int protocolId = 444;
|
|
||||||
|
|
||||||
LicenceReader licenceReader1 {};
|
|
||||||
|
|
||||||
InitStructure initStructure;
|
InitStructure initStructure;
|
||||||
initStructure.licenceType = (int)LicenceType::EOS_EOV;
|
initStructure.licenceType = (int)LicenceType::EOS_EOV;
|
||||||
initStructure.licenceVersion = 1;
|
initStructure.licenceVersion = 1;
|
||||||
initStructure.licenceIndex = 0;
|
initStructure.licenceIndex = 0;
|
||||||
initStructure.compatibility = 1;
|
initStructure.licenceFilePath = ""; // cesta k licenčnímu souboru
|
||||||
initStructure.licenceFilePath = "";
|
// initStructure.compatibility = 0; v případě kompatibility 0 či nezadané je výstup defaultní.
|
||||||
initStructure.cid_csd_filePath = "";
|
// pro ELC 1 LicenceELC1Info s výstupem isValid, pro ELC 2 strukura { int protocolId = -1; int dataPointsCount = 0; }
|
||||||
|
initStructure.cid_csd_filePath = ""; // cesta k cidu/csd pro načtení a kontorlu licence
|
||||||
|
|
||||||
cout << "-- verze #1: init a iterace" << "\n";
|
// verze původní ELC 1
|
||||||
|
LicenceReader licenceReaderELC1{};
|
||||||
//verze #1: načtení kompletní licence a zobrazení
|
if (licenceReaderELC1.initread(1, initStructure)) // iniciacni nacteni
|
||||||
if (licenceReader1.init(2, initStructure))
|
|
||||||
{
|
{
|
||||||
LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
LicenceELC1Info info; // struktura pro ELC1. Nemá tam asi nic jiného smysl nez true/false
|
||||||
|
if (licenceReaderELC1.getLicenceInfo(&info))
|
||||||
if (licenceReader1.getLicenceInfo(&info))
|
|
||||||
{
|
{
|
||||||
if (info.licences.count(protocolId) > 0) cout << "Počet z vectoru pro : " << protocolId << ": " << info.licences.at(protocolId) << endl;
|
if (info.isValid)
|
||||||
cout << "Všechny licenční body: " << endl;
|
cout << "Platna licence ELC1 \n";
|
||||||
for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; }
|
else
|
||||||
|
cout << "Neplatna licence ELC1\n";
|
||||||
}
|
}
|
||||||
else cout << "Došlo k chybě: " << licenceReader1.error.message;
|
else
|
||||||
|
cout << "CHYBA: " << licenceReaderELC1.error.message;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << "Došlo k chybě: " << licenceReader1.error.message;
|
cout << "CHYBA: " << licenceReaderELC1.error.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "\n" << "-- verze #2: init a iterace" << "\n";
|
// verze ELC 2 pro jeden protokol
|
||||||
//verze #2 : iterace pro kazdý bod zvlášť
|
LicenceReader licenceReaderELC2{};
|
||||||
|
|
||||||
LicenceReader licenceReader2 {};
|
if (licenceReaderELC2.initread(2, initStructure)) // iniciacni nacteni
|
||||||
|
|
||||||
if (licenceReader2.initread(2, initStructure))
|
|
||||||
{
|
{
|
||||||
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
// v případě kompatibility 0, či nezadané výstup nativně je defaultní.
|
||||||
|
// v případně nenulové kompatibility, třeba 1, přidáme číslo kompatibility. Tedy pro ELC1 to bude LicenceELC1_1, pro ELC LicenceELC2_1
|
||||||
|
LicenceELC2Item info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||||
|
// if ()
|
||||||
|
int protocolId = 333;
|
||||||
|
|
||||||
if (licenceReader2.getLicenceItemInfo(protocolId, &info))
|
// if (initStructure.compatibility == 1) //ukazka kompatibilita
|
||||||
|
// {
|
||||||
|
// LicenceELC2Item_1 info; //jiná struktura, zbytek stejný
|
||||||
|
// if (licenceReaderELC2.getLicenceItemInfo(protocolId, &info))
|
||||||
|
// {
|
||||||
|
// cout << "Pocet licencních bodu pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
|
||||||
|
// }
|
||||||
|
//...........
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (licenceReaderELC2.getLicenceItemInfo(protocolId, &info))
|
||||||
{
|
{
|
||||||
std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
|
cout << "Pocet licencních bodu pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cout << "Došlo k chybě: " << licenceReader2.error.message;
|
cout << "CHYBA: " << licenceReaderELC2.error.message;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << "Došlo k chybě: " << licenceReader2.error.message;
|
cout << "CHYBA: " << licenceReaderELC2.error.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
LicenceReader licenceReaderCompleteELC2{};
|
||||||
|
|
||||||
|
// verze ELC 2 kompletní načtení
|
||||||
|
if (licenceReaderCompleteELC2.init(2, initStructure)) // iniciacni nacteni
|
||||||
|
{
|
||||||
|
LicenceELC2Info info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||||
|
int protocolId = 333;
|
||||||
|
|
||||||
|
if (licenceReaderCompleteELC2.getLicenceInfo(&info))
|
||||||
|
{
|
||||||
|
if (info.licences.count(protocolId) > 0)
|
||||||
|
cout << "Pocet bodu z vectoru pro protokol : " << protocolId << ": " << info.licences.at(protocolId) << "\n";
|
||||||
|
else
|
||||||
|
cout << "Pro tento protokol nejsou definovay licencni body\n";
|
||||||
|
cout << "Vypis vsech licencnich bodu: " << endl;
|
||||||
|
for (const auto &pair : info.licences)
|
||||||
|
{
|
||||||
|
std::cout << "<" << pair.first << ", " << pair.second << ">" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cout << "CHYBA: " << licenceReaderCompleteELC2.error.message;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << "CHYBA: " << licenceReaderCompleteELC2.error.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
cout << "Obecná chyba\n";
|
cout << "Obecna chyba\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
system("pause");
|
// system("pause");
|
||||||
return SUCCES;
|
return SUCCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cid: 0353445355313647801b1a9f6600c747 csd: 400e00325b59000076b27f800a404013
|
||||||
|
// https://sprava.app.elzel.cz/device/417 cid: 9f54495344434954615ad803c50171bf csd: 400e00325b5900003be77f800a400043
|
||||||
@@ -8,15 +8,19 @@ SDCard::SDCard()
|
|||||||
SDCard::SDCard(const string cds_cid_Path)
|
SDCard::SDCard(const string cds_cid_Path)
|
||||||
{
|
{
|
||||||
this->filePath = cds_cid_Path;
|
this->filePath = cds_cid_Path;
|
||||||
if (getCIDFromFile() == false) return;
|
if (getCIDFromFile() == false)
|
||||||
if (getCSDFromFile() == false) return;
|
return;
|
||||||
|
if (getCSDFromFile() == false)
|
||||||
|
return;
|
||||||
this->isLoaded = SDCard::readSDCard();
|
this->isLoaded = SDCard::readSDCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDCard::SDCard(string cid, string csd)
|
SDCard::SDCard(string cid, string csd)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < cid.length(); i++) this->cid[i] = cid[i];
|
for (unsigned int i = 0; i < cid.length(); i++)
|
||||||
for (unsigned int i = 0; i < csd.length(); i++) this->csd[i] = csd[i];
|
this->cid[i] = cid[i];
|
||||||
|
for (unsigned int i = 0; i < csd.length(); i++)
|
||||||
|
this->csd[i] = csd[i];
|
||||||
|
|
||||||
this->isLoaded = SDCard::readSDCard();
|
this->isLoaded = SDCard::readSDCard();
|
||||||
}
|
}
|
||||||
@@ -99,7 +103,6 @@ bool SDCard:: readSDCard()
|
|||||||
this->cardData.CRCOK = ((sdCrc << 1) | 1) == this->cardData.CID[15];
|
this->cardData.CRCOK = ((sdCrc << 1) | 1) == this->cardData.CID[15];
|
||||||
this->cardData.crcCorrect = (int)this->cardData.CID[15] == (int)((sdCrc << 1) | 1);
|
this->cardData.crcCorrect = (int)this->cardData.CID[15] == (int)((sdCrc << 1) | 1);
|
||||||
return this->cardData.crcCorrect;
|
return this->cardData.crcCorrect;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDCard::getCIDFromFile()
|
bool SDCard::getCIDFromFile()
|
||||||
@@ -109,11 +112,14 @@ bool SDCard::getCIDFromFile()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (content.size() >= 32)
|
|
||||||
|
if (content.size() >= CID_LENGTH)
|
||||||
{
|
{
|
||||||
for (int i = 0; i<32;i++) this->cid[i] = content[i];
|
for (int i = 0; i < 32; i++)
|
||||||
|
this->cid[i] = content[i];
|
||||||
}
|
}
|
||||||
else return false;
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -125,11 +131,13 @@ bool SDCard::getCSDFromFile()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (content.size() >= 32)
|
if (content.size() >= CSD_LENGTH)
|
||||||
{
|
{
|
||||||
for (int i = 0; i<32;i++) this->csd[i] = content[i];
|
for (int i = 0; i < 32; i++)
|
||||||
|
this->csd[i] = content[i];
|
||||||
}
|
}
|
||||||
else return false;
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -58,8 +58,7 @@ LicenceELC1::LicenceELC1(LicenceIdentification &licIdentification) : lIdentifica
|
|||||||
|
|
||||||
bool LicenceELC1::getSDData()
|
bool LicenceELC1::getSDData()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CID_LENGTH; i++)
|
for (int i = 0; i < CID_LENGTH; i++) this->sdData.CID_nibble[i] = (BYTE)cid[i];
|
||||||
this->sdData.CID_nibble[i] = (BYTE)cid[i];
|
|
||||||
|
|
||||||
for (int i = 0; i < cnibblescount / 2; i++)
|
for (int i = 0; i < cnibblescount / 2; i++)
|
||||||
{
|
{
|
||||||
@@ -91,12 +90,10 @@ bool LicenceELC1::getSDData()
|
|||||||
this->sdData.manufacturerDate[i] = date[i];
|
this->sdData.manufacturerDate[i] = date[i];
|
||||||
|
|
||||||
// CSD
|
// CSD
|
||||||
for (unsigned int i = 0; i < CSD_LENGTH; i++)
|
for (unsigned int i = 0; i < CSD_LENGTH; i++) this->sdData.CSD_nibble[i] = (BYTE)csd[i];
|
||||||
this->sdData.CSD_nibble[i] = (BYTE)csd[i];
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < cnibblescount / 2; i++)
|
for (unsigned int i = 0; i < cnibblescount / 2; i++)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
this->sdData.CSD[i] = cHexNibble_to_No1[this->sdData.CSD_nibble[2 * i]] << 4 | cHexNibble_to_No1[this->sdData.CSD_nibble[2 * i + 1]];
|
this->sdData.CSD[i] = cHexNibble_to_No1[this->sdData.CSD_nibble[2 * i]] << 4 | cHexNibble_to_No1[this->sdData.CSD_nibble[2 * i + 1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,10 +101,6 @@ bool LicenceELC1::getSDData()
|
|||||||
{
|
{
|
||||||
this->sdData.cardSize = this->sdData.CSD[7] << 16 | this->sdData.CSD[8] << 8 | this->sdData.CSD[9];
|
this->sdData.cardSize = this->sdData.CSD[7] << 16 | this->sdData.CSD[8] << 8 | this->sdData.CSD[9];
|
||||||
this->sdData.cardGSize = (this->sdData.cardSize + 1) / 2048;
|
this->sdData.cardGSize = (this->sdData.cardSize + 1) / 2048;
|
||||||
|
|
||||||
if (this->sdData.cardSize > 17200) // TODO result.cardSize
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE sdCrc = 0;
|
BYTE sdCrc = 0;
|
||||||
@@ -189,10 +182,6 @@ string LicenceELC1::getLicenceName(BYTE licPostfix)
|
|||||||
string result = "";
|
string result = "";
|
||||||
char prefixChar = 97;
|
char prefixChar = 97;
|
||||||
|
|
||||||
if (licPostfix > 9) // chyba
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (licType == PlcLicenceType::LicenceOther)
|
if (licType == PlcLicenceType::LicenceOther)
|
||||||
{
|
{
|
||||||
result = "ezlic_";
|
result = "ezlic_";
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,6 @@
|
|||||||
#include <openssl/ssl.h> /* core library */
|
#include <openssl/ssl.h> /* core library */
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const std::string base64_chars =
|
const std::string base64_chars =
|
||||||
@@ -117,8 +116,8 @@ int encrypt(const unsigned char *plaintext, int plaintext_len, unsigned char *ke
|
|||||||
int ciphertext_len;
|
int ciphertext_len;
|
||||||
|
|
||||||
/* Create and initialise the context */
|
/* Create and initialise the context */
|
||||||
if (!(ctx = EVP_CIPHER_CTX_new())) return -1;
|
if (!(ctx = EVP_CIPHER_CTX_new()))
|
||||||
|
return -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise the encryption operation. IMPORTANT - ensure you use a key
|
* Initialise the encryption operation. IMPORTANT - ensure you use a key
|
||||||
@@ -316,7 +315,7 @@ string getCompletePath(string fileName)
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
return fileName;
|
return fileName;
|
||||||
#else
|
#else
|
||||||
//warning TODO filesystem
|
|
||||||
char path[PATH_MAX + 1] = {};
|
char path[PATH_MAX + 1] = {};
|
||||||
ssize_t length = readlink("/proc/self/exe", path, PATH_MAX);
|
ssize_t length = readlink("/proc/self/exe", path, PATH_MAX);
|
||||||
path[length] = '\0';
|
path[length] = '\0';
|
||||||
|
|||||||
Binary file not shown.
@@ -1,9 +1,8 @@
|
|||||||
src/generator/LicenceGenerator.o: src/generator/LicenceGenerator.cpp \
|
src/generator/LicenceGenerator.o: src/generator/LicenceGenerator.cpp \
|
||||||
include/generator/licenceGenerator.h include/generator/pugixml.hpp \
|
include/generator/licenceGenerator.h include/generator/pugixml.hpp \
|
||||||
include/generator/pugiconfig.hpp include/common/licenceCommon.h \
|
include/generator/pugiconfig.hpp include/common/licenceCommon.h \
|
||||||
include/licenceELC11.h include/common/SDCard.h include/licenceELC21.h \
|
include/generator/licGenELC1.h include/common/utils.h \
|
||||||
include/common/utils.h include/generator/pugixml.hpp \
|
|
||||||
include/licenceELC31.h include/generator/licGenELC1.h \
|
|
||||||
include/common/licenceELC1.h include/common/licenceCommon.h \
|
include/common/licenceELC1.h include/common/licenceCommon.h \
|
||||||
include/common/SDCard.h include/generator/licGenELC2.h \
|
include/common/SDCard.h include/common/SDCard.h \
|
||||||
include/common/licenceELC2.h include/generator/licGenELC3.h
|
include/generator/licGenELC2.h include/common/licenceELC2.h \
|
||||||
|
include/generator/licGenELC3.h include/generator/pugixml.hpp
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,109 +13,10 @@ LicenceReader::LicenceReader()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// LicenceReader::LicenceReader(string uid, string cid, string csd, string dataFileName)
|
/// @brief provede pouze inicialazaci čtecí třídy
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// if (dataFileName.empty())
|
|
||||||
// throw std::runtime_error("Missing dataFileName par.");
|
|
||||||
|
|
||||||
// if (uid.empty() == false)
|
|
||||||
// {
|
|
||||||
// this->licData.uid = uid;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (cid.empty())
|
|
||||||
// throw std::runtime_error("Missing CID par.");
|
|
||||||
// if (csd.empty())
|
|
||||||
// throw std::runtime_error("Missing CSD par.");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch (const std::exception &e)
|
|
||||||
// {
|
|
||||||
// this->argumentsCorrect = false;
|
|
||||||
// std::cerr << "error: " << e.what() << endl;
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this->configFileName = dataFileName;
|
|
||||||
// this->licData.cid = cid;
|
|
||||||
// this->licData.csd = csd;
|
|
||||||
|
|
||||||
// this->argumentsCorrect = true;
|
|
||||||
|
|
||||||
// if (processInputConfiguration() == false)
|
|
||||||
// {
|
|
||||||
// cerr << "Chyba: " << error.message << endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// LicenceReader::LicenceReader(int elcType, int licenceType, int licenceVersion, int licenceIndex, int compatibility)
|
|
||||||
// {
|
|
||||||
// this->licIdentification.licElcType = (ELCType)elcType;
|
|
||||||
// this->licIdentification.licLicenceType = (LicenceType)licenceType;
|
|
||||||
// this->licIdentification.licenceVersion = licenceVersion;
|
|
||||||
// this->licIdentification.licenceIndex = licenceIndex;
|
|
||||||
// this->licIdentification.licCompatibility = compatibility;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// @brief inicializace generátoru a načtení licenčních bodů
|
|
||||||
/// @param elcType
|
/// @param elcType
|
||||||
/// @param licenceType
|
/// @param initStructure
|
||||||
/// @param licenceVersion
|
|
||||||
/// @param licenceIndex
|
|
||||||
/// @param compatibility
|
|
||||||
/// @return
|
/// @return
|
||||||
bool LicenceReader::initread(int elcType, InitStructure &initStructure) // TOTO
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
elcSwitchType = elcType * 10 + licCompatibility;
|
|
||||||
|
|
||||||
if (init(elcType, initStructure))
|
|
||||||
{
|
|
||||||
switch (elcSwitchType)
|
|
||||||
{
|
|
||||||
case 11:
|
|
||||||
{ // old eoseov
|
|
||||||
LicenceELC11 licence = LicenceELC11(this->licIdentification);
|
|
||||||
this->licence11 = &licence;
|
|
||||||
licence.cid_cdsPath = initStructure.cid_csd_filePath;
|
|
||||||
licence.licenceFilePath = initStructure.licenceFilePath;
|
|
||||||
this->licence11->readLicence(&this->licenceInfo);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 21:
|
|
||||||
{
|
|
||||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
|
||||||
this->licence2 = &licenceELC2;
|
|
||||||
licenceELC2.cid_cdsPath = initStructure.cid_csd_filePath;
|
|
||||||
licenceELC2.licenceFilePath = initStructure.licenceFilePath;
|
|
||||||
this->licence2->readLicence(&this->licenceInfo);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 31:
|
|
||||||
{
|
|
||||||
LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch (const LicenceException &ex)
|
|
||||||
{
|
|
||||||
error.code = ex.getErrorCode();
|
|
||||||
error.message = ex.getErrorMessage();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true; // TODO testy
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LicenceReader::init(int elcType, InitStructure &initStructure)
|
bool LicenceReader::init(int elcType, InitStructure &initStructure)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -142,39 +43,128 @@ bool LicenceReader::init(int elcType, InitStructure &initStructure)
|
|||||||
|
|
||||||
elcSwitchType = elcType * 10 + licCompatibility;
|
elcSwitchType = elcType * 10 + licCompatibility;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief provede inicializaci čtecí třídy a zároveň načte licenční body do obecné struktury
|
||||||
|
/// @param elcType
|
||||||
|
/// @param licenceType
|
||||||
|
/// @param licenceVersion
|
||||||
|
/// @param licenceIndex
|
||||||
|
/// @param compatibility
|
||||||
|
/// @return
|
||||||
|
bool LicenceReader::initread(int elcType, InitStructure &initStructure)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
elcSwitchType = elcType * 10 + initStructure.compatibility;
|
||||||
|
|
||||||
|
if (init(elcType, initStructure))
|
||||||
|
{
|
||||||
|
switch (this->licIdentification.licElcType)
|
||||||
|
{
|
||||||
|
case ELCType::ELC1:
|
||||||
|
{ // old eoseov
|
||||||
|
Reader::Licence1 licenceELC1 = Reader::Licence1(this->licIdentification);
|
||||||
|
this->licence1 = &licenceELC1;
|
||||||
|
licenceELC1.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||||
|
licenceELC1.licenceFilePath = initStructure.licenceFilePath;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this->licence1->readLicence(&this->licenceInfo);
|
||||||
|
}
|
||||||
|
catch (const LicenceException &ex)
|
||||||
|
{
|
||||||
|
error.code = ex.getErrorCode();
|
||||||
|
error.message = ex.getErrorMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ELCType::ELC2:
|
||||||
|
{
|
||||||
|
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||||
|
this->licence2 = &licenceELC2;
|
||||||
|
licenceELC2.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||||
|
licenceELC2.licenceFilePath = initStructure.licenceFilePath;
|
||||||
|
this->licence2->readLicence(&this->licenceInfo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ELCType::ELC3:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw LicenceException((int)GeneralError::ELCNotImplemented, "Toto ELC není implementováno");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (const LicenceException &ex)
|
||||||
|
{
|
||||||
|
error.code = ex.getErrorCode();
|
||||||
|
error.message = ex.getErrorMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true; // TODO testy
|
return true; // TODO testy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief vrací informace o licenčím bodu na základě id protocolu a předané návratové struktury
|
||||||
|
/// @param protocolId
|
||||||
|
/// @param returnItemStructure
|
||||||
|
/// @return
|
||||||
bool LicenceReader::getLicenceItemInfo(int protocolId, void *returnItemStructure)
|
bool LicenceReader::getLicenceItemInfo(int protocolId, void *returnItemStructure)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (elcSwitchType)
|
switch (this->licIdentification.licElcType)
|
||||||
{
|
{
|
||||||
case 11:
|
case ELCType::ELC1:
|
||||||
{ // old eoseov
|
{
|
||||||
LicenceItem11 *resultPtr = static_cast<LicenceItem11 *>(returnItemStructure);
|
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||||
resultPtr->protocolId = protocolId;
|
{
|
||||||
if (this->licenceInfo.licences.count(protocolId))
|
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnItemStructure);
|
||||||
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
|
if (this->licenceInfo.licences.count(1)) // stare eov má natvrdo "id" 1.
|
||||||
|
resultPtr->isValid = true;
|
||||||
else
|
else
|
||||||
resultPtr->dataPointsCount = 0;
|
resultPtr->isValid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 21:
|
case ELCType::ELC2:
|
||||||
{
|
{
|
||||||
|
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||||
LicenceItem21 *resultPtr = static_cast<LicenceItem21 *>(returnItemStructure);
|
{
|
||||||
|
LicenceELC2Item *resultPtr = static_cast<LicenceELC2Item *>(returnItemStructure);
|
||||||
resultPtr->protocolId = protocolId; // protocolId;
|
resultPtr->protocolId = protocolId; // protocolId;
|
||||||
if (this->licenceInfo.licences.count(protocolId))
|
if (this->licenceInfo.licences.count(protocolId))
|
||||||
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
|
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
|
||||||
else
|
else
|
||||||
resultPtr->dataPointsCount = 0;
|
resultPtr->dataPointsCount = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (this->licIdentification.licCompatibility)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
// kod pro kompatibilitu 1
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 31:
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ELCType::ELC3:
|
||||||
{
|
{
|
||||||
LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -195,23 +185,71 @@ bool LicenceReader::getLicenceItemInfo(int protocolId, void *returnItemStructure
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief vrací informace o všech licenčních bodech základě předané návratové struktury
|
||||||
|
/// @param returnStructure
|
||||||
|
/// @return
|
||||||
bool LicenceReader::getLicenceInfo(void *returnStructure)
|
bool LicenceReader::getLicenceInfo(void *returnStructure)
|
||||||
{
|
|
||||||
// const type_info& ti1 = typeid(returnStructure);
|
|
||||||
// cout << "TTTYP: " << ti1.name() << endl;
|
|
||||||
switch (elcSwitchType)
|
|
||||||
{
|
|
||||||
case 11:
|
|
||||||
{ // old eoseov
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 21:
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
switch (this->licIdentification.licElcType)
|
||||||
|
{
|
||||||
|
case ELCType::ELC1:
|
||||||
|
{ // old eoseov
|
||||||
|
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||||
|
{
|
||||||
|
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnStructure);
|
||||||
|
|
||||||
|
if (this->licenceInfo.licences.count(1)) // starý EOS má natvrdo "id" 1
|
||||||
|
{
|
||||||
|
resultPtr->isValid = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resultPtr->isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (this->licIdentification.licCompatibility)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
// kod pro kompatibilitu 1
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ELCType::ELC2:
|
||||||
|
{
|
||||||
|
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||||
{
|
{
|
||||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||||
licenceELC2.readLicence(&this->licenceInfo);
|
licenceELC2.readLicence(&this->licenceInfo);
|
||||||
return licenceELC2.getLicenceInfo(returnStructure);
|
licenceELC2.getLicenceInfo(returnStructure);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (this->licIdentification.licCompatibility)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
// kod pro kompatibilitu 1
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ELCType::ELC3:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const LicenceException &ex)
|
catch (const LicenceException &ex)
|
||||||
{
|
{
|
||||||
@@ -219,42 +257,7 @@ bool LicenceReader::getLicenceInfo(void *returnStructure)
|
|||||||
error.message = ex.getErrorMessage();
|
error.message = ex.getErrorMessage();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
// LicenceELC21 licence = LicenceELC21(this->licIdentification);
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// licence.readLicence(&this->licenceInfo);
|
|
||||||
// return licence.getLicenceInfo(returnStructure);
|
|
||||||
// }
|
|
||||||
// catch (const LicenceException &ex)
|
|
||||||
// {
|
|
||||||
// error.code = ex.getErrorCode();
|
|
||||||
// error.message = ex.getErrorMessage();
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 31:
|
|
||||||
{
|
|
||||||
LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// licence.readLicence();
|
|
||||||
// return licence.getLicenceInfo(returnStructure);
|
|
||||||
// }
|
|
||||||
// catch (const LicenceException &ex)
|
|
||||||
// {
|
|
||||||
// error.code = ex.getErrorCode();
|
|
||||||
// error.message = ex.getErrorMessage();
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
error.code = -1;
|
|
||||||
error.message = "Nepodařilo se identifikovat licenci";
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LicenceReader::~LicenceReader()
|
LicenceReader::~LicenceReader()
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
src/reader/LicenceReader.o: src/reader/LicenceReader.cpp \
|
src/reader/LicenceReader.o: src/reader/LicenceReader.cpp \
|
||||||
include/reader/licenceReader.h include/common/utils.h \
|
include/reader/licenceReader.h include/common/utils.h \
|
||||||
include/licenceELC11.h include/common/licenceCommon.h \
|
include/reader/licReaderELC1.h include/common/licenceCommon.h \
|
||||||
include/common/SDCard.h include/licenceELC31.h \
|
include/common/licenceELC1.h include/common/licenceCommon.h \
|
||||||
include/generator/pugixml.hpp include/generator/pugiconfig.hpp \
|
include/common/SDCard.h include/common/SDCard.h \
|
||||||
include/reader/licReaderELC1.h include/reader/licReaderELC2.h \
|
include/reader/licReaderELC2.h include/common/licenceELC2.h \
|
||||||
include/common/licenceELC2.h include/common/licenceCommon.h \
|
include/reader/licReaderELC3.h
|
||||||
include/common/SDCard.h include/reader/licReaderELC3.h
|
|
||||||
|
|||||||
Binary file not shown.
@@ -2,5 +2,123 @@
|
|||||||
|
|
||||||
namespace Reader
|
namespace Reader
|
||||||
{
|
{
|
||||||
|
Licence1::Licence1() {}
|
||||||
|
|
||||||
|
Licence1::~Licence1() {}
|
||||||
|
|
||||||
|
Licence1::Licence1(LicenceIdentification &licIdentification) : LicenceELC1(licIdentification)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief načte seznam licenčních bodů do obecné struktury
|
||||||
|
/// @param licences
|
||||||
|
/// @return
|
||||||
|
bool Licence1::readLicence(LicenceInfoGeneral *licences)
|
||||||
|
{
|
||||||
|
sdCard = SDCard(this->cid_cdsPath);
|
||||||
|
if (sdCard.isLoaded == false) throw LicenceException((int)GeneralError::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < CID_LENGTH;i++) this->cid[i] = sdCard.cid[i];
|
||||||
|
for (unsigned int i = 0; i < CSD_LENGTH;i++) this->csd[i] = sdCard.csd[i];
|
||||||
|
|
||||||
|
if (getSDData() == false) throw LicenceException((int)GeneralError::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath);
|
||||||
|
|
||||||
|
string licFileName = getLicenceName(0);
|
||||||
|
string licFilePath = this->licenceFilePath + licFileName;
|
||||||
|
|
||||||
|
char licFileNameToRead[licFilePath.length()+1] = {};
|
||||||
|
getCharsFromString(licFilePath, licFileNameToRead, licFilePath.length());
|
||||||
|
|
||||||
|
FILE *licenceFile;
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
licenceFile = fopen(licFileNameToRead, "rb");
|
||||||
|
|
||||||
|
if (licenceFile == nullptr) throw LicenceException((int)GeneralError::LicenceReadError, "LicenceReadError: " + licFilePath);
|
||||||
|
|
||||||
|
fseek(licenceFile, 0, SEEK_END);
|
||||||
|
const int size = ftell(licenceFile);
|
||||||
|
fseek(licenceFile, 0, SEEK_SET);
|
||||||
|
|
||||||
|
if (size <= 0) throw LicenceException((int)GeneralError::LicenceSizeMismatch, "LicenceSizeMismatch: " + licFilePath);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
unsigned char licenceContent[size];
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
ch = fgetc(licenceFile);
|
||||||
|
licenceContent[i] = ch;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(licenceFile);
|
||||||
|
|
||||||
|
LicenceDataMainELC licenceHeader{};
|
||||||
|
LicenceData licEncryptedData{};
|
||||||
|
|
||||||
|
memcpy(&licenceHeader, licenceContent, sizeof(LicenceDataMainELC));
|
||||||
|
|
||||||
|
const int sizeOfEncryptedData = size - sizeof(LicenceDataMainELC);
|
||||||
|
unsigned char encryptedData[sizeOfEncryptedData] = {};
|
||||||
|
for (int i = 0; i < sizeOfEncryptedData; i++)
|
||||||
|
encryptedData[i] = licenceContent[i + sizeof(LicenceDataMainELC)];
|
||||||
|
|
||||||
|
BYTE prefixType = (int)licenceContent[3] - 0x30;
|
||||||
|
if (prefixType == PrefixType::ELC1)
|
||||||
|
{
|
||||||
|
if (licenceHeader.licHeader.sizeData > 0)
|
||||||
|
{
|
||||||
|
if (licenceHeader.licHeader.licSubType == cEzLic_p78ou3_SubType_10_10)
|
||||||
|
{
|
||||||
|
initCrypto();
|
||||||
|
|
||||||
|
unsigned char decrypted[2000] = {};
|
||||||
|
int decrypted_len = decrypt(encryptedData, sizeof(encryptedData), cryptData.aesKey, cryptData.aesInitVector, decrypted);
|
||||||
|
|
||||||
|
if (sizeof(licEncryptedData) != decrypted_len)
|
||||||
|
{
|
||||||
|
throw LicenceException((int)GeneralError::LicenceSizeMismatch, "License size mismatch ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(&licEncryptedData, decrypted, sizeof(licEncryptedData));
|
||||||
|
|
||||||
|
if (licEncryptedData.id.version == cEzLic_p78ou3_HeaderType_10 && licEncryptedData.header.licVersion == cEzLic_p78ou3_HeaderType_10)
|
||||||
|
{
|
||||||
|
if (licEncryptedData.header.licType == cEzLic_p78ou3_IDType_EOVOSV)
|
||||||
|
{
|
||||||
|
if (licEncryptedData.header.licCount > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < licMaxCount; i++)
|
||||||
|
{
|
||||||
|
licences->licences.insert(pair<int, int>(licEncryptedData.items[i].protoId, licEncryptedData.items[i].licCount));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw LicenceException((int)GeneralError::ItemsCountMismatch, "ItemsCountMismatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw LicenceException((int)GeneralError::LicenceMismatch, "Licence mismatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw LicenceException((int)GeneralError::LicenceMismatch, "Licence mismatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw LicenceException((int)GeneralError::LicenceReadError, "Licence error");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
src/reader/licReaderELC1.o: src/reader/licReaderELC1.cpp \
|
src/reader/licReaderELC1.o: src/reader/licReaderELC1.cpp \
|
||||||
include/reader/licReaderELC1.h
|
include/reader/licReaderELC1.h include/common/utils.h \
|
||||||
|
include/common/licenceCommon.h include/common/licenceELC1.h \
|
||||||
|
include/common/licenceCommon.h include/common/SDCard.h \
|
||||||
|
include/common/SDCard.h
|
||||||
|
|||||||
Binary file not shown.
@@ -11,7 +11,7 @@ namespace Reader
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief načte licence do obecné struktury ELC2
|
/// @brief načte seznam licenčních bodů do obecné struktury
|
||||||
/// @param licences
|
/// @param licences
|
||||||
/// @return
|
/// @return
|
||||||
bool Licence2::readLicence(LicenceInfoGeneral *licences)
|
bool Licence2::readLicence(LicenceInfoGeneral *licences)
|
||||||
@@ -93,7 +93,7 @@ namespace Reader
|
|||||||
{
|
{
|
||||||
if (returnStructure != nullptr)
|
if (returnStructure != nullptr)
|
||||||
{
|
{
|
||||||
LicenceInfo21 *resultPtr = static_cast<LicenceInfo21 *>(returnStructure);
|
LicenceELC2Info *resultPtr = static_cast<LicenceELC2Info *>(returnStructure);
|
||||||
for (auto item : this->licBody.privateContent.dataItems)
|
for (auto item : this->licBody.privateContent.dataItems)
|
||||||
{
|
{
|
||||||
resultPtr->licences.insert(pair<int, int>(item.protoId, item.licCount));
|
resultPtr->licences.insert(pair<int, int>(item.protoId, item.licCount));
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user