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
be8d427e
Commit
be8d427e
authored
May 12, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7e0749dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
39 deletions
+140
-39
DesktopEditor/xmlsec/src/OOXMLVerifier.h
DesktopEditor/xmlsec/src/OOXMLVerifier.h
+120
-0
DesktopEditor/xmlsec/src/XmlCertificate.h
DesktopEditor/xmlsec/src/XmlCertificate.h
+17
-0
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
+3
-39
No files found.
DesktopEditor/xmlsec/src/OOXMLVerifier.h
0 → 100644
View file @
be8d427e
#ifndef _XML_OOXMLVERIFIER_H_
#define _XML_OOXMLVERIFIER_H_
#include "./XmlCanonicalizator.h"
#include "./XmlSignerBase.h"
#include "./XmlTransform.h"
#define OOXML_SIGNATURE_VALID 0
#define OOXML_SIGNATURE_INVALID 1
#define OOXML_SIGNATURE_NOTSUPPORTED 2
class
COOXMLSignature
{
private:
int
m_valid
;
std
::
string
m_guid
;
ICertificate
*
m_cert
;
std
::
string
m_sImageValidBase64
;
std
::
string
m_sImageInvalidBase64
;
private:
XmlUtils
::
CXmlNode
m_node
;
// signature file
public:
COOXMLSignature
()
{
m_valid
=
OOXML_SIGNATURE_INVALID
;
m_guid
=
""
;
m_cert
=
NULL
;
}
~
COOXMLSignature
()
{
RELEASEOBJECT
(
m_cert
);
}
public:
int
GetValid
()
{
return
m_valid
;
}
std
::
string
GetGuid
()
{
return
m_guid
;
}
ICertificate
*
GetCertificate
()
{
return
m_cert
;
}
std
::
string
GetImageValidBase64
()
{
return
m_sImageValidBase64
;
}
std
::
string
GetImageInvalidBase64
()
{
return
m_sImageInvalidBase64
;
}
public:
void
Check
();
friend
class
COOXMLVerifier
;
};
class
COOXMLVerifier
{
public:
std
::
wstring
m_sFolder
;
std
::
vector
<
COOXMLSignature
*>
m_arSignatures
;
public:
COOXMLVerifier
(
const
std
::
wstring
&
sFolder
)
{
m_sFolder
=
sFolder
;
if
(
!
NSFile
::
CFileBinary
::
Exists
(
m_sFolder
+
L"/_xmlsignatures/origin.sigs"
))
return
;
XmlUtils
::
CXmlNode
oContentTypes
;
if
(
!
oContentTypes
.
FromXmlFile
(
m_sFolder
+
L"/[Content_Types].xml"
))
return
;
XmlUtils
::
CXmlNodes
oOverrides
=
oContentTypes
.
GetNodes
(
L"Override"
);
int
nCount
=
oOverrides
.
GetCount
();
for
(
int
i
=
0
;
i
<
nCount
;
i
++
)
{
XmlUtils
::
CXmlNode
node
;
oOverrides
.
GetAt
(
i
,
node
);
if
(
node
.
GetAttributeA
(
"ContentType"
)
!=
"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
)
continue
;
std
::
wstring
sFile
=
m_sFolder
+
node
.
GetAttribute
(
"PartName"
);
XmlUtils
::
CXmlNode
nodeSig
;
if
(
!
nodeSig
.
FromXmlFile
(
sFile
))
continue
;
if
(
nodeSig
.
GetName
()
!=
L"Signature"
)
continue
;
COOXMLSignature
*
pSignature
=
new
COOXMLSignature
();
pSignature
->
m_node
=
nodeSig
;
pSignature
->
Check
();
m_arSignatures
.
push_back
(
pSignature
);
}
}
~
COOXMLVerifier
()
{
for
(
std
::
vector
<
COOXMLSignature
*>::
iterator
i
=
m_arSignatures
.
begin
();
i
!=
m_arSignatures
.
end
();
i
++
)
{
COOXMLSignature
*
v
=
*
i
;
RELEASEOBJECT
(
v
);
}
m_arSignatures
.
clear
();
}
};
#endif //_XML_OOXMLVERIFIER_H_
DesktopEditor/xmlsec/src/XmlCertificate.h
0 → 100644
View file @
be8d427e
#ifndef _XMLSIGNER_CERTIFICATE_H_
#define _XMLSIGNER_CERTIFICATE_H_
#ifdef WIN32
#include "XmlSigner_mscrypto.h"
#define CCertificate CCertificate_mscrypto
#endif
#if defined(_LINUX) && !defined(_MAC)
#endif
#ifdef _MAC
#endif
#endif // _XMLSIGNER_CERTIFICATE_H_
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
View file @
be8d427e
#include "../../src/Xml
Signer_mscrypto
.h"
#include "../../src/Xml
Certificate
.h"
#include "../../src/OOXMLSigner.h"
#include "../../src/OOXMLVerifier.h"
#pragma comment (lib, "crypt32.lib")
#pragma comment (lib, "cryptui.lib")
...
...
@@ -7,50 +8,13 @@
void
main
(
void
)
{
if
(
false
)
{
BYTE
*
pData
=
NULL
;
DWORD
dwDataLen
=
0
;
bool
bRes
=
NSFile
::
CFileBinary
::
ReadAllBytes
(
L"D:
\\
cert2.bin"
,
&
pData
,
dwDataLen
);
if
(
!
bRes
)
return
;
PCCERT_CONTEXT
context
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
|
PKCS_7_ASN_ENCODING
,
pData
,
dwDataLen
);
if
(
!
context
)
{
RELEASEARRAYOBJECTS
(
pData
);
return
;
}
BOOL
result
=
CryptUIDlgViewContext
(
CERT_STORE_CERTIFICATE_CONTEXT
,
context
,
NULL
,
NULL
,
0
,
NULL
);
result
;
if
(
context
)
CertFreeCertificateContext
(
context
);
RELEASEARRAYOBJECTS
(
pData
);
return
;
}
if
(
false
)
{
xmlLoadExtDtdDefaultValue
=
XML_DETECT_IDS
|
XML_COMPLETE_ATTRS
;
xmlSubstituteEntitiesDefault
(
1
);
std
::
string
sXmlCan
=
CXmlCanonicalizator
::
Execute
(
L"D:
\\
1.xml"
,
XML_C14N_1_0
);
NSFile
::
CFileBinary
::
SaveToFile
(
L"D:
\\
2.xml"
,
UTF8_TO_U
(
sXmlCan
));
return
;
}
//std::wstring sFolderOOOXML = NSFile::GetProcessDirectory() + L"/ImageStamp";
//std::wstring sSignId = L"{39B6B9C7-60AD-45A2-9F61-40C74A24042E}";
std
::
wstring
sFolderOOXML
=
L"D:
\\
555"
;
std
::
wstring
sSignId
=
L"{9792D33F-AB37-4E5B-A465-481B9465818B}"
;
CCertificate
_mscrypto
oCertificate
;
CCertificate
oCertificate
;
if
(
!
oCertificate
.
ShowSelectDialog
())
return
;
...
...
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