This commit is contained in:
Elena.Subbotina
2021-12-08 20:05:06 +03:00
parent 0756b8ff90
commit a707ded8b2
2 changed files with 10 additions and 6 deletions

View File

@ -1140,6 +1140,8 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
unsigned char* data_inp = data_inp_ptr; unsigned char* data_inp = data_inp_ptr;
unsigned char* data_out = data_out_ptr + 8; unsigned char* data_out = data_out_ptr + 8;
int result_size_out = 0;
if (cryptData.bAgile) if (cryptData.bAgile)
{ {
_buf pBlockKey ((unsigned char*)encrKeyValueBlockKey, 8); _buf pBlockKey ((unsigned char*)encrKeyValueBlockKey, 8);
@ -1204,7 +1206,7 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
enc_size += sz; i++; enc_size += sz; i++;
} }
return enc_size + 8; result_size_out = enc_size + 8;
} }
else else
{ {
@ -1221,8 +1223,9 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
EncryptCipher(hashKey, empty, pInp, pOut, cryptData.cipherAlgorithm/*, StreamTransformationFilter::ZEROS_PADDING*/); EncryptCipher(hashKey, empty, pInp, pOut, cryptData.cipherAlgorithm/*, StreamTransformationFilter::ZEROS_PADDING*/);
return size_out + 8; result_size_out = size_out + 8;
} }
return result_size_out;
} }
//----------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------
ODFDecryptor::ODFDecryptor() ODFDecryptor::ODFDecryptor()

View File

@ -725,7 +725,7 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s
_UINT64 lengthFileSize = file.GetFileSize(); _UINT64 lengthFileSize = file.GetFileSize();
DWORD lengthData = lengthFileSize, lengthDataRead = 0 ; DWORD lengthData = lengthFileSize, lengthDataRead = 0 ;
unsigned char* data = new unsigned char[lengthData]; unsigned char* data = new unsigned char[lengthData];
unsigned char* data_out = NULL; unsigned char* data_out = NULL;
file.ReadFile(data, lengthData, lengthDataRead); file.ReadFile(data, lengthData, lengthDataRead);
@ -734,9 +734,10 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s
lengthData = cryptor.Encrypt(data, lengthData, data_out); lengthData = cryptor.Encrypt(data, lengthData, data_out);
delete[]data; data = NULL;
if (NULL == data_out) if (NULL == data_out)
{ {
delete []data;
return false; return false;
} }
cryptor.UpdateDataIntegrity(data_out, lengthData); cryptor.UpdateDataIntegrity(data_out, lengthData);
@ -910,7 +911,7 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s
// //
// if (decryptor.SetPassword(password)) // if (decryptor.SetPassword(password))
// { // {
// unsigned char* data_out2 = NULL; // unsigned char* data_out2 = NULL;
// decryptor.Decrypt(data_out, lengthData, data_out2, 0); // decryptor.Decrypt(data_out, lengthData, data_out2, 0);
// //
// bool bDataIntegrity = decryptor.CheckDataIntegrity(data_out, lengthData); // bool bDataIntegrity = decryptor.CheckDataIntegrity(data_out, lengthData);
@ -1029,7 +1030,7 @@ bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const s
{ {
_UINT64 lengthData, lengthRead = pStream->size(); _UINT64 lengthData, lengthRead = pStream->size();
unsigned char* data = new unsigned char[lengthRead]; unsigned char* data = new unsigned char[lengthRead];
unsigned char* data_out = NULL; unsigned char* data_out = NULL;
int readTrue = pStream->read(data, lengthRead); int readTrue = pStream->read(data, lengthRead);