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
77cc66e6
Unverified
Commit
77cc66e6
authored
Jul 16, 2020
by
Stan Kladko
Committed by
GitHub
Jul 16, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #126 from skalenetwork/SKALE-2871-reduce-sgx-logs
Skale 2871 reduce sgx logs
parents
7fa76e24
9e446bdf
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
37 deletions
+54
-37
LevelDB.cpp
LevelDB.cpp
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+18
-13
SGXWalletServer.h
SGXWalletServer.h
+2
-4
docker-compose.yml
run_sgx_sim/docker-compose.yml
+1
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+11
-11
sgxwall.cpp
sgxwall.cpp
+16
-4
sgxwallet.h
sgxwallet.h
+2
-0
testw.cpp
testw.cpp
+3
-3
No files found.
LevelDB.cpp
View file @
77cc66e6
...
@@ -53,7 +53,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
...
@@ -53,7 +53,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
throw
SGXException
(
NULL_DATABASE
,
"Null db"
);
throw
SGXException
(
NULL_DATABASE
,
"Null db"
);
}
}
spdlog
::
info
(
"key to read from db: {}"
,
_key
);
spdlog
::
debug
(
"key to read from db: {}"
,
_key
);
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
...
...
SGXWalletServer.cpp
View file @
77cc66e6
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
#include <stdio.h>
#include <stdio.h>
#include "sgxwallet_common.h"
#include "sgxwallet_common.h"
#include "sgxwallet.h"
#include "SGXException.h"
#include "SGXException.h"
#include "LevelDB.h"
#include "LevelDB.h"
...
@@ -50,27 +52,30 @@
...
@@ -50,27 +52,30 @@
#include "Log.h"
#include "Log.h"
void
setFullOptions
(
int
_printDebugInfo
,
using
namespace
std
;
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
)
{
if
(
_printDebugInfo
)
void
setFullOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
)
{
spdlog
::
set_level
(
spdlog
::
level
::
debug
);
else
if
(
_printTraceInfo
)
{
CHECK_STATE
(
_logLevel
<=
2
)
if
(
_logLevel
==
L_TRACE
)
{
spdlog
::
set_level
(
spdlog
::
level
::
trace
);
spdlog
::
set_level
(
spdlog
::
level
::
trace
);
}
else
if
(
_printTraceInfo
)
{
}
else
if
(
_logLevel
==
L_DEBUG
)
{
spdlog
::
set_level
(
spdlog
::
level
::
debug
);
}
else
{
spdlog
::
set_level
(
spdlog
::
level
::
info
);
spdlog
::
set_level
(
spdlog
::
level
::
info
);
}
}
useHTTPS
=
_useHTTPS
;
useHTTPS
=
_useHTTPS
;
spdlog
::
info
(
"useHTTPS set to "
+
std
::
to_string
(
_useHTTPS
));
spdlog
::
info
(
"useHTTPS set to "
+
to_string
(
_useHTTPS
));
autoconfirm
=
_autoconfirm
;
autoconfirm
=
_autoconfirm
;
spdlog
::
info
(
"autoconfirm set to "
+
std
::
to_string
(
autoconfirm
));
spdlog
::
info
(
"autoconfirm set to "
+
to_string
(
autoconfirm
));
encryptKeys
=
_encryptKeys
;
encryptKeys
=
_encryptKeys
;
spdlog
::
info
(
"encryptKeys set to "
+
std
::
to_string
(
encryptKeys
));
spdlog
::
info
(
"encryptKeys set to "
+
to_string
(
encryptKeys
));
}
}
void
setOptions
(
int
_printDebugInfo
,
void
setOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
)
{
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
)
{
setFullOptions
(
_logLevel
,
_useHTTPS
,
_autoconfirm
,
false
);
setFullOptions
(
_printDebugInfo
,
_printTraceInfo
,
_useHTTPS
,
_autoconfirm
,
false
);
}
}
bool
isStringDec
(
const
string
&
_str
)
{
bool
isStringDec
(
const
string
&
_str
)
{
...
...
SGXWalletServer.h
View file @
77cc66e6
...
@@ -30,11 +30,9 @@
...
@@ -30,11 +30,9 @@
#define EXTERNC
#define EXTERNC
#endif
#endif
EXTERNC
void
setFullOptions
(
int
_printDebugInfo
,
EXTERNC
void
setFullOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
);
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
,
int
_encryptKeys
);
EXTERNC
void
setOptions
(
int
_printDebugInfo
,
EXTERNC
void
setOptions
(
uint64_t
_logLevel
,
int
_useHTTPS
,
int
_autoconfirm
);
int
_printTraceInfo
,
int
_useHTTPS
,
int
_autoconfirm
);
#endif //SGXWALLET_SGXWALLETSERVER_H
#endif //SGXWALLET_SGXWALLETSERVER_H
run_sgx_sim/docker-compose.yml
View file @
77cc66e6
...
@@ -16,5 +16,5 @@ services:
...
@@ -16,5 +16,5 @@ services:
max-size
:
"
10m"
max-size
:
"
10m"
max-file
:
"
4"
max-file
:
"
4"
restart
:
unless-stopped
restart
:
unless-stopped
command
:
-s -y
-d
command
:
-s -y
secure_enclave/secure_enclave.c
View file @
77cc66e6
...
@@ -90,7 +90,7 @@ void trustedEnclaveInit(uint32_t _logLevel) {
...
@@ -90,7 +90,7 @@ void trustedEnclaveInit(uint32_t _logLevel) {
enclave_init
();
enclave_init
();
LOG_
DEBUG
(
"SUCCESS
"
);
LOG_
INFO
(
"Successfully inited enclave
"
);
}
}
void
free_function
(
void
*
ptr
,
size_t
sz
)
{
void
free_function
(
void
*
ptr
,
size_t
sz
)
{
...
@@ -1034,8 +1034,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -1034,8 +1034,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
int
status
=
AES_decrypt
(
encryptedPrivateKey
,
enc_len
,
skey
);
int
status
=
AES_decrypt
(
encryptedPrivateKey
,
enc_len
,
skey
);
skey
[
enc_len
-
SGX_AESGCM_MAC_SIZE
-
SGX_AESGCM_IV_SIZE
]
=
'\0'
;
skey
[
enc_len
-
SGX_AESGCM_MAC_SIZE
-
SGX_AESGCM_IV_SIZE
]
=
'\0'
;
LOG_
INFO
(
"ENCRYPTED SKEY"
);
LOG_
TRACE
(
"ENCRYPTED SKEY"
);
LOG_
INFO
(
skey
);
LOG_
TRACE
(
skey
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
snprintf
(
errString
,
BUF_LEN
,
"AES_decrypt failed with status %d"
,
status
);
snprintf
(
errString
,
BUF_LEN
,
"AES_decrypt failed with status %d"
,
status
);
...
@@ -1059,17 +1059,17 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -1059,17 +1059,17 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
return
;
return
;
}
}
LOG_
INFO
(
"SET STR SUCCESS"
);
LOG_
TRACE
(
"SET STR SUCCESS"
);
//Public key
//Public key
point
Pkey
=
point_init
();
point
Pkey
=
point_init
();
signature_extract_public_key
(
Pkey
,
privateKeyMpz
,
curve
);
signature_extract_public_key
(
Pkey
,
privateKeyMpz
,
curve
);
LOG_
INFO
(
"SIGNATURE EXTRACT PK SUCCESS"
);
LOG_
TRACE
(
"SIGNATURE EXTRACT PK SUCCESS"
);
point
Pkey_test
=
point_init
();
point
Pkey_test
=
point_init
();
point_multiplication
(
Pkey_test
,
privateKeyMpz
,
curve
->
G
,
curve
);
point_multiplication
(
Pkey_test
,
privateKeyMpz
,
curve
->
G
,
curve
);
LOG_
INFO
(
"POINT MULTIPLICATION SUCCESS"
);
LOG_
TRACE
(
"POINT MULTIPLICATION SUCCESS"
);
if
(
!
point_cmp
(
Pkey
,
Pkey_test
))
{
if
(
!
point_cmp
(
Pkey
,
Pkey_test
))
{
snprintf
(
errString
,
BUF_LEN
,
"Points are not equal"
);
snprintf
(
errString
,
BUF_LEN
,
"Points are not equal"
);
...
@@ -1082,14 +1082,14 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -1082,14 +1082,14 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
return
;
return
;
}
}
LOG_
INFO
(
"POINTS CMP SUCCESS"
);
LOG_
TRACE
(
"POINTS CMP SUCCESS"
);
int
len
=
mpz_sizeinbase
(
Pkey
->
x
,
ECDSA_SKEY_BASE
)
+
2
;
int
len
=
mpz_sizeinbase
(
Pkey
->
x
,
ECDSA_SKEY_BASE
)
+
2
;
char
arr_x
[
len
];
char
arr_x
[
len
];
mpz_get_str
(
arr_x
,
ECDSA_SKEY_BASE
,
Pkey
->
x
);
mpz_get_str
(
arr_x
,
ECDSA_SKEY_BASE
,
Pkey
->
x
);
LOG_
INFO
(
"GET STR X SUCCESS"
);
LOG_
TRACE
(
"GET STR X SUCCESS"
);
LOG_
INFO
(
arr_x
);
LOG_
TRACE
(
arr_x
);
int
n_zeroes
=
64
-
strlen
(
arr_x
);
int
n_zeroes
=
64
-
strlen
(
arr_x
);
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
...
@@ -1100,8 +1100,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -1100,8 +1100,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
char
arr_y
[
mpz_sizeinbase
(
Pkey
->
y
,
ECDSA_SKEY_BASE
)
+
2
];
char
arr_y
[
mpz_sizeinbase
(
Pkey
->
y
,
ECDSA_SKEY_BASE
)
+
2
];
mpz_get_str
(
arr_y
,
ECDSA_SKEY_BASE
,
Pkey
->
y
);
mpz_get_str
(
arr_y
,
ECDSA_SKEY_BASE
,
Pkey
->
y
);
LOG_
INFO
(
"GET STR Y SUCCESS"
);
LOG_
TRACE
(
"GET STR Y SUCCESS"
);
LOG_
INFO
(
arr_y
);
LOG_
TRACE
(
arr_y
);
n_zeroes
=
64
-
strlen
(
arr_y
);
n_zeroes
=
64
-
strlen
(
arr_y
);
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
pub_key_y
[
i
]
=
'0'
;
pub_key_y
[
i
]
=
'0'
;
...
...
sgxwall.cpp
View file @
77cc66e6
...
@@ -56,7 +56,7 @@ void SGXWallet::printUsage() {
...
@@ -56,7 +56,7 @@ void SGXWallet::printUsage() {
cerr
<<
"-T Generate test keys
\n
"
;
cerr
<<
"-T Generate test keys
\n
"
;
}
}
enum
log_level
{
L_TRACE
=
0
,
L_DEBUG
=
1
,
L_INFO
=
2
,
L_WARNING
=
3
,
L_ERROR
=
4
};
void
SGXWallet
::
serializeKeys
(
const
vector
<
string
>&
_ecdsaKeyNames
,
const
vector
<
string
>&
_blsKeyNames
,
const
string
&
_fileName
)
{
void
SGXWallet
::
serializeKeys
(
const
vector
<
string
>&
_ecdsaKeyNames
,
const
vector
<
string
>&
_blsKeyNames
,
const
string
&
_fileName
)
{
Json
::
Value
top
(
Json
::
objectValue
);
Json
::
Value
top
(
Json
::
objectValue
);
...
@@ -149,14 +149,26 @@ int main(int argc, char *argv[]) {
...
@@ -149,14 +149,26 @@ int main(int argc, char *argv[]) {
}
}
}
}
setFullOptions
(
printDebugInfoOption
,
printTraceInfoOption
,
useHTTPSOption
,
autoconfirmOption
,
encryptKeysOption
);
uint64_t
logLevel
=
L_INFO
;
if
(
printDebugInfoOption
)
{
logLevel
=
L_DEBUG
;
}
if
(
printTraceInfoOption
)
{
logLevel
=
L_TRACE
;
}
setFullOptions
(
logLevel
,
useHTTPSOption
,
autoconfirmOption
,
encryptKeysOption
);
uint32_t
enclaveLogLevel
=
L_INFO
;
uint32_t
enclaveLogLevel
=
L_INFO
;
if
(
printDebugInfoOption
)
{
enclaveLogLevel
=
L_DEBUG
;
}
if
(
printTraceInfoOption
)
{
if
(
printTraceInfoOption
)
{
enclaveLogLevel
=
L_TRACE
;
enclaveLogLevel
=
L_TRACE
;
}
else
if
(
printDebugInfoOption
)
{
enclaveLogLevel
=
L_DEBUG
;
}
}
initAll
(
enclaveLogLevel
,
checkClientCertOption
,
autoSignClientCertOption
);
initAll
(
enclaveLogLevel
,
checkClientCertOption
,
autoSignClientCertOption
);
...
...
sgxwallet.h
View file @
77cc66e6
...
@@ -51,4 +51,6 @@ extern sgx_status_t status;
...
@@ -51,4 +51,6 @@ extern sgx_status_t status;
#define ENCLAVE_NAME "secure_enclave.signed.so"
#define ENCLAVE_NAME "secure_enclave.signed.so"
enum
log_level
{
L_TRACE
=
0
,
L_DEBUG
=
1
,
L_INFO
=
2
,
L_WARNING
=
3
,
L_ERROR
=
4
};
#endif //SGXWALLET_SGXWALLET_H
#endif //SGXWALLET_SGXWALLET_H
testw.cpp
View file @
77cc66e6
...
@@ -70,8 +70,8 @@ class TestFixture {
...
@@ -70,8 +70,8 @@ class TestFixture {
public
:
public
:
TestFixture
()
{
TestFixture
()
{
TestUtils
::
resetDB
();
TestUtils
::
resetDB
();
setOptions
(
false
,
false
,
false
,
true
);
setOptions
(
L_INFO
,
false
,
true
);
initAll
(
2
,
false
,
true
);
initAll
(
L_INFO
,
false
,
true
);
}
}
~
TestFixture
()
{
~
TestFixture
()
{
...
@@ -83,7 +83,7 @@ class TestFixtureHTTPS {
...
@@ -83,7 +83,7 @@ class TestFixtureHTTPS {
public
:
public
:
TestFixtureHTTPS
()
{
TestFixtureHTTPS
()
{
TestUtils
::
resetDB
();
TestUtils
::
resetDB
();
setOptions
(
false
,
false
,
true
,
true
);
setOptions
(
L_INFO
,
true
,
true
);
initAll
(
0
,
false
,
true
);
initAll
(
0
,
false
,
true
);
}
}
...
...
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