x2t - add document ID for crypt ooxml

This commit is contained in:
ElenaSubbotina
2018-06-18 13:24:59 +03:00
parent 04eda04870
commit c17fa8462d
9 changed files with 103 additions and 19 deletions

View File

@ -484,7 +484,7 @@ bool ReadExtensibleEncryptionInfo(unsigned char* data, int size, _ecmaCryptData
//--------------------------------------------------------------
bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password)
bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, const std::wstring &documentID)
{
_ecmaCryptData cryptData;
@ -562,6 +562,17 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
pStream->flush();
delete pStream;
if (false == documentID.empty())
{
std::string utfDocumentID = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(documentID);
pStream = new POLE::Stream(pStorage, L"DocumentID", true, lengthData);
pStream->write((BYTE*)utfDocumentID.c_str(), utfDocumentID.length());
pStream->flush();
delete pStream;
}
pStorage->close();
delete pStorage;
@ -589,7 +600,7 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
return true;
}
bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password, bool & bDataIntegrity)
bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity)
{
bDataIntegrity = false;
@ -696,8 +707,7 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f
{
if (password.empty())
{
password = L"VelvetSweatshop";
if (!decryptor.SetPassword(password))
if (!decryptor.SetPassword(L"VelvetSweatshop"))
return false;
}
else

View File

@ -37,8 +37,8 @@
class ECMACryptFile
{
public:
bool DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password, bool & bDataIntegrity);
bool EncryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password);
bool DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity);
bool EncryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, const std::wstring &documentID = L"");
struct _refComponent
{