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
a437b0a9
Unverified
Commit
a437b0a9
authored
Aug 27, 2019
by
a72d9e2bad9edfd58d6c0248c12c953b71d409d2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added gmp
parent
d61b83b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
22 deletions
+19
-22
Makefile
Makefile
+1
-1
secure_enclave.c
secure_enclave/secure_enclave.c
+4
-16
secure_enclave.edl
secure_enclave/secure_enclave.edl
+4
-1
sgxd.c
sgxd.c
+10
-4
No files found.
Makefile
View file @
a437b0a9
...
...
@@ -233,7 +233,7 @@ AMTAR = $${TAR-tar}
AM_DEFAULT_VERBOSITY
=
1
AUTOCONF
=
${
SHELL
}
/d/sgxd/missing autoconf
AUTOHEADER
=
${
SHELL
}
/d/sgxd/missing autoheader
AUTOMAKE
=
${
SHELL
}
/d/sgxd/missing automake-1.15
AUTOMAKE
=
AWK
=
gawk
CC
=
gcc
CCDEPMODE
=
depmode
=
gcc3
...
...
secure_enclave/secure_enclave.c
View file @
a437b0a9
...
...
@@ -174,28 +174,16 @@ void e_mpf_div(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un) {
mpz_t
c3
,
c4
,
c5
;
int
pi_init
=
0
;
void
encrypt_key
(
mpf_t
*
pi_un
,
uint64_t
digits
,
char
key
[
100
])
{
void
encrypt_key
(
mpf_t
*
pi_un
,
int
*
err_status
,
char
key
[
100
])
{
*
err_status
=
-
1
;
if
(
strnlen
(
key
)
==
100
)
return
;
import_key
(
key
);
mpf_t
pi
;
/*
* Perform our operations on a variable that's located in the enclave,
* then marshal the final value out of the enclave.
*/
mpf_init
(
pi
);
e_calc_pi
(
&
pi
,
digits
);
/* Marshal our result to untrusted memory */
mpf_set_prec
(
*
pi_un
,
mpf_get_prec
(
pi
));
mpf_set
(
*
pi_un
,
pi
);
*
err_status
=
0
;
}
void
e_calc_pi
(
mpf_t
*
pi
,
uint64_t
digits
)
{
...
...
secure_enclave/secure_enclave.edl
View file @
a437b0a9
...
...
@@ -21,7 +21,10 @@ enclave {
[user_check] mpf_t *c, [user_check] mpf_t *a, [user_check] mpf_t *b
);
public void encrypt_key ([user_check] mpf_t *pi, uint64_t digits, [in] char key[100]);
public void encrypt_key (
[user_check] mpf_t *pi,
[user_check] int *err_status,
[in] char key[100]);
};
...
...
sgxd.c
View file @
a437b0a9
...
...
@@ -89,6 +89,8 @@ int main (int argc, char *argv[])
status
=
sgx_create_enclave_search
(
ENCLAVE_NAME
,
SGX_DEBUG_FLAG
,
&
token
,
&
updated
,
&
eid
,
0
);
if
(
status
!=
SGX_SUCCESS
)
{
if
(
status
==
SGX_ERROR_ENCLAVE_FILE_ACCESS
)
{
fprintf
(
stderr
,
"sgx_create_enclave: %s: file not found
\n
"
,
...
...
@@ -104,7 +106,7 @@ int main (int argc, char *argv[])
status
=
tgmp_init
(
eid
);
if
(
status
!=
SGX_SUCCESS
)
{
fprintf
(
stderr
,
"ECALL t
est_mpz_add
: 0x%04x
\n
"
,
status
);
fprintf
(
stderr
,
"ECALL t
gmp_init
: 0x%04x
\n
"
,
status
);
return
1
;
}
...
...
@@ -119,14 +121,18 @@ int main (int argc, char *argv[])
strncpy
(
keyArray
,
key
,
100
);
int
err_status
=
-
2
;
status
=
encrypt_key
(
eid
,
&
pi
,
&
err_status
,
keyArray
);
status
=
encrypt_key
(
eid
,
&
pi
,
digits
,
keyArray
);
if
(
status
!=
SGX_SUCCESS
)
{
fprintf
(
stderr
,
"ECALL e
_pi
: 0x%04x
\n
"
,
status
);
fprintf
(
stderr
,
"ECALL e
ncrypt_key
: 0x%04x
\n
"
,
status
);
return
1
;
}
gmp_printf
(
"pi : %.*Ff
\n
"
,
digits
,
pi
);
gmp_printf
(
"Encrypt key completed with status: %d
\n
"
,
err_status
);
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