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
4a103ecf
Unverified
Commit
4a103ecf
authored
Apr 17, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2454-add-logs-to-enclave
parent
2f267c40
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
253 additions
and
258 deletions
+253
-258
BLSCrypto.cpp
BLSCrypto.cpp
+1
-2
DKGCrypto.cpp
DKGCrypto.cpp
+35
-39
ECDSACrypto.cpp
ECDSACrypto.cpp
+13
-13
BLSEnclave.cpp
secure_enclave/BLSEnclave.cpp
+4
-4
BLSEnclave.h
secure_enclave/BLSEnclave.h
+2
-2
secure_enclave.c
secure_enclave/secure_enclave.c
+139
-139
secure_enclave.edl
secure_enclave/secure_enclave.edl
+33
-33
testw.cpp
testw.cpp
+26
-26
No files found.
BLSCrypto.cpp
View file @
4a103ecf
...
...
@@ -162,7 +162,7 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
if
(
!
hex2carray
(
_hashHex
,
&
binLen
,
hash
->
data
()))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
}
// assert(binLen == hash->size());
...
...
@@ -203,7 +203,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
if
(
!
hex2carray
(
_hashHex
,
&
binLen
,
hash
->
data
()))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid hash"
);
}
// assert(binLen == hash->size());
...
...
DKGCrypto.cpp
View file @
4a103ecf
...
...
@@ -77,21 +77,21 @@ string ConvertToString(T field_elem, int base = 10) {
string
gen_dkg_poly
(
int
_t
)
{
vector
<
char
>
errMsg
(
1024
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
vector
<
uint8_t
>
encrypted_dkg_secret
(
BUF_LEN
,
0
);
uint32_t
enc_len
=
0
;
if
(
!
encryptKeys
)
status
=
trustedGenDkgSecret
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
status
=
trustedGenDkgSecret
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
else
status
=
trustedGenDkgSecret_aes
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
if
(
err
_s
tatus
!=
0
)
{
status
=
trustedGenDkgSecret_aes
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
_t
);
if
(
err
S
tatus
!=
0
)
{
throw
SGXException
(
-
666
,
errMsg
.
data
());
}
spdlog
::
debug
(
"trustedGenDkgSecret, status {}"
,
err
_s
tatus
,
" err msg "
,
errMsg
.
data
());
spdlog
::
debug
(
"trustedGenDkgSecret, status {}"
,
err
S
tatus
,
" err msg "
,
errMsg
.
data
());
spdlog
::
debug
(
"in DKGCrypto encr len is {}"
,
enc_len
);
uint64_t
length
=
DKG_MAX_SEALED_LEN
;
...
...
@@ -99,11 +99,8 @@ string gen_dkg_poly(int _t) {
length
=
enc_len
;
}
//vector<char> hexEncrPoly(DKG_MAX_SEALED_LEN * 2 + 1, 0);//(4*BUF_LEN, 1);
vector
<
char
>
hexEncrPoly
(
2
*
length
+
1
,
0
);
assert
(
encrypted_dkg_secret
.
size
()
>=
length
);
//carray2Hex(encrypted_dkg_secret.data(), DKG_MAX_SEALED_LEN, hexEncrPoly.data());
CHECK_STATE
(
encrypted_dkg_secret
.
size
()
>=
length
);
carray2Hex
(
encrypted_dkg_secret
.
data
(),
length
,
hexEncrPoly
.
data
());
string
result
(
hexEncrPoly
.
data
());
...
...
@@ -138,10 +135,12 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
uint32_t
len
=
0
;
if
(
!
encryptKeys
)
status
=
trustedGetPublicShares
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrDKGPoly
.
data
(),
len
,
pubShares
.
data
(),
t
,
n
);
status
=
trustedGetPublicShares
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrDKGPoly
.
data
(),
len
,
pubShares
.
data
(),
t
,
n
);
else
{
status
=
trustedGetPublicShares_aes
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrDKGPoly
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
status
=
trustedGetPublicShares_aes
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrDKGPoly
.
data
(),
encLen
,
pubShares
.
data
(),
t
,
n
);
}
if
(
errStatus
!=
0
)
{
throw
SGXException
(
-
666
,
errMsg1
.
data
());
...
...
@@ -164,8 +163,9 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
return
pubSharesVect
;
}
string
trustedGetSecretShares
(
const
string
&
_polyName
,
const
char
*
_encryptedPolyHex
,
const
vector
<
string
>
&
_publicKeys
,
int
_t
,
int
_n
)
{
string
trustedGetSecretShares
(
const
string
&
_polyName
,
const
char
*
_encryptedPolyHex
,
const
vector
<
string
>
&
_publicKeys
,
int
_t
,
int
_n
)
{
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
vector
<
char
>
hexEncrKey
(
BUF_LEN
,
0
);
...
...
@@ -173,14 +173,13 @@ string trustedGetSecretShares(const string &_polyName, const char *_encryptedPol
uint64_t
encLen
=
0
;
vector
<
uint8_t
>
encrDKGPoly
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encrDKGPoly
(
BUF_LEN
,
0
);
if
(
!
hex2carray2
(
_encryptedPolyHex
,
&
encLen
,
encrDKGPoly
.
data
(),
6100
))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid encryptedPolyHex"
);
}
if
(
!
encryptKeys
)
status
=
trustedSetEncryptedDkgPoly
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encrDKGPoly
.
data
());
else
...
...
@@ -194,13 +193,13 @@ string trustedGetSecretShares(const string &_polyName, const char *_encryptedPol
for
(
int
i
=
0
;
i
<
_n
;
i
++
)
{
vector
<
uint8_t
>
encryptedSkey
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encryptedSkey
(
BUF_LEN
,
0
);
uint32_t
decLen
;
vector
<
char
>
currentShare
(
193
,
0
);
vector
<
char
>
sShareG2
(
320
,
0
);
string
pub_keyB
=
_publicKeys
.
at
(
i
);
vector
<
char
>
pubKeyB
(
129
,
0
);
vector
<
char
>
pubKeyB
(
129
,
0
);
strncpy
(
pubKeyB
.
data
(),
pub_keyB
.
c_str
(),
128
);
pubKeyB
.
at
(
128
)
=
0
;
...
...
@@ -210,10 +209,10 @@ string trustedGetSecretShares(const string &_polyName, const char *_encryptedPol
if
(
!
encryptKeys
)
trustedGetEncryptedSecretShare
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedSkey
.
data
(),
&
decLen
,
currentShare
.
data
(),
sShareG2
.
data
(),
pubKeyB
.
data
(),
_t
,
_n
,
i
+
1
);
currentShare
.
data
(),
sShareG2
.
data
(),
pubKeyB
.
data
(),
_t
,
_n
,
i
+
1
);
else
trustedGetEncryptedSecretShare_aes
(
eid
,
&
errStatus
,
errMsg1
.
data
(),
encryptedSkey
.
data
(),
&
decLen
,
currentShare
.
data
(),
sShareG2
.
data
(),
pubKeyB
.
data
(),
_t
,
_n
,
i
+
1
);
currentShare
.
data
(),
sShareG2
.
data
(),
pubKeyB
.
data
(),
_t
,
_n
,
i
+
1
);
if
(
errStatus
!=
0
)
{
throw
SGXException
(
-
666
,
errMsg1
.
data
());
}
...
...
@@ -245,9 +244,8 @@ string trustedGetSecretShares(const string &_polyName, const char *_encryptedPol
bool
verifyShares
(
const
char
*
publicShares
,
const
char
*
encr_sshare
,
const
char
*
encryptedKeyHex
,
int
t
,
int
n
,
int
ind
)
{
//char* errMsg1 = (char*) calloc(1024,1);
char
errMsg1
[
BUF_LEN
];
int
err_status
=
0
;
char
errMsg
[
BUF_LEN
];
int
errStatus
=
0
;
uint64_t
decKeyLen
;
uint8_t
encr_key
[
BUF_LEN
];
...
...
@@ -265,19 +263,17 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
if
(
!
encryptKeys
)
trustedDkgVerify
(
eid
,
&
err
_status
,
errMsg1
,
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
trustedDkgVerify
(
eid
,
&
err
Status
,
errMsg
,
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
else
trustedDkgVerify_aes
(
eid
,
&
err
_status
,
errMsg1
,
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
trustedDkgVerify_aes
(
eid
,
&
err
Status
,
errMsg
,
pshares
,
encr_sshare
,
encr_key
,
decKeyLen
,
t
,
ind
,
&
result
);
if
(
result
==
2
)
{
throw
SGXException
(
INVALID_HEX
,
"Invalid public shares"
);
}
spdlog
::
debug
(
"errMsg1: {}"
,
errMsg
1
);
spdlog
::
debug
(
"errMsg1: {}"
,
errMsg
);
spdlog
::
debug
(
"result is: {}"
,
result
);
//free(errMsg1);
return
result
;
}
...
...
@@ -286,8 +282,8 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
spdlog
::
debug
(
"ENTER CreateBLSShare"
);
// char* errMsg1 = (char*) calloc(1024,1);
char
errMsg
1
[
BUF_LEN
];
int
err
_s
tatus
=
0
;
char
errMsg
[
BUF_LEN
];
int
err
S
tatus
=
0
;
uint64_t
decKeyLen
;
uint8_t
encr_bls_key
[
BUF_LEN
];
...
...
@@ -302,14 +298,14 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
if
(
!
encryptKeys
)
trustedCreateBlsKey
(
eid
,
&
err
_status
,
errMsg1
,
s_shares
,
encr_key
,
decKeyLen
,
encr_bls_key
,
&
enc_bls_len
);
trustedCreateBlsKey
(
eid
,
&
err
Status
,
errMsg
,
s_shares
,
encr_key
,
decKeyLen
,
encr_bls_key
,
&
enc_bls_len
);
else
trustedCreateBlsKey_aes
(
eid
,
&
err
_status
,
errMsg1
,
s_shares
,
encr_key
,
decKeyLen
,
encr_bls_key
,
&
enc_bls_len
);
trustedCreateBlsKey_aes
(
eid
,
&
err
Status
,
errMsg
,
s_shares
,
encr_key
,
decKeyLen
,
encr_bls_key
,
&
enc_bls_len
);
if
(
err
_s
tatus
!=
0
)
{
if
(
err
S
tatus
!=
0
)
{
spdlog
::
error
(
errMsg
1
);
spdlog
::
error
(
"status {}"
,
err
_s
tatus
);
spdlog
::
error
(
errMsg
);
spdlog
::
error
(
"status {}"
,
err
S
tatus
);
throw
SGXException
(
ERROR_IN_ENCLAVE
,
"Create BLS private key failed in enclave"
);
}
else
{
...
...
@@ -361,7 +357,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) {
string
decryptDHKey
(
const
string
&
polyName
,
int
ind
)
{
vector
<
char
>
errMsg1
(
1024
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
string
DH_key_name
=
polyName
+
"_"
+
to_string
(
ind
)
+
":"
;
shared_ptr
<
string
>
hexEncrKeyPtr
=
SGXWalletServer
::
readFromDb
(
DH_key_name
,
"DKG_DH_KEY_"
);
...
...
@@ -382,11 +378,11 @@ string decryptDHKey(const string &polyName, int ind) {
char
DHKey
[
ECDSA_SKEY_LEN
];
if
(
!
encryptKeys
)
decrypt_key
(
eid
,
&
err
_s
tatus
,
errMsg1
.
data
(),
encryptedDHKey
,
dhEncLen
,
DHKey
);
decrypt_key
(
eid
,
&
err
S
tatus
,
errMsg1
.
data
(),
encryptedDHKey
,
dhEncLen
,
DHKey
);
else
decrypt_key_aes
(
eid
,
&
err
_s
tatus
,
errMsg1
.
data
(),
encryptedDHKey
,
dhEncLen
,
DHKey
);
if
(
err
_s
tatus
!=
0
)
{
throw
SGXException
(
/*ERROR_IN_ENCLAVE*/
err
_s
tatus
,
"decrypt key failed in enclave"
);
decrypt_key_aes
(
eid
,
&
err
S
tatus
,
errMsg1
.
data
(),
encryptedDHKey
,
dhEncLen
,
DHKey
);
if
(
err
S
tatus
!=
0
)
{
throw
SGXException
(
/*ERROR_IN_ENCLAVE*/
err
S
tatus
,
"decrypt key failed in enclave"
);
}
return
DHKey
;
...
...
ECDSACrypto.cpp
View file @
4a103ecf
...
...
@@ -45,18 +45,18 @@ string concatPubKeyWith0x(char *pub_key_x, char *pub_key_y) {
std
::
vector
<
std
::
string
>
genECDSAKey
()
{
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
uint8_t
*
encr_pr_key
=
(
uint8_t
*
)
calloc
(
1024
,
1
);
char
*
pub_key_x
=
(
char
*
)
calloc
(
1024
,
1
);
char
*
pub_key_y
=
(
char
*
)
calloc
(
1024
,
1
);
uint32_t
enc_len
=
0
;
if
(
!
encryptKeys
)
status
=
trustedGenerateEcdsaKey
(
eid
,
&
err
_s
tatus
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
status
=
trustedGenerateEcdsaKey
(
eid
,
&
err
S
tatus
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
else
status
=
trustedGenerateEcdsaKey_aes
(
eid
,
&
err
_s
tatus
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
status
=
trustedGenerateEcdsaKey_aes
(
eid
,
&
err
S
tatus
,
errMsg
,
encr_pr_key
,
&
enc_len
,
pub_key_x
,
pub_key_y
);
if
(
status
!=
SGX_SUCCESS
||
err
_s
tatus
!=
0
)
{
if
(
status
!=
SGX_SUCCESS
||
err
S
tatus
!=
0
)
{
spdlog
::
error
(
"RPCException thrown with status {}"
,
status
);
throw
SGXException
(
status
,
errMsg
);
}
...
...
@@ -106,7 +106,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
vector
<
char
>
pubKeyY
(
BUF_LEN
,
0
);
vector
<
uint8_t
>
encrPrKey
(
BUF_LEN
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
uint64_t
enc_len
=
0
;
if
(
!
hex2carray
(
_encryptedKeyHex
,
&
enc_len
,
encrPrKey
.
data
()))
{
...
...
@@ -114,11 +114,11 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
}
if
(
!
encryptKeys
)
status
=
trustedGetPublicEcdsaKey
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrPrKey
.
data
(),
enc_len
,
pubKeyX
.
data
(),
status
=
trustedGetPublicEcdsaKey
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrPrKey
.
data
(),
enc_len
,
pubKeyX
.
data
(),
pubKeyY
.
data
());
else
status
=
trustedGetPublicEcdsaKey_aes
(
eid
,
&
err
_s
tatus
,
else
status
=
trustedGetPublicEcdsaKey_aes
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrPrKey
.
data
(),
enc_len
,
pubKeyX
.
data
(),
pubKeyY
.
data
());
if
(
err
_s
tatus
!=
0
)
{
if
(
err
S
tatus
!=
0
)
{
throw
SGXException
(
-
666
,
errMsg
.
data
());
}
string
pubKey
=
string
(
pubKeyX
.
data
())
+
string
(
pubKeyY
.
data
());
//concatPubKeyWith0x(pub_key_x, pub_key_y);//
...
...
@@ -127,7 +127,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
spdlog
::
debug
(
"pubkey is {}"
,
pubKey
);
spdlog
::
debug
(
"pubkey length is {}"
,
pubKey
.
length
());
spdlog
::
debug
(
"err str is {}"
,
errMsg
.
data
());
spdlog
::
debug
(
"err status is {}"
,
err
_s
tatus
);
spdlog
::
debug
(
"err status is {}"
,
err
S
tatus
);
return
pubKey
;
...
...
@@ -137,7 +137,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i
vector
<
string
>
signature_vect
(
3
);
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
char
*
signature_r
=
(
char
*
)
calloc
(
1024
,
1
);
char
*
signature_s
=
(
char
*
)
calloc
(
1024
,
1
);
uint8_t
signature_v
=
0
;
...
...
@@ -156,12 +156,12 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i
if
(
!
encryptKeys
)
status
=
trustedEcdsaSign
(
eid
,
&
err
_s
tatus
,
errMsg
,
encr_key
,
ECDSA_ENCR_LEN
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
status
=
trustedEcdsaSign
(
eid
,
&
err
S
tatus
,
errMsg
,
encr_key
,
ECDSA_ENCR_LEN
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
&
signature_v
,
base
);
else
status
=
trustedEcdsaSignAES
(
eid
,
&
err
_s
tatus
,
errMsg
,
encr_key
,
dec_len
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
status
=
trustedEcdsaSignAES
(
eid
,
&
err
S
tatus
,
errMsg
,
encr_key
,
dec_len
,
(
unsigned
char
*
)
hashHex
,
signature_r
,
signature_s
,
&
signature_v
,
base
);
if
(
err
_s
tatus
!=
0
)
{
if
(
err
S
tatus
!=
0
)
{
throw
SGXException
(
-
666
,
errMsg
);
}
...
...
secure_enclave/BLSEnclave.cpp
View file @
4a103ecf
...
...
@@ -102,7 +102,7 @@ void init() {
libff
::
init_alt_bn128_params
();
}
void
checkKey
(
int
*
err
_s
tatus
,
char
*
err_string
,
const
char
*
_keyString
)
{
void
checkKey
(
int
*
err
S
tatus
,
char
*
err_string
,
const
char
*
_keyString
)
{
uint64_t
keyLen
=
strnlen
(
_keyString
,
MAX_KEY_LENGTH
);
...
...
@@ -114,7 +114,7 @@ void checkKey(int *err_status, char *err_string, const char *_keyString) {
}
*
err
_s
tatus
=
-
2
;
*
err
S
tatus
=
-
2
;
if
(
_keyString
==
nullptr
)
{
...
...
@@ -122,7 +122,7 @@ void checkKey(int *err_status, char *err_string, const char *_keyString) {
return
;
}
*
err
_s
tatus
=
-
3
;
*
err
S
tatus
=
-
3
;
//check that key is padded with 0s
...
...
@@ -145,7 +145,7 @@ void checkKey(int *err_status, char *err_string, const char *_keyString) {
// throw std::exception();
// }
*
err
_s
tatus
=
0
;
*
err
S
tatus
=
0
;
// return;
}
...
...
secure_enclave/BLSEnclave.h
View file @
4a103ecf
...
...
@@ -34,9 +34,9 @@
//#include <stdint.h>
EXTERNC
void
checkKey
(
int
*
err
_s
tatus
,
char
*
err_string
,
const
char
*
_keyString
);
EXTERNC
void
checkKey
(
int
*
err
S
tatus
,
char
*
err_string
,
const
char
*
_keyString
);
EXTERNC
void
check_key
(
int
*
err
_s
tatus
,
char
*
err_string
,
const
char
*
_keyString
);
EXTERNC
void
check_key
(
int
*
err
S
tatus
,
char
*
err_string
,
const
char
*
_keyString
);
...
...
secure_enclave/secure_enclave.c
View file @
4a103ecf
This diff is collapsed.
Click to expand it.
secure_enclave/secure_enclave.edl
View file @
4a103ecf
This diff is collapsed.
Click to expand it.
testw.cpp
View file @
4a103ecf
...
...
@@ -182,24 +182,24 @@ TEST_CASE("DKG gen test", "[dkg-gen]") {
vector
<
uint8_t
>
encryptedDKGSecret
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
uint32_t
enc_len
=
0
;
status
=
trustedGenDkgSecret
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encryptedDKGSecret
.
data
(),
&
enc_len
,
32
);
status
=
trustedGenDkgSecret
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encryptedDKGSecret
.
data
(),
&
enc_len
,
32
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// printf("trustedGenDkgSecret completed with status: %d %s \n", err
_s
tatus, errMsg.data());
// printf("trustedGenDkgSecret completed with status: %d %s \n", err
S
tatus, errMsg.data());
// printf("\n Length: %d \n", enc_len);
vector
<
char
>
secret
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
uint32_t
dec_len
;
status
=
trustedDecryptDkgSecret
(
eid
,
&
err
_s
tatus
,
errMsg1
.
data
(),
encryptedDKGSecret
.
data
(),
status
=
trustedDecryptDkgSecret
(
eid
,
&
err
S
tatus
,
errMsg1
.
data
(),
encryptedDKGSecret
.
data
(),
(
uint8_t
*
)
secret
.
data
(),
&
dec_len
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// printf("\ntrustedDecryptDkgSecret completed with status: %d %s \n", err
_s
tatus, errMsg1.data());
// printf("\ntrustedDecryptDkgSecret completed with status: %d %s \n", err
S
tatus, errMsg1.data());
// printf("decrypted secret %s \n\n", secret.data());
// printf("secret length %d \n", (int) strlen(secret.data()));
// printf("decr length %d \n", dec_len);
...
...
@@ -272,14 +272,14 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
vector
<
uint8_t
>
encrypted_dkg_secret
(
BUF_LEN
,
0
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
uint32_t
enc_len
=
0
;
unsigned
t
=
32
,
n
=
32
;
status
=
trustedGenDkgSecret
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
n
);
status
=
trustedGenDkgSecret
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
n
);
REQUIRE
(
status
==
SGX_SUCCESS
);
//printf("gen_dkg_public completed with status: %d %s \n", err
_s
tatus, errMsg);
//printf("gen_dkg_public completed with status: %d %s \n", err
S
tatus, errMsg);
vector
<
char
>
errMsg1
(
BUF_LEN
,
0
);
...
...
@@ -287,10 +287,10 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
char
colon
=
':'
;
vector
<
char
>
public_shares
(
10000
,
0
);
status
=
trustedGetPublicShares
(
eid
,
&
err
_s
tatus
,
errMsg1
.
data
(),
status
=
trustedGetPublicShares
(
eid
,
&
err
S
tatus
,
errMsg1
.
data
(),
encrypted_dkg_secret
.
data
(),
enc_len
,
public_shares
.
data
(),
t
,
n
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// printf("\ntrustedGetPublicShares status: %d error %s \n\n", err
_s
tatus, errMsg1.data());
// printf("\ntrustedGetPublicShares status: %d error %s \n\n", err
S
tatus, errMsg1.data());
// printf(" LEN: %d \n", (int) strlen(public_shares.data()));
// printf(" result: %s \n", public_shares.data());
...
...
@@ -306,10 +306,10 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
vector
<
char
>
secret
(
BUF_LEN
,
0
);
status
=
trustedDecryptDkgSecret
(
eid
,
&
err
_s
tatus
,
errMsg1
.
data
(),
encrypted_dkg_secret
.
data
(),
status
=
trustedDecryptDkgSecret
(
eid
,
&
err
S
tatus
,
errMsg1
.
data
(),
encrypted_dkg_secret
.
data
(),
(
uint8_t
*
)
secret
.
data
(),
&
enc_len
);
REQUIRE
(
status
==
SGX_SUCCESS
);
//printf("\ntrustedDecryptDkgSecret completed with status: %d %s \n", err
_s
tatus, errMsg1.data());
//printf("\ntrustedDecryptDkgSecret completed with status: %d %s \n", err
S
tatus, errMsg1.data());
signatures
::
Dkg
dkg_obj
(
t
,
n
);
...
...
@@ -345,15 +345,15 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") {
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
result
(
BUF_LEN
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
uint32_t
enc_len
=
0
;
vector
<
uint8_t
>
encrypted_dkg_secret
(
BUF_LEN
,
0
);
status
=
trustedGenDkgSecret
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
status
=
trustedGenDkgSecret
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly generated" << endl;
status
=
trustedSetEncryptedDkgPoly
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
());
status
=
trustedSetEncryptedDkgPoly
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
());
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly set" << endl;
...
...
@@ -362,7 +362,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") {
string
pub_keyB
=
"c0152c48bf640449236036075d65898fded1e242c00acb45519ad5f788ea7cbf9a5df1559e7fc87932eee5478b1b9023de19df654395574a690843988c3ff475"
;
vector
<
char
>
s_shareG2
(
BUF_LEN
,
0
);
status
=
trustedGetEncryptedSecretShare
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrPRDHKey
.
data
(),
&
enc_len
,
result
.
data
(),
status
=
trustedGetEncryptedSecretShare
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrPRDHKey
.
data
(),
&
enc_len
,
result
.
data
(),
s_shareG2
.
data
(),
(
char
*
)
pub_keyB
.
data
(),
2
,
2
,
1
);
...
...
@@ -382,16 +382,16 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
result
(
BUF_LEN
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
uint32_t
enc_len
=
0
;
vector
<
uint8_t
>
encrypted_dkg_secret
(
BUF_LEN
,
0
);
status
=
trustedGenDkgSecret
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
status
=
trustedGenDkgSecret
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
(),
&
enc_len
,
2
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly generated" << endl;
status
=
trustedSetEncryptedDkgPoly
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
());
status
=
trustedSetEncryptedDkgPoly
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrypted_dkg_secret
.
data
());
REQUIRE
(
status
==
SGX_SUCCESS
);
// cerr << " poly set" << endl;
...
...
@@ -401,11 +401,11 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
vector
<
char
>
s_shareG2
(
BUF_LEN
,
0
);
status
=
trustedGetEncryptedSecretShare
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encrPrDHKey
.
data
(),
&
enc_len
,
result
.
data
(),
status
=
trustedGetEncryptedSecretShare
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encrPrDHKey
.
data
(),
&
enc_len
,
result
.
data
(),
s_shareG2
.
data
(),
(
char
*
)
pub_keyB
.
data
(),
2
,
2
,
1
);
REQUIRE
(
status
==
SGX_SUCCESS
);
// printf(" trustedGetEncryptedSecretShare completed with status: %d %s \n", err
_s
tatus, errMsg.data());
// printf(" trustedGetEncryptedSecretShare completed with status: %d %s \n", err
S
tatus, errMsg.data());
// cerr << "secret share is " << result.data() << endl;
...
...
@@ -421,7 +421,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
vector
<
uint8_t
>
encr_pr_key
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_y
(
BUF_LEN
,
0
);
...
...
@@ -430,7 +430,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
//printf("before %p\n", pub_key_x);
status
=
trustedGenerateEcdsaKey
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
&
enc_len
,
pub_key_x
.
data
(),
status
=
trustedGenerateEcdsaKey
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
&
enc_len
,
pub_key_x
.
data
(),
pub_key_y
.
data
());
// printf("\nerrMsg %s\n", errMsg.data());
REQUIRE
(
status
==
SGX_SUCCESS
);
...
...
@@ -444,7 +444,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
vector
<
char
>
signature_s
(
BUF_LEN
,
0
);
uint8_t
signature_v
=
0
;
status
=
trustedEcdsaSign
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
enc_len
,
(
unsigned
char
*
)
hex
.
data
(),
status
=
trustedEcdsaSign
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
enc_len
,
(
unsigned
char
*
)
hex
.
data
(),
signature_r
.
data
(),
signature_s
.
data
(),
&
signature_v
,
16
);
REQUIRE
(
status
==
SGX_SUCCESS
);
...
...
@@ -464,13 +464,13 @@ TEST_CASE("Test test", "[test]") {
initAll
(
false
,
true
);
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
int
err
_s
tatus
=
0
;
int
err
S
tatus
=
0
;
vector
<
uint8_t
>
encr_pr_key
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_x
(
BUF_LEN
,
0
);
vector
<
char
>
pub_key_y
(
BUF_LEN
,
0
);
uint32_t
enc_len
=
0
;
status
=
trustedGenerateEcdsaKey
(
eid
,
&
err
_s
tatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
&
enc_len
,
pub_key_x
.
data
(),
status
=
trustedGenerateEcdsaKey
(
eid
,
&
err
S
tatus
,
errMsg
.
data
(),
encr_pr_key
.
data
(),
&
enc_len
,
pub_key_x
.
data
(),
pub_key_y
.
data
());
REQUIRE
(
status
==
SGX_SUCCESS
);
...
...
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