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
f2b8271f
Unverified
Commit
f2b8271f
authored
Feb 15, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2167 Memory warnings
parent
5229616e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
917 additions
and
948 deletions
+917
-948
BLSCrypto.cpp
BLSCrypto.cpp
+9
-10
BLSCrypto.h
BLSCrypto.h
+2
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+8
-2
testw.cpp
testw.cpp
+898
-934
No files found.
BLSCrypto.cpp
View file @
f2b8271f
...
...
@@ -314,22 +314,21 @@ bool bls_sign(const char* _encryptedKeyHex, const char* _hashHex, size_t _t, siz
}
}
char
*
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
)
{
char
*
keyArray
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
uint8_t
*
encryptedKey
=
(
uint8_t
*
)
calloc
(
BUF_LEN
,
1
);
char
*
errMsg
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
strncpy
((
char
*
)
keyArray
,
(
char
*
)
_key
,
BUF_LEN
);
char
*
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
)
{
auto
keyArray
=
make_shared
<
vector
<
char
>>
(
BUF_LEN
,
0
);
auto
encryptedKey
=
make_shared
<
vector
<
uint8_t
>>
(
BUF_LEN
,
0
);
auto
errMsg
=
make_shared
<
vector
<
char
>>
(
BUF_LEN
,
0
);
strncpy
(
keyArray
->
data
(),
_key
,
BUF_LEN
);
*
errStatus
=
-
1
;
unsigned
int
encryptedLen
=
0
;
//status = encrypt_key(eid, errStatus, errMsg, keyArray, encryptedKey, &encryptedLen);
status
=
encrypt_key_aes
(
eid
,
errStatus
,
errMsg
,
keyArray
,
encryptedKey
,
&
encryptedLen
);
status
=
encrypt_key_aes
(
eid
,
errStatus
,
errMsg
->
data
(),
keyArray
->
data
(),
encryptedKey
->
data
()
,
&
encryptedLen
);
if
(
DEBUG_PRINT
)
{
spdlog
::
info
(
"errStatus is {}"
,
*
errStatus
);
spdlog
::
info
(
" errMsg is "
,
errMsg
);
spdlog
::
info
(
" errMsg is "
,
errMsg
->
data
()
);
}
if
(
status
!=
SGX_SUCCESS
)
{
...
...
@@ -339,13 +338,13 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
}
if
(
*
errStatus
!=
0
)
{
throw
RPCException
(
-
666
,
errMsg
);
throw
RPCException
(
-
666
,
errMsg
->
data
()
);
}
char
*
result
=
(
char
*
)
calloc
(
2
*
BUF_LEN
,
1
);
carray2Hex
(
encryptedKey
,
encryptedLen
,
result
);
carray2Hex
(
encryptedKey
->
data
()
,
encryptedLen
,
result
);
return
result
;
}
...
...
BLSCrypto.h
View file @
f2b8271f
...
...
@@ -49,8 +49,8 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
EXTERNC
char
*
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
);
char
*
encryptBLSKeyShare2Hex
(
int
*
errStatus
,
char
*
err_string
,
const
char
*
_key
);
EXTERNC
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
);
char
*
decryptBLSKeyShareFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
);
#endif //SGXWALLET_BLSCRYPTO_H
SGXWalletServer.cpp
View file @
f2b8271f
...
...
@@ -152,11 +152,13 @@ importBLSKeyShareImpl(const string &_keyShare, const string &_keyShareName, int
result
[
"errorMessage"
]
=
""
;
result
[
"encryptedKeyShare"
]
=
""
;
char
*
encryptedKeyShareHex
=
nullptr
;
try
{
// if ( !checkName(_keyShare, "BLS_KEY")){
// throw RPCException(INVALID_POLY_NAME, "Invalid BLSKey name");
// }
char
*
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
errMsg
,
_keyShare
.
c_str
());
encryptedKeyShareHex
=
encryptBLSKeyShare2Hex
(
&
errStatus
,
errMsg
,
_keyShare
.
c_str
());
if
(
encryptedKeyShareHex
==
nullptr
)
{
throw
RPCException
(
UNKNOWN_ERROR
,
""
);
...
...
@@ -166,7 +168,7 @@ importBLSKeyShareImpl(const string &_keyShare, const string &_keyShareName, int
throw
RPCException
(
errStatus
,
errMsg
);
}
result
[
"encryptedKeyShare"
]
=
encryptedKeyShareHex
;
result
[
"encryptedKeyShare"
]
=
string
(
encryptedKeyShareHex
)
;
writeKeyShare
(
_keyShareName
,
encryptedKeyShareHex
,
index
,
n
,
t
);
...
...
@@ -175,6 +177,10 @@ importBLSKeyShareImpl(const string &_keyShare, const string &_keyShareName, int
result
[
"errorMessage"
]
=
_e
.
errString
;
}
if
(
encryptedKeyShareHex
!=
nullptr
)
{
free
(
encryptedKeyShareHex
);
}
return
result
;
}
...
...
testw.cpp
View file @
f2b8271f
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