Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
e8c184c5
Commit
e8c184c5
authored
Aug 09, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f06d166a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
29 deletions
+54
-29
OfficeCryptReader/source/CryptTransform.cpp
OfficeCryptReader/source/CryptTransform.cpp
+10
-10
OfficeCryptReader/source/ECMACryptReader.cpp
OfficeCryptReader/source/ECMACryptReader.cpp
+44
-19
No files found.
OfficeCryptReader/source/CryptTransform.cpp
View file @
e8c184c5
...
...
@@ -172,16 +172,7 @@ _buf HashAppend(_buf & hashBuf, _buf & block, CRYPT_METHOD::_hashAlgorithm algo
{
//todooo переделать
if
(
algorithm
==
CRYPT_METHOD
::
SHA1
)
{
CryptoPP
::
MD5
hash
;
if
(
hashBuf
.
ptr
&&
hashBuf
.
size
>
0
)
hash
.
Update
(
hashBuf
.
ptr
,
hashBuf
.
size
);
if
(
block
.
ptr
&&
block
.
size
>
0
)
hash
.
Update
(
block
.
ptr
,
block
.
size
);
CryptoPP
::
SecByteBlock
buffer
(
hash
.
DigestSize
());
hash
.
Final
(
buffer
);
return
_buf
(
buffer
.
BytePtr
(),
buffer
.
SizeInBytes
());
//CryptoPP::SHA1 hash;
//CryptoPP::MD5 hash;
//if (hashBuf.ptr && hashBuf.size > 0) hash.Update( hashBuf.ptr, hashBuf.size);
//if (block.ptr && block.size > 0) hash.Update( block.ptr , block.size);
...
...
@@ -190,6 +181,15 @@ _buf HashAppend(_buf & hashBuf, _buf & block, CRYPT_METHOD::_hashAlgorithm algo
//hash.Final(buffer);
//return _buf(buffer.BytePtr(), buffer.SizeInBytes());
CryptoPP
::
SHA1
hash
;
if
(
hashBuf
.
ptr
&&
hashBuf
.
size
>
0
)
hash
.
Update
(
hashBuf
.
ptr
,
hashBuf
.
size
);
if
(
block
.
ptr
&&
block
.
size
>
0
)
hash
.
Update
(
block
.
ptr
,
block
.
size
);
CryptoPP
::
SecByteBlock
buffer
(
hash
.
DigestSize
());
hash
.
Final
(
buffer
);
return
_buf
(
buffer
.
BytePtr
(),
buffer
.
SizeInBytes
());
}
else
if
(
algorithm
==
CRYPT_METHOD
::
SHA256
)
{
...
...
OfficeCryptReader/source/ECMACryptReader.cpp
View file @
e8c184c5
...
...
@@ -88,7 +88,32 @@ std::wstring ReadUnicodeLP(POLE::Stream *pStream)
unsigned
char
*
Data
=
new
unsigned
char
[
length
*
2
];
pStream
->
read
(
Data
,
length
*
2
);
std
::
wstring
res
((
wchar_t
*
)
Data
,
length
);
std
::
wstring
res
;
if
(
sizeof
(
wchar_t
)
==
4
)
{
unsigned
int
nLength
=
length
;
wchar_t
*
ptr
=
new
wchar_t
[
length
];
UTF16
*
pStrUtf16
=
(
UTF16
*
)
Data
;
UTF32
*
pStrUtf32
=
(
UTF32
*
)
ptr
;
const
UTF16
*
pStrUtf16_Conv
=
pStrUtf16
;
UTF32
*
pStrUtf32_Conv
=
pStrUtf32
;
ConversionResult
eUnicodeConversionResult
=
ConvertUTF16toUTF32
(
&
pStrUtf16_Conv
,
&
pStrUtf16
[
nLength
]
,
&
pStrUtf32_Conv
,
&
pStrUtf32
[
nLength
],
strictConversion
);
if
(
conversionOK
!=
eUnicodeConversionResult
)
{
}
res
=
std
::
wstring
(
ptr
,
length
);
delete
ptr
;
}
else
res
=
std
::
wstring
((
wchar_t
*
)
Data
,
length
);
return
res
;
...
...
@@ -416,24 +441,24 @@ bool ECMACryptReader::DecryptOfficeFile(std::wstring file_name_inp, std::wstring
return
false
;
}
//------------------------------------------------------------------------------------------------------------
pStream
=
new
POLE
::
Stream
(
pStorage
,
"DataSpaces/DataSpaceMap"
);
if
(
pStream
)
{
_UINT32
size
=
0
;
_UINT32
count
=
0
;
pStream
->
read
((
unsigned
char
*
)
&
size
,
4
);
pStream
->
read
((
unsigned
char
*
)
&
count
,
4
);
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
_mapEntry
m
;
ReadMapEntry
(
pStream
,
m
);
mapEntries
.
push_back
(
m
);
}
delete
pStream
;
}
//
pStream = new POLE::Stream(pStorage, "DataSpaces/DataSpaceMap");
//
if (pStream)
//
{
//
_UINT32 size = 0;
//
_UINT32 count = 0;
//
//
pStream->read((unsigned char*)&size, 4);
//
pStream->read((unsigned char*)&count, 4);
//
for (int i = 0 ; i < count; i++)
//
{
//
_mapEntry m;
//
ReadMapEntry(pStream, m);
//
mapEntries.push_back(m);
//
}
//
delete pStream;
//
}
//------------------------------------------------------------------------------------------------------------
ECMADecryptor
decryptor
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment