Added gmp

parent 5d2f9fcc
......@@ -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;
}
......@@ -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);
};
......
......@@ -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;
}
......
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