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
6223b8f3
Unverified
Commit
6223b8f3
authored
Sep 09, 2019
by
kladkogex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing
parent
7198aa3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
14 deletions
+32
-14
testw.cpp
testw.cpp
+32
-14
No files found.
testw.cpp
View file @
6223b8f3
...
@@ -88,6 +88,35 @@ char *encryptKey2Hex(int *errStatus, char *err_string, const char *_key) {
...
@@ -88,6 +88,35 @@ char *encryptKey2Hex(int *errStatus, char *err_string, const char *_key) {
return
result
;
return
result
;
}
}
char
*
decryptKeyFromHex
(
int
*
errStatus
,
char
*
errMsg
,
const
char
*
_encryptedKey
)
{
*
errStatus
=
-
1
;
uint64_t
decodedLen
=
0
;
uint8_t
decoded
[
BUF_LEN
];
if
(
!
(
hex2carray
(
_encryptedKey
,
&
decodedLen
,
decoded
)))
{
return
nullptr
;
}
char
*
plaintextKey
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
status
=
decrypt_key
(
eid
,
errStatus
,
errMsg
,
decoded
,
decodedLen
,
plaintextKey
);
if
(
status
!=
SGX_SUCCESS
)
{
return
nullptr
;
}
if
(
*
errStatus
!=
0
)
{
return
nullptr
;
}
return
plaintextKey
;
}
#define TEST_KEY "4160780231445160889237664391382223604184857153814275770598791864649971919844"
#define TEST_KEY "4160780231445160889237664391382223604184857153814275770598791864649971919844"
...
@@ -130,29 +159,18 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
...
@@ -130,29 +159,18 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
init_all
();
init_all
();
int
errStatus
=
-
1
;
int
errStatus
=
-
1
;
char
*
errMsg
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
char
*
errMsg
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
const
char
*
key
=
TEST_KEY
;
char
*
encryptedKey
=
encryptTestKey
();
char
*
encryptedKey
=
encryptTestKey
();
REQUIRE
(
encryptedKey
!=
nullptr
);
REQUIRE
(
encryptedKey
!=
nullptr
);
uint64_t
decodedLen
=
0
;
char
*
plaintextKey
=
decryptKeyFromHex
(
&
errStatus
,
errMsg
,
encryptedKey
)
;
uint8_t
decoded
[
BUF_LEN
];
REQUIRE
(
hex2carray
(
encryptedKey
,
&
decodedLen
,
decoded
));
char
*
plaintextKey
=
(
char
*
)
calloc
(
BUF_LEN
,
1
);
status
=
decrypt_key
(
eid
,
&
errStatus
,
errMsg
,
decoded
,
decodedLen
,
plaintextKey
);
REQUIRE
(
status
==
SGX_SUCCESS
);
REQUIRE
(
errStatus
==
0
);
REQUIRE
(
errStatus
==
0
);
REQUIRE
(
strcmp
(
plaintextKey
,
TEST_KEY
)
==
0
);
REQUIRE
(
strcmp
(
plaintextKey
,
key
)
==
0
);
printf
(
"Decrypt key completed with status: %d %s
\n
"
,
errStatus
,
errMsg
);
printf
(
"Decrypt key completed with status: %d %s
\n
"
,
errStatus
,
errMsg
);
printf
(
"Decrypted key len %d
\n
"
,
(
int
)
strlen
(
plaintextKey
));
printf
(
"Decrypted key len %d
\n
"
,
(
int
)
strlen
(
plaintextKey
));
...
...
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