Added gmp

parent d61b83b3
......@@ -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
......
......@@ -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) {
......
......@@ -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]);
};
......
......@@ -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 test_mpz_add: 0x%04x\n", status);
fprintf(stderr, "ECALL tgmp_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 encrypt_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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment