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
ffc03aad
Unverified
Commit
ffc03aad
authored
Aug 15, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3067-finished-cleanup
parent
64bb9335
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
19 deletions
+21
-19
DKGUtils.cpp
secure_enclave/DKGUtils.cpp
+1
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+20
-18
No files found.
secure_enclave/DKGUtils.cpp
View file @
ffc03aad
...
@@ -451,7 +451,7 @@ int Verification(char *public_shares, mpz_t decr_secret_share, int _t, int ind)
...
@@ -451,7 +451,7 @@ int Verification(char *public_shares, mpz_t decr_secret_share, int _t, int ind)
try
{
try
{
for
(
size_t
i
=
0
;
i
<
_t
;
++
i
)
{
for
(
int
i
=
0
;
i
<
_t
;
i
++
)
{
libff
::
alt_bn128_G2
pub_share
;
libff
::
alt_bn128_G2
pub_share
;
uint64_t
pos0
=
share_length
*
i
;
uint64_t
pos0
=
share_length
*
i
;
...
...
secure_enclave/secure_enclave.c
View file @
ffc03aad
...
@@ -285,7 +285,7 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -285,7 +285,7 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *errString,
point
Pkey
=
point_init
();
point
Pkey
=
point_init
();
get_global_random
(
rand_char
,
32
);
get_global_random
(
(
unsigned
char
*
)
rand_char
,
32
);
mpz_import
(
seed
,
32
,
1
,
sizeof
(
rand_char
[
0
]),
0
,
0
,
rand_char
);
mpz_import
(
seed
,
32
,
1
,
sizeof
(
rand_char
[
0
]),
0
,
0
,
rand_char
);
...
@@ -293,7 +293,7 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -293,7 +293,7 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *errString,
signature_extract_public_key
(
Pkey
,
skey
,
curve
);
signature_extract_public_key
(
Pkey
,
skey
,
curve
);
int
len
=
mpz_sizeinbase
(
Pkey
->
x
,
ECDSA_SKEY_BASE
)
+
2
;
SAFE_CHAR_BUF
(
arr_x
,
BUF_LEN
);
SAFE_CHAR_BUF
(
arr_x
,
BUF_LEN
);
mpz_get_str
(
arr_x
,
ECDSA_SKEY_BASE
,
Pkey
->
x
);
mpz_get_str
(
arr_x
,
ECDSA_SKEY_BASE
,
Pkey
->
x
);
int
n_zeroes
=
64
-
strlen
(
arr_x
);
int
n_zeroes
=
64
-
strlen
(
arr_x
);
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
...
@@ -318,9 +318,9 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -318,9 +318,9 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *errString,
}
}
strncpy
(
skey_str
+
n_zeroes
,
arr_skey_str
,
65
-
n_zeroes
);
strncpy
(
skey_str
+
n_zeroes
,
arr_skey_str
,
65
-
n_zeroes
);
skey_str
[
ECDSA_SKEY_LEN
-
1
]
=
0
;
skey_str
[
ECDSA_SKEY_LEN
-
1
]
=
0
;
snprintf
(
errString
,
BUF_LEN
,
"skey len is %d
\n
"
,
strlen
(
skey_str
));
snprintf
(
errString
,
BUF_LEN
,
"skey len is %d
\n
"
,
(
int
)
strlen
(
skey_str
));
int
status
=
AES_encrypt
(
skey_str
,
encryptedPrivateKey
,
BUF_LEN
);
int
status
=
AES_encrypt
(
(
char
*
)
skey_str
,
encryptedPrivateKey
,
BUF_LEN
);
CHECK_STATUS
(
"ecdsa private key encryption failed"
);
CHECK_STATUS
(
"ecdsa private key encryption failed"
);
*
enc_len
=
strlen
(
skey_str
)
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
;
*
enc_len
=
strlen
(
skey_str
)
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
;
...
@@ -341,15 +341,17 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -341,15 +341,17 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
LOG_DEBUG
(
__FUNCTION__
);
LOG_DEBUG
(
__FUNCTION__
);
INIT_ERROR_STATE
INIT_ERROR_STATE
CHECK_STATE
(
encryptedPrivateKey
);
CHECK_STATE
(
pub_key_x
);
CHECK_STATE
(
pub_key_y
);
SAFE_CHAR_BUF
(
skey
,
ECDSA_SKEY_LEN
);
SAFE_CHAR_BUF
(
skey
,
ECDSA_SKEY_LEN
);
mpz_t
privateKeyMpz
;
mpz_t
privateKeyMpz
;
mpz_init
(
privateKeyMpz
);
mpz_init
(
privateKeyMpz
);
point
Pkey
=
point_init
();
point
pKey
=
point_init
();
point
pKey_test
=
point_init
();
CHECK_STATE
(
encryptedPrivateKey
);
CHECK_STATE
(
pub_key_x
);
CHECK_STATE
(
pub_key_y
);
int
status
=
AES_decrypt
(
encryptedPrivateKey
,
enc_len
,
skey
,
ECDSA_SKEY_LEN
);
int
status
=
AES_decrypt
(
encryptedPrivateKey
,
enc_len
,
skey
,
ECDSA_SKEY_LEN
);
CHECK_STATUS2
(
"AES_decrypt failed with status %d"
);
CHECK_STATUS2
(
"AES_decrypt failed with status %d"
);
...
@@ -361,12 +363,12 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -361,12 +363,12 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
CHECK_STATUS
(
"mpz_set_str failed for private key"
);
CHECK_STATUS
(
"mpz_set_str failed for private key"
);
signature_extract_public_key
(
Pkey
,
privateKeyMpz
,
curve
);
signature_extract_public_key
(
pKey
,
privateKeyMpz
,
curve
);
point
Pkey_test
=
point_init
();
point_multiplication
(
pKey_test
,
privateKeyMpz
,
curve
->
G
,
curve
);
point_multiplication
(
Pkey_test
,
privateKeyMpz
,
curve
->
G
,
curve
);
if
(
!
point_cmp
(
Pkey
,
Pk
ey_test
))
{
if
(
!
point_cmp
(
pKey
,
pK
ey_test
))
{
snprintf
(
errString
,
BUF_LEN
,
"Points are not equal"
);
snprintf
(
errString
,
BUF_LEN
,
"Points are not equal"
);
LOG_ERROR
(
errString
);
LOG_ERROR
(
errString
);
*
errStatus
=
-
11
;
*
errStatus
=
-
11
;
...
@@ -374,7 +376,7 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -374,7 +376,7 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
}
}
SAFE_CHAR_BUF
(
arr_x
,
BUF_LEN
);
SAFE_CHAR_BUF
(
arr_x
,
BUF_LEN
);
mpz_get_str
(
arr_x
,
ECDSA_SKEY_BASE
,
Pk
ey
->
x
);
mpz_get_str
(
arr_x
,
ECDSA_SKEY_BASE
,
pK
ey
->
x
);
int
n_zeroes
=
64
-
strlen
(
arr_x
);
int
n_zeroes
=
64
-
strlen
(
arr_x
);
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
...
@@ -384,7 +386,7 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -384,7 +386,7 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
strncpy
(
pub_key_x
+
n_zeroes
,
arr_x
,
1024
-
n_zeroes
);
strncpy
(
pub_key_x
+
n_zeroes
,
arr_x
,
1024
-
n_zeroes
);
SAFE_CHAR_BUF
(
arr_y
,
BUF_LEN
);
SAFE_CHAR_BUF
(
arr_y
,
BUF_LEN
);
mpz_get_str
(
arr_y
,
ECDSA_SKEY_BASE
,
Pk
ey
->
y
);
mpz_get_str
(
arr_y
,
ECDSA_SKEY_BASE
,
pK
ey
->
y
);
n_zeroes
=
64
-
strlen
(
arr_y
);
n_zeroes
=
64
-
strlen
(
arr_y
);
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n_zeroes
;
i
++
)
{
...
@@ -395,8 +397,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
...
@@ -395,8 +397,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
SET_SUCCESS
SET_SUCCESS
clean:
clean:
mpz_clear
(
privateKeyMpz
);
mpz_clear
(
privateKeyMpz
);
point_clear
(
Pk
ey
);
point_clear
(
pK
ey
);
point_clear
(
Pk
ey_test
);
point_clear
(
pK
ey_test
);
}
}
static
uint64_t
sigCounter
=
0
;
static
uint64_t
sigCounter
=
0
;
...
@@ -494,7 +496,7 @@ void trustedEncryptKeyAES(int *errStatus, char *errString, const char *key,
...
@@ -494,7 +496,7 @@ void trustedEncryptKeyAES(int *errStatus, char *errString, const char *key,
*
errStatus
=
UNKNOWN_ERROR
;
*
errStatus
=
UNKNOWN_ERROR
;
int
status
=
AES_encrypt
(
key
,
encryptedPrivateKey
,
BUF_LEN
);
int
status
=
AES_encrypt
(
(
char
*
)
key
,
encryptedPrivateKey
,
BUF_LEN
);
CHECK_STATUS2
(
"AES encrypt failed with status %d"
);
CHECK_STATUS2
(
"AES encrypt failed with status %d"
);
...
...
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