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
a3c8adac
Unverified
Commit
a3c8adac
authored
Sep 09, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing
parent
5f5e8d9c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
24 deletions
+39
-24
BLSUtils.cpp
secure_enclave/BLSUtils.cpp
+31
-2
secure_enclave.c
secure_enclave/secure_enclave.c
+7
-22
testw.cpp
testw.cpp
+1
-0
No files found.
secure_enclave/BLSUtils.cpp
View file @
a3c8adac
...
...
@@ -70,8 +70,33 @@ libff::alt_bn128_Fr *keyFromString(const char* _keyString) {
bool
check_key
(
int
*
err_status
,
char
*
err_string
,
const
char
*
_keyString
)
{
libff
::
init_alt_bn128_params
();
uint64_t
keyLen
=
strnlen
(
_keyString
,
MAX_KEY_LENGTH
);
// check that key is zero terminated string
if
(
keyLen
==
MAX_KEY_LENGTH
)
{
snprintf
(
err_string
,
MAX_ERR_LEN
,
"keyLen != MAX_KEY_LENGTH"
);
return
false
;
}
*
err_status
=
-
2
;
// check that key is padded with 0s
for
(
int
i
=
keyLen
;
i
<
MAX_KEY_LENGTH
;
i
++
)
{
if
(
_keyString
[
i
]
!=
0
)
{
snprintf
(
err_string
,
BUF_LEN
,
"Unpadded key"
);
return
false
;
}
}
*
err_status
=
-
1
;
...
...
@@ -107,6 +132,10 @@ bool check_key(int *err_status, char *err_string, const char *_keyString) {
bool
sign
(
const
char
*
_keyString
,
const
char
*
_hashXString
,
const
char
*
_hashYString
,
char
sig
[
BUF_LEN
])
{
libff
::
init_alt_bn128_params
();
auto
key
=
keyFromString
(
_keyString
);
libff
::
alt_bn128_Fq
hashX
(
_hashXString
);
...
...
secure_enclave/secure_enclave.c
View file @
a3c8adac
...
...
@@ -120,28 +120,10 @@ void generate_ecdsa_key(int *err_status, char *err_string,
void
encrypt_key
(
int
*
err_status
,
char
*
err_string
,
char
*
key
,
uint8_t
*
encrypted_key
,
uint32_t
*
enc_len
)
{
*
err_status
=
-
1
;
memset
(
err_string
,
0
,
BUF_LEN
);
uint64_t
keyLen
=
strnlen
(
key
,
MAX_KEY_LENGTH
);
// check that key is zero terminated string
if
(
keyLen
==
MAX_KEY_LENGTH
)
{
snprintf
(
err_string
,
MAX_ERR_LEN
,
"keyLen != MAX_KEY_LENGTH"
);
return
;
}
*
err_status
=
-
2
;
// check that key is padded with 0s
for
(
int
i
=
keyLen
;
i
<
MAX_KEY_LENGTH
;
i
++
)
{
if
(
key
[
i
]
!=
0
)
{
snprintf
(
err_string
,
BUF_LEN
,
"Unpadded key"
);
return
;
}
}
*
err_status
=
-
3
;
...
...
@@ -208,6 +190,7 @@ void encrypt_key(int *err_status, char *err_string, char *key,
void
decrypt_key
(
int
*
err_status
,
char
*
err_string
,
uint8_t
*
encrypted_key
,
uint32_t
enc_len
,
char
*
key
)
{
uint32_t
decLen
;
*
err_status
=
-
9
;
...
...
@@ -262,6 +245,8 @@ void bls_sign_message(int *err_status, char *err_string, uint8_t *encrypted_key
char
key
[
BUF_LEN
];
char
sig
[
BUF_LEN
];
decrypt_key
(
err_status
,
err_string
,
encrypted_key
,
enc_len
,
key
);
if
(
err_status
!=
0
)
{
...
...
testw.cpp
View file @
a3c8adac
...
...
@@ -88,6 +88,7 @@ TEST_CASE( "BLS sign test", "[bls-sign]" ) {
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
);
...
...
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