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
d2fa720c
Unverified
Commit
d2fa720c
authored
Sep 05, 2019
by
ac10ef44eb72883e542a963cf52a088fc337b7a0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed server
parent
25f20f28
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
96 deletions
+75
-96
BLSCrypto.cpp
BLSCrypto.cpp
+53
-1
BLSCrypto.h
BLSCrypto.h
+5
-0
sgxwallet.c
sgxwallet.c
+3
-52
sgxwallet.h
sgxwallet.h
+14
-0
testw.cpp
testw.cpp
+0
-43
No files found.
BLSCrypto.cpp
View file @
d2fa720c
...
...
@@ -13,12 +13,60 @@
#include <jsonrpccpp/server/connectors/httpserver.h>
#include "BLSPrivateKeyShareSGX.h"
#include "sgxwallet_common.h"
#include "sgxwallet_common.h"
#include "create_enclave.h"
#include "secure_enclave_u.h"
#include "sgx_detect.h"
#include <gmp.h>
#include <sgx_urts.h>
#include "sgxwallet.h"
#include "BLSCrypto.h"
void
init_enclave
()
{
eid
=
0
;
updated
=
0
;
unsigned
long
support
;
#ifndef SGX_HW_SIM
support
=
get_sgx_support
();
if
(
!
SGX_OK
(
support
))
{
sgx_support_perror
(
support
);
exit
(
1
);
}
#endif
status
=
sgx_create_enclave_search
(
ENCLAVE_NAME
,
SGX_DEBUG_FLAG
,
&
token
,
&
updated
,
&
eid
,
0
);
if
(
status
!=
SGX_SUCCESS
)
{
if
(
status
==
SGX_ERROR_ENCLAVE_FILE_ACCESS
)
{
fprintf
(
stderr
,
"sgx_create_enclave: %s: file not found
\n
"
,
ENCLAVE_NAME
);
fprintf
(
stderr
,
"Did you forget to set LD_LIBRARY_PATH?
\n
"
);
}
else
{
fprintf
(
stderr
,
"%s: 0x%04x
\n
"
,
ENCLAVE_NAME
,
status
);
}
exit
(
1
);
}
fprintf
(
stderr
,
"Enclave launched
\n
"
);
status
=
tgmp_init
(
eid
);
if
(
status
!=
SGX_SUCCESS
)
{
fprintf
(
stderr
,
"ECALL tgmp_init: 0x%04x
\n
"
,
status
);
exit
(
1
);
}
fprintf
(
stderr
,
"libtgmp initialized
\n
"
);
}
int
char2int
(
char
_input
)
{
if
(
_input
>=
'0'
&&
_input
<=
'9'
)
return
_input
-
'0'
;
...
...
@@ -112,3 +160,7 @@ bool sign(char* _encryptedKeyHex, char* _hashHex, size_t _t, size_t _n, size_t _
}
void
init_all
()
{
init_enclave
();
init_daemon
();
}
\ No newline at end of file
BLSCrypto.h
View file @
d2fa720c
...
...
@@ -12,6 +12,8 @@
#define EXTERNC
#endif
EXTERNC
void
init_all
();
EXTERNC
void
init_daemon
();
EXTERNC
bool
sign
(
char
*
encryptedKeyHex
,
char
*
hashHex
,
size_t
t
,
size_t
n
,
char
*
_sig
);
...
...
@@ -24,5 +26,8 @@ EXTERNC bool hex2carray(const char * _hex, uint64_t *_bin_len,
EXTERNC
void
init_enclave
();
#endif //SGXD_BLSCRYPTO_H
sgxwallet.c
View file @
d2fa720c
...
...
@@ -31,18 +31,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sgxwallet_common.h"
#include "create_enclave.h"
#include "secure_enclave_u.h"
#include "sgx_detect.h"
#include <gmp.h>
#include <sgx_urts.h>
#include "sgxwallet.h"
#include "BLSCrypto.h"
#define ENCLAVE_NAME "secure_enclave.signed.so"
void
usage
()
{
...
...
@@ -51,49 +43,11 @@ void usage() {
}
sgx_launch_token_t
token
=
{
0
};
sgx_enclave_id_t
eid
;
sgx_status_t
status
;
int
updated
;
void
init_enclave
()
{
eid
=
0
;
updated
=
0
;
unsigned
long
support
;
#ifndef SGX_HW_SIM
support
=
get_sgx_support
();
if
(
!
SGX_OK
(
support
))
{
sgx_support_perror
(
support
);
exit
(
1
);
}
#endif
status
=
sgx_create_enclave_search
(
ENCLAVE_NAME
,
SGX_DEBUG_FLAG
,
&
token
,
&
updated
,
&
eid
,
0
);
if
(
status
!=
SGX_SUCCESS
)
{
if
(
status
==
SGX_ERROR_ENCLAVE_FILE_ACCESS
)
{
fprintf
(
stderr
,
"sgx_create_enclave: %s: file not found
\n
"
,
ENCLAVE_NAME
);
fprintf
(
stderr
,
"Did you forget to set LD_LIBRARY_PATH?
\n
"
);
}
else
{
fprintf
(
stderr
,
"%s: 0x%04x
\n
"
,
ENCLAVE_NAME
,
status
);
}
exit
(
1
);
}
fprintf
(
stderr
,
"Enclave launched
\n
"
);
status
=
tgmp_init
(
eid
);
if
(
status
!=
SGX_SUCCESS
)
{
fprintf
(
stderr
,
"ECALL tgmp_init: 0x%04x
\n
"
,
status
);
exit
(
1
);
}
fprintf
(
stderr
,
"libtgmp initialized
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
opt
;
...
...
@@ -112,10 +66,7 @@ int main(int argc, char *argv[]) {
if
(
argc
!=
0
)
usage
();
init_daemon
();
init_enclave
();
init_all
();
const
char
*
key
=
"4160780231445160889237664391382223604184857153814275770598"
...
...
sgxwallet.h
View file @
d2fa720c
...
...
@@ -5,7 +5,21 @@
#ifndef SGXD_SGXD_H
#define SGXD_SGXD_H
#include "sgxwallet_common.h"
#include "create_enclave.h"
#include "secure_enclave_u.h"
#include "sgx_detect.h"
#include <gmp.h>
#include <sgx_urts.h>
extern
sgx_enclave_id_t
eid
;
extern
int
updated
;
extern
sgx_launch_token_t
token
;
extern
sgx_status_t
status
;
#define ENCLAVE_NAME "secure_enclave.signed.so"
#endif //SGXD_SGXD_H
testw.cpp
View file @
d2fa720c
...
...
@@ -58,49 +58,6 @@ sgx_status_t status;
int
updated
;
void
init_enclave
()
{
eid
=
0
;
updated
=
0
;
unsigned
long
support
;
#ifndef SGX_HW_SIM
support
=
get_sgx_support
();
if
(
!
SGX_OK
(
support
))
{
sgx_support_perror
(
support
);
exit
(
1
);
}
#endif
status
=
sgx_create_enclave_search
(
ENCLAVE_NAME
,
SGX_DEBUG_FLAG
,
&
token
,
&
updated
,
&
eid
,
0
);
if
(
status
!=
SGX_SUCCESS
)
{
if
(
status
==
SGX_ERROR_ENCLAVE_FILE_ACCESS
)
{
fprintf
(
stderr
,
"sgx_create_enclave: %s: file not found
\n
"
,
ENCLAVE_NAME
);
fprintf
(
stderr
,
"Did you forget to set LD_LIBRARY_PATH?
\n
"
);
}
else
{
fprintf
(
stderr
,
"%s: 0x%04x
\n
"
,
ENCLAVE_NAME
,
status
);
}
exit
(
1
);
}
fprintf
(
stderr
,
"Enclave launched
\n
"
);
status
=
tgmp_init
(
eid
);
if
(
status
!=
SGX_SUCCESS
)
{
fprintf
(
stderr
,
"ECALL tgmp_init: 0x%04x
\n
"
,
status
);
exit
(
1
);
}
fprintf
(
stderr
,
"libtgmp initialized
\n
"
);
}
void
init_all
()
{
init_enclave
();
init_daemon
();
}
TEST_CASE
(
"BLS sign test"
,
"[bls-sign]"
)
{
...
...
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