Commit ebdfcbd7 authored by ElenaSubbotina's avatar ElenaSubbotina

PprFormatReader - read encrypted files

parent 867c09c8
...@@ -153,6 +153,24 @@ namespace DocFileFormat ...@@ -153,6 +153,24 @@ namespace DocFileFormat
} }
else else
{ {
//POLE::Stream * pStream = NULL;
//if (m_pStorage->GetStream ("EncryptedSummaryInformation", &pStream))
//{
// VirtualStreamReader tStream( pStream, 0, FIB->m_bOlderVersion);
// _UINT32 StreamDescriptorArrayOffset = tStream.ReadUInt32();
// _UINT32 StreamDescriptorArraySize = tStream.ReadUInt32();
// for (int i = 0; i < StreamDescriptorArraySize; i++)
// {
// }
// _UINT32 EncryptedStreamDescriptorCount = tStream.ReadUInt32();
// for (int i = 0; i < EncryptedStreamDescriptorCount; i++)
// {
// }
// RELEASEOBJECT(pStream);
//}
CRYPT::ECMADecryptor Decryptor; CRYPT::ECMADecryptor Decryptor;
Decryptor.SetCryptData(encryptionHeader->crypt_data_aes); Decryptor.SetCryptData(encryptionHeader->crypt_data_aes);
...@@ -470,11 +488,6 @@ namespace DocFileFormat ...@@ -470,11 +488,6 @@ namespace DocFileFormat
delete storageOut; delete storageOut;
return false; return false;
} }
//DecryptStream(Decryptor, "WordDocument", storageIn, storageOut);
//if (FIB->m_FibBase.fWhichTblStm)
// DecryptStream(Decryptor, "1Table", storageIn, storageOut);
//else
// DecryptStream(Decryptor, "0Table", storageIn, storageOut);
std::list<std::string> listStream = storageIn->entries(); std::list<std::string> listStream = storageIn->entries();
...@@ -486,15 +499,11 @@ namespace DocFileFormat ...@@ -486,15 +499,11 @@ namespace DocFileFormat
for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++) for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++)
{ {
//if (*it2 != "WordDocument" && std::wstring::npos == it2->find("Table"))
// CopyStream( *it2, storageIn, storageOut);
DecryptStream(Decryptor, *it2, storageIn, storageOut); DecryptStream(Decryptor, *it2, storageIn, storageOut);
} }
} }
else else
{ {
//if (*it != "WordDocument" && std::wstring::npos == it->find("Table"))
// CopyStream( *it, storageIn, storageOut);
DecryptStream(Decryptor, *it, storageIn, storageOut); DecryptStream(Decryptor, *it, storageIn, storageOut);
} }
...@@ -554,32 +563,40 @@ namespace DocFileFormat ...@@ -554,32 +563,40 @@ namespace DocFileFormat
if (!stream) return false; if (!stream) return false;
stream->seek(0); stream->seek(0);
int sz_stream = stream->size(); int size_stream = stream->size();
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, sz_stream); POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
if (!streamNew) return false; if (!streamNew) return false;
unsigned char* data_stream = new unsigned char[sz_stream]; unsigned char* data_stream = new unsigned char[size_stream];
stream->read(data_stream, sz_stream); stream->read(data_stream, size_stream);
unsigned char* data_store = NULL; unsigned char* data_store = NULL;
int sz_data_store = 0; int size_data_store = 0;
if ("WordDocument" == streamName) if ("WordDocument" == streamName)
{ {
sz_data_store = 68; size_data_store = 68;
data_store = new unsigned char[sz_data_store]; data_store = new unsigned char[size_data_store];
} }
if (data_store) if (data_store)
memcpy(data_store, data_stream, sz_data_store); memcpy(data_store, data_stream, size_data_store);
int size_block = 0x200;
for (int pos = 0, block = 0 ; pos < size_stream; pos += size_block, block++)
{
if (pos + size_block > size_stream)
size_block = size_stream - pos;
Decryptor->Decrypt((char*)data_stream + pos, size_block, block);
}
Decryptor->Decrypt((char*)data_stream, sz_stream, 0);
if (data_store) if (data_store)
memcpy(data_stream, data_store, sz_data_store); memcpy(data_stream, data_store, size_data_store);
streamNew->write(data_stream, sz_stream); streamNew->write(data_stream, size_stream);
RELEASEARRAYOBJECTS(data_store); RELEASEARRAYOBJECTS(data_store);
RELEASEARRAYOBJECTS(data_stream); RELEASEARRAYOBJECTS(data_stream);
......
...@@ -64,7 +64,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring ...@@ -64,7 +64,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring
m_pReader = new CPPTFileReader(pStgFrom, m_strTempDirectory); m_pReader = new CPPTFileReader(pStgFrom, m_strTempDirectory);
CPPTFileReader* pptReader = (CPPTFileReader*)m_pReader; CPPTFileReader* pptReader = (CPPTFileReader*)m_pReader;
pptReader->m_oDocumentInfo.m_strFileDirectory = GetDirectory(sFileName.c_str()); pptReader->m_oDocumentInfo.m_strTmpDirectory = m_strTempDirectory;
pptReader->m_oDocumentInfo.m_strPassword = password; pptReader->m_oDocumentInfo.m_strPassword = password;
if (pptReader->IsPowerPoint() == false) if (pptReader->IsPowerPoint() == false)
...@@ -75,50 +75,20 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring ...@@ -75,50 +75,20 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring
} }
if (pptReader->ReadPersists() == false) if (pptReader->ReadPersists() == false)
return AVS_ERROR_FILEFORMAT;
if (pptReader->IsEncrypted())
{ {
CEncryptionHeader *pEncryptionHeader = pptReader->GetEncryptionHeader(); if (pptReader->IsEncrypted())
if (!pEncryptionHeader) return AVS_ERROR_FILEFORMAT;
if (password.empty()) return AVS_ERROR_DRM;
if (pEncryptionHeader->bStandard)
{
CRYPT::RC4Decryptor Decryptor(pEncryptionHeader->crypt_data_rc4, password, 1);
if (Decryptor.IsVerify() == false)
{
return AVS_ERROR_PASSWORD;
}
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
return AVS_ERROR_PASSWORD;
//return OpenFile(m_sTempDecryptFileName, L"");
}
else
{ {
CRYPT::ECMADecryptor Decryptor; if (password.empty()) return AVS_ERROR_DRM;
else return AVS_ERROR_PASSWORD;
Decryptor.SetCryptData(pEncryptionHeader->crypt_data_aes);
if (Decryptor.SetPassword(password) == false)
{
return AVS_ERROR_PASSWORD;
}
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
return AVS_ERROR_PASSWORD;
pptReader->ReadDocument(&Decryptor);
//return OpenFile(m_sTempDecryptFileName, L"");
} }
return AVS_ERROR_FILEFORMAT;
} }
else
{
pptReader->ReadDocument(NULL);
m_Status = READMODE; //pptReader->ReadEncryptedSummary();
} //pptReader->ReadDocumentSummary();
pptReader->ReadDocument();
m_Status = READMODE;
return S_OK; return S_OK;
} }
...@@ -166,94 +136,3 @@ std::wstring COfficePPTFile::GetDirectory(std::wstring strFileName) ...@@ -166,94 +136,3 @@ std::wstring COfficePPTFile::GetDirectory(std::wstring strFileName)
} }
return strFileName; return strFileName;
} }
bool COfficePPTFile::DecryptOfficeFile(CRYPT::Decryptor* Decryptor)
{
if (!m_pReader) return false;
CPPTFileReader* pptReader = (CPPTFileReader*)(m_pReader);
if (m_strTempDirectory.empty())
{
m_strTempDirectory = NSFile::CFileBinary::GetTempPath();
}
m_sTempDecryptFileName = m_strTempDirectory + FILE_SEPARATOR_STR + L"~tempFile.ppt";
POLE::Storage *storageIn = pptReader->m_pPowerPointStg;
POLE::Storage *storageOut = new POLE::Storage(m_sTempDecryptFileName.c_str());
if (!storageOut || !storageIn) return false;
if (!storageOut->open(true, true))
{
delete storageOut;
return false;
}
std::list<std::string> listStream = storageIn->entries();
for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
{
if (storageIn->isDirectory(*it))
{
std::list<std::string> list_entry = storageIn->GetAllStreams(*it);
for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++)
{
DecryptStream(Decryptor, *it2, storageIn, storageOut);
}
}
else
DecryptStream(Decryptor, *it, storageIn, storageOut);
}
storageOut->close();
delete storageOut;
return true;
}
bool COfficePPTFile::DecryptStream(CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
{
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
if (!stream) return false;
stream->seek(0);
int sz_stream = stream->size();
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, sz_stream);
if (!streamNew) return false;
unsigned char* data_stream = new unsigned char[sz_stream];
stream->read(data_stream, sz_stream);
unsigned char* data_store = NULL;
int sz_data_store = 0;
//if ("WordDocument" == streamName)
//{
// sz_data_store = 68;
// data_store = new unsigned char[sz_data_store];
//}
if (data_store)
memcpy(data_store, data_stream, sz_data_store);
Decryptor->Decrypt((char*)data_stream, sz_stream, 0);
if (data_store)
memcpy(data_stream, data_store, sz_data_store);
streamNew->write(data_stream, sz_stream);
RELEASEARRAYOBJECTS(data_store);
RELEASEARRAYOBJECTS(data_stream);
streamNew->flush();
delete streamNew;
delete stream;
return true;
}
...@@ -79,9 +79,6 @@ private: ...@@ -79,9 +79,6 @@ private:
long OpenFile(const std::wstring & fileName, const std::wstring & password); long OpenFile(const std::wstring & fileName, const std::wstring & password);
bool CloseFile(); bool CloseFile();
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
bool DecryptStream (CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage* storageIn, POLE::Storage* storageOut);
std::wstring GetDirectory(std::wstring strFileName); std::wstring GetDirectory(std::wstring strFileName);
}; };
...@@ -38,7 +38,7 @@ class CPPTDocumentInfo ...@@ -38,7 +38,7 @@ class CPPTDocumentInfo
public: public:
CCurrentUser m_oCurrentUser; CCurrentUser m_oCurrentUser;
std::vector<CPPTUserInfo*> m_arUsers; std::vector<CPPTUserInfo*> m_arUsers;
std::wstring m_strFileDirectory; std::wstring m_strTmpDirectory;
std::map<int, std::wstring> m_mapStoreImageFile; std::map<int, std::wstring> m_mapStoreImageFile;
std::wstring m_strPassword; std::wstring m_strPassword;
...@@ -85,7 +85,7 @@ public: ...@@ -85,7 +85,7 @@ public:
CPPTUserInfo* pInfo = new CPPTUserInfo(); CPPTUserInfo* pInfo = new CPPTUserInfo();
pInfo->m_strFileDirectory = m_strFileDirectory; pInfo->m_strTmpDirectory = m_strTmpDirectory;
pInfo->m_bEncrypt = m_oCurrentUser.m_bIsEncrypt; pInfo->m_bEncrypt = m_oCurrentUser.m_bIsEncrypt;
pInfo->m_strPassword = m_strPassword; pInfo->m_strPassword = m_strPassword;
......
...@@ -48,6 +48,8 @@ CPPTUserInfo::CPPTUserInfo() : CDocument(), ...@@ -48,6 +48,8 @@ CPPTUserInfo::CPPTUserInfo() : CDocument(),
m_mapNotes(), m_mapNotes(),
m_mapSlides(), m_mapSlides(),
m_bEncrypt(false), m_bEncrypt(false),
m_pStorageDecrypt(NULL),
m_pDecryptor(NULL),
m_arOffsetPictures() m_arOffsetPictures()
{ {
m_pDocumentInfo = NULL; m_pDocumentInfo = NULL;
...@@ -59,7 +61,6 @@ CPPTUserInfo::CPPTUserInfo() : CDocument(), ...@@ -59,7 +61,6 @@ CPPTUserInfo::CPPTUserInfo() : CDocument(),
m_nWriteSlideTimeOffset = 0.0; m_nWriteSlideTimeOffset = 0.0;
m_nWriteSlideTime = 0.0; m_nWriteSlideTime = 0.0;
m_strFileDirectory = _T("");
m_bIsSetupEmpty = false; m_bIsSetupEmpty = false;
m_bRtl = false; m_bRtl = false;
...@@ -79,6 +80,9 @@ CPPTUserInfo::~CPPTUserInfo() ...@@ -79,6 +80,9 @@ CPPTUserInfo::~CPPTUserInfo()
void CPPTUserInfo::Clear() void CPPTUserInfo::Clear()
{ {
CDocument::Clear(); CDocument::Clear();
RELEASEOBJECT(m_pDecryptor);
RELEASEOBJECT(m_pStorageDecrypt);
for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapSlides.begin(); pPair != m_mapSlides.end(); ++pPair) for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapSlides.begin(); pPair != m_mapSlides.end(); ++pPair)
{ {
...@@ -150,7 +154,6 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -150,7 +154,6 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
oPersist.ReadFromStream(oHeader, pStream); oPersist.ReadFromStream(oHeader, pStream);
oPersist.ToMap(&m_mapOffsetInPIDs); oPersist.ToMap(&m_mapOffsetInPIDs);
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
CRYPT::ECMADecryptor *pDecryptor = NULL;
std::map<DWORD, DWORD>::iterator pPair = m_mapOffsetInPIDs.find(m_oUser.m_nEncryptRef); std::map<DWORD, DWORD>::iterator pPair = m_mapOffsetInPIDs.find(m_oUser.m_nEncryptRef);
if (pPair != m_mapOffsetInPIDs.end()) if (pPair != m_mapOffsetInPIDs.end())
...@@ -163,21 +166,49 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -163,21 +166,49 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
m_bEncrypt = true; m_bEncrypt = true;
m_oEncryptionHeader.ReadFromStream(oHeader, pStream); m_oEncryptionHeader.ReadFromStream(oHeader, pStream);
pDecryptor = new CRYPT::ECMADecryptor(); m_pDecryptor = new CRYPT::ECMADecryptor();
pDecryptor->SetCryptData(m_oEncryptionHeader.crypt_data_aes); m_pDecryptor->SetCryptData(m_oEncryptionHeader.crypt_data_aes);
if (pDecryptor->SetPassword(m_strPassword) == false) if (m_strPassword.empty())
{ {
delete pDecryptor; if (m_pDecryptor->SetPassword(L"VelvetSweatshop") == false)
pDecryptor = NULL; return false;
//return true;
} }
return true;//read persis decrypt else if (m_pDecryptor->SetPassword(m_strPassword) == false)
{
return false;
}
std::wstring sTemp = m_strTmpDirectory + FILE_SEPARATOR_STR + L"~tempFile.ppt";
m_pStorageDecrypt = new POLE::Storage(sTemp.c_str());
m_pStorageDecrypt->open(true, true);
} }
} }
//--------------------------------------------------------------------------------------------------
pPair = m_mapOffsetInPIDs.find(m_oUser.m_nDocumentRef); ReadDocumentPersists(pStream);
return true;
}
void CPPTUserInfo::DecryptStream(POLE::Stream *pStream, int block)
{
int size = pStream->size() - pStream->tell();
POLE::Stream *pStreamTmp = new POLE::Stream(m_pStorageDecrypt, "Tmp" + std::to_string(m_arStreamDecrypt.size() + 1), true, size);
unsigned char* data_stream = new unsigned char[size];
pStream->read(data_stream, size);
m_pDecryptor->Decrypt((char*)data_stream, size, block);
pStreamTmp->write(data_stream, size);
pStreamTmp->flush();
pStreamTmp->seek(0);
m_arStreamDecrypt.push_back(CFStreamPtr(new CFStream(pStreamTmp)));
}
bool CPPTUserInfo::ReadDocumentPersists(POLE::Stream* pStream)
{
SRecordHeader oHeader;
std::map<DWORD, DWORD>::iterator pPair = m_mapOffsetInPIDs.find(m_oUser.m_nDocumentRef);
if (pPair == m_mapOffsetInPIDs.end()) if (pPair == m_mapOffsetInPIDs.end())
return false; return false;
...@@ -185,44 +216,19 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -185,44 +216,19 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
DWORD offset_stream = pPair->second; DWORD offset_stream = pPair->second;
StreamUtils::StreamSeek(offset_stream, pStream); StreamUtils::StreamSeek(offset_stream, pStream);
oHeader.ReadFromStream(pStream);
if (pDecryptor) POLE::Stream * pStreamTmp = pStream;
if (m_pDecryptor)
{ {
POLE::Storage *pStorageOut = NULL; DecryptStream(pStream, m_oUser.m_nDocumentRef);
POLE::Stream *pStreamTmp = NULL; pStreamTmp = m_arStreamDecrypt.back()->stream_;
std::wstring sTemp = m_strFileDirectory + FILE_SEPARATOR_STR + L"~tempFile.ppt";
pStorageOut = new POLE::Storage(sTemp.c_str());
pStorageOut->open(true, true);
pStreamTmp = new POLE::Stream(pStorageOut, "Tmp", true, oHeader.RecLen);
unsigned char* data_stream = new unsigned char[oHeader.RecLen];
pStream->read(data_stream, oHeader.RecLen);
pDecryptor->Decrypt((char*)data_stream, oHeader.RecLen, m_oUser.m_nDocumentRef);
pStreamTmp->write(data_stream, oHeader.RecLen);
pStreamTmp->flush();
pStreamTmp->seek(0);
m_oDocument.ReadFromStream(oHeader, pStreamTmp);
delete pStream;
delete pStorageOut;
//NSFile::DeleteFile(sTemp);
} }
else oHeader.ReadFromStream(pStreamTmp);
if (RECORD_TYPE_DOCUMENT != oHeader.RecType)
{ {
if (RECORD_TYPE_DOCUMENT != oHeader.RecType) return false;
{
return false;
}
m_oDocument.ReadFromStream(oHeader, pStream);
} }
m_oDocument.ReadFromStream(oHeader, pStreamTmp);
Clear();
std::map<DWORD, DWORD>::iterator nIndexPsrRef; std::map<DWORD, DWORD>::iterator nIndexPsrRef;
...@@ -235,11 +241,16 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -235,11 +241,16 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
offset_stream = nIndexPsrRef->second; offset_stream = nIndexPsrRef->second;
StreamUtils::StreamSeek(offset_stream, pStream); StreamUtils::StreamSeek(offset_stream, pStream);
POLE::Stream *pStreamTmp = pStream;
oHeader.ReadFromStream(pStream); if (m_pDecryptor)
{
DecryptStream(pStream, m_oDocument.m_arMasterPersists[index].m_nPsrRef);
pStreamTmp = m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
CRecordSlide* pSlide = new CRecordSlide(); CRecordSlide* pSlide = new CRecordSlide();
pSlide->ReadFromStream(oHeader, pStream); pSlide->ReadFromStream(oHeader, pStreamTmp);
pSlide->m_oPersist = m_oDocument.m_arMasterPersists[index]; pSlide->m_oPersist = m_oDocument.m_arMasterPersists[index];
pSlide->m_Index = m_mapMasters.size(); pSlide->m_Index = m_mapMasters.size();
...@@ -260,10 +271,17 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -260,10 +271,17 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
{ {
offset_stream = nIndexPsrRef->second; offset_stream = nIndexPsrRef->second;
StreamUtils::StreamSeek(offset_stream, pStream); StreamUtils::StreamSeek(offset_stream, pStream);
oHeader.ReadFromStream(pStream); POLE::Stream *pStreamTmp = pStream;
if (m_pDecryptor)
{
DecryptStream(pStream, m_oDocument.m_arNotePersists[index].m_nPsrRef);
pStreamTmp = m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
CRecordSlide* pSlide = new CRecordSlide(); CRecordSlide* pSlide = new CRecordSlide();
pSlide->ReadFromStream(oHeader, pStream); pSlide->ReadFromStream(oHeader, pStreamTmp);
pSlide->m_oPersist = m_oDocument.m_arNotePersists[index]; pSlide->m_oPersist = m_oDocument.m_arNotePersists[index];
pSlide->m_Index = m_mapNotes.size(); pSlide->m_Index = m_mapNotes.size();
...@@ -284,13 +302,18 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -284,13 +302,18 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
if (m_mapOffsetInPIDs.end() != nIndexPsrRef) if (m_mapOffsetInPIDs.end() != nIndexPsrRef)
{ {
offset_stream = (long)nIndexPsrRef->second; offset_stream = (long)nIndexPsrRef->second;
StreamUtils::StreamSeek(offset_stream, pStream); StreamUtils::StreamSeek(offset_stream, pStream);
oHeader.ReadFromStream(pStream); POLE::Stream *pStreamTmp = pStream;
if (m_pDecryptor)
{
DecryptStream(pStream, m_oDocument.m_arSlidePersists[index].m_nPsrRef);
pStreamTmp = m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
CRecordSlide* pSlide = new CRecordSlide(); CRecordSlide* pSlide = new CRecordSlide();
pSlide->ReadFromStream(oHeader, pStream); pSlide->ReadFromStream(oHeader, pStreamTmp);
pSlide->m_oPersist = m_oDocument.m_arSlidePersists[index]; pSlide->m_oPersist = m_oDocument.m_arSlidePersists[index];
pSlide->m_Index = m_mapSlides.size(); // in m_arrSlidesOrder pSlide->m_Index = m_mapSlides.size(); // in m_arrSlidesOrder
...@@ -327,13 +350,18 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -327,13 +350,18 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
if (m_mapOffsetInPIDs.end() != nIndexPsrRef) if (m_mapOffsetInPIDs.end() != nIndexPsrRef)
{ {
offset_stream = nIndexPsrRef->second; offset_stream = nIndexPsrRef->second;
StreamUtils::StreamSeek(offset_stream, pStream); StreamUtils::StreamSeek(offset_stream, pStream);
oHeader.ReadFromStream(pStream); POLE::Stream *pStreamTmp = pStream;
if (m_pDecryptor)
{
DecryptStream(pStream, oArrayDoc[0]->m_nNotesMasterPersistIDRef);
pStreamTmp = m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
CRecordSlide* pSlide = new CRecordSlide(); CRecordSlide* pSlide = new CRecordSlide();
pSlide->ReadFromStream(oHeader, pStream); pSlide->ReadFromStream(oHeader, pStreamTmp);
pSlide->m_oPersist.m_nPsrRef = oArrayDoc[0]->m_nNotesMasterPersistIDRef; pSlide->m_oPersist.m_nPsrRef = oArrayDoc[0]->m_nNotesMasterPersistIDRef;
pSlide->m_Index = 0; pSlide->m_Index = 0;
...@@ -344,13 +372,18 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr ...@@ -344,13 +372,18 @@ bool CPPTUserInfo::ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStr
if (m_mapOffsetInPIDs.end() != nIndexPsrRef) if (m_mapOffsetInPIDs.end() != nIndexPsrRef)
{ {
offset_stream = nIndexPsrRef->second; offset_stream = nIndexPsrRef->second;
StreamUtils::StreamSeek(offset_stream, pStream); StreamUtils::StreamSeek(offset_stream, pStream);
oHeader.ReadFromStream(pStream); POLE::Stream *pStreamTmp = pStream;
if (m_pDecryptor)
{
DecryptStream(pStream, oArrayDoc[0]->m_nHandoutMasterPersistIDRef);
pStreamTmp = m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
CRecordSlide* pSlide = new CRecordSlide(); CRecordSlide* pSlide = new CRecordSlide();
pSlide->ReadFromStream(oHeader, pStream); pSlide->ReadFromStream(oHeader, pStreamTmp);
pSlide->m_oPersist.m_nPsrRef = oArrayDoc[0]->m_nHandoutMasterPersistIDRef; pSlide->m_oPersist.m_nPsrRef = oArrayDoc[0]->m_nHandoutMasterPersistIDRef;
pSlide->m_Index = 0; pSlide->m_Index = 0;
...@@ -364,7 +397,6 @@ void CPPTUserInfo::ReadExtenalObjects(std::wstring strFolderMem) ...@@ -364,7 +397,6 @@ void CPPTUserInfo::ReadExtenalObjects(std::wstring strFolderMem)
{ {
// так... теперь берем всю инфу о ExObject ----------------------------- // так... теперь берем всю инфу о ExObject -----------------------------
m_oExMedia.m_strPresentationDirectory = strFolderMem; m_oExMedia.m_strPresentationDirectory = strFolderMem;
m_oExMedia.m_strSourceDirectory = m_strFileDirectory;
NSPresentationEditor::CExFilesInfo oInfo; NSPresentationEditor::CExFilesInfo oInfo;
......
...@@ -51,7 +51,10 @@ public: ...@@ -51,7 +51,10 @@ public:
CEncryptionHeader m_oEncryptionHeader; CEncryptionHeader m_oEncryptionHeader;
bool m_bEncrypt; bool m_bEncrypt;
std::wstring m_strPassword; std::wstring m_strPassword;
CRYPT::ECMADecryptor* m_pDecryptor;
POLE::Storage* m_pStorageDecrypt;
std::vector<CFStreamPtr> m_arStreamDecrypt; // на каждый Persist свой ... оО
std::map<DWORD, CRecordSlide*> m_mapSlides; std::map<DWORD, CRecordSlide*> m_mapSlides;
std::map<DWORD, CRecordSlide*> m_mapMasters; std::map<DWORD, CRecordSlide*> m_mapMasters;
std::map<DWORD, CRecordSlide*> m_mapNotes; std::map<DWORD, CRecordSlide*> m_mapNotes;
...@@ -106,7 +109,7 @@ public: ...@@ -106,7 +109,7 @@ public:
std::vector<int> m_arOffsetPictures; std::vector<int> m_arOffsetPictures;
bool m_bIsSetupEmpty; bool m_bIsSetupEmpty;
std::wstring m_strFileDirectory; std::wstring m_strTmpDirectory;
// вся инфа о ex - файлах // вся инфа о ex - файлах
CExMedia m_oExMedia; CExMedia m_oExMedia;
...@@ -124,7 +127,11 @@ public: ...@@ -124,7 +127,11 @@ public:
void Clear(); void Clear();
bool ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStream); bool ReadFromStream(CRecordUserEditAtom* pUser, POLE::Stream* pStream);
bool ReadDocumentPersists(POLE::Stream* pStream);
void ReadExtenalObjects(std::wstring strFolderMem); void ReadExtenalObjects(std::wstring strFolderMem);
void DecryptStream(POLE::Stream *pStream, int block);
void FromDocument(); void FromDocument();
void NormalizeCoords(long lWidth, long lHeight); void NormalizeCoords(long lWidth, long lHeight);
...@@ -301,7 +308,6 @@ public: ...@@ -301,7 +308,6 @@ public:
} }
return _T("blank"); return _T("blank");
} }
void AddAnimation (DWORD dwSlideID, double Width, double Height, IElement* pElement); void AddAnimation (DWORD dwSlideID, double Width, double Height, IElement* pElement);
void AddAudioTransition (DWORD dwSlideID, CTransition* pTransition, const std::wstring& strFilePath); void AddAudioTransition (DWORD dwSlideID, CTransition* pTransition, const std::wstring& strFilePath);
......
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "PPTFileReader.h"
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/Decryptor.h"
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
#include "../../../DesktopEditor/common/Directory.h"
#include "../Records/Drawing/ArtBlip.h"
#define CURRENT_USER_STREAM "Current User"
#define DOCUMENT_STREAM "PowerPoint Document"
#define PICTURE_STREAM "Pictures"
#define HEADER_STREAM "Header"
#define PP97_DUALSTORAGE "PP97_DUALSTORAGE"
#define ENCRYPTED_SUMMARY_STREAM "EncryptedSummary"
#define DOCUMENT_SUMMARY_STREAM "DocumentSummaryInformation"
CPPTFileReader::CPPTFileReader(POLE::Storage *pStorage, std::wstring strTemp):
m_pStorage(pStorage),
m_bIsPPTFile(false),
m_nPresentationCodePage(1250),
m_pDocumentStream(NULL), m_pPictureStream(NULL), m_pDocumentSummaryStream(NULL), m_pEncryptedSummaryStream(NULL),
m_strTmpDirectory(strTemp),
m_oDocumentInfo()
{
m_bDualStorage = false;
POLE::Stream *pStm = new POLE::Stream( m_pStorage, CURRENT_USER_STREAM);
if ( ReadCurrentUser(pStm) )
{
m_bIsPPTFile = true;
}
else
{
RELEASEOBJECT(pStm);
std::string stream_name = std::string(PP97_DUALSTORAGE) + std::string("/") + std::string(CURRENT_USER_STREAM);
pStm = new POLE::Stream( m_pStorage, stream_name);
if (pStm == NULL)
return;
m_bDualStorage = true;
if ( ReadCurrentUser(pStm))
{
m_bIsPPTFile = true;
}
}
RELEASEOBJECT(pStm);
if (0 == m_strTmpDirectory.length())
{
m_strTmpDirectory = NSDirectory::GetTempPath();
}
m_strTmpDirectory = NSDirectory::CreateDirectoryWithUniqueName(m_strTmpDirectory);
}
CPPTFileReader::~CPPTFileReader()
{
RELEASEOBJECT(m_pStorage);
NSDirectory::DeleteDirectory(m_strTmpDirectory);
}
bool CPPTFileReader::IsPowerPoint()
{
return m_bIsPPTFile;
}
bool CPPTFileReader::IsEncrypted()
{
if (m_oDocumentInfo.m_arUsers.empty())
return m_oDocumentInfo.m_oCurrentUser.m_bIsEncrypt; //wps не выставляет флаг!
return m_oDocumentInfo.m_arUsers[0]->m_bEncrypt;
}
bool CPPTFileReader::ReadPersists()
{
CFStreamPtr pStream = GetDocumentStream();
if (!pStream) return false;
if (m_oDocumentInfo.ReadFromStream(&m_oCurrentUser, pStream->stream_) == false) return false;
}
void CPPTFileReader::ReadDocument()
{
ReadPictures();
m_oDocumentInfo.LoadDocument(m_strTmpDirectory);
}
bool CPPTFileReader::ReadCurrentUser(POLE::Stream *pStm)
{
if (!pStm) return false;
SRecordHeader oHeader;
bool isPP = false;
if( oHeader.ReadFromStream(pStm))
{
m_oCurrentUser.ReadFromStream(oHeader, pStm);
isPP = (m_oCurrentUser.m_nSize == 0x00000014 && (m_oCurrentUser.m_nLenUserName <= 255));
}
return isPP;
}
CFStreamPtr CPPTFileReader::GetDocumentStream()
{
if (!m_pDocumentStream)
{
m_pDocumentStream = GetStreamByName(DOCUMENT_STREAM);
}
return m_pDocumentStream;
}
CFStreamPtr CPPTFileReader::GetPictureStream()
{
if (!m_pPictureStream)
{
m_pPictureStream = GetStreamByName(PICTURE_STREAM);
}
return m_pPictureStream;
}
CFStreamPtr CPPTFileReader::GetStreamByName(const std::string & name)
{
if (!m_bIsPPTFile)
return CFStreamPtr();
std::string stream_name;
if (m_bDualStorage) stream_name = std::string(PP97_DUALSTORAGE) + std::string("/");
POLE::Stream *pStream = new POLE::Stream(m_pStorage, stream_name + name);
if (pStream->fail())
{
RELEASEOBJECT(pStream);
return CFStreamPtr();
}
return CFStreamPtr( new CFStream(pStream));
}
CFStreamPtr CPPTFileReader::GetEncryptedSummaryStream()
{
if (m_pEncryptedSummaryStream == NULL)
{
m_pEncryptedSummaryStream = GetStreamByName(ENCRYPTED_SUMMARY_STREAM);
}
return m_pEncryptedSummaryStream;
}
CFStreamPtr CPPTFileReader::GetDocumentSummaryStream()
{
if (!m_pDocumentSummaryStream)
{
m_pDocumentSummaryStream = GetStreamByName(DOCUMENT_SUMMARY_STREAM);
}
return m_pDocumentSummaryStream;
}
void CPPTFileReader::ReadEncryptedSummary()
{
CFStreamPtr pStream = GetEncryptedSummaryStream();
if (!pStream) return;
SRecordHeader oHeader;
ULONG nRd = 0;
if (oHeader.ReadFromStream(pStream) == false )
{
return;
}
CRecordEncryptedSummary info;
info.ReadFromStream(oHeader, pStream);
}
void CPPTFileReader::ReadDocumentSummary()
{
CFStreamPtr pStream = GetDocumentSummaryStream();
if (!pStream) return;
OLEPS::SummaryInformation doc_summary_info(pStream);
m_nPresentationCodePage = doc_summary_info.GetCodePage();
if (m_nPresentationCodePage == 0)
m_nPresentationCodePage = 1250;
}
void CPPTFileReader::ReadPictures()
{
CFStreamPtr pStream = GetPictureStream();
if (!pStream) return;
SRecordHeader oHeader;
ULONG nRd = 0;
CRYPT::ECMADecryptor *pDecryptor = m_oDocumentInfo.m_arUsers[0]->m_pDecryptor;
while (true)
{
if (pStream->isEOF())
break;
int pos = pStream->getStreamPointer();
POLE::Stream * pStreamTmp = pStream->stream_;
if (pDecryptor)
{
m_oDocumentInfo.m_arUsers[0]->DecryptStream(pStreamTmp, 0);
pStreamTmp = m_oDocumentInfo.m_arUsers[0]->m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
pStream->seekFromBegin(pos + 8);
CRecordOfficeArtBlip art_blip;
art_blip.m_strTmpDirectory = m_strTmpDirectory;
art_blip.m_oDocumentInfo = &m_oDocumentInfo;
pStreamTmp = pStream->stream_;
if (pDecryptor)
{
m_oDocumentInfo.m_arUsers[0]->DecryptStream(pStreamTmp, 1);
pStreamTmp = m_oDocumentInfo.m_arUsers[0]->m_arStreamDecrypt.back()->stream_;
}
art_blip.ReadFromStream(oHeader, pStreamTmp);
pStream->seekFromBegin(pos + oHeader.RecLen + 8);
m_oDocumentInfo.m_mapStoreImageFile[ pos ] = art_blip.m_sFileName;
}
}
...@@ -31,222 +31,48 @@ ...@@ -31,222 +31,48 @@
*/ */
#pragma once #pragma once
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/Decryptor.h"
#include "../../../DesktopEditor/common/Directory.h"
#include "../Records/Drawing/ArtBlip.h"
#include "PPTDocumentInfo.h" #include "PPTDocumentInfo.h"
#define CURRENT_USER_STREAM "Current User" using namespace XLS;
#define DOCUMENT_STREAM "PowerPoint Document"
#define PICTURE_STREAM "Pictures"
#define HEADER_STREAM "Header"
#define PP97_DUALSTORAGE "PP97_DUALSTORAGE"
#define ENCRYPTION_STREAM "EncryptedSummary"
class CPPTFileReader class CPPTFileReader
{ {
public: public:
CPPTFileReader(POLE::Storage *pStg, std::wstring strTemp): CPPTFileReader(POLE::Storage *pStorage, std::wstring strTemp);
m_pPowerPointStg(pStg), ~CPPTFileReader();
m_bIsPPTFile(false), bool IsPowerPoint();
m_pDocStream(NULL), bool IsEncrypted();
m_pPictureStream(NULL), bool ReadPersists();
m_strMemoryForder(strTemp), void ReadDocument();
m_oDocumentInfo()
{
m_bDualStorage = false;
POLE::Stream *pStm = new POLE::Stream( m_pPowerPointStg, CURRENT_USER_STREAM);
if ( ReadCurrentUser(pStm) )
{
m_bIsPPTFile = true;
}
else
{
RELEASEOBJECT(pStm);
std::string stream_name = std::string(PP97_DUALSTORAGE) + std::string("/") + std::string(CURRENT_USER_STREAM);
pStm = new POLE::Stream( m_pPowerPointStg, stream_name);
if (pStm == NULL)
return;
m_bDualStorage = true;
if ( ReadCurrentUser(pStm))
{
m_bIsPPTFile = true;
}
}
RELEASEOBJECT(pStm);
if (0 == m_strMemoryForder.length())
{
m_strMemoryForder = NSDirectory::GetTempPath();
}
m_strMemoryForder = NSDirectory::CreateDirectoryWithUniqueName(m_strMemoryForder);
}
~CPPTFileReader()
{
RELEASEOBJECT(m_pDocStream);
RELEASEOBJECT(m_pPictureStream);
RELEASEOBJECT(m_pPowerPointStg);
NSDirectory::DeleteDirectory(m_strMemoryForder);
}
bool IsPowerPoint()
{
return m_bIsPPTFile;
}
bool IsEncrypted()
{
if (m_oDocumentInfo.m_arUsers.empty())
return m_oDocumentInfo.m_oCurrentUser.m_bIsEncrypt; //wps не выставляет флаг!
return m_oDocumentInfo.m_arUsers[0]->m_bEncrypt;
}
CEncryptionHeader* GetEncryptionHeader()
{
if (m_oDocumentInfo.m_arUsers.empty()) return NULL;
return &m_oDocumentInfo.m_arUsers[0]->m_oEncryptionHeader;
}
bool ReadPersists()
{
return m_oDocumentInfo.ReadFromStream(&m_oCurrentUser, GetDocStream());
}
void ReadDocument(CRYPT::ECMADecryptor *pDecryptor)
{
ReadPictures(pDecryptor);
m_oDocumentInfo.LoadDocument(m_strMemoryForder);
}
protected: protected:
bool ReadCurrentUser(POLE::Stream *pStm) CFStreamPtr GetDocumentStream();
{ CFStreamPtr GetPictureStream();
if (!pStm) return false; CFStreamPtr GetEncryptedSummaryStream();
CFStreamPtr GetDocumentSummaryStream();
SRecordHeader oHeader;
bool isPP = false; CFStreamPtr GetStreamByName(const std::string & name);
if( oHeader.ReadFromStream(pStm))
{
m_oCurrentUser.ReadFromStream(oHeader, pStm);
isPP = (m_oCurrentUser.m_nSize == 0x00000014 && (m_oCurrentUser.m_nLenUserName <= 255));
}
return isPP;
}
POLE::Stream* GetDocStream()
{
if (m_pDocStream == NULL)
{
if (!m_bIsPPTFile)
return NULL;
std::string stream_name;
if (m_bDualStorage) stream_name = std::string(PP97_DUALSTORAGE) + std::string("/");
m_pDocStream = new POLE::Stream(m_pPowerPointStg, stream_name + DOCUMENT_STREAM);
}
return m_pDocStream;
}
POLE::Stream* GetPictureStream()
{
if (m_pPictureStream == NULL)
{
if (!m_bIsPPTFile)
return NULL;
std::string stream_name;
if (m_bDualStorage) stream_name = std::string(PP97_DUALSTORAGE) + std::string("/");
m_pPictureStream = new POLE::Stream(m_pPowerPointStg, stream_name + PICTURE_STREAM);
}
return m_pPictureStream;
}
void ReadPictures(CRYPT::ECMADecryptor *pDecryptor)
{
POLE::Stream* pStream = GetPictureStream();
if (NULL == pStream) return;
SRecordHeader oHeader;
ULONG nRd = 0;
while (true)
{
if (oHeader.ReadFromStream(pStream) == false )
{
break;
}
CRecordOfficeArtBlip art_blip;
art_blip.m_strMemoryForder = m_strMemoryForder;
art_blip.m_oDocumentInfo = &m_oDocumentInfo;
if (pDecryptor)
{
POLE::Storage *pStorageOut = NULL;
POLE::Stream *pStreamTmp = NULL;
std::wstring sTemp = m_strMemoryForder + FILE_SEPARATOR_STR + L"~tempFile.ppt";
pStorageOut = new POLE::Storage(sTemp.c_str());
pStorageOut->open(true, true);
pStreamTmp = new POLE::Stream(pStorageOut, "Tmp", true, oHeader.RecLen);
unsigned char* data_stream = new unsigned char[oHeader.RecLen];
pStream->read(data_stream, oHeader.RecLen);
pDecryptor->Decrypt((char*)data_stream, oHeader.RecLen, 0);
pStreamTmp->write(data_stream, oHeader.RecLen);
pStreamTmp->flush();
pStreamTmp->seek(0);
art_blip.ReadFromStream(oHeader, pStreamTmp);
delete pStream;
delete pStorageOut;
//NSFile::DeleteFile(sTemp);
}
else
{
art_blip.ReadFromStream(oHeader, pStream);
}
}
}
bool ReadCurrentUser(POLE::Stream *pStm);
void ReadEncryptedSummary();
void ReadDocumentSummary();
void ReadPictures();
private: private:
bool m_bDualStorage; bool m_bDualStorage;
CRecordCurrentUserAtom m_oCurrentUser; CRecordCurrentUserAtom m_oCurrentUser;
POLE::Stream * m_pDocStream;
POLE::Stream * m_pPictureStream; XLS::CFStreamPtr m_pDocumentStream;
XLS::CFStreamPtr m_pPictureStream;
XLS::CFStreamPtr m_pDocumentSummaryStream;
XLS::CFStreamPtr m_pEncryptedSummaryStream;
bool m_bIsPPTFile; bool m_bIsPPTFile;
public: public:
POLE::Storage* m_pPowerPointStg; POLE::Storage* m_pStorage;
std::wstring m_strMemoryForder; std::wstring m_strTmpDirectory;
std::vector<bool> m_arLoadImageFlags; std::vector<bool> m_arLoadImageFlags;
CPPTDocumentInfo m_oDocumentInfo; CPPTDocumentInfo m_oDocumentInfo;
int m_nPresentationCodePage;
}; };
...@@ -35,6 +35,97 @@ ...@@ -35,6 +35,97 @@
#include <iostream> #include <iostream>
std::wstring CUnknownRecord::ReadStringW(const CFStreamPtr &pStream, int lLen)
{
if (!pStream) return (L"");
unsigned char* pData = new unsigned char[2 * (lLen + 1)];
memset (pData, 0, 2 * (lLen + 1));
pStream->read(pData, 2 * lLen);
if (sizeof(wchar_t) == 4)
{
ConversionResult eUnicodeConversionResult;
UTF32 *pStrUtf32 = new UTF32 [lLen + 1];
pStrUtf32[lLen] = 0 ;
const UTF16 *pStrUtf16_Conv = (const UTF16 *) pData;
UTF32 *pStrUtf32_Conv = pStrUtf32;
eUnicodeConversionResult = ConvertUTF16toUTF32 ( &pStrUtf16_Conv
, &pStrUtf16_Conv[lLen]
, &pStrUtf32_Conv
, &pStrUtf32 [lLen]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return (L"");
}
std::wstring res((wchar_t*)pStrUtf32, lLen);
if (pStrUtf32) delete [] pStrUtf32;
return res;
}
else
{
std::wstring str((wchar_t*)pData);
delete[] pData;
return str;
}
}
std::string CUnknownRecord::ReadStringA(const CFStreamPtr &pStream, int lLen)
{
if (!pStream) return ("");
char* pData = new char[lLen + 1];
pStream->read((unsigned char*)pData, lLen);
pData[lLen] = 0;
std::string str(pData, lLen);
delete[] pData;
return str;
}
void CRecordsContainer::ReadFromStream(SRecordHeader & oHeader, const CFStreamPtr &pStream)
{
m_oHeader = oHeader;
m_arRecords.clear();
LONG lPosition = pStream->getStreamPointer();
m_oHeader = oHeader;
UINT lCurLen = 0;
ULONG lReadLen = 0;
SRecordHeader oRec;
while (lCurLen < m_oHeader.RecLen)
{
if (oRec.ReadFromStream(pStream) == FALSE )
{
break;
}
IRecord* pRecord = CreateByType(oRec);
pRecord->ReadFromStream(oRec, pStream);
m_arRecords.push_back(pRecord);
lCurLen += (8 + oRec.RecLen);
}
if (lCurLen != m_oHeader.RecLen)
{
// нужно разобраться, что тут такое!!!
LONG lPosition = 0;
pStream->seekFromBegin(lPosition + m_oHeader.RecLen);
}
}
void CRecordsContainer::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) void CRecordsContainer::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{ {
m_oHeader = oHeader; m_oHeader = oHeader;
......
...@@ -34,49 +34,77 @@ ...@@ -34,49 +34,77 @@
#include "PPTFileDefines.h" #include "PPTFileDefines.h"
#include "../Reader/ReadStructures.h" #include "../Reader/ReadStructures.h"
#include "../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/Enums.h" #include "../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/Enums.h"
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Binary/CFStream.h"
#include "../../../Common/3dParty/pole/pole.h" #include "../../../Common/3dParty/pole/pole.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h" #include "../../../OfficeCryptReader/source/CryptTransform.h"
using namespace NSPresentationEditor; using namespace NSPresentationEditor;
using namespace XLS;
class SRecordHeader class SRecordHeader
{ {
public: public:
BYTE RecVersion; unsigned char RecVersion;
USHORT RecInstance; unsigned short RecInstance;
USHORT RecType; unsigned short RecType;
UINT RecLen; _UINT32 RecLen;
SRecordHeader() void Clear()
{ {
RecVersion = 0; RecVersion = 0;
RecInstance = 0; RecInstance = 0;
RecType = 0; RecType = 0;
RecLen = 0; RecLen = 0;
} }
SRecordHeader()
{
Clear();
}
bool ReadFromStream(const CFStreamPtr &pStream)
{
Clear();
if (pStream->isEOF()) return FALSE;
POLE::uint64 nRd = 0;
unsigned short rec =0;
pStream->read((unsigned char*)&(rec), 2);
RecInstance = rec >> 4;
RecVersion = rec - (RecInstance << 4);
*pStream >> RecType >> RecLen;
unsigned long sz = pStream->getStreamSize() - pStream->getStreamPointer();
if (RecLen > sz )
{
RecLen = sz;
}
return true;
}
bool ReadFromStream(POLE::Stream * pStream) bool ReadFromStream(POLE::Stream * pStream)
{ {
RecVersion = 0; Clear();
RecInstance = RecType = 0; if (!pStream) return false;
RecLen = 0;
POLE::uint64 nRd = 0; POLE::uint64 nRd = 0;
unsigned short rec =0; unsigned short rec =0;
nRd = pStream->read((unsigned char*)&(rec), 2); nRd = pStream->read((unsigned char*)&(rec), 2);
if (nRd != 2) return FALSE; if (nRd != 2) return false;
//RecVersion = rec & 0xFF0F;
RecInstance = rec >> 4; RecInstance = rec >> 4;
RecVersion = rec - (RecInstance<<4); RecVersion = rec - (RecInstance<<4);
nRd = pStream->read((unsigned char*)&(RecType), 2); nRd = pStream->read((unsigned char*)&(RecType), 2);
nRd = pStream->read((unsigned char*)&(RecLen), 4); nRd = pStream->read((unsigned char*)&(RecLen), 4);
POLE::uint64 sz = pStream->size()-pStream->tell(); POLE::uint64 sz = pStream->size() - pStream->tell();
if (RecLen > sz ) if (RecLen > sz )
{ {
...@@ -119,8 +147,8 @@ public: ...@@ -119,8 +147,8 @@ public:
SRecordHeader m_oHeader; SRecordHeader m_oHeader;
public: public:
// читаем из файла
virtual ~IRecord(){} virtual ~IRecord(){}
virtual void ReadFromStream(SRecordHeader & oHeader, const CFStreamPtr &pStream) = 0;
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) = 0; virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) = 0;
}; };
...@@ -137,17 +165,26 @@ public: ...@@ -137,17 +165,26 @@ public:
~CUnknownRecord() ~CUnknownRecord()
{ {
} }
virtual void ReadFromStream(SRecordHeader & oHeader, const CFStreamPtr &pStream)
{
m_oHeader = oHeader;
pStream->seekFromCurForward(m_oHeader.RecLen);
}
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{ {
m_oHeader = oHeader; m_oHeader = oHeader;
StreamUtils::StreamSkip((long)m_oHeader.RecLen, pStream); StreamUtils::StreamSkip((long)m_oHeader.RecLen, pStream);
} }
std::wstring ReadStringW(const CFStreamPtr &pStream, int size);
std::string ReadStringA(const CFStreamPtr &pStream, int size);
}; };
IRecord* CreateByType(SRecordHeader oHeader); IRecord* CreateByType(SRecordHeader oHeader);
class CRecordsContainer : public IRecord class CRecordsContainer : public CUnknownRecord
{ {
protected: protected:
std::vector<IRecord*> m_arRecords; std::vector<IRecord*> m_arRecords;
...@@ -176,6 +213,7 @@ public: ...@@ -176,6 +213,7 @@ public:
} }
} }
virtual void ReadFromStream(SRecordHeader & oHeader, const CFStreamPtr &pStream);
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream); virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream);
template <typename T> template <typename T>
......
...@@ -36,8 +36,6 @@ class CRecordCString : public CUnknownRecord ...@@ -36,8 +36,6 @@ class CRecordCString : public CUnknownRecord
{ {
public: public:
std::wstring m_strText; std::wstring m_strText;
public:
CRecordCString() CRecordCString()
{ {
......
...@@ -32,6 +32,35 @@ ...@@ -32,6 +32,35 @@
#pragma once #pragma once
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/Decryptor.h" #include "../../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/Decryptor.h"
class CRecordEncryptedSummary : public CUnknownRecord
{
public:
CRecordEncryptedSummary(){}
~CRecordEncryptedSummary(){}
DWORD StreamOffset;
DWORD StreamSize;
unsigned short Block;
unsigned char NameSize;
bool fStream;
std::wstring StreamName;
virtual void ReadFromStream(SRecordHeader & oHeader, const CFStreamPtr &pStream)
{
m_oHeader = oHeader;
unsigned char flags;
*pStream >> StreamOffset >> StreamSize >> Block >> NameSize >> flags;
fStream = GETBIT(flags, 0);
if (NameSize > 0 && NameSize < 0xff)
{
StreamName = ReadStringW(pStream, NameSize);
}
}
};
class CEncryptionHeader : public CUnknownRecord class CEncryptionHeader : public CUnknownRecord
{ {
public: public:
...@@ -40,13 +69,8 @@ public: ...@@ -40,13 +69,8 @@ public:
CRYPT::_ecmaCryptData crypt_data_aes; CRYPT::_ecmaCryptData crypt_data_aes;
bool bStandard; bool bStandard;
CEncryptionHeader() CEncryptionHeader(){}
{ ~CEncryptionHeader(){}
}
~CEncryptionHeader()
{
}
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{ {
......
...@@ -130,7 +130,8 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* ...@@ -130,7 +130,8 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
if (0x046A == oHeader.RecInstance || 0x06E2 == oHeader.RecInstance) lOffset = 17; if (0x046A == oHeader.RecInstance || 0x06E2 == oHeader.RecInstance) lOffset = 17;
else if (0x046B == oHeader.RecInstance || 0x06E3 == oHeader.RecInstance) lOffset = 33; else if (0x046B == oHeader.RecInstance || 0x06E3 == oHeader.RecInstance) lOffset = 33;
StreamUtils::StreamSkip(lOffset, pStream); //StreamUtils::StreamSkip(lOffset, pStream);
std::string str = StreamUtils::ReadStringA(pStream, lOffset);
sExt = _T(".jpg"); sExt = _T(".jpg");
break; break;
...@@ -140,7 +141,8 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* ...@@ -140,7 +141,8 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
if (0x06E0 == oHeader.RecInstance) lOffset = 17; if (0x06E0 == oHeader.RecInstance) lOffset = 17;
else if (0x06E1 == oHeader.RecInstance) lOffset = 33; else if (0x06E1 == oHeader.RecInstance) lOffset = 33;
StreamUtils::StreamSkip(lOffset, pStream); //StreamUtils::StreamSkip(lOffset, pStream);
std::string str = StreamUtils::ReadStringA(pStream, lOffset);
sExt = _T(".png"); sExt = _T(".png");
break; break;
...@@ -182,7 +184,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* ...@@ -182,7 +184,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
std::wstring strFile = L"Image " +std::to_wstring(nImagesCount + 1) + oMetaFile.m_sExtension; std::wstring strFile = L"Image " +std::to_wstring(nImagesCount + 1) + oMetaFile.m_sExtension;
CFile fileMeta; CFile fileMeta;
HRESULT hr = fileMeta.CreateFile(m_strMemoryForder + FILE_SEPARATOR_STR + strFile); HRESULT hr = fileMeta.CreateFile(m_strTmpDirectory + FILE_SEPARATOR_STR + strFile);
if (hr == S_OK) if (hr == S_OK)
{ {
...@@ -200,7 +202,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* ...@@ -200,7 +202,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
std::wstring strFile = L"Image " + std::to_wstring(nImagesCount + 1) + sExt; std::wstring strFile = L"Image " + std::to_wstring(nImagesCount + 1) + sExt;
CFile fileImage; CFile fileImage;
HRESULT hr = fileImage.CreateFile(m_strMemoryForder + FILE_SEPARATOR_STR + strFile); HRESULT hr = fileImage.CreateFile(m_strTmpDirectory + FILE_SEPARATOR_STR + strFile);
if (hr == S_OK) if (hr == S_OK)
{ {
if (RECORD_TYPE_ESCHER_BLIP_DIB == oHeader.RecType) if (RECORD_TYPE_ESCHER_BLIP_DIB == oHeader.RecType)
...@@ -222,11 +224,6 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* ...@@ -222,11 +224,6 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
m_sFileName = strFile; m_sFileName = strFile;
} }
int dwOffset = pos - 8;
if (m_oDocumentInfo)
{
m_oDocumentInfo->m_mapStoreImageFile[dwOffset ] = m_sFileName;
}
} }
} }
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
CPPTDocumentInfo * m_oDocumentInfo; CPPTDocumentInfo * m_oDocumentInfo;
std::wstring m_sFileName; std::wstring m_sFileName;
std::wstring m_strMemoryForder; std::wstring m_strTmpDirectory;
CRecordOfficeArtBlip() CRecordOfficeArtBlip()
{ {
......
...@@ -486,6 +486,10 @@ ...@@ -486,6 +486,10 @@
RelativePath="..\Reader\PPTFileDefines.h" RelativePath="..\Reader\PPTFileDefines.h"
> >
</File> </File>
<File
RelativePath="..\Reader\PPTFileReader.cpp"
>
</File>
<File <File
RelativePath="..\Reader\PPTFileReader.h" RelativePath="..\Reader\PPTFileReader.h"
> >
......
...@@ -109,15 +109,14 @@ namespace NSPresentationEditor ...@@ -109,15 +109,14 @@ namespace NSPresentationEditor
class CExMedia class CExMedia
{ {
public: public:
std::wstring m_strPresentationDirectory; std::wstring m_strPresentationDirectory;
std::wstring m_strSourceDirectory;
std::vector<CExFilesInfo> m_arVideos; std::vector<CExFilesInfo> m_arVideos;
std::vector<CExFilesInfo> m_arImages; std::vector<CExFilesInfo> m_arImages;
std::vector<CExFilesInfo> m_arAudios; std::vector<CExFilesInfo> m_arAudios;
std::vector<CExFilesInfo> m_arHyperlinks; std::vector<CExFilesInfo> m_arHyperlinks;
std::vector<CExFilesInfo> m_arAudioCollection; std::vector<CExFilesInfo> m_arAudioCollection;
public: public:
void Clear() void Clear()
...@@ -131,8 +130,6 @@ namespace NSPresentationEditor ...@@ -131,8 +130,6 @@ namespace NSPresentationEditor
public: public:
CExMedia() : m_arVideos(), m_arImages(), m_arAudios() CExMedia() : m_arVideos(), m_arImages(), m_arAudios()
{ {
m_strPresentationDirectory = _T("");
m_strSourceDirectory = _T("");
} }
CExMedia(const CExMedia& oSrc) CExMedia(const CExMedia& oSrc)
...@@ -143,7 +140,6 @@ namespace NSPresentationEditor ...@@ -143,7 +140,6 @@ namespace NSPresentationEditor
CExMedia& operator=(const CExMedia& oSrc) CExMedia& operator=(const CExMedia& oSrc)
{ {
m_strPresentationDirectory = oSrc.m_strPresentationDirectory; m_strPresentationDirectory = oSrc.m_strPresentationDirectory;
m_strSourceDirectory = oSrc.m_strSourceDirectory;
for (size_t i=0; i < oSrc.m_arVideos.size(); i++) for (size_t i=0; i < oSrc.m_arVideos.size(); i++)
m_arVideos.push_back(oSrc.m_arVideos[i]); m_arVideos.push_back(oSrc.m_arVideos[i]);
......
...@@ -165,23 +165,6 @@ public: ...@@ -165,23 +165,6 @@ public:
} }
} }
} }
// std::wstring ToString()
// {
// std::wstring str = _T("");
// str.Format(_T("%d,%d,%d,%d"), (long)m_ePID, (long)m_bIsBlip, (long)m_bComplex, (long)m_lValue);
// // не будем ничего писать - а то xml - не распознаются
// /*if (m_bComplex)
// {
// std::wstring strProp = CDirectory::BYTEArrayToString(m_pOptions, m_lValue);
// if (NSOfficeDrawing::pibName == m_ePID)
// {
// strProp = (std::wstring)CDirectory::BYTEArrayToStringW(m_pOptions, m_lValue);
// }
// str += _T(" options=") + strProp;
// }*/
// return _T("<Property command='") + str + _T("'/>");
// }
}; };
// А вот контейнер пропертей // А вот контейнер пропертей
......
...@@ -96,9 +96,8 @@ public: ...@@ -96,9 +96,8 @@ public:
void appendDelayedItems(const ReceiverItems& receiver_items_from_record, const SourceItems& source_items_from_record); void appendDelayedItems(const ReceiverItems& receiver_items_from_record, const SourceItems& source_items_from_record);
void applyDelayedItems(); void applyDelayedItems();
POLE::Stream *stream_;
private: private:
POLE::Stream * stream_;
CFStream::ReceiverItems receiver_items; CFStream::ReceiverItems receiver_items;
CFStream::SourceItems source_items; CFStream::SourceItems source_items;
}; };
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#include "../../Common/DocxFormat/Source/Base/unicode_util.h" #include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h" #include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/cipher.h"
static const unsigned char encrVerifierHashInputBlockKey[8] = { 0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79 }; static const unsigned char encrVerifierHashInputBlockKey[8] = { 0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79 };
static const unsigned char encrVerifierHashValueBlockKey[8] = { 0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e }; static const unsigned char encrVerifierHashValueBlockKey[8] = { 0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e };
...@@ -381,8 +380,8 @@ bool EncryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYP ...@@ -381,8 +380,8 @@ bool EncryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYP
return true; return true;
} }
//ARC4::Decryption rc4Decryption;
CipherARCFOUR rc4Decryption; ARC4::Decryption rc4Decryption; // todooo -> in impl
bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYPT_METHOD::_cipherAlgorithm algorithm, bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYPT_METHOD::_cipherAlgorithm algorithm,
StreamTransformationFilter::BlockPaddingScheme padding = StreamTransformationFilter::NO_PADDING) StreamTransformationFilter::BlockPaddingScheme padding = StreamTransformationFilter::NO_PADDING)
...@@ -398,8 +397,7 @@ bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRY ...@@ -398,8 +397,7 @@ bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRY
} }
else if (algorithm == CRYPT_METHOD::RC4) else if (algorithm == CRYPT_METHOD::RC4)
{ {
rc4Decryption.Decode(data_inp.ptr, data_inp.size, data_out.ptr, data_out.size); rc4Decryption.ProcessData(data_out.ptr, data_inp.ptr, data_inp.size);
//rc4Decryption.ProcessData(data_out.ptr, data_inp.ptr, data_inp.size);
} }
else //AES else //AES
{ {
...@@ -486,10 +484,8 @@ bool ECMADecryptor::SetPassword(std::wstring _password) ...@@ -486,10 +484,8 @@ bool ECMADecryptor::SetPassword(std::wstring _password)
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4) if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{ {
//rc4Decryption.SetKey(verifierKey.ptr, verifierKey.size); rc4Decryption.SetKey(verifierKey.ptr, verifierKey.size);
rc4Decryption.Init(CipherARCFOUR::rtl_Cipher_DirectionDecode, verifierKey.ptr, verifierKey.size, 0, 0);
} }
//-------------------------------------------- //--------------------------------------------
_buf decryptedVerifierHashInputBytes; _buf decryptedVerifierHashInputBytes;
DecryptCipher(verifierKey, pSalt, pEncVerInput, decryptedVerifierHashInputBytes, cryptData.cipherAlgorithm); DecryptCipher(verifierKey, pSalt, pEncVerInput, decryptedVerifierHashInputBytes, cryptData.cipherAlgorithm);
...@@ -568,19 +564,14 @@ bool ECMADecryptor::CheckDataIntegrity(unsigned char* data, int size) ...@@ -568,19 +564,14 @@ bool ECMADecryptor::CheckDataIntegrity(unsigned char* data, int size)
return (hmac == expected); return (hmac == expected);
} }
void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned char*& data_out, int start_iv_block) void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*& data_out, int start_iv_block)
{ {
data_out = NULL; data_out = new unsigned char[size];
_buf pPassword (password); _buf pPassword (password);
_buf pSalt (cryptData.saltValue); _buf pSalt (cryptData.saltValue);
_buf empty (NULL, 0, false); _buf empty (NULL, 0, false);
int size = data_size - 8;
unsigned char* data_inp = data_ptr + 8;
data_out = new unsigned char[size];
if (cryptData.bAgile) if (cryptData.bAgile)
{ {
_buf pBlockKey ((unsigned char*)encrKeyValueBlockKey, 8); _buf pBlockKey ((unsigned char*)encrKeyValueBlockKey, 8);
...@@ -595,7 +586,7 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch ...@@ -595,7 +586,7 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch
_buf iv(cryptData.blockSize); _buf iv(cryptData.blockSize);
memset( iv.ptr, 0x00, cryptData.blockSize ); memset( iv.ptr, 0x00, cryptData.blockSize );
int i = start_iv_block, sz = 4096, pos = 0; int i = start_iv_block, sz = 4096, pos = 0;//aes block size = 4096
while (pos < size) while (pos < size)
{ {
...@@ -617,43 +608,21 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch ...@@ -617,43 +608,21 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch
} }
else else
{ {
_buf hashKey = GenerateHashKey(pSalt, pPassword, cryptData.hashSize, cryptData.spinCount, cryptData.hashAlgorithm, start_iv_block);
CorrectHashSize(hashKey, cryptData.keySize, 0);
if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4) if (cryptData.cipherAlgorithm == CRYPT_METHOD::RC4)
{ {
int i = start_iv_block, sz = 512, pos = 0; if (cryptData.keySize == 5)
CorrectHashSize(hashKey, 16, 0); //40-bit crypt key !!!
_buf pHashBuf = HashAppend(pSalt, pPassword, cryptData.hashAlgorithm);
while (pos < size) rc4Decryption.SetKey(hashKey.ptr, hashKey.size);
{
if (pos + sz > size)
sz = size - pos;
_buf block ((unsigned char*)&i, 4, false);
_buf pDecryptedKey = HashAppend( pHashBuf, block, cryptData.hashAlgorithm);
CorrectHashSize(pDecryptedKey, cryptData.keySize, 0);
if (cryptData.keySize == 5)
CorrectHashSize(pDecryptedKey, 16, 0); //40-bit crypt key !!!
CipherARCFOUR rc4;
rc4.Init(CipherARCFOUR::rtl_Cipher_DirectionDecode, pDecryptedKey.ptr, pDecryptedKey.size, 0, 0);
rc4.Decode(data_inp + pos, sz, data_out + pos, sz);
pos += sz, i++;
}
} }
else
{ _buf pInp(data_inp, size, false);
_buf hashKey = GenerateHashKey(pSalt, pPassword, cryptData.hashSize, cryptData.spinCount, cryptData.hashAlgorithm); _buf pOut(data_out, size, false);
CorrectHashSize(hashKey, cryptData.keySize, 0);
_buf pInp(data_inp, size, false);
_buf pOut(data_out, size, false);
DecryptCipher(hashKey, empty, pInp, pOut, cryptData.cipherAlgorithm); DecryptCipher(hashKey, empty, pInp, pOut, cryptData.cipherAlgorithm);
}
} }
} }
......
...@@ -713,10 +713,11 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f ...@@ -713,10 +713,11 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f
unsigned char* data_out = NULL; unsigned char* data_out = NULL;
int readTrue = pStream->read(data, lengthRead); int readTrue = pStream->read(data, lengthRead);
int readData = readTrue - 8;
lengthData = *((_UINT64*)data); lengthData = *((_UINT64*)data);
decryptor.Decrypt(data, readTrue, data_out);//todoo сделать покусочное чтение декриптование decryptor.Decrypt(data + 8, readData, data_out);//todoo сделать покусочное чтение декриптование
if (data_out) if (data_out)
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
QT -= core QT -= core
QT -= gui QT -= gui
VERSION = 2.4.464.0 VERSION = 2.4.465.0
DEFINES += INTVER=$$VERSION DEFINES += INTVER=$$VERSION
TARGET = x2t TARGET = x2t
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment