ELC 3
This commit is contained in:
@@ -52,6 +52,7 @@ enum class GeneralError
|
||||
LicenceSizeCardMismatch = 53,
|
||||
LicenceMismatch = 54,
|
||||
LicenceCRCMismatch = 54,
|
||||
UIDReadError = 55,
|
||||
ItemsCountMismatch = 61
|
||||
};
|
||||
|
||||
@@ -168,6 +169,13 @@ struct LicenceELC2Info
|
||||
map<DWORD, DWORD> licences = {};
|
||||
};
|
||||
|
||||
/* struktury pro ELC 3 */
|
||||
// defaultní struktura pro ELC 3
|
||||
struct LicenceELC3Info
|
||||
{
|
||||
map<DWORD, DWORD> licences = {};
|
||||
};
|
||||
|
||||
// struct LicenceELC2Info_1
|
||||
// {
|
||||
// map<int, int> licences = {};
|
||||
@@ -180,13 +188,27 @@ struct LicenceELC2Item
|
||||
DWORD dataPointsCount{};
|
||||
};
|
||||
|
||||
// struktura polozky ELC 2,
|
||||
// struktura polozky ELC 2 pro další kompatibility
|
||||
struct LicenceELC2Item_1
|
||||
{
|
||||
DWORD protocolId{};
|
||||
DWORD dataPointsCount{};
|
||||
};
|
||||
|
||||
// defaultni struktura polozky ELC 3
|
||||
struct LicenceELC3Item
|
||||
{
|
||||
DWORD protocolId{};
|
||||
DWORD dataPointsCount{};
|
||||
};
|
||||
|
||||
// struktura polozky ELC 3 pro další kompatibility,
|
||||
struct LicenceELC3Item_1
|
||||
{
|
||||
DWORD protocolId{};
|
||||
DWORD dataPointsCount{};
|
||||
};
|
||||
|
||||
class LicenceException : public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
89
include/common/licenceELC3.h
Normal file
89
include/common/licenceELC3.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#ifndef EZ_APPLICATION_LICENCE_DISABLE
|
||||
|
||||
#ifndef PLC_LICENCE3_COMMON_H
|
||||
#define PLC_LICENCE3_COMMON_H
|
||||
|
||||
#define UID_LENGTH 32
|
||||
|
||||
#include <vector>
|
||||
#include "licenceCommon.h"
|
||||
|
||||
/// @brief společná třída pro pro reader i generator licence typu ELC2
|
||||
class LicenceELC3
|
||||
{
|
||||
public:
|
||||
LicenceELC3();
|
||||
LicenceELC3(LicenceIdentification &licIdentification);
|
||||
~LicenceELC3();
|
||||
|
||||
string licenceFilePath = "";
|
||||
string licFileName = "";
|
||||
string uid = "";
|
||||
BYTE uidb[UID_LENGTH] = {};
|
||||
string uid_path = ""; ///etc/machine-id
|
||||
|
||||
|
||||
Mapping mapping;
|
||||
|
||||
ErrorMessage errorMessage;
|
||||
|
||||
struct LicenceId
|
||||
{
|
||||
char licIdent[5] = {'E', 'L', 'C', '0', '_'};
|
||||
};
|
||||
|
||||
// struct __attribute__((__packed__)) LicencePublicHeader
|
||||
struct LicenceIdentDataHeader
|
||||
{
|
||||
BYTE licenceType{}; // EOSEOV, DRT ...
|
||||
BYTE licenceTypeVersion = 1; // verze licence, urcuje nuance sifrování a pojmenování souborů
|
||||
BYTE licenceIndex{}; // puvodní post fix, identifikátor pro více licencí
|
||||
BYTE compatibilityVersion = 1; // udava verzi komplet PrivateContent
|
||||
BYTE licItemCount{}; // počet protokolů v linenci
|
||||
WORD publicHeaderLength{}; // délka veřejné hlavičy
|
||||
// WORD cardSize{}; // velikost SD karty
|
||||
// DWORD serialNumber = {}; // seriove cislo karty
|
||||
};
|
||||
|
||||
struct licDataItem
|
||||
{
|
||||
DWORD protoId{}; // id protokolu pro ktery je licence
|
||||
DWORD licCount{}; // pocet datovych bodu licence
|
||||
};
|
||||
|
||||
struct PublicHeader
|
||||
{
|
||||
string version = "";
|
||||
string projectDescription = "";
|
||||
string date = "";
|
||||
string licenceType = "";
|
||||
};
|
||||
|
||||
struct PrivateContent // privátní šifrovaná část
|
||||
{
|
||||
LicenceIdentDataHeader licenceIdentHeader{};
|
||||
vector<licDataItem> dataItems{};
|
||||
WORD crc{};
|
||||
};
|
||||
|
||||
struct LicenceBody
|
||||
{
|
||||
LicenceId licId{};
|
||||
LicenceIdentDataHeader licenceIdentHeader{};
|
||||
string publicHeader = ""; // JSON
|
||||
PrivateContent privateContent{};
|
||||
};
|
||||
|
||||
protected:
|
||||
vector<unsigned char> cryptPrivateContent(const std::vector<unsigned char> &content);
|
||||
vector<unsigned char> decryptPrivateContent(const std::vector<unsigned char> &content);
|
||||
void initVector(BYTE *iVector, BYTE *key);
|
||||
string getLicenceName();
|
||||
LicenceBody licBody{};
|
||||
LicenceIdentification lIdentification{};
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,9 +1,38 @@
|
||||
#ifndef ELC3_GENERATOR__H
|
||||
#define ELC3_GENERATOR__H
|
||||
#ifndef ELC3_GENERATOR_H
|
||||
#define ELC3_GENERATOR_H
|
||||
|
||||
#include "utils.h"
|
||||
#include "licenceCommon.h"
|
||||
#include "licenceELC3.h"
|
||||
#include "pugixml.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Generator
|
||||
{
|
||||
|
||||
class Licence3 : public LicenceELC3
|
||||
{
|
||||
|
||||
public:
|
||||
Licence3();
|
||||
Licence3(string uuid, pugi::xml_document * xmlDoc);
|
||||
~Licence3();
|
||||
|
||||
string cid = "";
|
||||
string csd = "";
|
||||
pugi::xml_document *xmlDoc;
|
||||
string projectDescription = "";
|
||||
|
||||
bool createLicence();
|
||||
|
||||
private:
|
||||
void getHeader();
|
||||
string getVersion(int middleVersion);
|
||||
bool processInputConfiguration();
|
||||
void getLicenceItems();
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,9 +3,29 @@
|
||||
#ifndef ELC3_READER__H
|
||||
#define ELC3_READER__H
|
||||
|
||||
#include "utils.h"
|
||||
#include "licenceCommon.h"
|
||||
#include "licenceELC3.h"
|
||||
|
||||
namespace Reader
|
||||
{
|
||||
|
||||
class Licence3 : public LicenceELC3
|
||||
{
|
||||
public:
|
||||
LicenceELC3Info licenceInfo;
|
||||
|
||||
Licence3();
|
||||
~Licence3();
|
||||
Licence3(LicenceIdentification &licIdentification);
|
||||
|
||||
bool readLicence(LicenceInfoGeneral *licences);
|
||||
bool getLicenceInfo(void *ptr);
|
||||
void getLicenceItems();
|
||||
|
||||
private:
|
||||
bool getUID();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,7 @@ struct InitStructure
|
||||
int compatibility = 0;
|
||||
string licenceFilePath = "";
|
||||
string cid_csd_filePath = "";
|
||||
string uid_filePath = "";
|
||||
};
|
||||
|
||||
/// @brief struktura pro informaci o licenci
|
||||
@@ -49,6 +50,7 @@ public:
|
||||
bool getLicenceItemInfo(int protocolId, void *returnItemStructure); //vrací informace o licenčím bodu na základě id protocolu a předané návratové struktury
|
||||
|
||||
private:
|
||||
Licence3 *licence3 {}; //interní struktura pro zpracování licence ELC2
|
||||
Licence2 *licence2 {}; //interní struktura pro zpracování licence ELC2
|
||||
Licence1 *licence1 {}; //interní struktura pro zpracování licence ELC1
|
||||
LicenceIdentification licIdentification {};
|
||||
|
||||
Reference in New Issue
Block a user