This commit is contained in:
Elena.Subbotina
2023-07-24 10:03:53 +03:00
parent fa2595612e
commit 93dc58c49e
2 changed files with 8 additions and 6 deletions

View File

@ -747,8 +747,10 @@ bool ECMADecryptor::CheckDataIntegrity(unsigned char* data, int size)
return (hmac == expected);
}
void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*& data_out, unsigned long start_iv_block)
void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*& data_out, unsigned long start_iv_block)
{
if (!data_inp || size < 0) return;
data_out = new unsigned char[size];
_buf pPassword (password);

View File

@ -1084,18 +1084,18 @@ bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const s
unsigned char* data = new unsigned char[lengthRead];
unsigned char* data_out = NULL;
int readTrue = pStream->read(data, lengthRead);
int readData = readTrue - 8;
_UINT64 readTrue = pStream->read(data, lengthRead);
_UINT64 readData = readTrue - 8;
lengthData = *((_UINT64*)data);
lengthData = (std::min)(*((_UINT64*)data), readData);
decryptor.Decrypt(data + 8, readData, data_out, 0);//todoo сделать покусочное чтение декриптование
decryptor.Decrypt(data + 8, (int)readData, data_out, 0);
if (data_out)
{
NSFile::CFileBinary f;
f.CreateFileW(file_name_out);
f.WriteFile(data_out, (std::min)((int)lengthData, readData));
f.WriteFile(data_out, lengthData);
f.CloseFile();
delete []data_out;