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
524617b7
Unverified
Commit
524617b7
authored
Nov 17, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3504 finalize tests
parent
462d89ea
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
8 deletions
+62
-8
.gitmodules
.gitmodules
+0
-4
TestUtils.cpp
TestUtils.cpp
+36
-0
TestUtils.h
TestUtils.h
+2
-0
DHDkg.c
secure_enclave/DHDkg.c
+16
-2
secp256k1-sgx
secure_enclave/secp256k1-sgx
+0
-1
testw.cpp
testw.cpp
+8
-1
No files found.
.gitmodules
View file @
524617b7
...
...
@@ -16,7 +16,3 @@
[submodule "sgx-software-enable"]
path = sgx-software-enable
url = https://github.com/intel/sgx-software-enable
[submodule "secure_enclave/secp256k1-sgx"]
path = secure_enclave/secp256k1-sgx
url = https://github.com/bl4ck5un/secp256k1-sgx
branch = master
TestUtils.cpp
View file @
524617b7
...
...
@@ -777,3 +777,39 @@ int xorDecryptDH(char *key, const char *cypher, vector<char>& message) {
return
ret
;
}
int
xorDecryptDHV2
(
char
*
key
,
const
char
*
cypher
,
vector
<
char
>&
message
)
{
int
ret
=
-
1
;
if
(
!
cypher
)
{
return
ret
;
}
if
(
!
key
)
{
return
ret
;
}
if
(
!
message
.
data
())
{
return
ret
;
}
SAFE_CHAR_BUF
(
msg_bin
,
33
)
uint64_t
cypher_length
;
SAFE_CHAR_BUF
(
cypher_bin
,
33
);
if
(
!
hex2carray
(
cypher
,
&
cypher_length
,
(
uint8_t
*
)
cypher_bin
,
33
))
{
return
ret
;
}
for
(
int
i
=
0
;
i
<
32
;
i
++
)
{
msg_bin
[
i
]
=
cypher_bin
[
i
]
^
(
uint8_t
)
key
[
i
];
}
message
=
carray2Hex
((
unsigned
char
*
)
msg_bin
,
32
);
ret
=
0
;
return
ret
;
}
TestUtils.h
View file @
524617b7
...
...
@@ -87,4 +87,6 @@ int sessionKeyRecoverDH(const char *skey_str, const char *sshare, char *common_k
int
xorDecryptDH
(
char
*
key
,
const
char
*
cypher
,
vector
<
char
>&
message
);
int
xorDecryptDHV2
(
char
*
key
,
const
char
*
cypher
,
vector
<
char
>&
message
);
#endif //SGXWALLET_TESTW_H
secure_enclave/DHDkg.c
View file @
524617b7
...
...
@@ -161,7 +161,7 @@ int session_key_recover(const char *skey_str, const char *sshare, char *common_k
point_clear
(
pub_keyB
);
point_clear
(
session_key
);
return
ret
;
return
ret
;
}
int
xor_encrypt
(
char
*
key
,
char
*
message
,
char
*
cypher
)
{
...
...
@@ -333,5 +333,19 @@ int xor_decrypt_v2(char *key, char *cypher, char *message) {
}
int
hash_key
(
char
*
key
,
char
*
hashed_key
)
{
return
sgx_sha256_msg
((
uint8_t
*
)
key
,
ECDSA_SKEY_LEN
,
(
uint8_t
*
)
hashed_key
);
int
ret
=
-
1
;
if
(
!
key
)
{
LOG_ERROR
(
"hash_key: null key"
);
return
ret
;
}
if
(
!
hashed_key
)
{
LOG_ERROR
(
"hash_key: null hashed_key"
);
return
ret
;
}
ret
=
sgx_sha256_msg
((
uint8_t
*
)
key
,
ECDSA_SKEY_LEN
-
1
,
(
uint8_t
*
)
hashed_key
);
return
ret
;
}
secp256k1-sgx
@
5f235e8e
Subproject commit 5f235e8e9e821cd972c4a57afdfe47a7fe83acd0
testw.cpp
View file @
524617b7
...
...
@@ -943,10 +943,17 @@ TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") {
SAFE_CHAR_BUF
(
common_key
,
BUF_LEN
);
REQUIRE
(
sessionKeyRecoverDH
(
dhKey
.
c_str
(),
encr_sshare
,
common_key
)
==
0
);
auto
hashed_key
=
cryptlite
::
sha256
::
hash_hex
(
string
(
common_key
,
64
));
SAFE_CHAR_BUF
(
derived_key
,
33
)
uint64_t
key_length
;
REQUIRE
(
hex2carray
(
&
hashed_key
[
0
],
&
key_length
,
(
uint8_t
*
)
derived_key
,
33
));
SAFE_CHAR_BUF
(
encr_sshare_check
,
BUF_LEN
)
strncpy
(
encr_sshare_check
,
secretShare
.
c_str
(),
ECDSA_SKEY_LEN
-
1
);
REQUIRE
(
xorDecryptDH
(
common
_key
,
encr_sshare_check
,
message
)
==
0
);
REQUIRE
(
xorDecryptDH
V2
(
derived
_key
,
encr_sshare_check
,
message
)
==
0
);
mpz_t
hex_share
;
mpz_init
(
hex_share
);
...
...
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