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
68c645da
Unverified
Commit
68c645da
authored
Aug 15, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3067 Cleaning up
parent
9bb69a8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
19 deletions
+27
-19
AESUtils.c
secure_enclave/AESUtils.c
+2
-4
DHDkg.c
secure_enclave/DHDkg.c
+25
-15
No files found.
secure_enclave/AESUtils.c
View file @
68c645da
...
...
@@ -41,7 +41,7 @@ int AES_encrypt(char *message, uint8_t *encr_message, uint64_t encrLen) {
return
-
2
;
}
auto
len
=
strlen
(
message
);
uint64_t
len
=
strlen
(
message
);
if
(
len
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
>
encrLen
)
{
LOG_ERROR
(
"Output buffer too small"
);
...
...
@@ -50,8 +50,6 @@ int AES_encrypt(char *message, uint8_t *encr_message, uint64_t encrLen) {
sgx_read_rand
(
encr_message
+
SGX_AESGCM_MAC_SIZE
,
SGX_AESGCM_IV_SIZE
);
auto
msgLen
=
strlen
(
message
);
sgx_status_t
status
=
sgx_rijndael128GCM_encrypt
(
&
AES_key
,
(
uint8_t
*
)
message
,
strlen
(
message
),
encr_message
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
,
encr_message
+
SGX_AESGCM_MAC_SIZE
,
SGX_AESGCM_IV_SIZE
,
...
...
@@ -90,7 +88,7 @@ int AES_decrypt(uint8_t *encr_message, uint64_t length, char *message, uint64_t
sgx_status_t
status
=
sgx_rijndael128GCM_decrypt
(
&
AES_key
,
encr_message
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
,
len
,
message
,
(
unsigned
char
*
)
message
,
encr_message
+
SGX_AESGCM_MAC_SIZE
,
SGX_AESGCM_IV_SIZE
,
NULL
,
0
,
(
sgx_aes_gcm_128bit_tag_t
*
)
encr_message
);
...
...
secure_enclave/DHDkg.c
View file @
68c645da
...
...
@@ -114,6 +114,22 @@ int session_key_recover(const char *skey_str, const char *sshare, char *common_k
int
ret
=
-
1
;
SAFE_CHAR_BUF
(
pb_keyB_x
,
65
);
SAFE_CHAR_BUF
(
pb_keyB_y
,
65
);
mpz_t
skey
;
mpz_init
(
skey
);
point
pub_keyB
=
point_init
();
point
session_key
=
point_init
();
pb_keyB_x
[
64
]
=
0
;
strncpy
(
pb_keyB_x
,
sshare
+
64
,
64
);
strncpy
(
pb_keyB_y
,
sshare
+
128
,
64
);
pb_keyB_y
[
64
]
=
0
;
if
(
!
common_key
)
{
LOG_ERROR
(
"session_key_recover: Null common_key"
);
goto
clean
;
...
...
@@ -132,18 +148,12 @@ int session_key_recover(const char *skey_str, const char *sshare, char *common_k
}
SAFE_CHAR_BUF
(
pb_keyB_x
,
65
);
strncpy
(
pb_keyB_x
,
sshare
+
64
,
64
);
pb_keyB_x
[
64
]
=
0
;
SAFE_CHAR_BUF
(
pb_keyB_y
,
65
);
strncpy
(
pb_keyB_y
,
sshare
+
128
,
64
);
pb_keyB_y
[
64
]
=
0
;
mpz_t
skey
;
mpz_init
(
skey
);
point
pub_keyB
=
point_init
();
point
session_key
=
point_init
();
if
(
mpz_set_str
(
skey
,
skey_str
,
16
)
==
-
1
)
{
goto
clean
;
...
...
@@ -195,7 +205,7 @@ int xor_encrypt(char *key, char *message, char *cypher) {
uint64_t
key_length
;
if
(
!
hex2carray
(
key
,
&
key_length
,
key_bin
))
{
if
(
!
hex2carray
(
key
,
&
key_length
,
(
uint8_t
*
)
key_bin
))
{
goto
clean
;
}
...
...
@@ -209,7 +219,7 @@ int xor_encrypt(char *key, char *message, char *cypher) {
cypher_bin
[
i
]
=
msg_bin
[
i
]
^
key_bin
[
i
];
}
carray2Hex
(
cypher_bin
,
32
,
cypher
);
carray2Hex
(
(
unsigned
char
*
)
cypher_bin
,
32
,
cypher
);
ret
=
0
;
...
...
@@ -245,14 +255,14 @@ int xor_decrypt(char *key, char *cypher, char *message) {
SAFE_CHAR_BUF
(
key_bin
,
33
)
uint64_t
key_length
;
if
(
!
hex2carray
(
key
,
&
key_length
,
key_bin
))
{
if
(
!
hex2carray
(
key
,
&
key_length
,
(
uint8_t
*
)
key_bin
))
{
goto
clean
;
}
uint64_t
cypher_length
;
SAFE_CHAR_BUF
(
cypher_bin
,
33
);
if
(
!
hex2carray
(
cypher
,
&
cypher_length
,
cypher_bin
))
{
if
(
!
hex2carray
(
cypher
,
&
cypher_length
,
(
uint8_t
*
)
cypher_bin
))
{
goto
clean
;
}
...
...
@@ -260,7 +270,7 @@ int xor_decrypt(char *key, char *cypher, char *message) {
msg_bin
[
i
]
=
cypher_bin
[
i
]
^
key_bin
[
i
];
}
carray2Hex
(
msg_bin
,
32
,
message
);
carray2Hex
(
(
unsigned
char
*
)
msg_bin
,
32
,
message
);
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