oddělení, čištění, kontrola ELC1
This commit is contained in:
@@ -10,6 +10,9 @@ namespace Reader
|
||||
{
|
||||
}
|
||||
|
||||
/// @brief načte seznam licenčních bodů do obecné struktury
|
||||
/// @param licences
|
||||
/// @return
|
||||
bool Licence1::readLicence(LicenceInfoGeneral *licences)
|
||||
{
|
||||
sdCard = SDCard(this->cid_cdsPath);
|
||||
@@ -20,11 +23,6 @@ namespace Reader
|
||||
|
||||
if (getSDData() == false) throw LicenceException((int)GeneralError::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath);
|
||||
|
||||
for (unsigned int i = 0; i < sdCard.cidString.length(); i++)
|
||||
this->cid[i] = sdCard.cidString[i]; // nutné pro původní algoritmus
|
||||
for (unsigned int i = 0; i < sdCard.csdString.length(); i++)
|
||||
this->csd[i] = sdCard.csdString[i]; // nutné pro původní algoritmus
|
||||
|
||||
string licFileName = getLicenceName(0);
|
||||
string licFilePath = this->licenceFilePath + licFileName;
|
||||
|
||||
@@ -34,12 +32,12 @@ namespace Reader
|
||||
FILE *licenceFile;
|
||||
char ch;
|
||||
|
||||
licenceFile = fopen(licFileNameToRead, "rb"); // read mode
|
||||
licenceFile = fopen(licFileNameToRead, "rb");
|
||||
|
||||
if (licenceFile == nullptr) throw LicenceException((int)GeneralError::LicenceReadError, "LicenceReadError: " + licFilePath);
|
||||
|
||||
fseek(licenceFile, 0, SEEK_END); // seek to end of file
|
||||
const int size = ftell(licenceFile); // get current file pointer
|
||||
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);
|
||||
@@ -75,7 +73,7 @@ namespace Reader
|
||||
if (licenceHeader.licHeader.licSubType == cEzLic_p78ou3_SubType_10_10)
|
||||
{
|
||||
initCrypto();
|
||||
// CryptData cryptData = initCrypto(sdData, licIdent.licIDType);
|
||||
|
||||
unsigned char decrypted[2000] = {};
|
||||
int decrypted_len = decrypt(encryptedData, sizeof(encryptedData), cryptData.aesKey, cryptData.aesInitVector, decrypted);
|
||||
|
||||
@@ -85,7 +83,6 @@ namespace Reader
|
||||
}
|
||||
else
|
||||
{
|
||||
// memset(&licEncryptedData, 0, sizeof(licEncryptedData));
|
||||
memcpy(&licEncryptedData, decrypted, sizeof(licEncryptedData));
|
||||
|
||||
if (licEncryptedData.id.version == cEzLic_p78ou3_HeaderType_10 && licEncryptedData.header.licVersion == cEzLic_p78ou3_HeaderType_10)
|
||||
@@ -101,7 +98,7 @@ namespace Reader
|
||||
}
|
||||
else
|
||||
{
|
||||
throw LicenceException((int)GeneralError::LicenceSizeCardMismatch, "Size card info mismatch");
|
||||
throw LicenceException((int)GeneralError::ItemsCountMismatch, "ItemsCountMismatch");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user