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
7ed4c926
Unverified
Commit
7ed4c926
authored
Aug 26, 2020
by
Oleh Nikolaiev
Committed by
GitHub
Aug 26, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into bug/SKALE-3114-bls-import-error
parents
37c4960c
7d5c41bc
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
116 additions
and
43 deletions
+116
-43
DockerfileSimulation
DockerfileSimulation
+1
-0
Log.h
Log.h
+7
-3
SEKManager.cpp
SEKManager.cpp
+1
-1
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+4
-4
SGXWalletServer.cpp
SGXWalletServer.cpp
+22
-5
SGXWalletServer.h
SGXWalletServer.h
+1
-1
VERSION
VERSION
+1
-1
start.sh
docker/start.sh
+3
-4
EnclaveCommon.cpp
secure_enclave/EnclaveCommon.cpp
+13
-3
secure_enclave.c
secure_enclave/secure_enclave.c
+16
-3
secure_enclave.config.xml.sim
secure_enclave/secure_enclave.config.xml.sim
+14
-0
sgxwall.cpp
sgxwall.cpp
+15
-14
sgxwallet_common.h
sgxwallet_common.h
+3
-3
testw.cpp
testw.cpp
+15
-1
No files found.
DockerfileSimulation
View file @
7ed4c926
...
@@ -6,6 +6,7 @@ RUN apt update && apt install -y curl
...
@@ -6,6 +6,7 @@ RUN apt update && apt install -y curl
RUN ccache -sz
RUN ccache -sz
COPY . /usr/src/sdk
COPY . /usr/src/sdk
RUN cp -f secure_enclave/secure_enclave.config.xml.sim secure_enclave/secure_enclave.config.xml
WORKDIR /usr/src/sdk
WORKDIR /usr/src/sdk
RUN ./autoconf.bash && \
RUN ./autoconf.bash && \
./configure --enable-sgx-simulation && \
./configure --enable-sgx-simulation && \
...
...
Log.h
View file @
7ed4c926
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include "InvalidArgumentException.h"
#include "InvalidArgumentException.h"
#include "InvalidStateException.h"
#include "InvalidStateException.h"
#include <boost/core/ignore_unused.hpp>
#include "common.h"
#include "common.h"
#include <shared_mutex>
#include <shared_mutex>
...
@@ -74,22 +75,25 @@ public:
...
@@ -74,22 +75,25 @@ public:
};
};
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] = UNKNOWN_ERROR; __RESULT__["errorMessage"] = \
int errStatus = UNKNOWN_ERROR;
boost::ignore_unused(errStatus);
string errMsg(BUF_LEN, '\0');__RESULT__["status"] = UNKNOWN_ERROR; __RESULT__["errorMessage"] = \
"Server error. Please see server log.";
"Server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
catch (SGXException& _e) { \
catch (SGXException& _e) { \
if (_e.status != 0) {__RESULT__["status"] = _e.status;} else { __RESULT__["status"] = UNKNOWN_ERROR;}; \
if (_e.status != 0) {__RESULT__["status"] = _e.status;} else { __RESULT__["status"] = UNKNOWN_ERROR;}; \
__RESULT__["errorMessage"] = _e.errString; \
__RESULT__["errorMessage"] = _e.errString; \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
return __RESULT__; \
} catch (exception& _e) { \
} catch (exception& _e) { \
__RESULT__["errorMessage"] = _e.what(); \
__RESULT__["errorMessage"] = _e.what(); \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
return __RESULT__; \
}\
}\
catch (...) { \
catch (...) { \
exception_ptr p = current_exception(); \
exception_ptr p = current_exception(); \
printf("Exception %s \n", p.__cxa_exception_type()->name()); \
printf("Exception %s \n", p.__cxa_exception_type()->name()); \
__RESULT__["errorMessage"] = "Unknown exception"; \
__RESULT__["errorMessage"] = "Unknown exception"; \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
return __RESULT__; \
}
}
...
...
SEKManager.cpp
View file @
7ed4c926
...
@@ -234,7 +234,7 @@ void enter_SEK() {
...
@@ -234,7 +234,7 @@ void enter_SEK() {
void
initSEK
()
{
void
initSEK
()
{
std
::
shared_ptr
<
std
::
string
>
encr_SEK_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
"SEK"
);
std
::
shared_ptr
<
std
::
string
>
encr_SEK_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
"SEK"
);
if
(
en
cryptKeys
)
{
if
(
en
terBackupKey
)
{
enter_SEK
();
enter_SEK
();
}
else
{
}
else
{
if
(
encr_SEK_ptr
==
nullptr
)
{
if
(
encr_SEK_ptr
==
nullptr
)
{
...
...
SGXRegistrationServer.cpp
View file @
7ed4c926
...
@@ -46,10 +46,10 @@
...
@@ -46,10 +46,10 @@
#include "Log.h"
#include "Log.h"
#include "common.h"
#include "common.h"
int
printDebugInfo
=
-
1
;
bool
printDebugInfo
=
false
;
int
useHTTPS
=
-
1
;
bool
useHTTPS
=
false
;
int
encryptKeys
=
-
1
;
bool
enterBackupKey
=
false
;
int
autoconfirm
=
-
1
;
bool
autoconfirm
=
false
;
shared_ptr
<
SGXRegistrationServer
>
SGXRegistrationServer
::
server
=
nullptr
;
shared_ptr
<
SGXRegistrationServer
>
SGXRegistrationServer
::
server
=
nullptr
;
shared_ptr
<
HttpServer
>
SGXRegistrationServer
::
httpServer
=
nullptr
;
shared_ptr
<
HttpServer
>
SGXRegistrationServer
::
httpServer
=
nullptr
;
...
...
SGXWalletServer.cpp
View file @
7ed4c926
...
@@ -54,7 +54,8 @@
...
@@ -54,7 +54,8 @@
using
namespace
std
;
using
namespace
std
;
void
setFullOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
)
{
void
setFullOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_enterBackupKey
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
CHECK_STATE
(
_logLevel
<=
2
)
CHECK_STATE
(
_logLevel
<=
2
)
...
@@ -70,11 +71,12 @@ void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _en
...
@@ -70,11 +71,12 @@ void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _en
spdlog
::
info
(
"useHTTPS set to "
+
to_string
(
_useHTTPS
));
spdlog
::
info
(
"useHTTPS set to "
+
to_string
(
_useHTTPS
));
autoconfirm
=
_autoconfirm
;
autoconfirm
=
_autoconfirm
;
spdlog
::
info
(
"autoconfirm set to "
+
to_string
(
autoconfirm
));
spdlog
::
info
(
"autoconfirm set to "
+
to_string
(
autoconfirm
));
en
cryptKeys
=
_encryptKeys
;
en
terBackupKey
=
_enterBackupKey
;
spdlog
::
info
(
"en
cryptKeys set to "
+
to_string
(
encryptKeys
));
spdlog
::
info
(
"en
terBackupKey set to "
+
to_string
(
enterBackupKey
));
}
}
void
setOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
)
{
void
setOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
setFullOptions
(
_logLevel
,
_useHTTPS
,
_autoconfirm
,
false
);
setFullOptions
(
_logLevel
,
_useHTTPS
,
_autoconfirm
,
false
);
}
}
...
@@ -107,6 +109,7 @@ void SGXWalletServer::printDB() {
...
@@ -107,6 +109,7 @@ void SGXWalletServer::printDB() {
}
}
int
SGXWalletServer
::
initHttpsServer
(
bool
_checkCerts
)
{
int
SGXWalletServer
::
initHttpsServer
(
bool
_checkCerts
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
string
rootCAPath
=
string
(
SGXDATA_FOLDER
)
+
"cert_data/rootCA.pem"
;
string
rootCAPath
=
string
(
SGXDATA_FOLDER
)
+
"cert_data/rootCA.pem"
;
string
keyCAPath
=
string
(
SGXDATA_FOLDER
)
+
"cert_data/rootCA.key"
;
string
keyCAPath
=
string
(
SGXDATA_FOLDER
)
+
"cert_data/rootCA.key"
;
...
@@ -154,6 +157,7 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
...
@@ -154,6 +157,7 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
}
}
int
SGXWalletServer
::
initHttpServer
()
{
//without ssl
int
SGXWalletServer
::
initHttpServer
()
{
//without ssl
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
3
);
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
3
);
server
=
make_shared
<
SGXWalletServer
>
(
*
httpServer
,
server
=
make_shared
<
SGXWalletServer
>
(
*
httpServer
,
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
...
@@ -166,7 +170,7 @@ int SGXWalletServer::initHttpServer() { //without ssl
...
@@ -166,7 +170,7 @@ int SGXWalletServer::initHttpServer() { //without ssl
Json
::
Value
Json
::
Value
SGXWalletServer
::
importBLSKeyShareImpl
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
t
,
int
n
,
int
_index
)
{
SGXWalletServer
::
importBLSKeyShareImpl
(
const
string
&
_keyShare
,
const
string
&
_keyShareName
,
int
t
,
int
n
,
int
_index
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
);
INIT_RESULT
(
result
);
result
[
"encryptedKeyShare"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
...
@@ -195,7 +199,7 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
...
@@ -195,7 +199,7 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
Json
::
Value
Json
::
Value
SGXWalletServer
::
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
SGXWalletServer
::
blsSignMessageHashImpl
(
const
string
&
_keyShareName
,
const
string
&
_messageHash
,
int
t
,
int
n
,
int
_signerIndex
)
{
int
_signerIndex
)
{
spdlog
::
trace
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"status"
]
=
-
1
;
result
[
"status"
]
=
-
1
;
...
@@ -242,6 +246,7 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string
...
@@ -242,6 +246,7 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string
}
}
Json
::
Value
SGXWalletServer
::
generateECDSAKeyImpl
()
{
Json
::
Value
SGXWalletServer
::
generateECDSAKeyImpl
()
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"encryptedKey"
]
=
""
;
result
[
"encryptedKey"
]
=
""
;
...
@@ -268,6 +273,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
...
@@ -268,6 +273,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
}
}
Json
::
Value
SGXWalletServer
::
renameECDSAKeyImpl
(
const
string
&
_keyName
,
const
string
&
_tempKeyName
)
{
Json
::
Value
SGXWalletServer
::
renameECDSAKeyImpl
(
const
string
&
_keyName
,
const
string
&
_tempKeyName
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"encryptedKey"
]
=
""
;
result
[
"encryptedKey"
]
=
""
;
...
@@ -295,6 +301,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
...
@@ -295,6 +301,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
}
}
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
int
_base
,
const
string
&
_keyName
,
const
string
&
_messageHash
)
{
Json
::
Value
SGXWalletServer
::
ecdsaSignMessageHashImpl
(
int
_base
,
const
string
&
_keyName
,
const
string
&
_messageHash
)
{
spdlog
::
trace
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"signature_v"
]
=
""
;
result
[
"signature_v"
]
=
""
;
...
@@ -338,6 +345,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
...
@@ -338,6 +345,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
}
}
Json
::
Value
SGXWalletServer
::
getPublicECDSAKeyImpl
(
const
string
&
_keyName
)
{
Json
::
Value
SGXWalletServer
::
getPublicECDSAKeyImpl
(
const
string
&
_keyName
)
{
spdlog
::
debug
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"publicKey"
]
=
""
;
result
[
"publicKey"
]
=
""
;
...
@@ -359,6 +367,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
...
@@ -359,6 +367,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
}
}
Json
::
Value
SGXWalletServer
::
generateDKGPolyImpl
(
const
string
&
_polyName
,
int
_t
)
{
Json
::
Value
SGXWalletServer
::
generateDKGPolyImpl
(
const
string
&
_polyName
,
int
_t
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
string
encrPolyHex
;
string
encrPolyHex
;
...
@@ -379,6 +388,7 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
...
@@ -379,6 +388,7 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
}
}
Json
::
Value
SGXWalletServer
::
getVerificationVectorImpl
(
const
string
&
_polyName
,
int
_t
,
int
_n
)
{
Json
::
Value
SGXWalletServer
::
getVerificationVectorImpl
(
const
string
&
_polyName
,
int
_t
,
int
_n
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
vector
<
vector
<
string
>>
verifVector
;
vector
<
vector
<
string
>>
verifVector
;
...
@@ -407,6 +417,7 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
...
@@ -407,6 +417,7 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
}
}
Json
::
Value
SGXWalletServer
::
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pubKeys
,
int
_t
,
int
_n
)
{
Json
::
Value
SGXWalletServer
::
getSecretShareImpl
(
const
string
&
_polyName
,
const
Json
::
Value
&
_pubKeys
,
int
_t
,
int
_n
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
);
INIT_RESULT
(
result
);
result
[
"secretShare"
]
=
""
;
result
[
"secretShare"
]
=
""
;
result
[
"SecretShare"
]
=
""
;
result
[
"SecretShare"
]
=
""
;
...
@@ -442,6 +453,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
...
@@ -442,6 +453,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
Json
::
Value
SGXWalletServer
::
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
Json
::
Value
SGXWalletServer
::
dkgVerificationImpl
(
const
string
&
_publicShares
,
const
string
&
_ethKeyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
,
int
_index
)
{
const
string
&
_secretShare
,
int
_t
,
int
_n
,
int
_index
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"result"
]
=
false
;
result
[
"result"
]
=
false
;
...
@@ -472,6 +484,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
...
@@ -472,6 +484,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
Json
::
Value
Json
::
Value
SGXWalletServer
::
createBLSPrivateKeyImpl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
SGXWalletServer
::
createBLSPrivateKeyImpl
(
const
string
&
_blsKeyName
,
const
string
&
_ethKeyName
,
const
string
&
_polyName
,
const
string
&
_secretShare
,
int
_t
,
int
_n
)
{
const
string
&
_secretShare
,
int
_t
,
int
_n
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
...
@@ -515,6 +528,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
...
@@ -515,6 +528,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
}
}
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShareImpl
(
const
string
&
_blsKeyName
)
{
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShareImpl
(
const
string
&
_blsKeyName
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
...
@@ -533,6 +547,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
...
@@ -533,6 +547,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
}
}
Json
::
Value
SGXWalletServer
::
complaintResponseImpl
(
const
string
&
_polyName
,
int
_ind
)
{
Json
::
Value
SGXWalletServer
::
complaintResponseImpl
(
const
string
&
_polyName
,
int
_ind
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
...
@@ -565,6 +580,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
...
@@ -565,6 +580,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
}
}
Json
::
Value
SGXWalletServer
::
isPolyExistsImpl
(
const
string
&
_polyName
)
{
Json
::
Value
SGXWalletServer
::
isPolyExistsImpl
(
const
string
&
_polyName
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"IsExist"
]
=
false
;
result
[
"IsExist"
]
=
false
;
...
@@ -592,6 +608,7 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
...
@@ -592,6 +608,7 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
}
}
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
string
&
name
)
{
Json
::
Value
SGXWalletServer
::
deleteBlsKeyImpl
(
const
string
&
name
)
{
spdlog
::
info
(
"Entering {}"
,
__FUNCTION__
);
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"deleted"
]
=
false
;
result
[
"deleted"
]
=
false
;
...
...
SGXWalletServer.h
View file @
7ed4c926
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define EXTERNC
#define EXTERNC
#endif
#endif
EXTERNC
void
setFullOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_en
cryptKeys
);
EXTERNC
void
setFullOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_en
terBackupKey
);
EXTERNC
void
setOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
);
EXTERNC
void
setOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
);
...
...
VERSION
View file @
7ed4c926
1.57.0
1.58.0
\ No newline at end of file
\ No newline at end of file
docker/start.sh
View file @
7ed4c926
...
@@ -24,10 +24,6 @@ ls /root/.rnd;
...
@@ -24,10 +24,6 @@ ls /root/.rnd;
cd
/usr/src/sdk
;
cd
/usr/src/sdk
;
echo
"Checking that sgxwallet can connect to SGX whitelist update server whitelist.trustedservices.intel.com "
echo
"If this test fails, you need to update your network config or firewall to allow this connection"
curl
-I
http://whitelist.trustedservices.intel.com/SGX/LCWL/Linux/sgx_white_list_cert.bin
if
[[
-f
"/var/hwmode"
]]
if
[[
-f
"/var/hwmode"
]]
then
then
...
@@ -37,6 +33,9 @@ jhid -d
...
@@ -37,6 +33,9 @@ jhid -d
/opt/intel/sgxpsw/aesm/aesm_service &
/opt/intel/sgxpsw/aesm/aesm_service &
pid
=
$!
pid
=
$!
sleep
2
sleep
2
echo
"Checking that sgxwallet can connect to SGX whitelist update server whitelist.trustedservices.intel.com "
echo
"If this test fails, you need to update your network config or firewall to allow this connection"
curl
-I
http://whitelist.trustedservices.intel.com/SGX/LCWL/Linux/sgx_white_list_cert.bin
else
else
echo
"Running in SGX simulation mode"
echo
"Running in SGX simulation mode"
fi
fi
...
...
secure_enclave/EnclaveCommon.cpp
View file @
7ed4c926
...
@@ -164,13 +164,23 @@ int inited = 0;
...
@@ -164,13 +164,23 @@ int inited = 0;
domain_parameters
curve
;
domain_parameters
curve
;
void
enclave_init
()
{
void
enclave_init
()
{
LOG_INFO
(
__FUNCTION__
);
if
(
inited
==
1
)
if
(
inited
==
1
)
return
;
return
;
inited
=
1
;
inited
=
1
;
libff
::
init_alt_bn128_params
();
curve
=
domain_parameters_init
();
LOG_INFO
(
"Initing libff"
);
domain_parameters_load_curve
(
curve
,
secp256k1
);
try
{
libff
::
init_alt_bn128_params
();
curve
=
domain_parameters_init
();
domain_parameters_load_curve
(
curve
,
secp256k1
);
}
catch
(
exception
&
e
)
{
LOG_ERROR
(
"Exception in libff init"
);
LOG_ERROR
(
e
.
what
());
}
LOG_INFO
(
"Inited libff"
);
}
}
bool
enclave_sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
bool
enclave_sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
...
...
secure_enclave/secure_enclave.c
View file @
7ed4c926
...
@@ -113,20 +113,33 @@ void free_function(void *, size_t);
...
@@ -113,20 +113,33 @@ void free_function(void *, size_t);
unsigned
char
*
globalRandom
;
unsigned
char
*
globalRandom
;
void
trustedEnclaveInit
(
uint32_t
_logLevel
)
{
void
trustedEnclaveInit
(
uint32_t
_logLevel
)
{
LOG_
DEBUG
(
__FUNCTION__
);
LOG_
INFO
(
__FUNCTION__
);
globalLogLevel_
=
_logLevel
;
globalLogLevel_
=
_logLevel
;
oc_realloc_func
=
&
reallocate_function
;
oc_realloc_func
=
&
reallocate_function
;
oc_free_func
=
&
free_function
;
oc_free_func
=
&
free_function
;
LOG_INFO
(
"Setting memory functions"
);
mp_get_memory_functions
(
NULL
,
&
gmp_realloc_func
,
&
gmp_free_func
);
mp_get_memory_functions
(
NULL
,
&
gmp_realloc_func
,
&
gmp_free_func
);
mp_set_memory_functions
(
NULL
,
oc_realloc_func
,
oc_free_func
);
mp_set_memory_functions
(
NULL
,
oc_realloc_func
,
oc_free_func
);
LOG_INFO
(
"Reading random"
);
globalRandom
=
calloc
(
32
,
1
);
auto
ret
=
sgx_read_rand
(
globalRandom
,
32
);
if
(
ret
!=
SGX_SUCCESS
)
{
LOG_ERROR
(
"sgx_read_rand failed. Aboring enclave."
);
abort
();
}
globalRandom
=
(
unsigned
char
*
)
calloc
(
32
,
1
);
sgx_read_rand
(
globalRandom
,
32
);
LOG_INFO
(
"Calling enclave init"
);
enclave_init
();
enclave_init
();
...
...
secure_enclave/secure_enclave.config.xml.sim
0 → 100644
View file @
7ed4c926
<EnclaveConfiguration>
<ProdID>0</ProdID>
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x1000000</StackMaxSize>
<HeapMaxSize>0x10000000</HeapMaxSize>
<TCSNum>32</TCSNum>
<TCSMaxNum>32</TCSMaxNum>
<TCSMinPool>32</TCSMinPool>
<TCSPolicy>0</TCSPolicy>
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
sgxwall.cpp
View file @
7ed4c926
...
@@ -44,16 +44,17 @@ void SGXWallet::usage() {
...
@@ -44,16 +44,17 @@ void SGXWallet::usage() {
}
}
void
SGXWallet
::
printUsage
()
{
void
SGXWallet
::
printUsage
()
{
cerr
<<
"Available flags:
\n
"
;
cerr
<<
"
\n
Available flags:
\n
"
;
cerr
<<
"-c Do not verify client certificate
\n
"
;
cerr
<<
"
\n
Debug flags:
\n\n
"
;
cerr
<<
"-s Sign client certificate without human confirmation
\n
"
;
cerr
<<
" -v Verbose mode: turn on debug output
\n
"
;
cerr
<<
"-d Turn on debug output
\n
"
;
cerr
<<
" -vv Detailed verbose mode: turn on debug and trace outputs
\n
"
;
cerr
<<
"-v Verbose mode: turn on debug output
\n
"
;
cerr
<<
"
\n
Backup, restore, update flags:
\n\n
"
;
cerr
<<
"-vv Detailed verbose mode: turn on debug and trace outputs
\n
"
;
cerr
<<
" -b Restore from back up or software update. You will need to type in the backup key.
\n
"
;
cerr
<<
"-n Launch SGXWalletServer using http (not https)
\n
"
;
cerr
<<
" -y Do not ask user to acknowledge receipt of the backup key
\n
"
;
cerr
<<
"-b Restore from back up (you will need to enter backup key)
\n
"
;
cerr
<<
"
\n
HTTPS flags:
\n\n
"
;
cerr
<<
"-y Do not ask user to acknowledge receipt of backup key
\n
"
;
cerr
<<
" -n Launch sgxwallet using http. Default is to use https with a selg-signed server cert.
\n
"
;
cerr
<<
"-T Generate test keys
\n
"
;
cerr
<<
" -c Do not verify SSL client certs
\n
"
;
cerr
<<
" -s Sign SSL client certs without human confirmation
\n
"
;
}
}
...
@@ -86,7 +87,7 @@ void SGXWallet::serializeKeys(const vector<string>& _ecdsaKeyNames, const vector
...
@@ -86,7 +87,7 @@ void SGXWallet::serializeKeys(const vector<string>& _ecdsaKeyNames, const vector
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
bool
en
cryptKeys
Option
=
false
;
bool
en
terBackupKey
Option
=
false
;
bool
useHTTPSOption
=
true
;
bool
useHTTPSOption
=
true
;
bool
printDebugInfoOption
=
false
;
bool
printDebugInfoOption
=
false
;
bool
printTraceInfoOption
=
false
;
bool
printTraceInfoOption
=
false
;
...
@@ -130,10 +131,10 @@ int main(int argc, char *argv[]) {
...
@@ -130,10 +131,10 @@ int main(int argc, char *argv[]) {
useHTTPSOption
=
false
;
useHTTPSOption
=
false
;
break
;
break
;
case
'a'
:
case
'a'
:
en
cryptKeys
Option
=
false
;
en
terBackupKey
Option
=
false
;
break
;
break
;
case
'b'
:
case
'b'
:
en
cryptKeys
Option
=
true
;
en
terBackupKey
Option
=
true
;
break
;
break
;
case
'y'
:
case
'y'
:
autoconfirmOption
=
true
;
autoconfirmOption
=
true
;
...
@@ -158,7 +159,7 @@ int main(int argc, char *argv[]) {
...
@@ -158,7 +159,7 @@ int main(int argc, char *argv[]) {
logLevel
=
L_TRACE
;
logLevel
=
L_TRACE
;
}
}
setFullOptions
(
logLevel
,
useHTTPSOption
,
autoconfirmOption
,
en
cryptKeys
Option
);
setFullOptions
(
logLevel
,
useHTTPSOption
,
autoconfirmOption
,
en
terBackupKey
Option
);
uint32_t
enclaveLogLevel
=
L_INFO
;
uint32_t
enclaveLogLevel
=
L_INFO
;
...
...
sgxwallet_common.h
View file @
7ed4c926
...
@@ -44,9 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...
@@ -44,9 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <stdbool.h>
extern
int
useHTTPS
;
extern
bool
useHTTPS
;
extern
int
encryptKeys
;
extern
bool
enterBackupKey
;
extern
int
autoconfirm
;
extern
bool
autoconfirm
;
#define BUF_LEN 4096
#define BUF_LEN 4096
...
...
testw.cpp
View file @
7ed4c926
...
@@ -461,8 +461,18 @@ TEST_CASE_METHOD(TestFixture, "Get ServerVersion", "[get-server-version]") {
...
@@ -461,8 +461,18 @@ TEST_CASE_METHOD(TestFixture, "Get ServerVersion", "[get-server-version]") {
REQUIRE
(
c
.
getServerVersion
()[
"version"
]
==
SGXWalletServer
::
getVersion
());
REQUIRE
(
c
.
getServerVersion
()[
"version"
]
==
SGXWalletServer
::
getVersion
());
}
}
TEST_CASE_METHOD
(
TestFixtureHTTPS
,
"Cert request sign"
,
"[cert-sign]"
)
{
TEST_CASE_METHOD
(
TestFixtureHTTPS
,
"Cert request sign"
,
"[cert-sign]"
)
{
REQUIRE
(
SGXRegistrationServer
::
getServer
()
!=
nullptr
);
PRINT_SRC_LINE
REQUIRE_NOTHROW
(
SGXRegistrationServer
::
getServer
());
PRINT_SRC_LINE
string
csrFile
=
"insecure-samples/yourdomain.csr"
;
string
csrFile
=
"insecure-samples/yourdomain.csr"
;
...
@@ -472,9 +482,13 @@ TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
...
@@ -472,9 +482,13 @@ TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
ss
<<
infile
.
rdbuf
();
ss
<<
infile
.
rdbuf
();
infile
.
close
();
infile
.
close
();
PRINT_SRC_LINE
auto
result
=
SGXRegistrationServer
::
getServer
()
->
SignCertificate
(
ss
.
str
());
auto
result
=
SGXRegistrationServer
::
getServer
()
->
SignCertificate
(
ss
.
str
());
REQUIRE
(
result
[
"status"
]
==
0
);
REQUIRE
(
result
[
"status"
]
==
0
);
PRINT_SRC_LINE
PRINT_SRC_LINE
result
=
SGXRegistrationServer
::
getServer
()
->
SignCertificate
(
"Haha"
);
result
=
SGXRegistrationServer
::
getServer
()
->
SignCertificate
(
"Haha"
);
...
...
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