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
bd79376f
Unverified
Commit
bd79376f
authored
Oct 23, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3009 return vector
parent
a0d87319
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
29 deletions
+15
-29
BLSCrypto.cpp
BLSCrypto.cpp
+5
-6
BLSCrypto.h
BLSCrypto.h
+1
-1
DKGCrypto.cpp
DKGCrypto.cpp
+3
-6
ECDSACrypto.cpp
ECDSACrypto.cpp
+2
-6
SEKManager.cpp
SEKManager.cpp
+3
-9
TestUtils.cpp
TestUtils.cpp
+1
-1
No files found.
BLSCrypto.cpp
View file @
bd79376f
...
...
@@ -75,21 +75,22 @@ int char2int(char _input) {
return
-
1
;
}
v
oid
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
_len
,
vector
<
char
>&
_hexArray
)
{
v
ector
<
char
>
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
_len
)
{
CHECK_STATE
(
d
);
vector
<
char
>
_hexArray
(
2
*
_len
+
1
);
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
];
}
_hexArray
[
_len
*
2
]
=
0
;
return
_hexArray
;
}
...
...
@@ -262,9 +263,7 @@ string encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
*
errStatus
,
errMsg
.
data
());
vector
<
char
>
resultBuf
(
2
*
BUF_LEN
+
1
,
0
);
carray2Hex
(
encryptedKey
->
data
(),
encryptedLen
,
resultBuf
);
vector
<
char
>
resultBuf
=
carray2Hex
(
encryptedKey
->
data
(),
encryptedLen
);
return
string
(
resultBuf
.
begin
(),
resultBuf
.
end
());
}
BLSCrypto.h
View file @
bd79376f
...
...
@@ -39,7 +39,7 @@ EXTERNC bool bls_sign(const char* encryptedKeyHex, const char* hashHex, size_t t
EXTERNC
int
char2int
(
char
_input
);
EXTERNC
void
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
,
std
::
vector
<
char
>&
_hexArray
);
EXTERNC
std
::
vector
<
char
>
carray2Hex
(
const
unsigned
char
*
d
,
uint64_t
_len
);
EXTERNC
bool
hex2carray
(
const
char
*
_hex
,
uint64_t
*
_bin_len
,
uint8_t
*
_bin
,
uint64_t
_max_length
);
...
...
DKGCrypto.cpp
View file @
bd79376f
...
...
@@ -144,9 +144,8 @@ string gen_dkg_poly(int _t) {
uint64_t
length
=
enc_len
;;
vector
<
char
>
hexEncrPoly
(
BUF_LEN
,
0
);
CHECK_STATE
(
encrypted_dkg_secret
.
size
()
>=
length
);
carray2Hex
(
encrypted_dkg_secret
.
data
(),
length
,
hexEncrPoly
);
vector
<
char
>
hexEncrPoly
=
carray2Hex
(
encrypted_dkg_secret
.
data
(),
length
);
string
result
(
hexEncrPoly
.
data
());
return
result
;
...
...
@@ -271,7 +270,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
);
hexEncrKey
=
carray2Hex
(
encryptedSkey
.
data
(),
decLen
);
string
dhKeyName
=
"DKG_DH_KEY_"
+
_polyName
+
"_"
+
to_string
(
i
)
+
":"
;
spdlog
::
debug
(
"hexEncr DH Key: { }"
,
hexEncrKey
.
data
());
...
...
@@ -351,9 +350,7 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
vector
<
char
>
hexBLSKey
(
2
*
BUF_LEN
,
0
);
carray2Hex
(
encr_bls_key
,
enc_bls_len
,
hexBLSKey
);
vector
<
char
>
hexBLSKey
=
carray2Hex
(
encr_bls_key
,
enc_bls_len
);
SGXWalletServer
::
writeDataToDB
(
blsKeyName
,
hexBLSKey
.
data
());
...
...
ECDSACrypto.cpp
View file @
bd79376f
...
...
@@ -69,18 +69,14 @@ vector <string> genECDSAKey() {
vector
<
string
>
keys
(
3
);
vector
<
char
>
hexEncrKey
(
BUF_LEN
*
2
,
0
);
carray2Hex
(
encr_pr_key
.
data
(),
enc_len
,
hexEncrKey
);
vector
<
char
>
hexEncrKey
=
carray2Hex
(
encr_pr_key
.
data
(),
enc_len
);
keys
.
at
(
0
)
=
hexEncrKey
.
data
();
keys
.
at
(
1
)
=
string
(
pub_key_x
.
data
())
+
string
(
pub_key_y
.
data
());
vector
<
unsigned
char
>
randBuffer
(
32
,
0
);
fillRandomBuffer
(
randBuffer
);
vector
<
char
>
rand_str
(
BUF_LEN
,
0
);
carray2Hex
(
randBuffer
.
data
(),
32
,
rand_str
);
vector
<
char
>
rand_str
=
carray2Hex
(
randBuffer
.
data
(),
32
);
keys
.
at
(
2
)
=
rand_str
.
data
();
...
...
SEKManager.cpp
View file @
bd79376f
...
...
@@ -71,9 +71,7 @@ void create_test_key() {
HANDLE_TRUSTED_FUNCTION_ERROR
(
status
,
errStatus
,
errMsg
.
data
());
vector
<
char
>
hexEncrKey
(
2
*
enc_len
+
1
,
0
);
carray2Hex
(
encrypted_key
,
enc_len
,
hexEncrKey
);
vector
<
char
>
hexEncrKey
=
carray2Hex
(
encrypted_key
,
enc_len
);
LevelDB
::
getLevelDb
()
->
writeDataUnique
(
"TEST_KEY"
,
hexEncrKey
.
data
());
}
...
...
@@ -167,9 +165,7 @@ void gen_SEK() {
throw
SGXException
(
-
1
,
"strnlen(SEK,33) != 32"
);
}
vector
<
char
>
hexEncrKey
(
2
*
enc_len
+
1
,
0
);
carray2Hex
(
encrypted_SEK
.
data
(),
enc_len
,
hexEncrKey
);
vector
<
char
>
hexEncrKey
=
carray2Hex
(
encrypted_SEK
.
data
(),
enc_len
);
spdlog
::
info
(
string
(
"Encrypted storage encryption key:"
)
+
hexEncrKey
.
data
());
...
...
@@ -281,9 +277,7 @@ void enter_SEK() {
auto
encrypted_SEK
=
check_and_set_SEK
(
sek
);
vector
<
char
>
hexEncrKey
(
BUF_LEN
,
0
);
carray2Hex
(
encrypted_SEK
->
data
(),
encrypted_SEK
->
size
(),
hexEncrKey
);
vector
<
char
>
hexEncrKey
=
carray2Hex
(
encrypted_SEK
->
data
(),
encrypted_SEK
->
size
());
spdlog
::
info
(
"Got sealed storage encryption key."
);
...
...
TestUtils.cpp
View file @
bd79376f
...
...
@@ -529,7 +529,7 @@ int xorDecryptDH(char *key, const char *cypher, vector<char>& message) {
msg_bin
[
i
]
=
cypher_bin
[
i
]
^
key_bin
[
i
];
}
carray2Hex
((
unsigned
char
*
)
msg_bin
,
32
,
message
);
message
=
carray2Hex
((
unsigned
char
*
)
msg_bin
,
32
);
ret
=
0
;
...
...
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