kk
This commit is contained in:
@@ -4,6 +4,7 @@ Generování licence pro SD kartu
|
|||||||
|
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
/bin/bash
|
||||||
- docker-compose up, spustí kontejner
|
- docker-compose up, spustí kontejner
|
||||||
- otevření terminálu konterjneru, docker exec -it sd_gen-sd_gen-1 /bin/bash
|
- otevření terminálu konterjneru, docker exec -it sd_gen-sd_gen-1 /bin/bash
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ typedef uint32_t DWORD; // DWORD = unsigned 32 bit value
|
|||||||
typedef uint16_t WORD; // WORD = unsigned 16 bit value
|
typedef uint16_t WORD; // WORD = unsigned 16 bit value
|
||||||
typedef uint8_t BYTE; // BYTE = unsigned 8 bit value
|
typedef uint8_t BYTE; // BYTE = unsigned 8 bit value
|
||||||
typedef uint32_t UDINT;
|
typedef uint32_t UDINT;
|
||||||
typedef unsigned long DATE;
|
typedef uint32_t DATE;
|
||||||
typedef uint8_t USINT;
|
typedef uint8_t USINT;
|
||||||
typedef int32_t DINT;
|
typedef int32_t DINT;
|
||||||
typedef uint16_t UINT;
|
typedef uint16_t UINT;
|
||||||
@@ -213,8 +213,8 @@ class PlcLicence
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
string cidString = "";
|
string cidString = "";
|
||||||
string csdString = "";
|
|
||||||
char *cid; // CID
|
char *cid; // CID
|
||||||
|
string csdString = "";
|
||||||
char *csd; // CSD
|
char *csd; // CSD
|
||||||
string stationName; // name of station
|
string stationName; // name of station
|
||||||
string distributor; // name of switch
|
string distributor; // name of switch
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ typedef uint32_t DWORD;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DATE
|
#ifndef DATE
|
||||||
typedef unsigned long DATE;
|
typedef uint32_t DATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -109,26 +108,10 @@ int main(int argc, char *argv[])
|
|||||||
const int csdLength = argumentsString["-csd"].length();
|
const int csdLength = argumentsString["-csd"].length();
|
||||||
char csdArg[32] = {};
|
char csdArg[32] = {};
|
||||||
getCharsFromString(argumentsString["-csd"], csdArg, csdLength);
|
getCharsFromString(argumentsString["-csd"], csdArg, csdLength);
|
||||||
//cout << "csd delka pred: " << strlen(csdArg) << "\n";
|
|
||||||
|
|
||||||
//cout << "csd delka po: " << strlen(csdArg) << "\n";
|
|
||||||
//cout << "csd:" << csdArg << "\n";
|
|
||||||
|
|
||||||
const int cidLength = argumentsString["-cid"].length();
|
const int cidLength = argumentsString["-cid"].length();
|
||||||
char cidArg[32] = {};
|
char cidArg[32] = {};
|
||||||
getCharsFromString(argumentsString["-cid"], cidArg, cidLength);
|
getCharsFromString(argumentsString["-cid"], cidArg, cidLength);
|
||||||
//cout << "cid delka pred: " << strlen(cidArg) << "\n";
|
|
||||||
|
|
||||||
//for (int i=0;i<32;i++) cidArg[i]=argumentsString["-cid"][i];
|
|
||||||
//cout << "cid delka po: " << strlen(cidArg) << "\n";
|
|
||||||
//cout << "cid delka sizeof po: " << sizeof(cidArg) << "\n";
|
|
||||||
//cout << "cid:" << cidArg;
|
|
||||||
|
|
||||||
// char cidTest = getCharArray(argumentsString["-cid"]);
|
|
||||||
|
|
||||||
// PlcLicence plcWriteLicence = PlcLicence(argumentsString);
|
|
||||||
// PlcLicence plcWriteLicence = PlcLicence(cidArg, csdArg, stationName, switchName, licenceType, binaryType, nullptr);
|
|
||||||
// PlcLicence plcWriteLicence = PlcLicence(arguments["-cid"], arguments["-csd"], stationName, switchName, licenceType, binaryType, nullptr);
|
|
||||||
|
|
||||||
PlcLicence plcWriteLicence = PlcLicence(cidArg, csdArg, argumentsString["-outputType"], argumentsString["-configFileName"]);
|
PlcLicence plcWriteLicence = PlcLicence(cidArg, csdArg, argumentsString["-outputType"], argumentsString["-configFileName"]);
|
||||||
if (plcWriteLicence.CreateLicence() == false)
|
if (plcWriteLicence.CreateLicence() == false)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#define CID_LENGTH 32
|
#define CID_LENGTH 32
|
||||||
#define CSD_LENGTH 32
|
#define CSD_LENGTH 32
|
||||||
|
|
||||||
|
|
||||||
const std::string cEzLic_p78ou3_sdinfofilepath = "/sys/block/mmcblk0/device/";
|
const std::string cEzLic_p78ou3_sdinfofilepath = "/sys/block/mmcblk0/device/";
|
||||||
const std::string cEzLic_p78ou3_licencfilepath_f21 = "/mnt/mmc/ez_sys/licence/";
|
const std::string cEzLic_p78ou3_licencfilepath_f21 = "/mnt/mmc/ez_sys/licence/";
|
||||||
const std::string cEzLic_p78ou3_licencfilepath_f17 = "/home/admin/ez/licence/";
|
const std::string cEzLic_p78ou3_licencfilepath_f17 = "/home/admin/ez/licence/";
|
||||||
@@ -607,6 +608,16 @@ bool PlcLicence::CreateLicence()
|
|||||||
|
|
||||||
LicenceSourceData licSourceData;
|
LicenceSourceData licSourceData;
|
||||||
|
|
||||||
|
// cout << "size of WORD:" << sizeof(WORD) << endl;
|
||||||
|
// cout << "size of DWORD:" << sizeof(DWORD) << endl;
|
||||||
|
// cout << "size of DATE:" << sizeof(DATE) << endl;
|
||||||
|
// cout << "size of BYTE:" << sizeof(BYTE) << endl;
|
||||||
|
// cout << "size of int:" << sizeof(int) << endl;
|
||||||
|
// cout << "size of char:" << sizeof(char) << endl;
|
||||||
|
// cout << "size of float:" << sizeof(float) << endl;
|
||||||
|
// cout << "Size of dataToFile: " << sizeof(dataToFile) << endl;
|
||||||
|
// return true;
|
||||||
|
|
||||||
if (plcData.licenceType == "EOV" || plcData.licenceType == to_string((int)LicenceType::LicenceEov))
|
if (plcData.licenceType == "EOV" || plcData.licenceType == to_string((int)LicenceType::LicenceEov))
|
||||||
{
|
{
|
||||||
licSourceData.licType = 0x1AA2; // 6818 ... proč ?
|
licSourceData.licType = 0x1AA2; // 6818 ... proč ?
|
||||||
@@ -657,7 +668,7 @@ bool PlcLicence::CreateLicence()
|
|||||||
|
|
||||||
dataToFile.header.licVersion = 10;
|
dataToFile.header.licVersion = 10;
|
||||||
dataToFile.header.licType = licIdent.licIDType;
|
dataToFile.header.licType = licIdent.licIDType;
|
||||||
dataToFile.header.licDate = getLicDate();
|
dataToFile.header.licDate = getLicDate(); //1692230400; //getLicDate(); //1692144000;// getLicDate();
|
||||||
mainLicDescription += dataToFile.header.licDescription1;
|
mainLicDescription += dataToFile.header.licDescription1;
|
||||||
mainLicDescription += " [";
|
mainLicDescription += " [";
|
||||||
mainLicDescription += dataToFile.header.licDescription2;
|
mainLicDescription += dataToFile.header.licDescription2;
|
||||||
@@ -715,6 +726,8 @@ bool PlcLicence::CreateLicence()
|
|||||||
unsigned char bdataMainToFileELC1[dataMainLength] = {};
|
unsigned char bdataMainToFileELC1[dataMainLength] = {};
|
||||||
memcpy(bdataMainToFileELC1, &dataMainToFileELC1, dataMainLength);
|
memcpy(bdataMainToFileELC1, &dataMainToFileELC1, dataMainLength);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char bdataToFile[dataToFileLength] = {};
|
unsigned char bdataToFile[dataToFileLength] = {};
|
||||||
memcpy(bdataToFile, &dataToFile, dataToFileLength);
|
memcpy(bdataToFile, &dataToFile, dataToFileLength);
|
||||||
unsigned char totalEncryptedArray[totalEncryptedLength] = {};
|
unsigned char totalEncryptedArray[totalEncryptedLength] = {};
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
const std::string base64_chars =
|
const std::string base64_chars =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
@@ -385,6 +386,7 @@ DateAndTime getCurrentDateTimeAsCODESYSDateTime()
|
|||||||
return codesysDateTime;
|
return codesysDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DATE getLicDate()
|
DATE getLicDate()
|
||||||
{
|
{
|
||||||
time_t ttime = time(0);
|
time_t ttime = time(0);
|
||||||
@@ -393,10 +395,17 @@ DATE getLicDate()
|
|||||||
int minutesSeconds = 60 * local_time->tm_min;
|
int minutesSeconds = 60 * local_time->tm_min;
|
||||||
int seconds = 1 * local_time->tm_sec;
|
int seconds = 1 * local_time->tm_sec;
|
||||||
int totalSeconds = hoursSeconds + minutesSeconds + seconds;
|
int totalSeconds = hoursSeconds + minutesSeconds + seconds;
|
||||||
DATE dateOnly = ttime - totalSeconds + 7200; // 7200 + vteřina za dvě hodiny pro srování
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
DATE dateOnly = ttime - totalSeconds + 7200;// (pro windows); // 7200 + vteřina za dvě hodiny pro srování
|
||||||
|
#else
|
||||||
|
DATE dateOnly = ttime - totalSeconds;
|
||||||
|
#endif
|
||||||
|
|
||||||
return dateOnly;
|
return dateOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<unsigned char> aes256_cbc_encrypt(const std::vector<unsigned char> &plaintext, const std::vector<unsigned char> &key, const std::vector<unsigned char> &iv)
|
std::vector<unsigned char> aes256_cbc_encrypt(const std::vector<unsigned char> &plaintext, const std::vector<unsigned char> &key, const std::vector<unsigned char> &iv)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> ciphertext;
|
std::vector<unsigned char> ciphertext;
|
||||||
|
|||||||
Reference in New Issue
Block a user