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
6f35e65a
Unverified
Commit
6f35e65a
authored
Aug 13, 2020
by
Stan Kladko
Committed by
GitHub
Aug 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #141 from skalenetwork/SKALE-3067-cleanip2
Skale 3067 cleanip2
parents
b95ab32d
f3456f30
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
169 deletions
+89
-169
CSRManagerServer.cpp
CSRManagerServer.cpp
+3
-6
LevelDB.cpp
LevelDB.cpp
+8
-31
Log.h
Log.h
+1
-1
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+2
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+66
-125
SGXWalletServer.hpp
SGXWalletServer.hpp
+1
-2
TestUtils.cpp
TestUtils.cpp
+4
-2
secure_enclave.edl
secure_enclave/secure_enclave.edl
+2
-0
sgxwallet_common.h
sgxwallet_common.h
+2
-0
No files found.
CSRManagerServer.cpp
View file @
6f35e65a
...
...
@@ -40,7 +40,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
serverVersion_t
type
)
:
abstractCSRManagerServer
(
connector
,
type
)
{}
Json
::
Value
getUnsignedCSRsImpl
()
{
spdlog
::
info
(
__FUNCTION__
);
INIT_RESULT
(
result
)
try
{
...
...
@@ -50,12 +49,11 @@ Json::Value getUnsignedCSRsImpl() {
}
}
HANDLE_SGX_EXCEPTION
(
result
);
return
result
;
RETURN_SUCCESS
(
result
)
}
Json
::
Value
signByHashImpl
(
const
string
&
hash
,
int
status
)
{
Json
::
Value
result
;
result
[
"errorMessage"
]
=
""
;
INIT_RESULT
(
result
)
try
{
if
(
!
(
status
==
0
||
status
==
2
))
{
...
...
@@ -89,7 +87,6 @@ Json::Value signByHashImpl(const string &hash, int status) {
LevelDB
::
getCsrStatusDb
()
->
deleteKey
(
status_db_key
);
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
status_db_key
,
"-1"
);
throw
SGXException
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
//exit(-1);
}
}
...
...
@@ -102,7 +99,7 @@ Json::Value signByHashImpl(const string &hash, int status) {
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
Json
::
Value
CSRManagerServer
::
getUnsignedCSRs
()
{
...
...
LevelDB.cpp
View file @
6f35e65a
...
...
@@ -43,15 +43,10 @@ static WriteOptions writeOptions;
static
ReadOptions
readOptions
;
std
::
shared_ptr
<
string
>
LevelDB
::
readString
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
result
=
std
::
make_shared
<
string
>
();
if
(
db
==
nullptr
)
{
throw
SGXException
(
NULL_DATABASE
,
"Null db"
);
}
spdlog
::
debug
(
"key to read from db: {}"
,
_key
);
CHECK_STATE
(
db
)
auto
status
=
db
->
Get
(
readOptions
,
_key
,
result
.
get
());
...
...
@@ -65,18 +60,14 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
}
void
LevelDB
::
writeString
(
const
string
&
_key
,
const
string
&
_value
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
_value
));
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"written key: {}"
,
_key
);
}
void
LevelDB
::
deleteDHDKGKey
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
string
full_key
=
"DKG_DH_KEY_"
+
_key
;
...
...
@@ -84,48 +75,31 @@ void LevelDB::deleteDHDKGKey(const string &_key) {
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
full_key
);
}
void
LevelDB
::
deleteTempNEK
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
string
prefix
=
_key
.
substr
(
0
,
8
);
if
(
prefix
!=
"tmp_NEK:"
)
{
return
;
}
CHECK_STATE
(
_key
.
rfind
(
"tmp_NEK"
,
0
)
==
0
);
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
_key
);
}
void
LevelDB
::
deleteKey
(
const
string
&
_key
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Delete
(
writeOptions
,
Slice
(
_key
));
throwExceptionOnError
(
status
);
spdlog
::
debug
(
"key deleted: {}"
,
_key
);
}
void
LevelDB
::
writeByteArray
(
const
char
*
_key
,
size_t
_keyLen
,
const
char
*
value
,
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
,
_keyLen
),
Slice
(
value
,
_valueLen
));
throwExceptionOnError
(
status
);
}
void
LevelDB
::
writeByteArray
(
string
&
_key
,
const
char
*
value
,
size_t
_valueLen
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex
);
CHECK_STATE
(
value
);
auto
status
=
db
->
Put
(
writeOptions
,
Slice
(
_key
),
Slice
(
value
,
_valueLen
));
...
...
@@ -142,6 +116,9 @@ void LevelDB::throwExceptionOnError(Status _status) {
}
uint64_t
LevelDB
::
visitKeys
(
LevelDB
::
KeyVisitor
*
_visitor
,
uint64_t
_maxKeysToVisit
)
{
CHECK_STATE
(
_visitor
);
uint64_t
readCounter
=
0
;
leveldb
::
Iterator
*
it
=
db
->
NewIterator
(
readOptions
);
...
...
@@ -187,7 +164,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
writeString
(
key
,
value
);
spdlog
::
debug
(
"{}"
,
Name
,
" is written to db"
);
}
...
...
Log.h
View file @
6f35e65a
...
...
@@ -74,7 +74,7 @@ public:
};
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] =
0
; __RESULT__["errorMessage"] = \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] =
UNKNOWN_ERROR
; __RESULT__["errorMessage"] = \
"Server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
...
...
SGXRegistrationServer.cpp
View file @
6f35e65a
...
...
@@ -112,7 +112,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
Json
::
Value
getCertificateImpl
(
const
string
&
hash
)
{
...
...
@@ -147,7 +147,7 @@ Json::Value getCertificateImpl(const string &hash) {
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
RETURN_SUCCESS
(
result
)
}
...
...
SGXWalletServer.cpp
View file @
6f35e65a
This diff is collapsed.
Click to expand it.
SGXWalletServer.hpp
View file @
6f35e65a
...
...
@@ -24,10 +24,9 @@
#ifndef SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP
#include <boost/thread/shared_mutex.hpp>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <mutex>
#include "abstractstubserver.h"
using
namespace
jsonrpc
;
...
...
TestUtils.cpp
View file @
6f35e65a
...
...
@@ -174,8 +174,10 @@ void TestUtils::sendRPCRequest() {
vector
<
string
>
pubShares
(
n
);
vector
<
string
>
polyNames
(
n
);
int
schainID
=
randGen
();
int
dkgID
=
randGen
();
static
atomic
<
int
>
counter
(
1
);
int
schainID
=
counter
.
fetch_add
(
1
);
int
dkgID
=
counter
.
fetch_add
(
1
);
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
ethKeys
[
i
]
=
c
.
generateECDSAKey
();
CHECK_STATE
(
ethKeys
[
i
][
"status"
]
==
0
);
...
...
secure_enclave/secure_enclave.edl
View file @
6f35e65a
...
...
@@ -3,6 +3,8 @@
#define ECDSA_ENCR_LEN 93
#define ECDSA_BIN_LEN 33
#define SMALL_BUF_SIZE 1024
#define TINY_BUF_SIZE 256
enclave {
trusted {
...
...
sgxwallet_common.h
View file @
6f35e65a
...
...
@@ -89,6 +89,8 @@ extern int autoconfirm;
#define INVALID_ECDSA_KEY_NAME -20
#define INVALID_HEX -21
#define INVALID_ECSDA_SIGNATURE -22
#define KEY_NAME_ALREADY_EXISTS -23 \
#define ERROR_IN_ENCLAVE -33
...
...
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