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
b8ea6026
Unverified
Commit
b8ea6026
authored
Jan 25, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed add README toc
parent
3ca52107
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
132 deletions
+92
-132
LevelDB.cpp
LevelDB.cpp
+32
-5
LevelDB.h
LevelDB.h
+22
-20
ServerInit.cpp
ServerInit.cpp
+1
-22
Makefile.in
secure_enclave/Makefile.in
+37
-85
No files found.
LevelDB.cpp
View file @
b8ea6026
...
...
@@ -267,22 +267,49 @@ std::shared_ptr<LevelDB> LevelDB::csrDb = nullptr;
std
::
shared_ptr
<
LevelDB
>
LevelDB
::
csrStatusDb
=
nullptr
;
st
d
::
shared_ptr
<
string
>
LevelDB
::
sgx_data_folder
=
nullpt
r
;
st
ring
LevelDB
::
sgx_data_folde
r
;
bool
LevelDB
::
isInited
=
false
;
void
LevelDB
::
initD
Bs
(
string
&
_sgx_data_folder
)
{
void
LevelDB
::
initD
ataFolderAndDBs
(
)
{
if
(
isInited
)
return
;
auto
dbName
=
_sgx_data_folder
+
WALLETDB_NAME
;
char
cwd
[
PATH_MAX
];
if
(
getcwd
(
cwd
,
sizeof
(
cwd
))
==
NULL
)
{
spdlog
::
error
(
"could not get cwd"
);
exit
(
-
1
);
}
sgx_data_folder
=
string
(
cwd
)
+
"/"
+
SGXDATA_FOLDER
;
struct
stat
info
;
if
(
stat
(
sgx_data_folder
.
c_str
(),
&
info
)
!=
0
){
spdlog
::
info
(
"going to create sgx_data folder"
);
std
::
string
make_sgx_data_folder
=
"mkdir "
+
sgx_data_folder
;
if
(
system
(
make_sgx_data_folder
.
c_str
())
==
0
){
spdlog
::
info
(
"sgx_data folder was created"
);
}
else
{
spdlog
::
error
(
"creating sgx_data folder failed"
);
exit
(
-
1
);
}
}
auto
dbName
=
sgx_data_folder
+
WALLETDB_NAME
;
levelDb
=
make_shared
<
LevelDB
>
(
dbName
);
auto
csr_dbname
=
_
sgx_data_folder
+
"CSR_DB"
;
auto
csr_dbname
=
sgx_data_folder
+
"CSR_DB"
;
csrDb
=
make_shared
<
LevelDB
>
(
csr_dbname
);
auto
csr_status_dbname
=
_
sgx_data_folder
+
"CSR_STATUS_DB"
;
auto
csr_status_dbname
=
sgx_data_folder
+
"CSR_STATUS_DB"
;
csrStatusDb
=
make_shared
<
LevelDB
>
(
csr_status_dbname
);
}
const
string
&
LevelDB
::
getSgxDataFolder
()
{
return
sgx_data_folder
;
}
LevelDB.h
View file @
b8ea6026
...
...
@@ -38,54 +38,54 @@ namespace leveldb {
class
LevelDB
{
std
::
recursive_mutex
mutex
;
recursive_mutex
mutex
;
s
td
::
s
hared_ptr
<
leveldb
::
DB
>
db
;
shared_ptr
<
leveldb
::
DB
>
db
;
static
bool
isInited
;
static
s
td
::
s
hared_ptr
<
LevelDB
>
levelDb
;
static
shared_ptr
<
LevelDB
>
levelDb
;
static
s
td
::
s
hared_ptr
<
LevelDB
>
csrDb
;
static
shared_ptr
<
LevelDB
>
csrDb
;
static
s
td
::
s
hared_ptr
<
LevelDB
>
csrStatusDb
;
static
shared_ptr
<
LevelDB
>
csrStatusDb
;
static
st
d
::
shared_ptr
<
std
::
string
>
sgx_data_folder
;
static
st
ring
sgx_data_folder
;
public
:
static
void
initD
Bs
(
std
::
string
&
_sgx_data_folder
);
static
void
initD
ataFolderAndDBs
(
);
static
const
s
td
::
s
hared_ptr
<
LevelDB
>
&
getLevelDb
();
static
const
shared_ptr
<
LevelDB
>
&
getLevelDb
();
static
const
s
td
::
s
hared_ptr
<
LevelDB
>
&
getCsrDb
();
static
const
shared_ptr
<
LevelDB
>
&
getCsrDb
();
static
const
s
td
::
s
hared_ptr
<
LevelDB
>
&
getCsrStatusDb
();
static
const
shared_ptr
<
LevelDB
>
&
getCsrStatusDb
();
public
:
s
td
::
shared_ptr
<
std
::
string
>
readString
(
const
std
::
string
&
_key
);
s
hared_ptr
<
string
>
readString
(
const
string
&
_key
);
void
writeString
(
const
st
d
::
string
&
key1
,
const
std
::
string
&
value1
);
void
writeString
(
const
st
ring
&
key1
,
const
string
&
value1
);
void
writeDataUnique
(
const
st
d
::
string
&
Name
,
const
std
::
string
&
value
);
void
writeDataUnique
(
const
st
ring
&
Name
,
const
string
&
value
);
void
writeByteArray
(
const
char
*
_key
,
size_t
_keyLen
,
const
char
*
value
,
size_t
_valueLen
);
void
writeByteArray
(
st
d
::
st
ring
&
_key
,
const
char
*
value
,
void
writeByteArray
(
string
&
_key
,
const
char
*
value
,
size_t
_valueLen
);
void
deleteDHDKGKey
(
const
st
d
::
st
ring
&
_key
);
void
deleteDHDKGKey
(
const
string
&
_key
);
void
deleteTempNEK
(
const
st
d
::
st
ring
&
_key
);
void
deleteTempNEK
(
const
string
&
_key
);
void
deleteKey
(
const
st
d
::
st
ring
&
_key
);
void
deleteKey
(
const
string
&
_key
);
public
:
...
...
@@ -93,7 +93,7 @@ public:
void
throwExceptionOnError
(
leveldb
::
Status
result
);
LevelDB
(
st
d
::
st
ring
&
filename
);
LevelDB
(
string
&
filename
);
...
...
@@ -101,15 +101,17 @@ public:
class
KeyVisitor
{
public
:
virtual
void
visitDBKey
(
const
char
*
_data
)
=
0
;
virtual
void
writeDBKeysToVector
(
const
char
*
_data
,
std
::
vector
<
const
char
*>
&
keys_vect
)
{}
virtual
void
writeDBKeysToVector
(
const
char
*
_data
,
vector
<
const
char
*>
&
keys_vect
)
{}
};
uint64_t
visitKeys
(
KeyVisitor
*
_visitor
,
uint64_t
_maxKeysToVisit
);
std
::
vector
<
std
::
string
>
writeKeysToVector1
(
uint64_t
_maxKeysToVisit
);
vector
<
string
>
writeKeysToVector1
(
uint64_t
_maxKeysToVisit
);
virtual
~
LevelDB
();
static
const
string
&
getSgxDataFolder
();
};
...
...
ServerInit.cpp
View file @
b8ea6026
...
...
@@ -72,28 +72,7 @@ void init_daemon() {
libff
::
init_alt_bn128_params
();
char
cwd
[
PATH_MAX
];
if
(
getcwd
(
cwd
,
sizeof
(
cwd
))
==
NULL
)
{
spdlog
::
error
(
"could not get cwd"
);
exit
(
-
1
);
}
std
::
string
sgx_data_folder
=
string
(
cwd
)
+
"/"
+
SGXDATA_FOLDER
;
struct
stat
info
;
if
(
stat
(
sgx_data_folder
.
c_str
(),
&
info
)
!=
0
){
spdlog
::
info
(
"going to create sgx_data folder"
);
std
::
string
make_sgx_data_folder
=
"mkdir "
+
sgx_data_folder
;
if
(
system
(
make_sgx_data_folder
.
c_str
())
==
0
){
spdlog
::
info
(
"sgx_data folder was created"
);
}
else
{
spdlog
::
error
(
"creating sgx_data folder failed"
);
exit
(
-
1
);
}
}
LevelDB
::
initDBs
(
sgx_data_folder
);
LevelDB
::
initDataFolderAndDBs
();
std
::
shared_ptr
<
std
::
string
>
encr_SEK_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
"SEK"
);
...
...
secure_enclave/Makefile.in
View file @
b8ea6026
# Makefile.in generated by automake 1.1
6
.1 from Makefile.am.
# Makefile.in generated by automake 1.1
5
.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-201
8
Free Software Foundation, Inc.
# Copyright (C) 1994-201
7
Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
...
...
@@ -137,16 +137,7 @@ am__v_at_0 = @
am__v_at_1
=
DEFAULT_INCLUDES
=
-I
.@am__isrc@
depcomp
=
$(SHELL)
$(top_srcdir)
/depcomp
am__maybe_remake_depfiles
=
depfiles
am__depfiles_remade
=
./
$(DEPDIR)
/AESUtils.Po
\
./
$(DEPDIR)
/BLSEnclave.Po ./
$(DEPDIR)
/DH_dkg.Po
\
./
$(DEPDIR)
/DKGUtils.Po ./
$(DEPDIR)
/alt_bn128_g1.Po
\
./
$(DEPDIR)
/alt_bn128_g2.Po ./
$(DEPDIR)
/alt_bn128_init.Po
\
./
$(DEPDIR)
/curves.Po ./
$(DEPDIR)
/domain_parameters.Po
\
./
$(DEPDIR)
/numbertheory.Po ./
$(DEPDIR)
/point.Po
\
./
$(DEPDIR)
/secure_enclave.Po ./
$(DEPDIR)
/secure_enclave_t.Po
\
./
$(DEPDIR)
/signature.Po ./
$(DEPDIR)
/signed_enclave_debug.Po
\
./
$(DEPDIR)
/signed_enclave_rel.Po
am__depfiles_maybe
=
depfiles
am__mv
=
mv
-f
COMPILE
=
$(CC)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(AM_CPPFLAGS)
\
$(CPPFLAGS)
$(AM_CFLAGS)
$(CFLAGS)
...
...
@@ -375,8 +366,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*
config.status
*
)
\
cd
$(top_builddir)
&&
$(MAKE)
$(AM_MAKEFLAGS)
am--refresh
;;
\
*
)
\
echo
' cd
$(top_builddir)
&&
$(SHELL)
./config.status
$(subdir)
/$@
$(am__
maybe_remake_depfiles
)
'
;
\
cd
$(top_builddir)
&&
$(SHELL)
./config.status
$(subdir)
/
$@
$(am__
maybe_remake_depfiles
)
;;
\
echo
' cd
$(top_builddir)
&&
$(SHELL)
./config.status
$(subdir)
/$@
$(am__
depfiles_maybe
)
'
;
\
cd
$(top_builddir)
&&
$(SHELL)
./config.status
$(subdir)
/
$@
$(am__
depfiles_maybe
)
;;
\
esac
;
$(top_srcdir)/build-aux/sgx_enclave.am $(am__empty)
:
...
...
@@ -441,28 +432,22 @@ mostlyclean-compile:
distclean-compile
:
-
rm
-f
*
.tab.c
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/AESUtils.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/BLSEnclave.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/DH_dkg.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/DKGUtils.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/alt_bn128_g1.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/alt_bn128_g2.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/alt_bn128_init.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/curves.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/domain_parameters.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/numbertheory.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/point.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/secure_enclave.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/secure_enclave_t.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/signature.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/signed_enclave_debug.Po@am__quote@
# am--include-marker
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/signed_enclave_rel.Po@am__quote@
# am--include-marker
$(am__depfiles_remade)
:
@
$(MKDIR_P)
$
(
@D
)
@
echo
'# dummy'
>
$@
-t
&&
$(am__mv)
$@
-t
$@
am--depfiles
:
$(am__depfiles_remade)
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/AESUtils.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/BLSEnclave.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/DH_dkg.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/DKGUtils.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/alt_bn128_g1.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/alt_bn128_g2.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/alt_bn128_init.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/curves.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/domain_parameters.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/numbertheory.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/point.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/secure_enclave.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/secure_enclave_t.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/signature.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/signed_enclave_debug.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/signed_enclave_rel.Po@am__quote@
.c.o
:
@am__fastdepCC_TRUE@
$(AM_V_CC)$(COMPILE)
-MT
$@
-MD
-MP
-MF
$(DEPDIR)/$*.Tpo
-c
-o
$@
$<
...
...
@@ -586,10 +571,7 @@ cscopelist-am: $(am__tagged_files)
distclean-tags
:
-
rm
-f
TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir
:
$(BUILT_SOURCES)
$(MAKE)
$(AM_MAKEFLAGS)
distdir-am
distdir-am
:
$(DISTFILES)
distdir
:
$(DISTFILES)
@
srcdirstrip
=
`
echo
"
$(srcdir)
"
|
sed
's/[].[^$$\\*]/\\\\&/g'
`
;
\
topsrcdirstrip
=
`
echo
"
$(top_srcdir)
"
|
sed
's/[].[^$$\\*]/\\\\&/g'
`
;
\
list
=
'
$(DISTFILES)
'
;
\
...
...
@@ -662,22 +644,7 @@ clean: clean-am
clean-am
:
clean-generic clean-libexecPROGRAMS mostlyclean-am
distclean
:
distclean-am
-
rm
-f
./
$(DEPDIR)
/AESUtils.Po
-
rm
-f
./
$(DEPDIR)
/BLSEnclave.Po
-
rm
-f
./
$(DEPDIR)
/DH_dkg.Po
-
rm
-f
./
$(DEPDIR)
/DKGUtils.Po
-
rm
-f
./
$(DEPDIR)
/alt_bn128_g1.Po
-
rm
-f
./
$(DEPDIR)
/alt_bn128_g2.Po
-
rm
-f
./
$(DEPDIR)
/alt_bn128_init.Po
-
rm
-f
./
$(DEPDIR)
/curves.Po
-
rm
-f
./
$(DEPDIR)
/domain_parameters.Po
-
rm
-f
./
$(DEPDIR)
/numbertheory.Po
-
rm
-f
./
$(DEPDIR)
/point.Po
-
rm
-f
./
$(DEPDIR)
/secure_enclave.Po
-
rm
-f
./
$(DEPDIR)
/secure_enclave_t.Po
-
rm
-f
./
$(DEPDIR)
/signature.Po
-
rm
-f
./
$(DEPDIR)
/signed_enclave_debug.Po
-
rm
-f
./
$(DEPDIR)
/signed_enclave_rel.Po
-
rm
-rf
./
$(DEPDIR)
-
rm
-f
Makefile
distclean-am
:
clean-am distclean-compile distclean-generic
\
distclean-tags
...
...
@@ -723,22 +690,7 @@ install-ps-am:
installcheck-am
:
maintainer-clean
:
maintainer-clean-am
-
rm
-f
./
$(DEPDIR)
/AESUtils.Po
-
rm
-f
./
$(DEPDIR)
/BLSEnclave.Po
-
rm
-f
./
$(DEPDIR)
/DH_dkg.Po
-
rm
-f
./
$(DEPDIR)
/DKGUtils.Po
-
rm
-f
./
$(DEPDIR)
/alt_bn128_g1.Po
-
rm
-f
./
$(DEPDIR)
/alt_bn128_g2.Po
-
rm
-f
./
$(DEPDIR)
/alt_bn128_init.Po
-
rm
-f
./
$(DEPDIR)
/curves.Po
-
rm
-f
./
$(DEPDIR)
/domain_parameters.Po
-
rm
-f
./
$(DEPDIR)
/numbertheory.Po
-
rm
-f
./
$(DEPDIR)
/point.Po
-
rm
-f
./
$(DEPDIR)
/secure_enclave.Po
-
rm
-f
./
$(DEPDIR)
/secure_enclave_t.Po
-
rm
-f
./
$(DEPDIR)
/signature.Po
-
rm
-f
./
$(DEPDIR)
/signed_enclave_debug.Po
-
rm
-f
./
$(DEPDIR)
/signed_enclave_rel.Po
-
rm
-rf
./
$(DEPDIR)
-
rm
-f
Makefile
maintainer-clean-am
:
distclean-am maintainer-clean-generic
...
...
@@ -758,19 +710,19 @@ uninstall-am: uninstall-libexecPROGRAMS
.MAKE
:
install-am install-strip
.PHONY
:
CTAGS GTAGS TAGS all all-am
am--depfiles check check-am clean
\
clean-
generic clean-libexecPROGRAMS cscopelist-am ctags
\
ctags-am distclean distclean-compile distclean-generic
\
d
istclean-tags distdir dvi dvi-am html html-am info info
-am
\
install
install-am install-data install-data-am install-dvi
\
install-
dvi-am install-exec install-exec-am install-html
\
install-
html-am install-info install-info-am
\
install-
libexecPROGRAMS install-man install-pdf install-pdf-am
\
install-ps
install-ps-am install-strip installcheck
\
install
check-am installdirs maintainer-clean
\
m
aintainer-clean-generic mostlyclean mostlyclean-compile
\
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall
\
uninstall-
am uninstall-
libexecPROGRAMS
.PHONY
:
CTAGS GTAGS TAGS all all-am
check check-am clean clean-generic
\
clean-
libexecPROGRAMS cscopelist-am ctags ctags-am distclean
\
distclean-compile distclean-generic distclean-tags distdir dvi
\
d
vi-am html html-am info info-am install install
-am
\
install
-data install-data-am install-dvi install-dvi-am
\
install-
exec install-exec-am install-html install-html-am
\
install-
info install-info-am install-libexecPROGRAMS
\
install-
man install-pdf install-pdf-am install-ps
\
install-ps
-am install-strip installcheck installcheck-am
\
install
dirs maintainer-clean maintainer-clean-generic
\
m
ostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am
\
ps ps-am tags tags-am uninstall uninstall-am
\
uninstall-libexecPROGRAMS
.PRECIOUS
:
Makefile
...
...
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