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
a62b69fb
Commit
a62b69fb
authored
May 22, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
5eb36efb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
1 deletion
+140
-1
DesktopEditor/xmlsec/src/include/XmlCertificate.h
DesktopEditor/xmlsec/src/include/XmlCertificate.h
+31
-0
DesktopEditor/xmlsec/src/src/OOXMLVerifier.cpp
DesktopEditor/xmlsec/src/src/OOXMLVerifier.cpp
+2
-0
DesktopEditor/xmlsec/src/src/XmlCertificate.cpp
DesktopEditor/xmlsec/src/src/XmlCertificate.cpp
+64
-0
DesktopEditor/xmlsec/src/src/XmlSigner_mscrypto.h
DesktopEditor/xmlsec/src/src/XmlSigner_mscrypto.h
+33
-1
DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h
DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h
+10
-0
No files found.
DesktopEditor/xmlsec/src/include/XmlCertificate.h
View file @
a62b69fb
...
...
@@ -8,6 +8,22 @@
#define OOXML_HASH_ALG_SHA1 0
#define OOXML_HASH_ALG_INVALID 1
class
Q_DECL_EXPORT
CCertificateInfo
{
public:
std
::
wstring
m_name
;
std
::
string
m_date
;
std
::
string
m_id
;
public:
CCertificateInfo
()
{
}
~
CCertificateInfo
()
{
}
};
class
Q_DECL_EXPORT
ICertificate
{
public:
...
...
@@ -26,6 +42,9 @@ public:
virtual
std
::
string
GetCertificateBase64
()
=
0
;
virtual
std
::
string
GetCertificateHash
()
=
0
;
virtual
std
::
string
GetDate
()
=
0
;
virtual
std
::
string
GetId
()
=
0
;
public:
virtual
std
::
string
Sign
(
const
std
::
string
&
sXml
)
=
0
;
virtual
std
::
string
GetHash
(
unsigned
char
*
pData
,
unsigned
int
nSize
,
int
nAlg
)
=
0
;
...
...
@@ -39,6 +58,18 @@ public:
virtual
bool
ShowSelectDialog
()
=
0
;
virtual
int
ShowCertificate
()
=
0
;
static
CCertificateInfo
GetDefault
();
static
ICertificate
*
GetById
(
const
std
::
string
&
id
);
virtual
CCertificateInfo
GetInfo
()
{
CCertificateInfo
info
;
info
.
m_name
=
GetSignerName
();
info
.
m_date
=
GetDate
();
info
.
m_id
=
GetId
();
return
info
;
}
public:
static
int
GetOOXMLHashAlg
(
const
std
::
string
&
sAlg
);
static
ICertificate
*
CreateInstance
();
...
...
DesktopEditor/xmlsec/src/src/OOXMLVerifier.cpp
View file @
a62b69fb
...
...
@@ -543,5 +543,7 @@ int COOXMLVerifier::GetSignatureCount()
COOXMLSignature
*
COOXMLVerifier
::
GetSignature
(
const
int
&
index
)
{
if
(
index
>=
(
int
)
m_internal
->
m_arSignatures
.
size
())
return
NULL
;
return
m_internal
->
m_arSignatures
[
index
];
}
DesktopEditor/xmlsec/src/src/XmlCertificate.cpp
View file @
a62b69fb
...
...
@@ -26,3 +26,67 @@ ICertificate* ICertificate::CreateInstance()
{
return
new
CCertificate
();
}
CCertificateInfo
ICertificate
::
GetDefault
()
{
CCertificateInfo
info
;
// detect user name
std
::
wstring
sUserName
;
#ifdef WIN32
DWORD
dwUserNameLen
=
1024
;
wchar_t
*
_name
=
new
wchar_t
[
dwUserNameLen
+
1
];
GetUserNameW
(
_name
,
&
dwUserNameLen
);
sUserName
=
std
::
wstring
(
_name
);
delete
[]
_name
;
#endif
////////////////////
#ifdef WIN32
HANDLE
hStoreHandle
=
CertOpenSystemStoreA
(
NULL
,
"MY"
);
if
(
!
hStoreHandle
)
return
info
;
PCCERT_CONTEXT
pCertContext
=
NULL
;
while
(
pCertContext
=
CertEnumCertificatesInStore
(
hStoreHandle
,
pCertContext
))
{
CCertificate_mscrypto
_cert
(
pCertContext
);
if
(
sUserName
==
_cert
.
GetSignerName
())
{
info
=
_cert
.
GetInfo
();
}
}
CertCloseStore
(
hStoreHandle
,
0
);
#endif
return
info
;
}
ICertificate
*
ICertificate
::
GetById
(
const
std
::
string
&
id
)
{
#ifdef WIN32
HANDLE
hStoreHandle
=
CertOpenSystemStoreA
(
NULL
,
"MY"
);
if
(
!
hStoreHandle
)
return
NULL
;
PCCERT_CONTEXT
pCertContext
=
NULL
;
while
(
pCertContext
=
CertEnumCertificatesInStore
(
hStoreHandle
,
pCertContext
))
{
CCertificate_mscrypto
*
_cert
=
new
CCertificate_mscrypto
(
pCertContext
);
if
(
id
==
_cert
->
GetId
())
{
_cert
->
m_release
=
true
;
return
_cert
;
}
RELEASEOBJECT
(
_cert
);
}
CertCloseStore
(
hStoreHandle
,
0
);
#endif
return
NULL
;
}
DesktopEditor/xmlsec/src/src/XmlSigner_mscrypto.h
View file @
a62b69fb
...
...
@@ -16,6 +16,7 @@ class CCertificate_mscrypto : public ICertificate
public:
HCERTSTORE
m_store
;
PCCERT_CONTEXT
m_context
;
bool
m_release
;
protected:
BYTE
*
m_rawData
;
...
...
@@ -29,6 +30,8 @@ public:
m_rawData
=
NULL
;
m_rawDataLen
=
0
;
m_release
=
false
;
}
CCertificate_mscrypto
(
PCCERT_CONTEXT
ctx
)
:
ICertificate
()
{
...
...
@@ -37,11 +40,13 @@ public:
m_rawData
=
NULL
;
m_rawDataLen
=
0
;
m_release
=
false
;
}
virtual
~
CCertificate_mscrypto
()
{
if
(
m_store
!=
NULL
||
m_rawData
!=
NULL
)
if
(
m_store
!=
NULL
||
m_rawData
!=
NULL
||
m_release
)
{
if
(
NULL
!=
m_context
)
CertFreeCertificateContext
(
m_context
);
...
...
@@ -99,6 +104,33 @@ public:
return
GetHash
(
m_context
->
pbCertEncoded
,
(
unsigned
int
)
m_context
->
cbCertEncoded
,
OOXML_HASH_ALG_SHA1
);
}
virtual
std
::
string
GetDate
()
{
SYSTEMTIME
t1
;
FileTimeToSystemTime
(
&
m_context
->
pCertInfo
->
NotBefore
,
&
t1
);
SYSTEMTIME
t2
;
FileTimeToSystemTime
(
&
m_context
->
pCertInfo
->
NotAfter
,
&
t2
);
std
::
string
sRet
=
std
::
to_string
(
t1
.
wDay
)
+
"/"
+
std
::
to_string
(
t1
.
wMonth
)
+
"/"
+
std
::
to_string
(
t1
.
wYear
)
+
" - "
+
std
::
to_string
(
t1
.
wDay
)
+
"/"
+
std
::
to_string
(
t2
.
wMonth
)
+
"/"
+
std
::
to_string
(
t2
.
wYear
);
return
sRet
;
}
virtual
std
::
string
GetId
()
{
// TODO: + public key?
return
GetNumber
();
}
public:
virtual
std
::
string
Sign
(
const
std
::
string
&
sXml
)
{
...
...
DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h
View file @
a62b69fb
...
...
@@ -45,6 +45,16 @@ public:
return
""
;
}
virtual
std
::
string
GetDate
()
{
return
""
;
}
virtual
std
::
string
GetId
()
{
return
""
;
}
public:
virtual
std
::
string
Sign
(
const
std
::
string
&
sXml
)
{
...
...
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