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
ba3c11cc
Unverified
Commit
ba3c11cc
authored
Aug 27, 2019
by
a72d9e2bad9edfd58d6c0248c12c953b71d409d2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added gmp
parent
5d2f9fcc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
secure_enclave.c
secure_enclave/secure_enclave.c
+3
-1
secure_enclave.edl
secure_enclave/secure_enclave.edl
+2
-2
sgxd.c
sgxd.c
+13
-4
No files found.
secure_enclave/secure_enclave.c
View file @
ba3c11cc
...
...
@@ -111,7 +111,7 @@ void e_mpf_div(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un) {
void
encrypt_key
(
int
*
err_status
,
char
*
key
,
char
*
encrypted_key
)
{
void
encrypt_key
(
int
*
err_status
,
unsigned
char
*
key
,
unsigned
char
*
encrypted_key
,
uint32_t
*
enc_len
)
{
*
err_status
=
-
1
;
...
...
@@ -135,6 +135,8 @@ void encrypt_key(int *err_status, char* key, char* encrypted_key) {
if
(
sgx_seal_data
(
0
,
NULL
,
strlen
(
key
)
+
1
,
key
,
sealedLen
,
encrypted_key
)
!=
SGX_SUCCESS
)
return
;
*
enc_len
=
sealedLen
;
*
err_status
=
0
;
}
secure_enclave/secure_enclave.edl
View file @
ba3c11cc
...
...
@@ -23,8 +23,8 @@ enclave {
public void encrypt_key (
[user_check] int *err_status,
[in, count = 128] char* key,
[out, count = 1024]
char* encrypted_key
);
[in, count = 128]
unsigned
char* key,
[out, count = 1024]
unsigned char* encrypted_key, [user_check] uint32_t *enc_len
);
};
...
...
sgxd.c
View file @
ba3c11cc
...
...
@@ -119,16 +119,19 @@ int main (int argc, char *argv[])
char
keyArray
[
128
];
char
encryptedKey
[
1024
];
unsigned
char
encryptedKey
[
1024
];
strncpy
(
keyArray
,
key
,
128
);
int
err_status
=
-
2
;
status
=
encrypt_key
(
eid
,
&
err_status
,
keyArray
,
encryptedKey
)
;
int
enc_len
=
-
1
;
if
(
status
!=
SGX_SUCCESS
)
{
status
=
encrypt_key
(
eid
,
&
err_status
,
keyArray
,
encryptedKey
,
&
enc_len
);
if
(
status
!=
SGX_SUCCESS
||
enc_len
<
10
)
{
fprintf
(
stderr
,
"ECALL encrypt_key: 0x%04x
\n
"
,
status
);
return
1
;
}
...
...
@@ -136,7 +139,13 @@ int main (int argc, char *argv[])
gmp_printf
(
"Encrypt key completed with status: %d
\n
"
,
err_status
);
gmp_printf
(
"Result: %s
\n
"
,
encryptedKey
);
gmp_printf
(
"Result:"
);
for
(
int
i
=
0
;
i
<
enc_len
;
i
++
)
{
gmp_printf
(
"%d"
,
encryptedKey
[
i
]);
}
gmp_printf
(
"
\n
Length: %d
\n
"
,
enc_len
);
return
0
;
}
...
...
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