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
5f5e8d9c
Unverified
Commit
5f5e8d9c
authored
Sep 09, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed problem
parent
6d82dafc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
6 deletions
+17
-6
BLSUtils.cpp
secure_enclave/BLSUtils.cpp
+9
-3
BLSUtils.h
secure_enclave/BLSUtils.h
+1
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+6
-2
testw.cpp
testw.cpp
+1
-0
No files found.
secure_enclave/BLSUtils.cpp
View file @
5f5e8d9c
...
@@ -68,10 +68,13 @@ libff::alt_bn128_Fr *keyFromString(const char* _keyString) {
...
@@ -68,10 +68,13 @@ libff::alt_bn128_Fr *keyFromString(const char* _keyString) {
return
new
libff
::
alt_bn128_Fr
(
_keyString
);
return
new
libff
::
alt_bn128_Fr
(
_keyString
);
}
}
bool
check_key
(
const
char
*
_keyString
)
{
bool
check_key
(
int
*
err_status
,
char
*
err_string
,
const
char
*
_keyString
)
{
libff
::
init_alt_bn128_params
();
libff
::
init_alt_bn128_params
();
*
err_status
=
-
1
;
if
(
_keyString
==
nullptr
)
if
(
_keyString
==
nullptr
)
return
false
;
return
false
;
...
@@ -84,8 +87,9 @@ bool check_key(const char *_keyString) {
...
@@ -84,8 +87,9 @@ bool check_key(const char *_keyString) {
auto
s1
=
stringFromKey
(
key
);
auto
s1
=
stringFromKey
(
key
);
if
(
s1
->
compare
(
ks
)
!=
0
)
if
(
s1
->
compare
(
ks
)
!=
0
)
{
return
false
;
throw
std
::
exception
();
}
if
(
s1
->
size
()
<
10
)
if
(
s1
->
size
()
<
10
)
return
false
;
return
false
;
...
@@ -93,6 +97,8 @@ bool check_key(const char *_keyString) {
...
@@ -93,6 +97,8 @@ bool check_key(const char *_keyString) {
if
(
s1
->
size
()
>=
100
)
if
(
s1
->
size
()
>=
100
)
return
false
;
return
false
;
*
err_status
=
0
;
return
true
;
return
true
;
}
}
...
...
secure_enclave/BLSUtils.h
View file @
5f5e8d9c
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#define EXTERNC
#define EXTERNC
#endif
#endif
EXTERNC
bool
check_key
(
const
char
*
_keyString
);
EXTERNC
bool
check_key
(
int
*
err_status
,
char
*
err_string
,
const
char
*
_keyString
);
EXTERNC
bool
sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
EXTERNC
bool
sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
char
*
_sig
);
char
*
_sig
);
...
...
secure_enclave/secure_enclave.c
View file @
5f5e8d9c
...
@@ -121,6 +121,7 @@ void encrypt_key(int *err_status, char *err_string, char *key,
...
@@ -121,6 +121,7 @@ void encrypt_key(int *err_status, char *err_string, char *key,
uint8_t
*
encrypted_key
,
uint32_t
*
enc_len
)
{
uint8_t
*
encrypted_key
,
uint32_t
*
enc_len
)
{
*
err_status
=
-
1
;
*
err_status
=
-
1
;
memset
(
err_string
,
0
,
BUF_LEN
);
uint64_t
keyLen
=
strnlen
(
key
,
MAX_KEY_LENGTH
);
uint64_t
keyLen
=
strnlen
(
key
,
MAX_KEY_LENGTH
);
...
@@ -144,8 +145,11 @@ void encrypt_key(int *err_status, char *err_string, char *key,
...
@@ -144,8 +145,11 @@ void encrypt_key(int *err_status, char *err_string, char *key,
*
err_status
=
-
3
;
*
err_status
=
-
3
;
if
(
!
check_key
(
key
))
{
snprintf
(
err_string
,
BUF_LEN
,
"check_key failed"
);
check_key
(
err_status
,
err_string
,
key
);
if
(
*
err_status
!=
0
)
{
snprintf
(
err_string
+
strlen
(
err_string
),
BUF_LEN
,
"check_key failed"
);
return
;
return
;
}
}
...
...
testw.cpp
View file @
5f5e8d9c
...
@@ -86,6 +86,7 @@ TEST_CASE( "BLS sign test", "[bls-sign]" ) {
...
@@ -86,6 +86,7 @@ TEST_CASE( "BLS sign test", "[bls-sign]" ) {
status
=
encrypt_key
(
eid
,
&
err_status
,
errMsg
,
keyArray
,
encryptedKey
,
&
enc_len
);
status
=
encrypt_key
(
eid
,
&
err_status
,
errMsg
,
keyArray
,
encryptedKey
,
&
enc_len
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
err_status
==
0
);
printf
(
"Encrypt key completed with status: %d %s
\n
"
,
err_status
,
errMsg
);
printf
(
"Encrypt key completed with status: %d %s
\n
"
,
err_status
,
errMsg
);
printf
(
" Encrypted key len %d
\n
"
,
enc_len
);
printf
(
" Encrypted key len %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