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
20b54803
Unverified
Commit
20b54803
authored
Sep 05, 2019
by
ac10ef44eb72883e542a963cf52a088fc337b7a0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rpc server
parent
d2fa720c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
73 deletions
+19
-73
BLSCrypto.cpp
BLSCrypto.cpp
+3
-1
BLSCrypto.h
BLSCrypto.h
+2
-2
Makefile.am
Makefile.am
+1
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+1
-6
SGXWalletServer.h
SGXWalletServer.h
+10
-0
sgxwallet.c
sgxwallet.c
+2
-63
No files found.
BLSCrypto.cpp
View file @
20b54803
...
...
@@ -23,6 +23,8 @@
#include "sgxwallet.h"
#include "SGXWalletServer.h"
#include "BLSCrypto.h"
...
...
@@ -132,7 +134,6 @@ void init_daemon() {
leveldb
::
Status
status
=
leveldb
::
DB
::
Open
(
options
,
"./keysdb"
,
&
db
);
}
...
...
@@ -161,6 +162,7 @@ bool sign(char* _encryptedKeyHex, char* _hashHex, size_t _t, size_t _n, size_t _
void
init_all
()
{
init_server
();
init_enclave
();
init_daemon
();
}
\ No newline at end of file
BLSCrypto.h
View file @
20b54803
...
...
@@ -16,6 +16,8 @@ EXTERNC void init_all();
EXTERNC
void
init_daemon
();
EXTERNC
void
init_enclave
();
EXTERNC
bool
sign
(
char
*
encryptedKeyHex
,
char
*
hashHex
,
size_t
t
,
size_t
n
,
char
*
_sig
);
EXTERNC
int
char2int
(
char
_input
);
...
...
@@ -26,8 +28,6 @@ EXTERNC bool hex2carray(const char * _hex, uint64_t *_bin_len,
EXTERNC
void
init_enclave
();
#endif //SGXD_BLSCRYPTO_H
Makefile.am
View file @
20b54803
...
...
@@ -90,7 +90,7 @@ secure_enclave.signed.so: secure_enclave/secure_enclave.signed.so
sgxwallet_LDADD
=
-l
$(SGX_URTS_LIB)
-Lleveldb
/build
-LlibBLS
/build
-LlibBLS
/build/libff/libff
-l
:libbls.a
-l
:libleveldb.a
-l
:libff.a
-lgmp
-ldl
-l
:libsgx_capable.a
-l
:libsgx_tprotected_fs.a
-ljsonrpccpp-stub
-lpthread
-ljsonrpccpp-common
-ljsonrpccpp-server
-ljsoncpp
-lprocps
testw_SOURCES
=
testw.cpp BLSCrypto.cpp BLSPrivateKeyShareSGX.cpp
$(COMMON_SRC)
testw_SOURCES
=
testw.cpp
SGXWalletServer.cpp
BLSCrypto.cpp BLSPrivateKeyShareSGX.cpp
$(COMMON_SRC)
nodist_testw_SOURCES
=
${
nodist_sgxwallet_SOURCES
}
EXTRA_testw_DEPENDENCIES
=
${
EXTRA_sgxwallet_DEPENDENCIES
}
testw_LDADD
=
${
sgxwallet_LDADD
}
\ No newline at end of file
SGXWalletServer.cpp
View file @
20b54803
...
...
@@ -68,14 +68,9 @@ Json::Value SGXWalletServer::buildObject(const string &name, int age) {
string
SGXWalletServer
::
methodWithoutParameters
()
{
return
"Test"
;
}
int
init_server
()
{
HttpServer
httpserver
(
8383
);
HttpServer
httpserver
(
1025
);
SGXWalletServer
s
(
httpserver
,
JSONRPC_SERVER_V1V2
);
// hybrid server (json-rpc 1.0 & 2.0)
s
.
StartListening
();
cout
<<
"Hit enter to stop the server"
<<
endl
;
getchar
();
s
.
StopListening
();
return
0
;
}
\ No newline at end of file
SGXWalletServer.h
View file @
20b54803
...
...
@@ -5,4 +5,14 @@
#ifndef SGXD_SGXWALLETSERVER_H
#define SGXD_SGXWALLETSERVER_H
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
EXTERNC
int
init_server
();
#endif //SGXD_SGXWALLETSERVER_H
sgxwallet.c
View file @
20b54803
...
...
@@ -68,70 +68,9 @@ int main(int argc, char *argv[]) {
init_all
();
const
char
*
key
=
"4160780231445160889237664391382223604184857153814275770598"
"791864649971919844"
;
char
*
keyArray
=
calloc
(
128
,
1
);
uint8_t
*
encryptedKey
=
calloc
(
1024
,
1
);
char
*
errMsg
=
calloc
(
1024
,
1
);
strncpy
((
char
*
)
keyArray
,
(
char
*
)
key
,
128
);
int
err_status
=
0
;
unsigned
int
enc_len
=
0
;
status
=
encrypt_key
(
eid
,
&
err_status
,
errMsg
,
keyArray
,
encryptedKey
,
&
enc_len
);
if
(
status
!=
SGX_SUCCESS
)
{
printf
(
"ECALL encrypt_key: 0x%04x
\n
"
,
status
);
return
1
;
}
printf
(
"Encrypt key completed with status: %d %s
\n
"
,
err_status
,
errMsg
);
printf
(
" Encrypted key len %d
\n
"
,
enc_len
);
char
result
[
2
*
BUF_LEN
];
carray2Hex
(
encryptedKey
,
enc_len
,
result
);
uint64_t
dec_len
=
0
;
uint8_t
bin
[
BUF_LEN
];
if
(
!
hex2carray
(
result
,
&
dec_len
,
bin
))
{
printf
(
"hex2carray returned false"
);
}
for
(
int
i
=
0
;
i
<
dec_len
;
i
++
)
{
if
(
bin
[
i
]
!=
encryptedKey
[
i
])
{
printf
(
"Hex does not match"
);
return
1
;
}
while
(
true
)
{
sleep
(
10
);
}
if
(
dec_len
!=
enc_len
)
{
printf
(
"Dec_len != enc_len %d %d
\n
"
,
(
uint32_t
)
dec_len
,
(
uint32_t
)
enc_len
);
return
1
;
}
gmp_printf
(
"Result: %s"
,
result
);
gmp_printf
(
"
\n
Length: %d
\n
"
,
enc_len
);
return
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