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
8cc1d2c4
Unverified
Commit
8cc1d2c4
authored
Dec 11, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature/SKALE-3023-comand-for-sgx-keys-information
parents
ff80f1cc
c2042fe5
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
245 additions
and
137 deletions
+245
-137
BLSCrypto.cpp
BLSCrypto.cpp
+1
-1
DKGCrypto.cpp
DKGCrypto.cpp
+34
-33
ECDSACrypto.cpp
ECDSACrypto.cpp
+2
-2
Log.cpp
Log.cpp
+3
-3
Log.h
Log.h
+16
-9
SEKManager.cpp
SEKManager.cpp
+1
-1
SGXException.h
SGXException.h
+17
-6
SGXWalletServer.cpp
SGXWalletServer.cpp
+88
-61
TestUtils.cpp
TestUtils.cpp
+4
-5
VERSION
VERSION
+1
-1
sgxwallet_common.h
sgxwallet_common.h
+76
-13
testw.cpp
testw.cpp
+2
-2
No files found.
BLSCrypto.cpp
View file @
8cc1d2c4
...
...
@@ -140,7 +140,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
uint64_t
binLen
;
if
(
!
hex2carray
(
_hashHex
,
&
binLen
,
hash
->
data
(),
hash
->
size
()))
{
throw
SGXException
(
INVALID_HEX
,
"
Invalid hash"
);
throw
SGXException
(
SIGN_AES_INVALID_HASH
,
string
(
__FUNCTION__
)
+
":
Invalid hash"
);
}
shared_ptr
<
signatures
::
Bls
>
obj
;
...
...
DKGCrypto.cpp
View file @
8cc1d2c4
This diff is collapsed.
Click to expand it.
ECDSACrypto.cpp
View file @
8cc1d2c4
...
...
@@ -96,7 +96,7 @@ string getECDSAPubKey(const std::string& _encryptedKeyHex) {
if
(
!
hex2carray
(
_encryptedKeyHex
.
c_str
(),
&
enc_len
,
encrPrKey
.
data
(),
BUF_LEN
))
{
throw
SGXException
(
INVALID
_HEX
,
"Invalid encryptedKeyHex"
);
throw
SGXException
(
GET_ECDSA_PUB_KEY_INVALID_KEY
_HEX
,
"Invalid encryptedKeyHex"
);
}
sgx_status_t
status
=
SGX_SUCCESS
;
...
...
@@ -185,7 +185,7 @@ vector <string> ecdsaSignHash(const std::string& encryptedKeyHex, const char *ha
if
(
!
hex2carray
(
encryptedKeyHex
.
c_str
(),
&
decLen
,
encryptedKey
.
data
(),
BUF_LEN
))
{
throw
SGXException
(
INVALID
_HEX
,
"Invalid encryptedKeyHex"
);
throw
SGXException
(
ECDSA_SIGN_INVALID_KEY
_HEX
,
"Invalid encryptedKeyHex"
);
}
sgx_status_t
status
=
SGX_SUCCESS
;
...
...
Log.cpp
View file @
8cc1d2c4
...
...
@@ -52,7 +52,7 @@ level_enum Log::logLevelFromString(string &_s) {
}
void
Log
::
handleSGXException
(
Json
::
Value
&
_result
,
SGXException
&
_e
)
{
spdlog
::
error
(
"Responding with JSON error:"
+
_e
.
errString
);
_result
[
"status"
]
=
_e
.
status
;
_result
[
"errorMessage"
]
=
_e
.
errString
;
spdlog
::
error
(
"Responding with JSON error:"
+
_e
.
getErrString
()
);
_result
[
"status"
]
=
_e
.
getStatus
()
;
_result
[
"errorMessage"
]
=
_e
.
getErrString
()
;
}
Log.h
View file @
8cc1d2c4
/*
*
Copyright (C) 2019-Present SKALE Labs
This file is part of sgxwallet.
...
...
@@ -83,26 +84,32 @@ spdlog::info(string(__FUNCTION__) + " processed " + to_string(__COUNT__) + " re
}
// if uknown error, the error is 10000 + line number
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
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.";
int errStatus = -1 * (10000 + __LINE__); boost::ignore_unused(errStatus); string errMsg(BUF_LEN, '\0');__RESULT__["status"] = -1 * (10000 + __LINE__); __RESULT__["errorMessage"] = \
string(__FUNCTION__); \
string(__FUNCTION__) + ": server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
catch (SGXException& _e) { \
if (_e.status != 0) {__RESULT__["status"] = _e.status;} else { __RESULT__["status"] = UNKNOWN_ERROR;}; \
__RESULT__["errorMessage"] = _e.errString; \
catch (const SGXException& _e) { \
if (_e.getStatus() != 0) {__RESULT__["status"] = _e.getStatus();} else { __RESULT__["status"] = -1 * (10000 + __LINE__);}; \
__RESULT__["errorMessage"] = _e.getErrString(); \
if (_e.getErrString().size() == 0) {__RESULT__["errorMessage"] = string(__FUNCTION__);}; \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
} catch (exception& _e) { \
__RESULT__["errorMessage"] = _e.what(); \
} catch (const exception& _e) { \
__RESULT__["status"] = -1 * (10000 + __LINE__); \
exception_ptr p = current_exception(); \
__RESULT__["errorMessage"] = string(p.__cxa_exception_type()->name()) + ":" + _e.what(); \
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
}\
catch (...) { \
exception_ptr p = current_exception(); \
printf("Exception %s \n",
p.__cxa_exception_type()->name()); \
__RESULT__["errorMessage"] =
"Unknown exception";
\
spdlog::error(string("Exception:") +
p.__cxa_exception_type()->name()); \
__RESULT__["errorMessage"] =
string(p.__cxa_exception_type()->name());
\
spdlog::error("JSON call failed {}", __FUNCTION__); \
return __RESULT__; \
}
...
...
SEKManager.cpp
View file @
8cc1d2c4
...
...
@@ -231,7 +231,7 @@ void setSEK(shared_ptr <string> hex_encrypted_SEK) {
if
(
!
hex2carray
(
hex_encrypted_SEK
->
c_str
(),
&
len
,
encrypted_SEK
,
BUF_LEN
))
{
throw
SGXException
(
INVALID
_HEX
,
"Invalid encrypted SEK Hex"
);
throw
SGXException
(
SET_SEK_INVALID_SEK
_HEX
,
"Invalid encrypted SEK Hex"
);
}
sgx_status_t
status
=
SGX_SUCCESS
;
...
...
SGXException.h
View file @
8cc1d2c4
...
...
@@ -27,19 +27,30 @@
#include <string>
#include <exception>
class
SGXException
:
public
std
::
exception
{
using
namespace
std
;
class
SGXException
:
public
exception
{
const
int32_t
status
;
const
string
errString
;
public
:
int32_t
status
;
std
::
string
errString
;
SGXException
(
int32_t
_status
,
const
string
&
_errString
)
:
status
(
_status
),
errString
(
_errString
)
{}
const
string
getMessage
()
const
{
return
"SGXException:status:"
+
to_string
(
status
)
+
":"
+
errString
;
}
SGXException
(
int32_t
_status
,
const
char
*
_errString
)
:
status
(
_status
),
errString
(
_errString
)
{}
const
string
&
getErrString
()
const
{
return
errString
;
}
std
::
string
getMessage
()
{
return
"SGXException:status:"
+
std
::
to_string
(
status
)
+
":"
+
errString
;
const
int32_t
getStatus
()
const
{
return
status
;
}
};
#endif //SGXD_RPCEXCEPTION_H
SGXWalletServer.cpp
View file @
8cc1d2c4
This diff is collapsed.
Click to expand it.
TestUtils.cpp
View file @
8cc1d2c4
...
...
@@ -241,7 +241,7 @@ void TestUtils::sendRPCRequest() {
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
(),
32
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
TEST_
INVALID_HEX
,
"Invalid hash"
);
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
...
...
@@ -355,7 +355,7 @@ void TestUtils::sendRPCRequestV2() {
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
(),
32
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
TEST_
INVALID_HEX
,
"Invalid hash"
);
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
...
...
@@ -488,7 +488,7 @@ void TestUtils::doDKG(StubClient &c, int n, int t,
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
(),
32
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
TEST_
INVALID_HEX
,
"Invalid hash"
);
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
pubKeyShares
;
...
...
@@ -629,7 +629,7 @@ void TestUtils::doDKGV2(StubClient &c, int n, int t,
auto
hash_arr
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
(),
32
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
TEST_
INVALID_HEX
,
"Invalid hash"
);
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
pubKeyShares
;
...
...
@@ -721,7 +721,6 @@ int sessionKeyRecoverDH(const char *skey_str, const char *sshare, char *common_k
mpz_clear
(
skey
);
point_clear
(
pub_keyB
);
point_clear
(
session_key
);
return
ret
;
}
...
...
VERSION
View file @
8cc1d2c4
1.64.1
\ No newline at end of file
1.64.2
\ No newline at end of file
sgxwallet_common.h
View file @
8cc1d2c4
...
...
@@ -67,35 +67,98 @@ extern bool autoconfirm;
#define ECDSA_ENCR_LEN 93
#define ECDSA_BIN_LEN 33
#define UNKNOWN_ERROR -1
#define PLAINTEXT_KEY_TOO_LONG -2
#define UNPADDED_KEY -3
#define NULL_KEY -4
#define INCORRECT_STRING_CONVERSION -5
#define ENCRYPTED_KEY_TOO_LONG -6
#define SEAL_KEY_FAILED -7
#define KEY_SHARE_DOES_NOT_EXIST -7
#define KEY_SHARE_ALREADY_EXISTS -8
#define COULD_NOT_ACCESS_DATABASE -9
#define NULL_DATABASE -10
#define INVALID_POLY_NAME -11
#define INVALID_DKG_PARAMS -12
#define BLS_SIGN_INVALID_KS_NAME -11
#define BLS_SIGN_INVALID_PARAMS -12
#define INVALID_SECRET_SHARES_LENGTH -13
#define INVALID_BLS_NAME -15
#define CERT_REQUEST_DOES_NOT_EXIST -14
#define BLS_IMPORT_INVALID_KEY_NAME -15
#define SEAL_KEY_FAILED -16
#define GET_VV_INVALID_POLY_HEX -17
#define GET_SS_INVALID_HEX -18
#define DECRYPT_DH_KEY_INVALID_KEY_HEX -19
#define INVALID_ECDSA_KEY_NAME -20
#define
INVALID
_HEX -21
#define
VERIFY_SHARES_INVALID_KEY
_HEX -21
#define INVALID_ECSDA_SIGNATURE -22
#define KEY_NAME_ALREADY_EXISTS -23 \
#define KEY_NAME_ALREADY_EXISTS -23
#define BLS_IMPORT_EMPTY_ENCRYPTED_KEY_SHARE -24
#define BLS_IMPORT_INVALID_KEY_SHARE -25
#define INVALID_BLS_HEX -26
#define INVALID_ECDSA_HEX -27
#define COULD_NOT_BLS_SIGN -28
#define INVALID_ECDSA_IMPORT_KEY_NAME -29
#define INVALID_ECDSA_IMPORT_HEX -30
#define ECDSA_GEN_EMPTY_KEY -31
#define INVALID_ECDSA_SIGN_KEY_NAME -32
#define ERROR_IN_ENCLAVE -33
#define INVALID_ECDSA_SIGN_HASH -34
#define INVALID_ECDSA_SIGN_BASE -35
#define INVALID_ECSDA_SIGN_SIGNATURE -36
#define INVALID_ECDSA_GETPKEY_KEY_NAME -37
#define INVALID_GEN_DKG_POLY_NAME -38
#define INVALID_GEN_DKG_PARAM_T -39
#define INVALID_VERIFY_DKG_PARAM_T -40
#define INVALID_DKG_GETVV_POLY_NAME -41
#define INVALID_DKG_GETVV_PARAMS -42
#define INVALID_DKG_GETSS_POLY_NAME -43
#define FILE_NOT_FOUND -44
#define INVALID_DKG_GETSS_PARAMS -45
#define INVALID_DKG_GETSS_PUB_KEY_COUNT -46
#define INVALID_DKG_GETSS_KEY_HEX -47
#define INVALID_DKG_VERIFY_ECDSA_KEY_NAME -48
#define INVALID_DKG_VERIFY_PARAMS -49
#define INVALID_DKG_VERIFY_SS_HEX -50
#define INVALID_DKG_VERIFY_PUBSHARES_LENGTH -51
#define INVALID_CREATE_BLS_KEY_SECRET_SHARES_LENGTH -52
#define INVALID_CREATE_BLS_ECDSA_KEY_NAME -53
#define INVALID_CREATE_BLS_POLY_NAME -54
#define FAIL_TO_CREATE_CERTIFICATE -55
#define INVALID_CREATE_BLS_KEY_NAME -56
#define INVALID_CREATE_BLS_DKG_PARAMS -57
#define INVALID_CREATE_BLS_SHARE -58
#define INVALID_GET_BLS_PUBKEY_NAME -59
#define INVALID_DKG_CALCULATE_ALL_PARAMS -60
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES -61
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_SIZE -62
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_STRING -63
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBSHARES_SLENGTH -64
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBKEYS_SIZE -65
#define INVALID_COMPLAINT_RESPONSE_POLY_NAME -66
#define INVALID_DKG_GETSS_V2_PARAMS -63
#define INVALID_DKG_GETSS_V2_POLY_NAME -64
#define INVALID_DKG_GETSS_V2_PUBKEY_COUNT -65
#define INVALID_DKG_GETSS_V2_PUBKEY_HEX -66
#define INVALID_DKG_VV_V2_ECDSA_KEY_NAME -67
#define INVALID_DKG_VV_V2_PARAMS -68
#define INVALID_DKG_VV_V2_SS_HEX -69
#define INVALID_DKG_VV_V2_SS_COUNT -70
#define EXCEPTION_IN_CONVERT_HEX_TO_DEC -71
#define GET_SS_V2_INVALID_HEX -72
#define EXCEPTION_IN_CONVERT_G2_STRING -73
#define CONVERT_G2_INCORRECT_STRING_CONVERSION -74
#define DELETE_BLS_KEY_INVALID_KEYNAME -75
#define DELETE_BLS_KEY_NOT_FOUND -76
#define VERIFY_SHARES_INVALID_PUBLIC_SHARES -77
#define VERIFY_SHARES_V2_INVALID_POLY_HEX -78
#define VERIFY_SHARES_V2_INVALID_PUBLIC_SHARES -79
#define CREATE_BLS_SHARE_INVALID_KEY_HEX -80
#define GET_BLS_PUBKEY_INVALID_KEY_HEX -81
#define GENERATE_DKG_POLY_INVALID_PARAMS -82
#define SIGN_FUNCTION_INVALID_HEX -83
#define SIGN_AES_INVALID_HASH -84
#define GET_ECDSA_PUB_KEY_INVALID_KEY_HEX -85
#define ECDSA_SIGN_INVALID_KEY_HEX -86
#define SET_SEK_INVALID_SEK_HEX -87
#define TEST_INVALID_HEX -88
#define SGX_ENCLAVE_ERROR -666
...
...
testw.cpp
View file @
8cc1d2c4
...
...
@@ -825,7 +825,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
(),
32
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
TEST_
INVALID_HEX
,
"Invalid hash"
);
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
...
...
@@ -991,7 +991,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") {
uint64_t
binLen
;
if
(
!
hex2carray
(
hash
.
c_str
(),
&
binLen
,
hash_arr
->
data
(),
32
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
throw
SGXException
(
TEST_
INVALID_HEX
,
"Invalid hash"
);
}
map
<
size_t
,
shared_ptr
<
BLSPublicKeyShare
>>
coeffs_pkeys_map
;
...
...
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