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
b7a233bb
Unverified
Commit
b7a233bb
authored
Aug 09, 2020
by
Stan Kladko
Committed by
GitHub
Aug 09, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #133 from skalenetwork/SKALE-3067-remove-use-check
Skale 3067 remove use check
parents
0ff442ae
db6a4749
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
328 additions
and
144 deletions
+328
-144
DKGCrypto.cpp
DKGCrypto.cpp
+2
-0
VERSION
VERSION
+1
-1
AESUtils.c
secure_enclave/AESUtils.c
+37
-2
AESUtils.h
secure_enclave/AESUtils.h
+2
-2
EnclaveCommon.cpp
secure_enclave/EnclaveCommon.cpp
+8
-0
EnclaveCommon.h
secure_enclave/EnclaveCommon.h
+2
-0
secure_enclave.c
secure_enclave/secure_enclave.c
+199
-47
secure_enclave.config.xml
secure_enclave/secure_enclave.config.xml
+6
-5
secure_enclave.edl
secure_enclave/secure_enclave.edl
+69
-86
testw.cpp
testw.cpp
+2
-1
No files found.
DKGCrypto.cpp
View file @
b7a233bb
...
...
@@ -35,6 +35,8 @@
#include "third_party/spdlog/spdlog.h"
#include "common.h"
vector
<
string
>
splitString
(
const
char
*
coeffs
,
const
char
symbol
)
{
string
str
(
coeffs
);
string
delim
;
...
...
VERSION
View file @
b7a233bb
1.5
4
.0
1.5
6
.0
secure_enclave/AESUtils.c
View file @
b7a233bb
...
...
@@ -29,8 +29,29 @@
#include "AESUtils.h"
int
AES_encrypt
(
char
*
message
,
uint8_t
*
encr_message
)
{
int
AES_encrypt
(
char
*
message
,
uint8_t
*
encr_message
,
uint64_t
encrLen
)
{
if
(
!
message
)
{
LOG_ERROR
(
"Null message in AES_encrypt"
);
return
-
1
;
}
if
(
!
encr_message
)
{
LOG_ERROR
(
"Null encr message in AES_encrypt"
);
return
-
2
;
}
auto
len
=
strlen
(
message
);
if
(
len
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
>
encrLen
)
{
LOG_ERROR
(
"Output buffer too small"
);
return
-
3
;
}
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
,
...
...
@@ -40,9 +61,23 @@ int AES_encrypt(char *message, uint8_t *encr_message) {
return
status
;
}
int
AES_decrypt
(
uint8_t
*
encr_message
,
uint64_t
length
,
char
*
message
)
{
int
AES_decrypt
(
uint8_t
*
encr_message
,
uint64_t
length
,
char
*
message
,
uint64_t
msgLen
)
{
if
(
length
<
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
)
{
LOG_ERROR
(
"length < SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE"
);
return
-
1
;
}
uint64_t
len
=
length
-
SGX_AESGCM_MAC_SIZE
-
SGX_AESGCM_IV_SIZE
;
if
(
msgLen
<
len
)
{
LOG_ERROR
(
"Output buffer not large enough"
);
return
-
2
;
}
sgx_status_t
status
=
sgx_rijndael128GCM_decrypt
(
&
AES_key
,
encr_message
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
,
len
,
message
,
...
...
secure_enclave/AESUtils.h
View file @
b7a233bb
...
...
@@ -26,8 +26,8 @@
sgx_aes_gcm_128bit_key_t
AES_key
;
int
AES_encrypt
(
char
*
message
,
uint8_t
*
encr_message
);
int
AES_encrypt
(
char
*
message
,
uint8_t
*
encr_message
,
uint64_t
encrLen
);
int
AES_decrypt
(
uint8_t
*
encr_message
,
uint64_t
length
,
char
*
message
)
;
int
AES_decrypt
(
uint8_t
*
encr_message
,
uint64_t
length
,
char
*
message
,
uint64_t
msgLen
)
;
#endif //SGXD_AESUTILS_H
secure_enclave/EnclaveCommon.cpp
View file @
b7a233bb
...
...
@@ -36,6 +36,14 @@
using
namespace
std
;
thread_local
uint8_t
decryptedDkgPoly
[
DKG_BUFER_LENGTH
];
uint8_t
*
getThreadLocalDecryptedDkgPoly
()
{
return
decryptedDkgPoly
;
}
string
*
stringFromKey
(
libff
::
alt_bn128_Fr
*
_key
)
{
mpz_t
t
;
mpz_init
(
t
);
...
...
secure_enclave/EnclaveCommon.h
View file @
b7a233bb
...
...
@@ -47,6 +47,8 @@ EXTERNC void enclave_init();
void
get_global_random
(
unsigned
char
*
_randBuff
,
uint64_t
size
);
EXTERNC
uint8_t
*
getThreadLocalDecryptedDkgPoly
();
EXTERNC
void
LOG_INFO
(
const
char
*
msg
);
EXTERNC
void
LOG_WARN
(
const
char
*
_msg
);
EXTERNC
void
LOG_ERROR
(
const
char
*
_msg
);
...
...
secure_enclave/secure_enclave.c
View file @
b7a233bb
This diff is collapsed.
Click to expand it.
secure_enclave/secure_enclave.config.xml
View file @
b7a233bb
<EnclaveConfiguration>
<ProdID>
0
</ProdID>
<ISVSVN>
0
</ISVSVN>
<StackMaxSize>
0x100000
</StackMaxSize>
<HeapMaxSize>
0x1000000
</HeapMaxSize>
<TCSNum>
16
</TCSNum>
<TCSMaxNum>
16
</TCSMaxNum>
<TCSPolicy>
1
</TCSPolicy>
<StackMaxSize>
0x1000000
</StackMaxSize>
<HeapMaxSize>
0x100000000
</HeapMaxSize>
<TCSNum>
128
</TCSNum>
<TCSMaxNum>
128
</TCSMaxNum>
<TCSMinPool>
128
</TCSMinPool>
<TCSPolicy>
0
</TCSPolicy>
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>
0
</DisableDebug>
<MiscSelect>
0
</MiscSelect>
...
...
secure_enclave/secure_enclave.edl
View file @
b7a233bb
This diff is collapsed.
Click to expand it.
testw.cpp
View file @
b7a233bb
...
...
@@ -342,11 +342,12 @@ TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") {
vector
<
char
>
secret
(
2490
,
0
);
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
status
=
trustedDecryptDkgSecretAES
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedDKGSecret
.
data
(),
/*
status = trustedDecryptDkgSecretAES(eid, &errStatus, errMsg1.data(), encryptedDKGSecret.data(),
(uint8_t *) secret.data(), &encLen);
REQUIRE(status == SGX_SUCCESS);
REQUIRE(errStatus == SGX_SUCCESS);
*/
}
TEST_CASE_METHOD
(
TestFixture
,
"DKG public shares test"
,
"[dkg-pub-shares]"
)
{
...
...
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