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
c3f6c989
Unverified
Commit
c3f6c989
authored
Sep 05, 2019
by
ac10ef44eb72883e542a963cf52a088fc337b7a0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added catch
parent
59f8cb74
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
161 additions
and
2 deletions
+161
-2
.gitmodules
.gitmodules
+3
-0
BLSCrypto.cpp
BLSCrypto.cpp
+2
-0
Catch2
Catch2
+1
-0
Makefile.am
Makefile.am
+7
-2
sgxwallet.c
sgxwallet.c
+1
-0
testw.cpp
testw.cpp
+147
-0
No files found.
.gitmodules
View file @
c3f6c989
...
...
@@ -16,3 +16,6 @@
[submodule "sgx-software-enable"]
path = sgx-software-enable
url = https://github.com/intel/sgx-software-enable
[submodule "Catch2"]
path = Catch2
url = https://github.com/catchorg/Catch2
BLSCrypto.cpp
View file @
c3f6c989
...
...
@@ -15,6 +15,8 @@
#include "sgxwallet_common.h"
#include "BLSCrypto.h"
int
char2int
(
char
_input
)
{
...
...
Catch2
@
ce42deb7
Subproject commit ce42deb72fab2be85a862f559984580c24cb76c4
Makefile.am
View file @
c3f6c989
...
...
@@ -45,7 +45,7 @@ secure_enclave.edl: secure_enclave/secure_enclave.edl
## AM_CFLAGS =
## AM_CXXFLAGS =
AM_CPPFLAGS
+=
-Wall
-DSKALE_SGX
=
1
-DBINARY_OUTPUT
=
1
-Ileveldb
/include
-IlibBLS
/bls
-IlibBLS
/libff
-IlibBLS
-fno-builtin-memset
$(GMP_CPPFLAGS)
AM_CPPFLAGS
+=
-Wall
-DSKALE_SGX
=
1
-DBINARY_OUTPUT
=
1
-I
Catch2
/include
-I
leveldb
/include
-IlibBLS
/bls
-IlibBLS
/libff
-IlibBLS
-fno-builtin-memset
$(GMP_CPPFLAGS)
## Additional targets to remove with 'make clean'. You must list
## any edger8r generated files here.
...
...
@@ -56,7 +56,7 @@ CLEANFILES = $(COMMON_ENCLAVE_SRC) secure_enclave.edl \
## The build target
bin_PROGRAMS
=
sgxwallet
bin_PROGRAMS
=
sgxwallet
testw
## You can't use $(wildcard ...) with automake so all source files
...
...
@@ -66,6 +66,7 @@ COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC
=
secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES
=
sgxwallet.c BLSCrypto.cpp BLSPrivateKeyShareSGX.cpp
$(COMMON_SRC)
nodist_sgxwallet_SOURCES
=
$(COMMON_ENCLAVE_SRC)
EXTRA_sgxwallet_DEPENDENCIES
=
secure_enclave.signed.so
...
...
@@ -89,3 +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
-lpthread
-ljsonrpccpp-common
-ljsonrpccpp-server
-ljsonrpccpp-stub
-lprocps
testw_SOURCES
=
testw.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
sgxwallet.c
View file @
c3f6c989
...
...
@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <gmp.h>
#include <sgx_urts.h>
#include "BLSCrypto.h"
#define ENCLAVE_NAME "secure_enclave.signed.so"
...
...
testw.cpp
0 → 100644
View file @
c3f6c989
/*
Copyright 2018 Intel Corporation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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 "BLSCrypto.h"
#define ENCLAVE_NAME "secure_enclave.signed.so"
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
void
usage
()
{
fprintf
(
stderr
,
"usage: sgxwallet
\n
"
);
exit
(
1
);
}
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
"
);
}
TEST_CASE
(
"BLS test"
,
"[blssign]"
)
{
init_daemon
();
init_enclave
();
const
char
*
key
=
"4160780231445160889237664391382223604184857153814275770598"
"791864649971919844"
;
char
*
keyArray
=
(
char
*
)
calloc
(
128
,
1
);
uint8_t
*
encryptedKey
=
(
uint8_t
*
)
calloc
(
1024
,
1
);
char
*
errMsg
=
(
char
*
)
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
);
REQUIRE
(
status
==
SGX_SUCCESS
);
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
];
REQUIRE
(
hex2carray
(
result
,
&
dec_len
,
bin
));
for
(
uint64_t
i
=
0
;
i
<
dec_len
;
i
++
)
{
REQUIRE
(
bin
[
i
]
==
encryptedKey
[
i
]);
}
REQUIRE
(
dec_len
==
enc_len
);
gmp_printf
(
"Result: %s"
,
result
);
gmp_printf
(
"
\n
Length: %d
\n
"
,
enc_len
);
}
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