oddělení generatoru od readeru

This commit is contained in:
2024-01-29 14:50:12 +01:00
parent 36a799057c
commit a7fc519138
62 changed files with 1147 additions and 932 deletions

View File

@@ -5,6 +5,7 @@
#include <stdint.h>
#include <unordered_map>
#include "licenceCommon.h"
#include "pugixml.hpp"
#include "SDCard.h"
using namespace std;
@@ -12,22 +13,33 @@ using namespace std;
class LicenceELC21
{
struct LicData
{
string station = "";
string distributor = "";
string licenceName = "";
string projectDescription = "";
string cid = ""; // CID z SD karty
string csd = ""; // CSD z SD karty
string uid = ""; // jedinečný identifikátor z jiného systému
pugi::xml_document *doc;
};
public:
ErrorMessage errorMessage;
LicenceInfo21 licenceInfo;
string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/
string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/
string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\";
LicenceELC21();
~LicenceELC21();
LicenceELC21(LicenceIdentification & licIdentification, LicData & icData);
LicenceELC21(LicenceIdentification & licIdentification);
LicenceELC21(LicData & icData);
LicenceELC21(LicenceIdentification &licIdentification, LicData &licData);
LicenceELC21(LicenceIdentification &licIdentification);
LicenceELC21(LicData &licData);
bool createLicence();
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);
enum class Error21
@@ -48,31 +60,31 @@ public:
{Error21::LicenceMismatch, "Nesouhlasí licence."},
{Error21::ItemsCountMismatch, "Nesouhlasí počet položek licence."},
};
struct LicenceId
{
char licIdent[5] = { 'E', 'L', 'C', '0','_'};
char licIdent[5] = {'E', 'L', 'C', '0', '_'};
};
//struct __attribute__((__packed__)) LicencePublicHeader
// struct __attribute__((__packed__)) LicencePublicHeader
struct LicenceIdentDataHeader
{
BYTE licenceType = 0; //EOSEOV, DRT ...
BYTE licenceTypeVersion = 1; //verze licence, urcuje nuance sifrování a pojmenování souborů
BYTE licenceIndex = 0; //puvodní post fix, identifikátor pro více licencí
BYTE compatibilityVersion = 1; //udava verzi komplet PrivateContent
BYTE licItemCount = 0; //počet licenčních bodů
WORD publicHeaderLength = 0; //délka veřejné hlavičy
WORD cardSize = 0; //velikost SD karty
DWORD serialNumber = 0;//seriove cislo karty
BYTE licenceType = 0; // EOSEOV, DRT ...
BYTE licenceTypeVersion = 1; // verze licence, urcuje nuance sifrování a pojmenování souborů
BYTE licenceIndex = 0; // puvodní post fix, identifikátor pro více licencí
BYTE compatibilityVersion = 1; // udava verzi komplet PrivateContent
BYTE licItemCount = 0; // počet licenčních bodů
WORD publicHeaderLength = 0; // délka veřejné hlavičy
WORD cardSize = 0; // velikost SD karty
DWORD serialNumber = 0; // seriove cislo karty
};
///
///
struct licDataItem
{
WORD protoId = 0; // id protokolu pro ktery je licence
WORD licCount = 0; // pocet datovych bodu licence
char dummy[64] = {};
WORD protoId = 0; // id protokolu pro ktery je licence
WORD licCount = 0; // pocet datovych bodu licence
char dummy[64] = {}; // dummy pro větší velikost licence v případě méně licenčních bodů
};
struct PublicHeader
@@ -84,7 +96,7 @@ public:
int crc = 0;
};
struct PrivateContent //privátní šifrovaná část
struct PrivateContent // privátní šifrovaná část
{
LicenceIdentDataHeader licenceIdentHeader;
vector<licDataItem> dataItems;
@@ -95,12 +107,11 @@ public:
{
LicenceId licId;
LicenceIdentDataHeader licenceIdentHeader;
string publicHeader = ""; //JSON
PrivateContent privateContent;
string publicHeader = ""; // JSON
PrivateContent privateContent;
};
private:
private:
int licItemCount = 0;
LicenceBody licBody;
LicenceIdentification lIdentification;
@@ -110,11 +121,10 @@ public:
string getVersion(int middleVersion);
void getLicenceItems();
bool processInputConfiguration();
vector<unsigned char> cryptPrivateContent(const std::vector<unsigned char>& content);
vector<unsigned char> decryptPrivateContent(const std::vector<unsigned char>& content);
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();
};
#endif