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
b7ffbd6a
Unverified
Commit
b7ffbd6a
authored
Dec 09, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug/SKALE-3654-SGX-errors
parent
551b80ab
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
81 deletions
+121
-81
DKGCrypto.cpp
DKGCrypto.cpp
+12
-10
Log.cpp
Log.cpp
+3
-3
Log.h
Log.h
+3
-3
SGXException.h
SGXException.h
+17
-6
SGXWalletServer.cpp
SGXWalletServer.cpp
+86
-59
No files found.
DKGCrypto.cpp
View file @
b7ffbd6a
...
...
@@ -170,7 +170,7 @@ vector <vector<string>> get_verif_vect(const string& encryptedPolyHex, int t, in
vector
<
uint8_t
>
encrDKGPoly
(
2
*
BUF_LEN
,
0
);
if
(
!
hex2carray
(
encryptedPolyHexPtr
,
&
encLen
,
encrDKGPoly
.
data
(),
6100
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
throw
SGXException
(
INVALID_HEX
,
"
:
Invalid encryptedPolyHex"
);
}
...
...
@@ -233,7 +233,7 @@ getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const ve
if
(
!
hex2carray
(
_encryptedPolyHex
,
&
encLen
,
encrDKGPoly
.
data
(),
BUF_LEN
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
throw
SGXException
(
INVALID_HEX
,
"
:
Invalid encryptedPolyHex"
);
}
...
...
@@ -294,7 +294,8 @@ string getSecretSharesV2(const string& _polyName, const char* _encryptedPolyHex,
if
(
!
hex2carray
(
_encryptedPolyHex
,
&
encLen
,
encrDKGPoly
.
data
(),
BUF_LEN
))
{
throw
SGXException
(
GET_SS_V2_INVALID_HEX
,
"Invalid encrypted poly Hex"
);
throw
SGXException
(
GET_SS_V2_INVALID_HEX
,
string
(
__FUNCTION__
)
+
":Invalid encrypted poly Hex"
);
}
...
...
@@ -358,7 +359,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
SAFE_UINT8_BUF
(
encr_key
,
BUF_LEN
);
if
(
!
hex2carray
(
encryptedKeyHex
,
&
decKeyLen
,
encr_key
,
BUF_LEN
))
{
throw
SGXException
(
INVALID_HEX
,
"
Invalid encryptedPolyHex"
);
throw
SGXException
(
INVALID_HEX
,
string
(
__FUNCTION__
)
+
":
Invalid encryptedPolyHex"
);
}
SAFE_CHAR_BUF
(
pshares
,
8193
);
...
...
@@ -374,7 +375,8 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
if
(
result
==
2
)
{
throw
SGXException
(
INVALID_HEX
,
"Invalid public shares"
);
throw
SGXException
(
INVALID_HEX
,
string
(
__FUNCTION__
)
+
+
":Invalid public shares"
);
}
return
result
;
...
...
@@ -394,7 +396,7 @@ verifySharesV2(const char *publicShares, const char *encr_sshare, const char *en
SAFE_UINT8_BUF
(
encr_key
,
BUF_LEN
);
if
(
!
hex2carray
(
encryptedKeyHex
,
&
decKeyLen
,
encr_key
,
BUF_LEN
))
{
throw
SGXException
(
INVALID_HEX
,
"
Invalid encryptedPolyHex"
);
throw
SGXException
(
INVALID_HEX
,
string
(
__FUNCTION__
)
+
":
Invalid encryptedPolyHex"
);
}
SAFE_CHAR_BUF
(
pshares
,
8193
);
...
...
@@ -410,7 +412,7 @@ verifySharesV2(const char *publicShares, const char *encr_sshare, const char *en
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
if
(
result
==
2
)
{
throw
SGXException
(
INVALID_HEX
,
"
Invalid public shares"
);
throw
SGXException
(
INVALID_HEX
,
string
(
__FUNCTION__
)
+
":
Invalid public shares"
);
}
return
result
;
...
...
@@ -426,7 +428,7 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *
uint64_t
decKeyLen
;
SAFE_UINT8_BUF
(
encr_bls_key
,
BUF_LEN
);
SAFE_UINT8_BUF
(
encr_key
,
BUF_LEN
);
if
(
!
hex2carray
(
encryptedKeyHex
,
&
decKeyLen
,
encr_key
,
BUF_LEN
))
{
throw
SGXException
(
INVALID_HEX
,
"
Invalid encryptedKeyHex"
);
throw
SGXException
(
INVALID_HEX
,
string
(
__FUNCTION__
)
+
":
Invalid encryptedKeyHex"
);
}
uint64_t
enc_bls_len
=
0
;
...
...
@@ -459,7 +461,7 @@ vector <string> getBLSPubKey(const char *encryptedKeyHex) {
SAFE_UINT8_BUF
(
encrKey
,
BUF_LEN
);
if
(
!
hex2carray
(
encryptedKeyHex
,
&
decKeyLen
,
encrKey
,
BUF_LEN
))
{
throw
SGXException
(
INVALID_HEX
,
"
Invalid encryptedKeyHex"
);
throw
SGXException
(
INVALID_HEX
,
string
(
__FUNCTION__
)
+
":
Invalid encryptedKeyHex"
);
}
SAFE_CHAR_BUF
(
pubKey
,
320
)
...
...
@@ -546,7 +548,7 @@ string decryptDHKey(const string &polyName, int ind) {
uint64_t
dhEncLen
=
0
;
SAFE_UINT8_BUF
(
encryptedDHKey
,
BUF_LEN
)
if
(
!
hex2carray
(
hexEncrKeyPtr
->
c_str
(),
&
dhEncLen
,
encryptedDHKey
,
BUF_LEN
))
{
throw
SGXException
(
INVALID_HEX
,
"
Invalid hexEncrKey"
);
throw
SGXException
(
INVALID_HEX
,
string
(
__FUNCTION__
)
+
":
Invalid hexEncrKey"
);
}
spdlog
::
debug
(
"encr DH key length is {}"
,
dhEncLen
);
...
...
Log.cpp
View file @
b7ffbd6a
...
...
@@ -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 @
b7ffbd6a
...
...
@@ -94,9 +94,9 @@ string(__FUNCTION__) + ": server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \
catch (const SGXException& _e) { \
if (_e.
status != 0) {__RESULT__["status"] = _e.status
;} else { __RESULT__["status"] = -1 * (10000 + __LINE__);}; \
__RESULT__["errorMessage"] = _e.
errString
; \
if (_e.
errString
.size() == 0) {__RESULT__["errorMessage"] = string(__FUNCTION__);}; \
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 (const exception& _e) { \
...
...
SGXException.h
View file @
b7ffbd6a
...
...
@@ -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 @
b7ffbd6a
This diff is collapsed.
Click to expand it.
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