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
d827d5e2
Unverified
Commit
d827d5e2
authored
Jan 21, 2020
by
Stan Kladko
Committed by
GitHub
Jan 21, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into SKALE-2038-sgx-auto-restart
parents
c1d4eccb
3b32f8c1
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
32 deletions
+38
-32
CSRManagerServer.cpp
CSRManagerServer.cpp
+2
-2
SGXWalletServer.cpp
SGXWalletServer.cpp
+4
-4
ServerInit.cpp
ServerInit.cpp
+10
-9
ca.config
cert/ca.config
+5
-5
create_CA
cert/create_CA
+9
-4
create_server_cert
cert/create_server_cert
+3
-3
secure_enclave.c
secure_enclave/secure_enclave.c
+3
-3
sgxwallet_common.h
sgxwallet_common.h
+2
-2
No files found.
CSRManagerServer.cpp
View file @
d827d5e2
...
@@ -60,7 +60,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){
...
@@ -60,7 +60,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){
}
}
if
(
status
==
0
)
{
if
(
status
==
0
)
{
std
::
string
csr_name
=
"cert/"
+
hash
+
".csr"
;
std
::
string
csr_name
=
"
sgx_data/
cert/"
+
hash
+
".csr"
;
std
::
ofstream
outfile
(
csr_name
);
std
::
ofstream
outfile
(
csr_name
);
outfile
<<
*
csr_ptr
<<
std
::
endl
;
outfile
<<
*
csr_ptr
<<
std
::
endl
;
outfile
.
close
();
outfile
.
close
();
...
@@ -69,7 +69,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){
...
@@ -69,7 +69,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){
throw
RPCException
(
FILE_NOT_FOUND
,
"Csr does not exist"
);
throw
RPCException
(
FILE_NOT_FOUND
,
"Csr does not exist"
);
}
}
std
::
string
signClientCert
=
"cd cert && ./create_client_cert "
+
hash
;
std
::
string
signClientCert
=
"cd
sgx_data/
cert && ./create_client_cert "
+
hash
;
if
(
system
(
signClientCert
.
c_str
())
==
0
)
{
if
(
system
(
signClientCert
.
c_str
())
==
0
)
{
spdlog
::
info
(
"CLIENT CERTIFICATE IS SUCCESSFULLY GENERATED"
);
spdlog
::
info
(
"CLIENT CERTIFICATE IS SUCCESSFULLY GENERATED"
);
...
...
SGXWalletServer.cpp
View file @
d827d5e2
...
@@ -82,8 +82,8 @@ void debug_print(){
...
@@ -82,8 +82,8 @@ void debug_print(){
int
init_https_server
(
bool
check_certs
)
{
int
init_https_server
(
bool
check_certs
)
{
std
::
string
rootCAPath
=
"cert
/rootCA.pem"
;
std
::
string
rootCAPath
=
std
::
string
(
SGXDATA_FOLDER
)
+
"cert_data
/rootCA.pem"
;
std
::
string
keyCAPath
=
"cert
/rootCA.key"
;
std
::
string
keyCAPath
=
std
::
string
(
SGXDATA_FOLDER
)
+
"cert_data
/rootCA.key"
;
if
(
access
(
rootCAPath
.
c_str
(),
F_OK
)
!=
0
||
access
(
keyCAPath
.
c_str
(),
F_OK
)
!=
0
){
if
(
access
(
rootCAPath
.
c_str
(),
F_OK
)
!=
0
||
access
(
keyCAPath
.
c_str
(),
F_OK
)
!=
0
){
spdlog
::
info
(
"YOU DO NOT HAVE ROOT CA CERTIFICATE"
);
spdlog
::
info
(
"YOU DO NOT HAVE ROOT CA CERTIFICATE"
);
...
@@ -100,8 +100,8 @@ int init_https_server(bool check_certs) {
...
@@ -100,8 +100,8 @@ int init_https_server(bool check_certs) {
}
}
}
}
std
::
string
certPath
=
"cert
/SGXServerCert.crt"
;
std
::
string
certPath
=
std
::
string
(
SGXDATA_FOLDER
)
+
"cert_data
/SGXServerCert.crt"
;
std
::
string
keyPath
=
"cert
/SGXServerCert.key"
;
std
::
string
keyPath
=
std
::
string
(
SGXDATA_FOLDER
)
+
"cert_data
/SGXServerCert.key"
;
if
(
access
(
certPath
.
c_str
(),
F_OK
)
!=
0
||
access
(
certPath
.
c_str
(),
F_OK
)
!=
0
){
if
(
access
(
certPath
.
c_str
(),
F_OK
)
!=
0
||
access
(
certPath
.
c_str
(),
F_OK
)
!=
0
){
spdlog
::
info
(
"YOU DO NOT HAVE SERVER CERTIFICATE"
);
spdlog
::
info
(
"YOU DO NOT HAVE SERVER CERTIFICATE"
);
...
...
ServerInit.cpp
View file @
d827d5e2
...
@@ -64,32 +64,33 @@ void init_daemon() {
...
@@ -64,32 +64,33 @@ void init_daemon() {
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
std
::
string
sgx_data_folder
=
SGXDATA_FOLDER
;
struct
stat
info
;
struct
stat
info
;
if
(
stat
(
"SGXData"
,
&
info
)
!=
0
){
if
(
stat
(
sgx_data_folder
.
c_str
(),
&
info
)
!=
0
){
spdlog
::
info
(
"going to create SGXData folder"
);
spdlog
::
info
(
"going to create sgx_data folder"
);
if
(
system
(
"mkdir SGXData"
)
==
0
){
std
::
string
make_sgx_data_folder
=
"mkdir "
+
sgx_data_folder
;
spdlog
::
info
(
"SGXData folder was created"
);
if
(
system
(
make_sgx_data_folder
.
c_str
())
==
0
){
spdlog
::
info
(
"sgx_data folder was created"
);
}
}
else
{
else
{
spdlog
::
info
(
"creating
SGXD
ata folder failed"
);
spdlog
::
info
(
"creating
sgx_d
ata folder failed"
);
exit
(
-
1
);
exit
(
-
1
);
}
}
}
}
static
std
::
string
dbName
(
"./"
WALLETDB_NAME
)
;
static
std
::
string
dbName
=
sgx_data_folder
+
WALLETDB_NAME
;
levelDb
=
new
LevelDB
(
dbName
);
levelDb
=
new
LevelDB
(
dbName
);
static
std
::
string
csr_dbname
=
"SGXData/
CSR_DB"
;
static
std
::
string
csr_dbname
=
sgx_data_folder
+
"
CSR_DB"
;
csrDb
=
new
LevelDB
(
csr_dbname
);
csrDb
=
new
LevelDB
(
csr_dbname
);
static
std
::
string
csr_status_dbname
=
"SGXData/
CSR_STATUS_DB"
;
static
std
::
string
csr_status_dbname
=
sgx_data_folder
+
"
CSR_STATUS_DB"
;
csrStatusDb
=
new
LevelDB
(
csr_status_dbname
);
csrStatusDb
=
new
LevelDB
(
csr_status_dbname
);
std
::
shared_ptr
<
std
::
string
>
encr_SEK_ptr
=
levelDb
->
readString
(
"SEK"
);
std
::
shared_ptr
<
std
::
string
>
encr_SEK_ptr
=
levelDb
->
readString
(
"SEK"
);
if
(
encr_SEK_ptr
==
nullptr
){
if
(
encr_SEK_ptr
==
nullptr
){
spdlog
::
info
(
"SEK was not created yet"
);
spdlog
::
info
(
"SEK was not created yet"
);
}
}
}
}
...
...
cert/ca.config
View file @
d827d5e2
...
@@ -5,16 +5,16 @@
...
@@ -5,16 +5,16 @@
[
CA_CLIENT
]
[
CA_CLIENT
]
dir
= .
# Каталог для служебных файлов
dir
= .
# Каталог для служебных файлов
certs
= $
dir
/
certs
# Каталог для сертификатов
certs
= $
dir
/
certs
# Каталог для сертификатов
new_certs_dir
=
$
dir
/
new_certs
# Каталог для новых сертификатов
new_certs_dir
=
../
sgx_data
/
cert_data
/
new_certs
# Каталог для новых сертификатов
database
=
$
dir
/
index
.
txt
# Файл с базой данных
database
=
../
sgx_data
/
cert_data
/
index
.
txt
# Файл с базой данных
# подписанных сертификатов
# подписанных сертификатов
serial
=
$
dir
/
serial
# Файл содержащий серийный номер
serial
=
../
sgx_data
/
cert_data
/
serial
# Файл содержащий серийный номер
RANDFILE
= $
dir
/.
rnd
RANDFILE
= $
dir
/.
rnd
# сертификата
# сертификата
# (в шестнадцатиричном формате)
# (в шестнадцатиричном формате)
certificate
= ./
rootCA
.
pem
# Файл сертификата CA
certificate
= .
./
sgx_data
/
cert_data
/
rootCA
.
pem
# Файл сертификата CA
private_key
= ./
rootCA
.
key
# Файл закрытого ключа CA
private_key
= .
./
sgx_data
/
cert_data
/
rootCA
.
key
# Файл закрытого ключа CA
default_days
=
3650
# Срок действия подписываемого
default_days
=
3650
# Срок действия подписываемого
# сертификата
# сертификата
...
...
cert/create_CA
View file @
d827d5e2
#!/bin/bash
#!/bin/bash
cd
../sgx_data
mkdir
cert_data
cd
cert_data
mkdir
new_certs
touch
index.txt
touch
index.txt.attr
echo
"01"
>
serial
# Generate root CA key
# Generate root CA key
openssl genrsa
-out
rootCA.key 2048
openssl genrsa
-out
rootCA.key 2048
# Create an X.509 cert from the CA key
# Create an X.509 cert from the CA key
openssl req
-x509
-sha256
-nodes
-days
1024
-newkey
rsa:2048
-key
rootCA.key
-out
rootCA.pem
-subj
"/CN=SGXCACertificate"
openssl req
-x509
-sha256
-nodes
-days
1024
-newkey
rsa:2048
-key
rootCA.key
-out
rootCA.pem
-subj
"/CN=SGXCACertificate"
mkdir
new_certs
touch
index.txt
touch
index.txt.attr
echo
"01"
>
serial
cert/create_server_cert
View file @
d827d5e2
#!/bin/bash
#!/bin/bash
# Generate server key
# Generate server key
openssl genrsa
-out
"SGXServerCert.key"
2048
openssl genrsa
-out
../sgx_data/cert_data/SGXServerCert.key
2048
# Create server certificate request
# Create server certificate request
#openssl req -new -key "SGXServer.key" -out "SGXServer.csr" -subj "/CN=SGXCACertificate"
#openssl req -new -key "SGXServer.key" -out "SGXServer.csr" -subj "/CN=SGXCACertificate"
openssl req
-new
-sha256
-nodes
-out
"SGXServerCert.csr"
-newkey
rsa:2048
-keyout
"SGXServerCert.key"
-subj
/CN
=
SGXServer
openssl req
-new
-sha256
-nodes
-out
../sgx_data/cert_data/SGXServerCert.csr
-newkey
rsa:2048
-keyout
../sgx_data/cert_data/SGXServerCert.key
-subj
/CN
=
SGXServer
# Sign and generate the user certificate from the
# Sign and generate the user certificate from the
#openssl x509 -req -in "SGXServer.csr" -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out "SGXServerCertificate.crt" -days 3650
#openssl x509 -req -in "SGXServer.csr" -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out "SGXServerCertificate.crt" -days 3650
yes
| openssl ca
-config
ca.config
-in
"SGXServerCert.csr"
-out
"SGXServerCert.crt"
yes
| openssl ca
-config
ca.config
-in
../sgx_data/cert_data/SGXServerCert.csr
-out
../sgx_data/cert_data/SGXServerCert.crt
secure_enclave/secure_enclave.c
View file @
d827d5e2
...
@@ -53,7 +53,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...
@@ -53,7 +53,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sgxwallet_common.h"
#include "../sgxwallet_common.h"
uint8_t
Decrypted_dkg_poly
[
DKG_BUFER_LENGTH
]
;
uint8_t
Decrypted_dkg_poly
[
DKG_BUFER_LENGTH
];
uint8_t
SEK
[
32
];
void
*
(
*
gmp_realloc_func
)(
void
*
,
size_t
,
size_t
);
void
*
(
*
gmp_realloc_func
)(
void
*
,
size_t
,
size_t
);
...
@@ -587,7 +588,6 @@ void get_public_shares(int *err_status, char* err_string, uint8_t* encrypted_dkg
...
@@ -587,7 +588,6 @@ void get_public_shares(int *err_status, char* err_string, uint8_t* encrypted_dkg
}
}
void
set_encrypted_dkg_poly
(
int
*
err_status
,
char
*
err_string
,
uint8_t
*
encrypted_poly
){
void
set_encrypted_dkg_poly
(
int
*
err_status
,
char
*
err_string
,
uint8_t
*
encrypted_poly
){
uint32_t
decr_len
;
uint32_t
decr_len
;
...
...
sgxwallet_common.h
View file @
d827d5e2
...
@@ -92,9 +92,9 @@ extern int is_sgx_https;
...
@@ -92,9 +92,9 @@ extern int is_sgx_https;
#define BASE_PORT 1026
#define BASE_PORT 1026
#define WALLETDB_NAME "
SGXData/
sgxwallet.db"//"test_sgxwallet.db"//
#define WALLETDB_NAME "sgxwallet.db"//"test_sgxwallet.db"//
#define ENCLAVE_NAME "secure_enclave.signed.so"
#define ENCLAVE_NAME "secure_enclave.signed.so"
#define SGXDATA_FOLDER "sgx_data/"
...
...
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