Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
0479b4f9
Unverified
Commit
0479b4f9
authored
Feb 01, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug/SKALE-3751-enable-zeromq
parent
e63a90f2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
18 deletions
+79
-18
ServerWorker.cpp
ServerWorker.cpp
+24
-3
ServerWorker.h
ServerWorker.h
+21
-3
ZMQClient.cpp
ZMQClient.cpp
+13
-6
ZMQClient.h
ZMQClient.h
+2
-2
ZMQMessage.cpp
ZMQMessage.cpp
+17
-3
testw.cpp
testw.cpp
+2
-1
No files found.
ServerWorker.cpp
View file @
0479b4f9
//
// Created by kladko on 14.12.20.
//
/*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file ServerWorker.cpp
@author Stan Kladko
@date 2021
*/
#include "common.h"
#include <json/writer.h>
...
...
ServerWorker.h
View file @
0479b4f9
//
// Created by kladko on 14.12.20.
//
/*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
sgxwallet is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
sgxwallet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file ServerWorker.h
@author Stan Kladko
@date 2021
*/
#ifndef SGXWALLET_SERVERWORKER_H
#define SGXWALLET_SERVERWORKER_H
...
...
ZMQClient.cpp
View file @
0479b4f9
...
...
@@ -40,11 +40,16 @@
shared_ptr
<
ZMQMessage
>
ZMQClient
::
doRequestReply
(
Json
::
Value
&
_req
)
{
Json
::
FastWriter
fastWriter
;
string
reqStr
=
fastWriter
.
write
(
_req
);
//if (sign) {
if
(
sign
)
{
CHECK_STATE
(
!
certificate
.
empty
());
_req
[
"cert"
]
=
certificate
;
//}
_req
[
"msgSig"
]
=
"haha"
;
}
string
reqStr
=
fastWriter
.
write
(
_req
);
reqStr
=
reqStr
.
substr
(
0
,
reqStr
.
size
()
-
1
);
CHECK_STATE
(
reqStr
.
front
()
==
'{'
);
CHECK_STATE
(
reqStr
.
at
(
reqStr
.
size
()
-
1
)
==
'}'
);
...
...
@@ -118,16 +123,18 @@ string ZMQClient::doZmqRequestReply(string &_req) {
ZMQClient
::
ZMQClient
(
const
string
&
ip
,
uint16_t
port
,
bool
_sign
,
const
string
&
_certFileName
,
const
string
&
_certKeyName
)
:
ctx
(
1
)
{
const
string
&
_certKeyName
)
:
ctx
(
1
),
sign
(
_sign
),
certKeyName
(
_certKeyName
),
certFileName
(
_certFileName
)
{
if
(
_sign
)
{
spdlog
::
info
(
"Initing ZMQClient. Sign:{} "
,
_sign
);
if
(
sign
)
{
CHECK_STATE
(
!
_certFileName
.
empty
());
CHECK_STATE
(
!
_certKeyName
.
empty
());
ifstream
t
(
_certFileName
);
string
str
((
istreambuf_iterator
<
char
>
(
t
)),
istreambuf_iterator
<
char
>
());
certificate
=
str
;
CHECK_STATE
(
!
certificate
.
empty
());
}
else
{
...
...
ZMQClient.h
View file @
0479b4f9
...
...
@@ -45,10 +45,10 @@ class ZMQClient {
private
:
bool
sign
;
bool
sign
=
true
;
string
certFileName
=
""
;
string
certificate
=
""
;
string
certKeyName
=
""
;
string
certificate
=
""
;
recursive_mutex
mutex
;
...
...
ZMQMessage.cpp
View file @
0479b4f9
...
...
@@ -22,7 +22,11 @@
*/
#include "common.h"
#include <third_party/cryptlite/sha256.h>
#include <iostream>
#include <fstream>
#include "SGXWalletServer.hpp"
#include "BLSSignReqMessage.h"
#include "BLSSignRspMessage.h"
#include "ECDSASignReqMessage.h"
...
...
@@ -61,6 +65,7 @@ shared_ptr <ZMQMessage> ZMQMessage::parse(const char* _msg,
auto
d
=
make_shared
<
rapidjson
::
Document
>
();
cerr
<<
_msg
<<
endl
;
d
->
Parse
(
_msg
);
CHECK_STATE
(
!
d
->
HasParseError
());
...
...
@@ -73,7 +78,18 @@ shared_ptr <ZMQMessage> ZMQMessage::parse(const char* _msg,
if
(
d
->
HasMember
(
"cert"
))
{
CHECK_STATE
((
*
d
)[
"cert"
].
IsString
());
auto
cert
=
make_shared
<
string
>
((
*
d
)[
"cert"
].
GetString
());
cerr
<<
"Got cert:"
<<
cert
<<
endl
;
string
hash
=
cryptlite
::
sha256
::
hash_hex
(
*
cert
);
auto
filepath
=
"/tmp/sgx_wallet_cert_hash_"
+
hash
;
std
::
ofstream
outFile
(
filepath
);
outFile
<<
*
cert
;
outFile
.
close
();
CHECK_STATE
(
SGXWalletServer
::
verifyCert
(
filepath
));
}
if
(
d
->
HasMember
(
"msgSig"
))
{
...
...
@@ -84,8 +100,6 @@ shared_ptr <ZMQMessage> ZMQMessage::parse(const char* _msg,
shared_ptr
<
ZMQMessage
>
result
;
if
(
_isRequest
)
{
return
buildRequest
(
type
,
d
);
}
else
{
...
...
testw.cpp
View file @
0479b4f9
...
...
@@ -953,7 +953,8 @@ TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") {
string
ip
=
ZMQ_IP
;
auto
client
=
make_shared
<
ZMQClient
>
(
ip
,
ZMQ_PORT
,
false
,
""
,
""
);
auto
client
=
make_shared
<
ZMQClient
>
(
ip
,
ZMQ_PORT
,
true
,
"./sgx_data/cert_data/rootCA.pem"
,
"./sgx_data/cert_data/rootCA.key"
);
string
keyName
=
""
;
...
...
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