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
b36c2dba
Commit
b36c2dba
authored
May 15, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
verify ooxml file. first worked version
parent
10b9e9e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
DesktopEditor/xmlsec/src/OOXMLVerifier.h
DesktopEditor/xmlsec/src/OOXMLVerifier.h
+11
-3
DesktopEditor/xmlsec/src/XmlSigner_mscrypto.h
DesktopEditor/xmlsec/src/XmlSigner_mscrypto.h
+8
-2
No files found.
DesktopEditor/xmlsec/src/OOXMLVerifier.h
View file @
b36c2dba
...
@@ -99,7 +99,7 @@ private:
...
@@ -99,7 +99,7 @@ private:
for
(
int
i
=
0
;
i
<
nCount
;
i
++
)
for
(
int
i
=
0
;
i
<
nCount
;
i
++
)
{
{
oNodes
.
GetAt
(
i
,
ret
.
m_node
);
oNodes
.
GetAt
(
i
,
ret
.
m_node
);
CXmlStackNamespaces
_retRecursion
=
ret
.
GetByIdRec
(
ret
,
id
);
CXmlStackNamespaces
_retRecursion
=
ret
.
GetByIdRec
(
ret
,
id
,
isNameUse
);
if
(
_retRecursion
.
m_node
.
IsValid
())
if
(
_retRecursion
.
m_node
.
IsValid
())
return
_retRecursion
;
return
_retRecursion
;
}
}
...
@@ -117,7 +117,15 @@ private:
...
@@ -117,7 +117,15 @@ private:
std
::
wstring
sXmlFind
=
L"<"
+
sName
+
L" "
;
std
::
wstring
sXmlFind
=
L"<"
+
sName
+
L" "
;
if
(
0
==
sXml
.
find
(
sXmlFind
))
if
(
0
==
sXml
.
find
(
sXmlFind
))
{
sXml
.
replace
(
0
,
sXmlFind
.
length
(),
L"<"
+
sName
+
L" "
+
m_namespaces
+
L" "
);
sXml
.
replace
(
0
,
sXmlFind
.
length
(),
L"<"
+
sName
+
L" "
+
m_namespaces
+
L" "
);
}
else
{
sXmlFind
=
L"<"
+
sName
+
L">"
;
if
(
0
==
sXml
.
find
(
sXmlFind
))
sXml
.
replace
(
0
,
sXmlFind
.
length
(),
L"<"
+
sName
+
L" "
+
m_namespaces
+
L">"
);
}
}
}
return
U_TO_UTF8
(
sXml
);
return
U_TO_UTF8
(
sXml
);
...
@@ -223,7 +231,7 @@ public:
...
@@ -223,7 +231,7 @@ public:
std
::
string
sXml
=
stackRes
.
GetXml
();
std
::
string
sXml
=
stackRes
.
GetXml
();
std
::
string
sCanonicalizationMethod
=
m_node
.
ReadNode
(
L"SignedInfo"
).
ReadNode
(
L"CanonicalizationMethod"
).
GetAttributeA
(
"Algorithm"
);
std
::
string
sCanonicalizationMethod
=
m_node
.
ReadNode
(
L"SignedInfo"
).
ReadNode
(
L"CanonicalizationMethod"
).
GetAttributeA
(
"Algorithm"
);
std
::
string
sSignatureMethod
=
m_node
.
ReadNode
(
L"SignedInfo"
).
ReadNode
(
L"
Canonicalization
Method"
).
GetAttributeA
(
"Algorithm"
);
std
::
string
sSignatureMethod
=
m_node
.
ReadNode
(
L"SignedInfo"
).
ReadNode
(
L"
Signature
Method"
).
GetAttributeA
(
"Algorithm"
);
int
nSignatureMethod
=
ICertificate
::
GetOOXMLHashAlg
(
sSignatureMethod
);
int
nSignatureMethod
=
ICertificate
::
GetOOXMLHashAlg
(
sSignatureMethod
);
if
(
OOXML_HASH_ALG_INVALID
==
nSignatureMethod
)
if
(
OOXML_HASH_ALG_INVALID
==
nSignatureMethod
)
...
@@ -244,7 +252,7 @@ public:
...
@@ -244,7 +252,7 @@ public:
std
::
string
sSignatureValue
=
U_TO_UTF8
((
m_node
.
ReadValueString
(
L"SignatureValue"
)));
std
::
string
sSignatureValue
=
U_TO_UTF8
((
m_node
.
ReadValueString
(
L"SignatureValue"
)));
if
(
sSignatureCalcValue
!=
sSignatureValue
)
if
(
!
m_cert
->
Verify
(
sSignatureCalcValue
,
sSignatureValue
,
nSignatureMethod
)
)
m_valid
=
OOXML_SIGNATURE_INVALID
;
m_valid
=
OOXML_SIGNATURE_INVALID
;
}
}
...
...
DesktopEditor/xmlsec/src/XmlSigner_mscrypto.h
View file @
b36c2dba
...
@@ -181,6 +181,9 @@ public:
...
@@ -181,6 +181,9 @@ public:
bResult
=
CryptAcquireCertificatePrivateKey
(
m_context
,
0
,
NULL
,
&
hCryptProv
,
&
dwKeySpec
,
NULL
);
bResult
=
CryptAcquireCertificatePrivateKey
(
m_context
,
0
,
NULL
,
&
hCryptProv
,
&
dwKeySpec
,
NULL
);
if
(
!
bResult
)
bResult
=
CryptAcquireContext
(
&
hCryptProv
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
if
(
!
bResult
)
if
(
!
bResult
)
return
""
;
return
""
;
...
@@ -264,14 +267,17 @@ public:
...
@@ -264,14 +267,17 @@ public:
BOOL
bResult
=
CryptAcquireCertificatePrivateKey
(
m_context
,
0
,
NULL
,
&
hCryptProv
,
&
dwKeySpec
,
NULL
);
BOOL
bResult
=
CryptAcquireCertificatePrivateKey
(
m_context
,
0
,
NULL
,
&
hCryptProv
,
&
dwKeySpec
,
NULL
);
if
(
!
bResult
)
if
(
!
bResult
)
return
FALSE
;
bResult
=
CryptAcquireContext
(
&
hCryptProv
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
if
(
!
bResult
)
return
false
;
bResult
=
CryptCreateHash
(
hCryptProv
,
GetHashId
(
nAlg
),
0
,
0
,
&
hHash
);
bResult
=
CryptCreateHash
(
hCryptProv
,
GetHashId
(
nAlg
),
0
,
0
,
&
hHash
);
if
(
!
bResult
)
if
(
!
bResult
)
{
{
CryptReleaseContext
(
hCryptProv
,
0
);
CryptReleaseContext
(
hCryptProv
,
0
);
return
FALSE
;
return
false
;
}
}
BYTE
*
pDataHash
=
NULL
;
BYTE
*
pDataHash
=
NULL
;
...
...
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