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
2920d188
Unverified
Commit
2920d188
authored
Sep 03, 2019
by
a72d9e2bad9edfd58d6c0248c12c953b71d409d2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed warnings
parent
497d403d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
31 deletions
+36
-31
BLSUtils.cpp
secure_enclave/BLSUtils.cpp
+13
-1
Makefile.am
secure_enclave/Makefile.am
+1
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+10
-17
secure_enclave.edl
secure_enclave/secure_enclave.edl
+9
-9
sgxd.c
sgxd.c
+3
-3
No files found.
secure_enclave/BLSUtils.cpp
View file @
2920d188
...
...
@@ -3,6 +3,9 @@
//
#define GMP_WITH_SGX
#define MAX_SIG_LEN 1024
#include "BLSUtils.h"
#include "libff/algebra/curves/alt_bn128/alt_bn128_init.hpp"
#include "libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp"
...
...
@@ -109,6 +112,15 @@ char* sign(const char *_keyString, const char* _hashXString, const char* _hashYS
libff
::
alt_bn128_G1
sign
=
key
->
as_bigint
()
*
hash
;
// sign
return
nullptr
;
auto
r
=
stringFromG1
(
&
sign
);
char
*
result
=
(
char
*
)
calloc
(
r
->
size
()
+
1
,
1
);
strncpy
(
result
,
r
->
c_str
(),
MAX_SIG_LEN
);
delete
r
;
return
result
;
}
secure_enclave/Makefile.am
View file @
2920d188
...
...
@@ -63,7 +63,7 @@ ENCLAVE_KEY=$(ENCLAVE)_private.pem
## Additional Automake flags needed to build the enclave.
##
AM_CPPFLAGS
+=
-Wall
$(TGMP_CPPFLAGS)
-I
../trusted_libff
-I
../sgx-sdk-build/sgxsdk/include/libcxx
\
AM_CPPFLAGS
+=
-Wall
-Wno-implicit-function-declaration
$(TGMP_CPPFLAGS)
-I
../trusted_libff
-I
../sgx-sdk-build/sgxsdk/include/libcxx
\
-I
../intel-sgx-ssl/Linux/package/include
AM_CXXFLAGS
+=
-fno-builtin
...
...
secure_enclave/secure_enclave.c
View file @
2920d188
...
...
@@ -65,7 +65,6 @@ void (*oc_free_func)(void *, size_t);
void
*
reallocate_function
(
void
*
,
size_t
,
size_t
);
void
free_function
(
void
*
,
size_t
);
void
e_calc_pi
(
mpf_t
*
pi
,
uint64_t
digits
);
void
tgmp_init
()
{
oc_realloc_func
=
&
reallocate_function
;
...
...
@@ -121,8 +120,8 @@ void e_mpf_div(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un) {}
void
encrypt_key
(
int
*
err_status
,
unsigned
char
*
err_string
,
unsigned
char
*
key
,
u
nsigned
char
*
encrypted_key
,
uint32_t
*
enc_len
)
{
void
encrypt_key
(
int
*
err_status
,
char
*
err_string
,
char
*
key
,
u
int8_t
*
encrypted_key
,
uint32_t
*
enc_len
)
{
*
err_status
=
-
1
;
...
...
@@ -166,7 +165,7 @@ void encrypt_key(int *err_status, unsigned char *err_string, unsigned char *key,
memset
(
encrypted_key
,
0
,
MAX_ENCRYPTED_KEY_LENGTH
);
if
(
sgx_seal_data
(
0
,
NULL
,
MAX_KEY_LENGTH
,
key
,
sealedLen
,
encrypted_key
)
!=
if
(
sgx_seal_data
(
0
,
NULL
,
MAX_KEY_LENGTH
,
(
uint8_t
*
)
key
,
sealedLen
,
(
sgx_sealed_data_t
*
)
encrypted_key
)
!=
SGX_SUCCESS
)
{
snprintf
(
err_string
,
MAX_ERR_LEN
,
"SGX seal data failed"
);
return
;
...
...
@@ -205,15 +204,15 @@ void encrypt_key(int *err_status, unsigned char *err_string, unsigned char *key,
*
err_status
=
0
;
}
void
decrypt_key
(
int
*
err_status
,
unsigned
char
*
err_string
,
unsigned
char
*
encrypted_key
,
uint32_t
enc_len
,
unsigned
char
*
key
)
{
void
decrypt_key
(
int
*
err_status
,
char
*
err_string
,
uint8_t
*
encrypted_key
,
uint32_t
enc_len
,
char
*
key
)
{
uint32_t
decLen
;
*
err_status
=
-
9
;
sgx_status_t
status
=
sgx_unseal_data
(
(
const
sgx_sealed_data_t
*
)
encrypted_key
,
NULL
,
0
,
key
,
&
decLen
);
(
const
sgx_sealed_data_t
*
)
encrypted_key
,
NULL
,
0
,
(
uint8_t
*
)
key
,
&
decLen
);
if
(
status
!=
SGX_SUCCESS
)
{
snprintf
(
err_string
,
MAX_ERR_LEN
,
"sgx_unseal_data failed with status %d"
,
status
);
...
...
@@ -254,14 +253,12 @@ void decrypt_key(int *err_status, unsigned char *err_string, unsigned char *encr
void
sign_message
(
int
*
err_status
,
unsigned
char
*
err_string
,
unsigned
char
*
encrypted_key
,
uint32_t
enc_len
,
unsigned
char
*
message
,
unsigned
char
*
signature
)
{
void
sign_message
(
int
*
err_status
,
char
*
err_string
,
uint8_t
*
encrypted_key
,
uint32_t
enc_len
,
uint8_t
*
message
,
char
*
signature
)
{
*
err_status
=
-
1
;
uint8_t
key
[
MAX_KEY_LENGTH
];
char
key
[
MAX_KEY_LENGTH
];
decrypt_key
(
err_status
,
err_string
,
encrypted_key
,
enc_len
,
key
);
...
...
@@ -269,13 +266,9 @@ void sign_message(int *err_status, unsigned char *err_string, unsigned char *en
return
;
}
char
*
ecdsaSig
=
sign
(
key
,
""
,
""
,
""
);
if
(
ecdsaSig
==
NULL
)
{
return
;
}
strncpy
(
signature
,
ecdsaSig
,
MAX_SIG_LEN
);
//
strncpy(signature, ecdsaSig, MAX_SIG_LEN);
...
...
secure_enclave/secure_enclave.edl
View file @
2920d188
...
...
@@ -23,24 +23,24 @@ enclave {
public void encrypt_key (
[user_check] int *err_status,
[out, count = 1024]
unsigned
char* err_string,
[in, count = 128]
unsigned
char* key,
[out, count = 1024] u
nsigned char
* encrypted_key, [user_check] uint32_t *enc_len);
[out, count = 1024] char* err_string,
[in, count = 128] char* key,
[out, count = 1024] u
int8_t
* encrypted_key, [user_check] uint32_t *enc_len);
public void decrypt_key (
[user_check] int *err_status,
[out, count = 1024]
unsigned
char* err_string,
[in, count = 1024] u
nsigned char
* encrypted_key,
[out, count = 1024] char* err_string,
[in, count = 1024] u
int8_t
* encrypted_key,
uint32_t enc_len,
[out, count = 128]
unsigned
char* key );
[out, count = 128] char* key );
public void sign_message (
[user_check] int *err_status,
[out, count = 1024]
unsigned
char* err_string,
[out, count = 1024] char* err_string,
[in, count = 1024] unsigned char* encrypted_key,
uint32_t enc_len,
[in, count = 1
024] unsigned char* message
,
[out, count = 1024]
unsigned
char* signature);
[in, count = 1
6] uint8_t* hash
,
[out, count = 1024] char* signature);
...
...
sgxd.c
View file @
2920d188
...
...
@@ -176,11 +176,11 @@ int main(int argc, char *argv[]) {
const
char
*
key
=
"4160780231445160889237664391382223604184857153814275770598"
"791864649971919844"
;
unsigned
char
*
keyArray
=
calloc
(
128
,
1
);
char
*
keyArray
=
calloc
(
128
,
1
);
u
nsigned
char
*
encryptedKey
=
calloc
(
1024
,
1
);
u
int8_t
*
encryptedKey
=
calloc
(
1024
,
1
);
unsigned
char
*
errMsg
=
calloc
(
1024
,
1
);
char
*
errMsg
=
calloc
(
1024
,
1
);
strncpy
((
char
*
)
keyArray
,
(
char
*
)
key
,
128
);
...
...
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