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
3f19fe5a
Unverified
Commit
3f19fe5a
authored
Oct 23, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3009 use vector instead of char
parent
5fe6054f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
22 additions
and
22 deletions
+22
-22
BLSCrypto.cpp
BLSCrypto.cpp
+6
-6
BLSCrypto.h
BLSCrypto.h
+2
-1
DKGCrypto.cpp
DKGCrypto.cpp
+4
-4
ECDSACrypto.cpp
ECDSACrypto.cpp
+2
-2
SEKManager.cpp
SEKManager.cpp
+3
-3
TestUtils.cpp
TestUtils.cpp
+2
-2
TestUtils.h
TestUtils.h
+1
-1
testw.cpp
testw.cpp
+2
-2
testw.py
testw.py
+0
-1
No files found.
BLSCrypto.cpp
View file @
3f19fe5a
...
...
@@ -75,14 +75,15 @@ int char2int(char _input) {
return
-
1
;
}
void
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
_len
,
char
*
_hexArray
)
{
void
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
_len
,
vector
<
char
>&
_hexArray
)
{
CHECK_STATE
(
d
);
CHECK_STATE
(
_hexArray
);
char
hexval
[
16
]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
CHECK_STATE
(
_hexArray
.
size
()
>
2
*
_len
);
for
(
uint64_t
j
=
0
;
j
<
_len
;
j
++
)
{
_hexArray
[
j
*
2
]
=
hexval
[((
d
[
j
]
>>
4
)
&
0xF
)];
_hexArray
[
j
*
2
+
1
]
=
hexval
[(
d
[
j
])
&
0x0F
];
...
...
@@ -163,8 +164,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
CHECK_STATE
(
_hashHex
);
CHECK_STATE
(
_sig
);
auto
hash
=
make_shared
<
array
<
uint8_t
,
32
>>
();
auto
hash
=
make_shared
<
array
<
uint8_t
,
32
>>
();
uint64_t
binLen
;
...
...
@@ -262,9 +262,9 @@ string encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
*
errStatus
,
errMsg
.
data
());
SAFE_CHAR_BUF
(
resultBuf
,
2
*
BUF_LEN
+
1
);
vector
<
char
>
resultBuf
(
2
*
BUF_LEN
+
1
,
0
);
carray2Hex
(
encryptedKey
->
data
(),
encryptedLen
,
resultBuf
);
return
string
(
resultBuf
);
return
string
(
resultBuf
.
begin
(),
resultBuf
.
end
()
);
}
BLSCrypto.h
View file @
3f19fe5a
...
...
@@ -33,12 +33,13 @@
#include "stddef.h"
#include "stdint.h"
#include <string>
#include <vector>
EXTERNC
bool
bls_sign
(
const
char
*
encryptedKeyHex
,
const
char
*
hashHex
,
size_t
t
,
size_t
n
,
char
*
_sig
);
EXTERNC
int
char2int
(
char
_input
);
EXTERNC
void
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
,
char
*
_hexArray
);
EXTERNC
void
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
,
std
::
vector
<
char
>&
_hexArray
);
EXTERNC
bool
hex2carray
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
,
uint64_t
_max_length
);
...
...
DKGCrypto.cpp
View file @
3f19fe5a
...
...
@@ -146,7 +146,7 @@ string gen_dkg_poly(int _t) {
vector
<
char
>
hexEncrPoly
(
BUF_LEN
,
0
);
CHECK_STATE
(
encrypted_dkg_secret
.
size
()
>=
length
);
carray2Hex
(
encrypted_dkg_secret
.
data
(),
length
,
hexEncrPoly
.
data
()
);
carray2Hex
(
encrypted_dkg_secret
.
data
(),
length
,
hexEncrPoly
);
string
result
(
hexEncrPoly
.
data
());
return
result
;
...
...
@@ -271,7 +271,7 @@ getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const ve
result
+=
string
(
currentShare
.
data
());
spdlog
::
debug
(
"dec len is {}"
,
decLen
);
carray2Hex
(
encryptedSkey
.
data
(),
decLen
,
hexEncrKey
.
data
()
);
carray2Hex
(
encryptedSkey
.
data
(),
decLen
,
hexEncrKey
);
string
dhKeyName
=
"DKG_DH_KEY_"
+
_polyName
+
"_"
+
to_string
(
i
)
+
":"
;
spdlog
::
debug
(
"hexEncr DH Key: { }"
,
hexEncrKey
.
data
());
...
...
@@ -351,11 +351,11 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
SAFE_CHAR_BUF
(
hexBLSKey
,
2
*
BUF_LEN
)
vector
<
char
>
hexBLSKey
(
2
*
BUF_LEN
,
0
);
carray2Hex
(
encr_bls_key
,
enc_bls_len
,
hexBLSKey
);
SGXWalletServer
::
writeDataToDB
(
blsKeyName
,
hexBLSKey
);
SGXWalletServer
::
writeDataToDB
(
blsKeyName
,
hexBLSKey
.
data
()
);
return
true
;
...
...
ECDSACrypto.cpp
View file @
3f19fe5a
...
...
@@ -71,7 +71,7 @@ vector <string> genECDSAKey() {
vector
<
char
>
hexEncrKey
(
BUF_LEN
*
2
,
0
);
carray2Hex
(
encr_pr_key
.
data
(),
enc_len
,
hexEncrKey
.
data
()
);
carray2Hex
(
encr_pr_key
.
data
(),
enc_len
,
hexEncrKey
);
keys
.
at
(
0
)
=
hexEncrKey
.
data
();
keys
.
at
(
1
)
=
string
(
pub_key_x
.
data
())
+
string
(
pub_key_y
.
data
());
...
...
@@ -80,7 +80,7 @@ vector <string> genECDSAKey() {
vector
<
char
>
rand_str
(
BUF_LEN
,
0
);
carray2Hex
(
randBuffer
.
data
(),
32
,
rand_str
.
data
()
);
carray2Hex
(
randBuffer
.
data
(),
32
,
rand_str
);
keys
.
at
(
2
)
=
rand_str
.
data
();
...
...
SEKManager.cpp
View file @
3f19fe5a
...
...
@@ -73,7 +73,7 @@ void create_test_key() {
vector
<
char
>
hexEncrKey
(
2
*
enc_len
+
1
,
0
);
carray2Hex
(
encrypted_key
,
enc_len
,
hexEncrKey
.
data
()
);
carray2Hex
(
encrypted_key
,
enc_len
,
hexEncrKey
);
LevelDB
::
getLevelDb
()
->
writeDataUnique
(
"TEST_KEY"
,
hexEncrKey
.
data
());
}
...
...
@@ -169,7 +169,7 @@ void gen_SEK() {
vector
<
char
>
hexEncrKey
(
2
*
enc_len
+
1
,
0
);
carray2Hex
(
encrypted_SEK
.
data
(),
enc_len
,
hexEncrKey
.
data
()
);
carray2Hex
(
encrypted_SEK
.
data
(),
enc_len
,
hexEncrKey
);
spdlog
::
info
(
string
(
"Encrypted storage encryption key:"
)
+
hexEncrKey
.
data
());
...
...
@@ -283,7 +283,7 @@ void enter_SEK() {
vector
<
char
>
hexEncrKey
(
BUF_LEN
,
0
);
carray2Hex
(
encrypted_SEK
->
data
(),
encrypted_SEK
->
size
(),
hexEncrKey
.
data
()
);
carray2Hex
(
encrypted_SEK
->
data
(),
encrypted_SEK
->
size
(),
hexEncrKey
);
spdlog
::
info
(
"Got sealed storage encryption key."
);
...
...
TestUtils.cpp
View file @
3f19fe5a
...
...
@@ -493,7 +493,7 @@ int sessionKeyRecoverDH(const char *skey_str, const char *sshare, char *common_k
return
ret
;
}
int
xorDecryptDH
(
char
*
key
,
const
char
*
cypher
,
char
*
message
)
{
int
xorDecryptDH
(
char
*
key
,
const
char
*
cypher
,
vector
<
char
>&
message
)
{
int
ret
=
-
1
;
...
...
@@ -505,7 +505,7 @@ int xorDecryptDH(char *key, const char *cypher, char *message) {
return
ret
;
}
if
(
!
message
)
{
if
(
!
message
.
data
()
)
{
return
ret
;
}
...
...
TestUtils.h
View file @
3f19fe5a
...
...
@@ -80,6 +80,6 @@ public:
int
sessionKeyRecoverDH
(
const
char
*
skey_str
,
const
char
*
sshare
,
char
*
common_key
);
int
xorDecryptDH
(
char
*
key
,
const
char
*
cypher
,
char
*
message
);
int
xorDecryptDH
(
char
*
key
,
const
char
*
cypher
,
vector
<
char
>&
message
);
#endif //SGXWALLET_TESTW_H
testw.cpp
View file @
3f19fe5a
...
...
@@ -658,7 +658,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
string
shareG2
=
complaintResponse
[
"share*G2"
].
asString
();
string
secretShare
=
secretShares
[
1
][
"secretShare"
].
asString
().
substr
(
0
,
192
);
SAFE_CHAR_BUF
(
message
,
32
)
vector
<
char
>
message
(
65
,
0
);
SAFE_CHAR_BUF
(
encr_sshare
,
BUF_LEN
)
strncpy
(
encr_sshare
,
pubEthKeys
[
0
].
asString
().
c_str
(),
128
);
...
...
@@ -673,7 +673,7 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG test", "[aes-dkg]") {
mpz_t
hex_share
;
mpz_init
(
hex_share
);
mpz_set_str
(
hex_share
,
message
,
16
);
mpz_set_str
(
hex_share
,
message
.
data
()
,
16
);
libff
::
alt_bn128_Fr
share
(
hex_share
);
libff
::
alt_bn128_G2
decrypted_share_G2
=
share
*
libff
::
alt_bn128_G2
::
one
();
...
...
testw.py
View file @
3f19fe5a
...
...
@@ -43,7 +43,6 @@ testList = ["[first-run]",
"[bls-key-encrypt]"
,
"[dkg-aes-gen]"
,
"[dkg-aes-encr-sshares]"
,
"[dkg-verify]"
,
"[dkg-api]"
,
"[dkg-bls]"
,
"[dkg-poly-exists]"
,
...
...
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