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
ceaea2e0
Unverified
Commit
ceaea2e0
authored
Apr 17, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2454-add-logs-to-enclave
parent
0525b705
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
32 deletions
+25
-32
SGXWALLET_VERSION
SGXWALLET_VERSION
+1
-1
DHDkg.c
secure_enclave/DHDkg.c
+7
-7
DomainParameters.c
secure_enclave/DomainParameters.c
+2
-2
Point.c
secure_enclave/Point.c
+2
-2
Signature.c
secure_enclave/Signature.c
+1
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+12
-19
No files found.
SGXWALLET_VERSION
View file @
ceaea2e0
#define SGXWALLET_VERSION "1.45.1"
\ No newline at end of file
#define SGXWALLET_VERSION "1.47.1"
\ No newline at end of file
secure_enclave/DHDkg.c
View file @
ceaea2e0
...
...
@@ -16,7 +16,7 @@
You should have received a copy of the GNU Affero General Public License
along with sgxwallet. If not, see <https://www.gnu.org/licenses/>.
@file DH
_d
kg.c
@file DH
D
kg.c
@author Stan Kladko
@date 2019
*/
...
...
@@ -36,11 +36,11 @@
void
gen_session_key
(
char
*
skey_str
,
char
*
pb_keyB
,
char
*
common_key
){
char
*
pb_keyB_x
=
(
char
*
)
malloc
(
65
);
char
*
pb_keyB_x
=
(
char
*
)
calloc
(
65
,
1
);
strncpy
(
pb_keyB_x
,
pb_keyB
,
64
);
pb_keyB_x
[
64
]
=
0
;
char
*
pb_keyB_y
=
(
char
*
)
malloc
(
65
);
char
*
pb_keyB_y
=
(
char
*
)
calloc
(
65
,
1
);
strncpy
(
pb_keyB_y
,
pb_keyB
+
64
,
64
);
pb_keyB_y
[
64
]
=
0
;
...
...
@@ -76,11 +76,11 @@ void gen_session_key(char *skey_str, char* pb_keyB, char* common_key){
void
session_key_recover
(
const
char
*
skey_str
,
const
char
*
sshare
,
char
*
common_key
){
char
*
pb_keyB_x
=
(
char
*
)
malloc
(
65
);
char
*
pb_keyB_x
=
(
char
*
)
calloc
(
65
,
1
);
strncpy
(
pb_keyB_x
,
sshare
+
64
,
64
);
pb_keyB_x
[
64
]
=
0
;
char
*
pb_keyB_y
=
(
char
*
)
malloc
(
65
);
char
*
pb_keyB_y
=
(
char
*
)
calloc
(
65
,
1
);
strncpy
(
pb_keyB_y
,
sshare
+
128
,
64
);
pb_keyB_y
[
64
]
=
0
;
...
...
@@ -123,7 +123,7 @@ void xor_encrypt(char* key, char* message, char* cypher){
uint8_t
cypher_bin
[
33
];
//uint8_t key_bin[33];
uint8_t
*
key_bin
=
(
uint8_t
*
)
malloc
(
33
);
uint8_t
*
key_bin
=
(
uint8_t
*
)
calloc
(
33
,
1
);
uint64_t
key_length
;
if
(
!
hex2carray
(
key
,
&
key_length
,
key_bin
)){
cypher
=
NULL
;
...
...
@@ -152,7 +152,7 @@ void xor_decrypt(char* key, char* cypher, char* message){
uint8_t
msg_bin
[
33
];
//uint8_t key_bin[33];
uint8_t
*
key_bin
=
(
uint8_t
*
)
malloc
(
33
);
uint8_t
*
key_bin
=
(
uint8_t
*
)
calloc
(
33
,
1
);
uint64_t
key_length
;
if
(
!
hex2carray
(
key
,
&
key_length
,
key_bin
)){
message
=
NULL
;
...
...
secure_enclave/DomainParameters.c
View file @
ceaea2e0
...
...
@@ -32,7 +32,7 @@
domain_parameters
domain_parameters_init
()
{
domain_parameters
curve
;
curve
=
malloc
(
sizeof
(
struct
domain_parameters_s
)
);
curve
=
calloc
(
sizeof
(
struct
domain_parameters_s
),
1
);
//Initialize all members
mpz_init
(
curve
->
p
);
...
...
@@ -49,7 +49,7 @@ domain_parameters domain_parameters_init()
void
domain_parameters_set_name
(
domain_parameters
curve
,
char
*
name
)
{
int
len
=
strlen
(
name
);
curve
->
name
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
(
len
+
1
)
);
curve
->
name
=
(
char
*
)
calloc
(
sizeof
(
char
)
*
(
len
+
1
),
1
);
curve
->
name
[
len
]
=
'\0'
;
strncpy
(
curve
->
name
,
name
,
len
+
1
);
}
...
...
secure_enclave/Point.c
View file @
ceaea2e0
...
...
@@ -36,7 +36,7 @@
point
point_init
()
{
point
p
;
p
=
malloc
(
sizeof
(
struct
point_s
)
);
p
=
calloc
(
sizeof
(
struct
point_s
),
1
);
mpz_init
(
p
->
x
);
mpz_init
(
p
->
y
);
p
->
infinity
=
false
;
...
...
@@ -365,7 +365,7 @@ char* point_compress(point P)
//Reserve memory
int
l
=
mpz_sizeinbase
(
P
->
x
,
16
)
+
2
;
char
*
result
=
(
char
*
)
malloc
(
l
+
1
);
char
*
result
=
(
char
*
)
calloc
(
l
+
1
,
1
);
result
[
l
]
=
'\0'
;
mpz_t
t1
;
mpz_init
(
t1
);
...
...
secure_enclave/Signature.c
View file @
ceaea2e0
...
...
@@ -97,7 +97,7 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
mpz_init
(
k
);
mpz_init
(
x
);
mpz_init
(
r
);
mpz_init
(
t1
);
mpz_init
(
t2
);
mpz_init
(
t3
);
mpz_init
(
s
);
mpz_init
(
t4
);
mpz_init
(
t5
);
mpz_init
(
n_div_2
);
mpz_init
(
rem
);
mpz_init
(
neg
);
mpz_init
(
seed
);
unsigned
char
*
rand_char
=
(
unsigned
char
*
)
malloc
(
32
);
unsigned
char
*
rand_char
=
(
unsigned
char
*
)
calloc
(
32
,
1
);
sgx_read_rand
(
rand_char
,
32
);
...
...
secure_enclave/secure_enclave.c
View file @
ceaea2e0
...
...
@@ -133,7 +133,7 @@ void trustedGenerateEcdsaKey(int *errStatus, char *err_string,
domain_parameters
curve
=
domain_parameters_init
();
domain_parameters_load_curve
(
curve
,
secp256k1
);
unsigned
char
*
rand_char
=
(
unsigned
char
*
)
malloc
(
32
);
unsigned
char
*
rand_char
=
(
unsigned
char
*
)
calloc
(
32
,
1
);
sgx_read_rand
(
rand_char
,
32
);
mpz_t
seed
;
...
...
@@ -524,7 +524,7 @@ void trustedBlsSignMessage(int *errStatus, char *err_string, uint8_t *encrypted_
void
trustedGenDkgSecret
(
int
*
errStatus
,
char
*
err_string
,
uint8_t
*
encrypted_dkg_secret
,
uint32_t
*
enc_len
,
size_t
_t
)
{
char
dkg_secret
[
DKG_BUFER_LENGTH
];
//= (char*)malloc(DKG_BUFER_LENGTH);
char
dkg_secret
[
DKG_BUFER_LENGTH
];
if
(
gen_dkg_poly
(
dkg_secret
,
_t
)
!=
0
)
{
*
errStatus
=
-
1
;
...
...
@@ -570,11 +570,9 @@ void trustedGetSecretShares(int *errStatus, char *err_string, uint8_t *encrypted
char
*
secret_shares
,
unsigned
_t
,
unsigned
_n
)
{
char
decrypted_dkg_secret
[
DKG_BUFER_LENGTH
];
//= (char*)malloc(DKG_BUFER_LENGTH);
char
decrypted_dkg_secret
[
DKG_BUFER_LENGTH
];
//char decrypted_dkg_secret[DKG_MAX_SEALED_LEN];
uint32_t
decr_len
;
//uint32_t* decr_len_test = (char*)malloc(1);
trustedDecryptDkgSecret
(
errStatus
,
err_string
,
encrypted_dkg_secret
,
(
uint8_t
*
)
decrypted_dkg_secret
,
&
decr_len
);
//sgx_status_t status = sgx_unseal_data(
// (const sgx_sealed_data_t *)encrypted_dkg_secret, NULL, 0, (uint8_t*)decrypted_dkg_secret, &decr_len);
...
...
@@ -594,9 +592,8 @@ void trustedGetSecretShares(int *errStatus, char *err_string, uint8_t *encrypted
void
trustedGetPublicShares
(
int
*
errStatus
,
char
*
err_string
,
uint8_t
*
encrypted_dkg_secret
,
uint32_t
enc_len
,
char
*
public_shares
,
unsigned
_t
,
unsigned
_n
)
{
//char decrypted_dkg_secret[DKG_MAX_SEALED_LEN * 2]; //= (char*)malloc(DKG_MAX_SEALED_LEN);
char
*
decrypted_dkg_secret
=
(
char
*
)
malloc
(
DKG_MAX_SEALED_LEN
);
char
*
decrypted_dkg_secret
=
(
char
*
)
calloc
(
DKG_MAX_SEALED_LEN
,
1
);
uint32_t
decr_len
;
trustedDecryptDkgSecret
(
errStatus
,
err_string
,
(
uint8_t
*
)
encrypted_dkg_secret
,
decrypted_dkg_secret
,
&
decr_len
);
if
(
*
errStatus
!=
0
)
{
...
...
@@ -659,13 +656,10 @@ void trustedGetEncryptedSecretShare(int *errStatus, char *err_string, uint8_t *e
}
snprintf
(
err_string
,
BUF_LEN
,
"unsealed random skey is %s
\n
"
,
skey
);
char
*
common_key
[
ECDSA_SKEY_LEN
];
//= (char *)malloc(65);
char
*
common_key
[
ECDSA_SKEY_LEN
];
gen_session_key
(
skey
,
pub_keyB
,
common_key
);
//snprintf(err_string + 81, BUF_LEN,"pub_key_B is %s length is %d", pub_keyB, strlen(pub_keyB));
//snprintf(err_string + 88, BUF_LEN - 88,"\ncommon key is %s", common_key);
char
*
s_share
[
ECDSA_SKEY_LEN
];
;
char
*
s_share
[
ECDSA_SKEY_LEN
];
//= (char *)malloc(65);
//char s_share[65];
if
(
calc_secret_share
(
decryptedDkgPoly
,
s_share
,
_t
,
_n
,
ind
)
!=
0
)
{
*
errStatus
=
-
1
;
...
...
@@ -680,7 +674,7 @@ void trustedGetEncryptedSecretShare(int *errStatus, char *err_string, uint8_t *e
return
;
}
char
*
cypher
[
ECDSA_SKEY_LEN
];
//= (char *)malloc(65);
char
*
cypher
[
ECDSA_SKEY_LEN
];
xor_encrypt
(
common_key
,
s_share
,
cypher
);
if
(
cypher
==
NULL
)
{
*
errStatus
=
1
;
...
...
@@ -717,7 +711,7 @@ void trustedComplaintResponse(int *errStatus, char *err_string, uint8_t *encrypt
// return;
// }
char
decrypted_dkg_secret
[
DKG_BUFER_LENGTH
];
//= (char*)malloc(DKG_BUFER_LENGTH);
char
decrypted_dkg_secret
[
DKG_BUFER_LENGTH
];
uint32_t
decr_len
;
trustedDecryptDkgSecret
(
errStatus
,
err_string
,
encrypted_dkg_secret
,
(
uint8_t
*
)
decrypted_dkg_secret
,
&
decr_len
);
if
(
*
errStatus
!=
0
)
{
...
...
@@ -930,7 +924,6 @@ void trustedGetBlsPubKey(int *errStatus, char *err_string, uint8_t *encrypted_ke
void
trustedGenerateSEK
(
int
*
errStatus
,
char
*
err_string
,
uint8_t
*
encrypted_SEK
,
uint32_t
*
enc_len
,
char
*
SEK_hex
)
{
uint8_t
SEK_raw
[
SGX_AESGCM_KEY_SIZE
];
//unsigned char* rand_char = (unsigned char*)malloc(16);
sgx_read_rand
(
SEK_raw
,
SGX_AESGCM_KEY_SIZE
);
uint32_t
hex_aes_key_length
=
SGX_AESGCM_KEY_SIZE
*
2
;
...
...
@@ -1004,7 +997,7 @@ void trustedGenerateEcdsaKeyAES(int *errStatus, char *err_string,
domain_parameters
curve
=
domain_parameters_init
();
domain_parameters_load_curve
(
curve
,
secp256k1
);
unsigned
char
*
rand_char
=
(
unsigned
char
*
)
malloc
(
32
);
unsigned
char
*
rand_char
=
(
unsigned
char
*
)
calloc
(
32
,
1
);
sgx_read_rand
(
rand_char
,
32
);
mpz_t
seed
;
...
...
@@ -1449,12 +1442,12 @@ void trustedGetEncryptedSecretShareAES(int *errStatus, char *err_string, uint8_t
*
dec_len
=
enc_len
;
// + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE;
char
*
common_key
[
ECDSA_SKEY_LEN
];
//= (char *)malloc(65);
char
*
common_key
[
ECDSA_SKEY_LEN
];
gen_session_key
(
skey
,
pub_keyB
,
common_key
);
//snprintf(err_string + 81, BUF_LEN,"pub_key_B is %s length is %d", pub_keyB, strlen(pub_keyB));
//snprintf(err_string + 88, BUF_LEN - 88,"\ncommon key is %s", common_key);
char
*
s_share
[
ECDSA_SKEY_LEN
];
//= (char *)malloc(65);
char
*
s_share
[
ECDSA_SKEY_LEN
];
//char s_share[65];
if
(
calc_secret_share
(
decryptedDkgPoly
,
s_share
,
_t
,
_n
,
ind
)
!=
0
)
{
...
...
@@ -1471,7 +1464,7 @@ void trustedGetEncryptedSecretShareAES(int *errStatus, char *err_string, uint8_t
return
;
}
char
*
cypher
[
ECDSA_SKEY_LEN
];
//= (char *)malloc(65);
char
*
cypher
[
ECDSA_SKEY_LEN
];
xor_encrypt
(
common_key
,
s_share
,
cypher
);
if
(
cypher
==
NULL
)
{
*
errStatus
=
1
;
...
...
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