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
2dc5a146
Unverified
Commit
2dc5a146
authored
Jun 05, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2002 clean up and fix incorrect memset
parent
5d159a10
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
53 deletions
+19
-53
SGXWalletServer.cpp
SGXWalletServer.cpp
+0
-26
ServerInit.cpp
ServerInit.cpp
+0
-9
secure_enclave.c
secure_enclave/secure_enclave.c
+7
-1
sgxwallet.c
sgxwallet.c
+0
-4
testw.cpp
testw.cpp
+10
-11
testw.py
testw.py
+2
-2
No files found.
SGXWalletServer.cpp
View file @
2dc5a146
...
@@ -98,7 +98,6 @@ void SGXWalletServer::printDB() {
...
@@ -98,7 +98,6 @@ void SGXWalletServer::printDB() {
}
}
int
SGXWalletServer
::
initHttpsServer
(
bool
_checkCerts
)
{
int
SGXWalletServer
::
initHttpsServer
(
bool
_checkCerts
)
{
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"
;
...
@@ -147,7 +146,6 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
...
@@ -147,7 +146,6 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
int
SGXWalletServer
::
initHttpServer
()
{
//without ssl
int
SGXWalletServer
::
initHttpServer
()
{
//without ssl
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)
...
@@ -269,7 +267,6 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string
...
@@ -269,7 +267,6 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string
Json
::
Value
SGXWalletServer
::
generateECDSAKeyImpl
()
{
Json
::
Value
SGXWalletServer
::
generateECDSAKeyImpl
()
{
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
...
@@ -323,7 +320,6 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
...
@@ -323,7 +320,6 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
shared_ptr
<
string
>
encryptedKey
=
readFromDb
(
_tempKeyName
);
shared_ptr
<
string
>
encryptedKey
=
readFromDb
(
_tempKeyName
);
writeDataToDB
(
_keyName
,
*
encryptedKey
);
writeDataToDB
(
_keyName
,
*
encryptedKey
);
LevelDB
::
getLevelDb
()
->
deleteTempNEK
(
_tempKeyName
);
LevelDB
::
getLevelDb
()
->
deleteTempNEK
(
_tempKeyName
);
...
@@ -334,10 +330,8 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
...
@@ -334,10 +330,8 @@ 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
)
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"signature_v"
]
=
""
;
result
[
"signature_v"
]
=
""
;
result
[
"signature_r"
]
=
""
;
result
[
"signature_r"
]
=
""
;
result
[
"signature_s"
]
=
""
;
result
[
"signature_s"
]
=
""
;
...
@@ -345,7 +339,6 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
...
@@ -345,7 +339,6 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
vector
<
string
>
signatureVector
(
3
);
vector
<
string
>
signatureVector
(
3
);
try
{
try
{
string
hashTmp
=
_messageHash
;
string
hashTmp
=
_messageHash
;
if
(
hashTmp
[
0
]
==
'0'
&&
(
hashTmp
[
1
]
==
'x'
||
hashTmp
[
1
]
==
'X'
))
{
if
(
hashTmp
[
0
]
==
'0'
&&
(
hashTmp
[
1
]
==
'x'
||
hashTmp
[
1
]
==
'X'
))
{
hashTmp
.
erase
(
hashTmp
.
begin
(),
hashTmp
.
begin
()
+
2
);
hashTmp
.
erase
(
hashTmp
.
begin
(),
hashTmp
.
begin
()
+
2
);
...
@@ -383,7 +376,6 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
...
@@ -383,7 +376,6 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
}
}
Json
::
Value
SGXWalletServer
::
getPublicECDSAKeyImpl
(
const
string
&
_keyName
)
{
Json
::
Value
SGXWalletServer
::
getPublicECDSAKeyImpl
(
const
string
&
_keyName
)
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
result
[
"publicKey"
]
=
""
;
result
[
"publicKey"
]
=
""
;
...
@@ -409,7 +401,6 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
...
@@ -409,7 +401,6 @@ 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
)
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
string
encrPolyHex
;
string
encrPolyHex
;
...
@@ -432,7 +423,6 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
...
@@ -432,7 +423,6 @@ 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
)
{
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
...
@@ -494,7 +484,6 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
...
@@ -494,7 +484,6 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
}
}
string
s
=
trustedGetSecretShares
(
_polyName
,
encrPoly
->
c_str
(),
pubKeysStrs
,
_t
,
_n
);
string
s
=
trustedGetSecretShares
(
_polyName
,
encrPoly
->
c_str
(),
pubKeysStrs
,
_t
,
_n
);
//cerr << "result is " << s << endl;
result
[
"secretShare"
]
=
s
;
result
[
"secretShare"
]
=
s
;
}
catch
(
SGXException
&
_e
)
{
}
catch
(
SGXException
&
_e
)
{
...
@@ -509,14 +498,12 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
...
@@ -509,14 +498,12 @@ 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
)
{
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
result
[
"result"
]
=
true
;
result
[
"result"
]
=
true
;
try
{
try
{
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
if
(
!
checkECDSAKeyName
(
_ethKeyName
))
{
throw
SGXException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
throw
SGXException
(
INVALID_ECDSA_KEY_NAME
,
"Invalid ECDSA key name"
);
}
}
...
@@ -537,7 +524,6 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
...
@@ -537,7 +524,6 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
}
}
}
catch
(
SGXException
&
_e
)
{
}
catch
(
SGXException
&
_e
)
{
//cerr << " err str " << _e.errString << endl;
result
[
"status"
]
=
_e
.
status
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"result"
]
=
false
;
result
[
"result"
]
=
false
;
...
@@ -549,14 +535,11 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
...
@@ -549,14 +535,11 @@ 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
)
{
Json
::
Value
result
;
Json
::
Value
result
;
result
[
"status"
]
=
0
;
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"errorMessage"
]
=
""
;
try
{
try
{
if
(
_secretShare
.
length
()
!=
(
uint64_t
)
_n
*
192
)
{
if
(
_secretShare
.
length
()
!=
(
uint64_t
)
_n
*
192
)
{
spdlog
::
error
(
"Invalid secret share length - {}"
,
_secretShare
.
length
());
spdlog
::
error
(
"Invalid secret share length - {}"
,
_secretShare
.
length
());
spdlog
::
error
(
"Secret share - {}"
,
_secretShare
);
spdlog
::
error
(
"Secret share - {}"
,
_secretShare
);
...
@@ -600,7 +583,6 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
...
@@ -600,7 +583,6 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
}
}
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShareImpl
(
const
string
&
_blsKeyName
)
{
Json
::
Value
SGXWalletServer
::
getBLSPublicKeyShareImpl
(
const
string
&
_blsKeyName
)
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
...
@@ -615,14 +597,12 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
...
@@ -615,14 +597,12 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
for
(
uint8_t
i
=
0
;
i
<
4
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
4
;
i
++
)
{
result
[
"blsPublicKeyShare"
][
i
]
=
public_key_vect
.
at
(
i
);
result
[
"blsPublicKeyShare"
][
i
]
=
public_key_vect
.
at
(
i
);
}
}
}
HANDLE_SGX_EXCEPTION
(
result
)
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
return
result
;
}
}
Json
::
Value
SGXWalletServer
::
complaintResponseImpl
(
const
string
&
_polyName
,
int
_ind
)
{
Json
::
Value
SGXWalletServer
::
complaintResponseImpl
(
const
string
&
_polyName
,
int
_ind
)
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
...
@@ -644,7 +624,6 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
...
@@ -644,7 +624,6 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
}
}
Json
::
Value
SGXWalletServer
::
multG2Impl
(
const
string
&
_x
)
{
Json
::
Value
SGXWalletServer
::
multG2Impl
(
const
string
&
_x
)
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
try
{
try
{
...
@@ -675,7 +654,6 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
...
@@ -675,7 +654,6 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
}
}
Json
::
Value
SGXWalletServer
::
getServerStatusImpl
()
{
Json
::
Value
SGXWalletServer
::
getServerStatusImpl
()
{
INIT_RESULT
(
result
)
INIT_RESULT
(
result
)
return
result
;
return
result
;
...
@@ -792,7 +770,6 @@ Json::Value SGXWalletServer::getServerVersion() {
...
@@ -792,7 +770,6 @@ Json::Value SGXWalletServer::getServerVersion() {
}
}
shared_ptr
<
string
>
SGXWalletServer
::
readFromDb
(
const
string
&
name
,
const
string
&
prefix
)
{
shared_ptr
<
string
>
SGXWalletServer
::
readFromDb
(
const
string
&
name
,
const
string
&
prefix
)
{
auto
dataStr
=
LevelDB
::
getLevelDb
()
->
readString
(
prefix
+
name
);
auto
dataStr
=
LevelDB
::
getLevelDb
()
->
readString
(
prefix
+
name
);
if
(
dataStr
==
nullptr
)
{
if
(
dataStr
==
nullptr
)
{
...
@@ -803,7 +780,6 @@ shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string
...
@@ -803,7 +780,6 @@ shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string
}
}
shared_ptr
<
string
>
SGXWalletServer
::
readKeyShare
(
const
string
&
_keyShareName
)
{
shared_ptr
<
string
>
SGXWalletServer
::
readKeyShare
(
const
string
&
_keyShareName
)
{
auto
keyShareStr
=
LevelDB
::
getLevelDb
()
->
readString
(
"BLSKEYSHARE:"
+
_keyShareName
);
auto
keyShareStr
=
LevelDB
::
getLevelDb
()
->
readString
(
"BLSKEYSHARE:"
+
_keyShareName
);
if
(
keyShareStr
==
nullptr
)
{
if
(
keyShareStr
==
nullptr
)
{
...
@@ -815,7 +791,6 @@ shared_ptr <string> SGXWalletServer::readKeyShare(const string &_keyShareName) {
...
@@ -815,7 +791,6 @@ shared_ptr <string> SGXWalletServer::readKeyShare(const string &_keyShareName) {
}
}
void
SGXWalletServer
::
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
_value
,
int
_index
,
int
_n
,
int
_t
)
{
void
SGXWalletServer
::
writeKeyShare
(
const
string
&
_keyShareName
,
const
string
&
_value
,
int
_index
,
int
_n
,
int
_t
)
{
Json
::
Value
val
;
Json
::
Value
val
;
Json
::
FastWriter
writer
;
Json
::
FastWriter
writer
;
...
@@ -850,6 +825,5 @@ void SGXWalletServer::writeDataToDB(const string &Name, const string &value) {
...
@@ -850,6 +825,5 @@ void SGXWalletServer::writeDataToDB(const string &Name, const string &value) {
}
}
LevelDB
::
getLevelDb
()
->
writeString
(
key
,
value
);
LevelDB
::
getLevelDb
()
->
writeString
(
key
,
value
);
}
}
ServerInit.cpp
View file @
2dc5a146
...
@@ -60,13 +60,10 @@ void initUserSpace() {
...
@@ -60,13 +60,10 @@ void initUserSpace() {
LevelDB
::
initDataFolderAndDBs
();
LevelDB
::
initDataFolderAndDBs
();
}
}
void
initEnclave
(
uint32_t
_logLevel
)
{
void
initEnclave
(
uint32_t
_logLevel
)
{
eid
=
0
;
eid
=
0
;
updated
=
0
;
updated
=
0
;
#ifndef SGX_HW_SIM
#ifndef SGX_HW_SIM
unsigned
long
support
;
unsigned
long
support
;
support
=
get_sgx_support
();
support
=
get_sgx_support
();
...
@@ -78,7 +75,6 @@ void initEnclave(uint32_t _logLevel) {
...
@@ -78,7 +75,6 @@ void initEnclave(uint32_t _logLevel) {
spdlog
::
debug
(
"SGX_DEBUG_FLAG = {}"
,
SGX_DEBUG_FLAG
);
spdlog
::
debug
(
"SGX_DEBUG_FLAG = {}"
,
SGX_DEBUG_FLAG
);
status
=
sgx_create_enclave_search
(
ENCLAVE_NAME
,
SGX_DEBUG_FLAG
,
&
token
,
status
=
sgx_create_enclave_search
(
ENCLAVE_NAME
,
SGX_DEBUG_FLAG
,
&
token
,
&
updated
,
&
eid
,
0
);
&
updated
,
&
eid
,
0
);
...
@@ -101,14 +97,9 @@ void initEnclave(uint32_t _logLevel) {
...
@@ -101,14 +97,9 @@ void initEnclave(uint32_t _logLevel) {
}
}
spdlog
::
info
(
"Enclave libtgmp library and logging initialized successfully"
);
spdlog
::
info
(
"Enclave libtgmp library and logging initialized successfully"
);
}
}
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
)
{
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
)
{
static
int
sgxServerInited
;
static
int
sgxServerInited
;
cout
<<
"Running sgxwallet version:"
<<
SGXWalletServer
::
getVersion
()
<<
endl
;
cout
<<
"Running sgxwallet version:"
<<
SGXWalletServer
::
getVersion
()
<<
endl
;
...
...
secure_enclave/secure_enclave.c
View file @
2dc5a146
...
@@ -1097,7 +1097,9 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
...
@@ -1097,7 +1097,9 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
*
errStatus
=
status
;
*
errStatus
=
status
;
snprintf
(
errString
,
BUF_LEN
,
"aes decrypt failed with status %d"
,
status
);
snprintf
(
errString
,
BUF_LEN
,
"aes decrypt failed with status %d"
,
status
);
domain_parameters_clear
(
curve
);
domain_parameters_clear
(
curve
);
return
;
return
;
}
}
...
@@ -1109,8 +1111,10 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
...
@@ -1109,8 +1111,10 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
if
(
mpz_set_str
(
privateKeyMpz
,
skey
,
ECDSA_SKEY_BASE
)
==
-
1
)
{
if
(
mpz_set_str
(
privateKeyMpz
,
skey
,
ECDSA_SKEY_BASE
)
==
-
1
)
{
*
errStatus
=
-
1
;
*
errStatus
=
-
1
;
snprintf
(
errString
,
BUF_LEN
,
"invalid secret key"
);
snprintf
(
errString
,
BUF_LEN
,
"invalid secret key"
);
mpz_clear
(
privateKeyMpz
);
mpz_clear
(
privateKeyMpz
);
domain_parameters_clear
(
curve
);
domain_parameters_clear
(
curve
);
return
;
return
;
}
}
...
@@ -1119,9 +1123,11 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
...
@@ -1119,9 +1123,11 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
if
(
mpz_set_str
(
msgMpz
,
hash
,
16
)
==
-
1
)
{
if
(
mpz_set_str
(
msgMpz
,
hash
,
16
)
==
-
1
)
{
*
errStatus
=
-
1
;
*
errStatus
=
-
1
;
snprintf
(
errString
,
BUF_LEN
,
"invalid message hash"
);
snprintf
(
errString
,
BUF_LEN
,
"invalid message hash"
);
mpz_clear
(
privateKeyMpz
);
mpz_clear
(
privateKeyMpz
);
mpz_clear
(
msgMpz
);
mpz_clear
(
msgMpz
);
domain_parameters_clear
(
curve
);
domain_parameters_clear
(
curve
);
return
;
return
;
}
}
...
@@ -1352,7 +1358,7 @@ void trustedGetEncryptedSecretShareAES(int *errStatus, char *errString, uint8_t
...
@@ -1352,7 +1358,7 @@ void trustedGetEncryptedSecretShareAES(int *errStatus, char *errString, uint8_t
LOG_DEBUG
(
__FUNCTION__
);
LOG_DEBUG
(
__FUNCTION__
);
char
skey
[
ECDSA_SKEY_LEN
];
char
skey
[
ECDSA_SKEY_LEN
];
memset
(
skey
,
0
,
BUF
_LEN
);
memset
(
skey
,
0
,
ECDSA_SKEY
_LEN
);
char
pub_key_x
[
BUF_LEN
];
char
pub_key_x
[
BUF_LEN
];
memset
(
pub_key_x
,
0
,
BUF_LEN
);
memset
(
pub_key_x
,
0
,
BUF_LEN
);
char
pub_key_y
[
BUF_LEN
];
char
pub_key_y
[
BUF_LEN
];
...
...
sgxwallet.c
View file @
2dc5a146
...
@@ -68,7 +68,6 @@ void printUsage() {
...
@@ -68,7 +68,6 @@ void printUsage() {
enum
log_level
{
L_TRACE
=
0
,
L_DEBUG
=
1
,
L_INFO
=
2
,
L_WARNING
=
3
,
L_ERROR
=
4
};
enum
log_level
{
L_TRACE
=
0
,
L_DEBUG
=
1
,
L_INFO
=
2
,
L_WARNING
=
3
,
L_ERROR
=
4
};
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
bool
encryptKeysOption
=
false
;
bool
encryptKeysOption
=
false
;
bool
useHTTPSOption
=
true
;
bool
useHTTPSOption
=
true
;
bool
printDebugInfoOption
=
false
;
bool
printDebugInfoOption
=
false
;
...
@@ -84,9 +83,6 @@ int main(int argc, char *argv[]) {
...
@@ -84,9 +83,6 @@ int main(int argc, char *argv[]) {
exit
(
1
);
exit
(
1
);
}
}
while
((
opt
=
getopt
(
argc
,
argv
,
"cshd0abyvVn"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"cshd0abyvVn"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'h'
:
case
'h'
:
...
...
testw.cpp
View file @
2dc5a146
...
@@ -1011,6 +1011,7 @@ TEST_CASE_METHOD(TestFixture, "Many threads ecdsa dkg bls", "[many-threads-crypt
...
@@ -1011,6 +1011,7 @@ TEST_CASE_METHOD(TestFixture, "Many threads ecdsa dkg bls", "[many-threads-crypt
TEST_CASE_METHOD
(
TestFixture
,
"AES == NOT AES"
,
"[aes-not-aes]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"AES == NOT AES"
,
"[aes-not-aes]"
)
{
std
::
string
key
=
SAMPLE_AES_KEY
;
std
::
string
key
=
SAMPLE_AES_KEY
;
std
::
string
hex
=
SAMPLE_HEX_HASH
;
int
errStatus
=
0
;
int
errStatus
=
0
;
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
...
@@ -1019,36 +1020,34 @@ TEST_CASE_METHOD(TestFixture, "AES == NOT AES", "[aes-not-aes]") {
...
@@ -1019,36 +1020,34 @@ TEST_CASE_METHOD(TestFixture, "AES == NOT AES", "[aes-not-aes]") {
trustedEncryptKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
key
.
c_str
(),
encrPrivKey
.
data
(),
&
enc_len
);
trustedEncryptKey
(
eid
,
&
errStatus
,
errMsg
.
data
(),
key
.
c_str
(),
encrPrivKey
.
data
(),
&
enc_len
);
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
int
errStatusAES
=
0
;
vector
<
char
>
errMsgAES
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encrPrivKeyAES
(
BUF_LEN
,
0
);
uint32_t
enc_lenAES
=
0
;
trustedEncryptKeyAES
(
eid
,
&
errStatusAES
,
errMsgAES
.
data
(),
key
.
c_str
(),
encrPrivKeyAES
.
data
(),
&
enc_lenAES
);
REQUIRE
(
errStatusAES
==
SGX_SUCCESS
);
errMsg
.
clear
();
errMsg
.
clear
();
string
hex
=
SAMPLE_HEX_HASH
;
vector
<
char
>
signatureR
(
BUF_LEN
,
0
);
vector
<
char
>
signatureR
(
BUF_LEN
,
0
);
vector
<
char
>
signatureS
(
BUF_LEN
,
0
);
vector
<
char
>
signatureS
(
BUF_LEN
,
0
);
uint8_t
signatureV
=
0
;
uint8_t
signatureV
=
0
;
//uint32_t dec_len = 0;
status
=
trustedEcdsaSign
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrPrivKey
.
data
(),
enc_len
,
(
unsigned
char
*
)
hex
.
data
(),
status
=
trustedEcdsaSign
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encrPrivKey
.
data
(),
enc_len
,
(
unsigned
char
*
)
hex
.
data
(),
signatureR
.
data
(),
signatureR
.
data
(),
signatureS
.
data
(),
&
signatureV
,
16
);
signatureS
.
data
(),
&
signatureV
,
16
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
REQUIRE
(
errStatus
==
SGX_SUCCESS
);
int
errStatusAES
=
0
;
vector
<
char
>
errMsgAES
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encrPrivKeyAES
(
BUF_LEN
,
0
);
uint32_t
enc_lenAES
=
0
;
trustedEncryptKeyAES
(
eid
,
&
errStatusAES
,
errMsgAES
.
data
(),
key
.
c_str
(),
encrPrivKeyAES
.
data
(),
&
enc_lenAES
);
REQUIRE
(
errStatusAES
==
SGX_SUCCESS
);
errMsgAES
.
clear
();
errMsgAES
.
clear
();
vector
<
char
>
signatureRAES
(
BUF_LEN
,
0
);
vector
<
char
>
signatureRAES
(
BUF_LEN
,
0
);
vector
<
char
>
signatureSAES
(
BUF_LEN
,
0
);
vector
<
char
>
signatureSAES
(
BUF_LEN
,
0
);
uint8_t
signatureVAES
=
0
;
uint8_t
signatureVAES
=
0
;
uint32_t
dec_lenAES
=
0
;
status
=
trustedEcdsaSignAES
(
eid
,
&
errStatusAES
,
errMsgAES
.
data
(),
encrPrivKeyAES
.
data
(),
enc_lenAES
,
(
unsigned
char
*
)
hex
.
data
(),
status
=
trustedEcdsaSignAES
(
eid
,
&
errStatusAES
,
errMsgAES
.
data
(),
encrPrivKeyAES
.
data
(),
dec_lenAES
,
(
unsigned
char
*
)
hex
.
data
(),
signatureRAES
.
data
(),
signatureRAES
.
data
(),
signatureSAES
.
data
(),
&
signatureVAES
,
16
);
signatureSAES
.
data
(),
&
signatureVAES
,
16
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
errStatusAES
==
SGX_SUCCESS
);
REQUIRE
(
signatureR
==
signatureRAES
);
REQUIRE
(
signatureR
==
signatureRAES
);
REQUIRE
(
signatureS
==
signatureSAES
);
REQUIRE
(
signatureS
==
signatureSAES
);
...
...
testw.py
View file @
2dc5a146
...
@@ -50,8 +50,8 @@ testList = [ "[cert-sign]",
...
@@ -50,8 +50,8 @@ testList = [ "[cert-sign]",
"[many-threads-crypto]"
,
"[many-threads-crypto]"
,
"[aes-encrypt-decrypt]"
,
"[aes-encrypt-decrypt]"
,
"[sgx-encrypt-decrypt]"
,
"[sgx-encrypt-decrypt]"
,
"[aes-dkg]"
#
,
"[aes-dkg]"
,
#"[aes-not-aes]" <- this test doesn't pass for now - will fix it later
"[aes-not-aes]"
]
]
...
...
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