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
a24a27f4
Unverified
Commit
a24a27f4
authored
Sep 09, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing tests
parent
df5efe3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
35 deletions
+91
-35
CMakeLists.txt
CMakeLists.txt
+2
-1
testw.cpp
testw.cpp
+89
-34
No files found.
CMakeLists.txt
View file @
a24a27f4
...
...
@@ -114,5 +114,6 @@ add_custom_target(sgxd COMMAND make all
sgx_stub.c
sgx_stub.h
sgx_tgmp.h
sgxd.c
sgxwallet.c
testw.cpp
)
testw.cpp
View file @
a24a27f4
...
...
@@ -46,11 +46,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#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
);
fprintf
(
stderr
,
"usage: sgxwallet
\n
"
);
exit
(
1
);
}
sgx_launch_token_t
token
=
{
0
};
...
...
@@ -59,74 +60,128 @@ sgx_status_t status;
int
updated
;
TEST_CASE
(
"BLS key encrypt/decrypt"
,
"[bls-key-encrypt-decrypt]"
)
{
{
TEST_CASE
(
"BLS sign test"
,
"[bls-sign]"
)
{
init_all
();
init_all
();
const
char
*
key
=
"4160780231445160889237664391382223604184857153814275770598"
"791864649971919844"
;
const
char
*
key
=
"4160780231445160889237664391382223604184857153814275770598"
"791864649971919844"
;
char
*
keyArray
=
(
char
*
)
calloc
(
128
,
1
);
const
char
*
hexHash
=
"001122334455667788"
"001122334455667788"
"001122334455667788"
"001122334455667788"
;
uint8_t
*
encryptedKey
=
(
uint8_t
*
)
calloc
(
1024
,
1
)
;
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
);
char
*
keyArray
=
(
char
*
)
calloc
(
128
,
1
);
strncpy
((
char
*
)
keyArray
,
(
char
*
)
key
,
128
);
uint8_t
*
encryptedKey
=
(
uint8_t
*
)
calloc
(
1024
,
1
)
;
int
err_status
=
0
;
char
*
errMsg
=
(
char
*
)
calloc
(
1024
,
1
)
;
unsigned
int
enc_len
=
0
;
strncpy
((
char
*
)
keyArray
,
(
char
*
)
key
,
128
);
status
=
encrypt_key
(
eid
,
&
err_status
,
errMsg
,
keyArray
,
encryptedKey
,
&
enc_len
);
int
err_status
=
0
;
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
err_status
==
0
);
unsigned
int
enc_len
=
0
;
status
=
encrypt_key
(
eid
,
&
err_status
,
errMsg
,
keyArray
,
encryptedKey
,
&
enc_len
);
printf
(
"Encrypt key completed with status: %d %s
\n
"
,
err_status
,
errMsg
);
printf
(
" Encrypted key len %d
\n
"
,
enc_len
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
err_status
==
0
);
char
result
[
2
*
BUF_LEN
];
printf
(
"Encrypt key completed with status: %d %s
\n
"
,
err_status
,
errMsg
);
printf
(
" Encrypted key len %d
\n
"
,
enc_len
);
carray2Hex
(
encryptedKey
,
enc_len
,
result
);
uint64_t
dec_len
=
0
;
uint8_t
bin
[
BUF_LEN
];
char
result
[
2
*
BUF_LEN
]
;
REQUIRE
(
hex2carray
(
result
,
&
dec_len
,
bin
))
;
carray2Hex
(
encryptedKey
,
enc_len
,
result
);
for
(
uint64_t
i
=
0
;
i
<
dec_len
;
i
++
)
{
REQUIRE
(
bin
[
i
]
==
encryptedKey
[
i
]);
}
uint64_t
dec_len
=
0
;
REQUIRE
(
dec_len
==
enc_len
)
;
uint8_t
bin
[
BUF_LEN
]
;
gmp_printf
(
"Result: %s"
,
result
)
;
REQUIRE
(
hex2carray
(
result
,
&
dec_len
,
bin
)
);
gmp_printf
(
"
\n
Length: %d
\n
"
,
enc_len
);
for
(
uint64_t
i
=
0
;
i
<
dec_len
;
i
++
)
{
REQUIRE
(
bin
[
i
]
==
encryptedKey
[
i
]);
}
}
}
REQUIRE
(
dec_len
==
enc_len
);
gmp_printf
(
"Result: %s"
,
result
);
TEST_CASE
(
"BLS sign test"
,
"[bls-sign]"
)
{
gmp_printf
(
"
\n
Length: %d
\n
"
,
enc_len
);
init_all
(
);
const
char
*
key
=
"4160780231445160889237664391382223604184857153814275770598"
"791864649971919844"
;
char
sig
[
BUF_LEN
];
REQUIRE
(
sign
(
result
,
hexHash
,
2
,
2
,
1
,
sig
))
;
const
char
*
hexHash
=
"001122334455667788"
"001122334455667788"
"001122334455667788"
"001122334455667788"
;
}
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
);
REQUIRE
(
err_status
==
0
);
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
);
char
sig
[
BUF_LEN
];
REQUIRE
(
sign
(
result
,
hexHash
,
2
,
2
,
1
,
sig
));
}
TEST_CASE
(
"DKG gen test"
,
"[dkg-gen]"
)
{
TEST_CASE
(
"DKG gen test"
,
"[dkg-gen]"
)
{
init_all
();
// put your test here
// put your test here
}
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