Fixed warnings

parent 497d403d
......@@ -3,6 +3,9 @@
//
#define GMP_WITH_SGX
#define MAX_SIG_LEN 1024
#include "BLSUtils.h"
#include "libff/algebra/curves/alt_bn128/alt_bn128_init.hpp"
#include "libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp"
......@@ -109,6 +112,15 @@ char* sign(const char *_keyString, const char* _hashXString, const char* _hashYS
libff::alt_bn128_G1 sign = key->as_bigint() * hash; // sign
return nullptr;
auto r = stringFromG1(&sign);
char* result = (char*) calloc(r->size() + 1, 1);
strncpy(result, r->c_str(), MAX_SIG_LEN);
delete r;
return result;
}
......@@ -63,7 +63,7 @@ ENCLAVE_KEY=$(ENCLAVE)_private.pem
## Additional Automake flags needed to build the enclave.
##
AM_CPPFLAGS += -Wall $(TGMP_CPPFLAGS) -I../trusted_libff -I../sgx-sdk-build/sgxsdk/include/libcxx \
AM_CPPFLAGS += -Wall -Wno-implicit-function-declaration $(TGMP_CPPFLAGS) -I../trusted_libff -I../sgx-sdk-build/sgxsdk/include/libcxx \
-I../intel-sgx-ssl/Linux/package/include
AM_CXXFLAGS += -fno-builtin
......
......@@ -65,7 +65,6 @@ void (*oc_free_func)(void *, size_t);
void *reallocate_function(void *, size_t, size_t);
void free_function(void *, size_t);
void e_calc_pi(mpf_t *pi, uint64_t digits);
void tgmp_init() {
oc_realloc_func = &reallocate_function;
......@@ -121,8 +120,8 @@ void e_mpf_div(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un) {}
void encrypt_key(int *err_status, unsigned char *err_string, unsigned char *key,
unsigned char *encrypted_key, uint32_t *enc_len) {
void encrypt_key(int *err_status, char *err_string, char *key,
uint8_t *encrypted_key, uint32_t *enc_len) {
*err_status = -1;
......@@ -166,7 +165,7 @@ void encrypt_key(int *err_status, unsigned char *err_string, unsigned char *key,
memset(encrypted_key, 0, MAX_ENCRYPTED_KEY_LENGTH);
if (sgx_seal_data(0, NULL, MAX_KEY_LENGTH, key, sealedLen, encrypted_key) !=
if (sgx_seal_data(0, NULL, MAX_KEY_LENGTH, (uint8_t*) key, sealedLen, (sgx_sealed_data_t*) encrypted_key) !=
SGX_SUCCESS) {
snprintf(err_string, MAX_ERR_LEN,"SGX seal data failed");
return;
......@@ -205,15 +204,15 @@ void encrypt_key(int *err_status, unsigned char *err_string, unsigned char *key,
*err_status = 0;
}
void decrypt_key(int *err_status, unsigned char *err_string, unsigned char *encrypted_key,
uint32_t enc_len, unsigned char *key) {
void decrypt_key(int *err_status, char *err_string, uint8_t *encrypted_key,
uint32_t enc_len, char* key) {
uint32_t decLen;
*err_status = -9;
sgx_status_t status = sgx_unseal_data(
(const sgx_sealed_data_t *)encrypted_key, NULL, 0, key, &decLen);
(const sgx_sealed_data_t *)encrypted_key, NULL, 0, (uint8_t*) key, &decLen);
if (status != SGX_SUCCESS) {
snprintf(err_string, MAX_ERR_LEN,"sgx_unseal_data failed with status %d", status);
......@@ -254,14 +253,12 @@ void decrypt_key(int *err_status, unsigned char *err_string, unsigned char *encr
void sign_message(int *err_status, unsigned char *err_string, unsigned char *encrypted_key,
uint32_t enc_len, unsigned char *message,
unsigned char *signature) {
void sign_message(int *err_status, char *err_string, uint8_t *encrypted_key,
uint32_t enc_len, uint8_t *message, char *signature) {
*err_status = -1;
uint8_t key[MAX_KEY_LENGTH];
char key[MAX_KEY_LENGTH];
decrypt_key(err_status, err_string, encrypted_key, enc_len, key);
......@@ -269,13 +266,9 @@ void sign_message(int *err_status, unsigned char *err_string, unsigned char *en
return;
}
char* ecdsaSig = sign(key, "", "", "");
if (ecdsaSig == NULL) {
return;
}
strncpy(signature, ecdsaSig, MAX_SIG_LEN);
//strncpy(signature, ecdsaSig, MAX_SIG_LEN);
......
......@@ -23,24 +23,24 @@ enclave {
public void encrypt_key (
[user_check] int *err_status,
[out, count = 1024] unsigned char* err_string,
[in, count = 128] unsigned char* key,
[out, count = 1024] unsigned char* encrypted_key, [user_check] uint32_t *enc_len);
[out, count = 1024] char* err_string,
[in, count = 128] char* key,
[out, count = 1024] uint8_t* encrypted_key, [user_check] uint32_t *enc_len);
public void decrypt_key (
[user_check] int *err_status,
[out, count = 1024] unsigned char* err_string,
[in, count = 1024] unsigned char* encrypted_key,
[out, count = 1024] char* err_string,
[in, count = 1024] uint8_t* encrypted_key,
uint32_t enc_len,
[out, count = 128] unsigned char* key );
[out, count = 128] char* key );
public void sign_message (
[user_check] int *err_status,
[out, count = 1024] unsigned char* err_string,
[out, count = 1024] char* err_string,
[in, count = 1024] unsigned char* encrypted_key,
uint32_t enc_len,
[in, count = 1024] unsigned char* message,
[out, count = 1024] unsigned char* signature);
[in, count = 16] uint8_t* hash,
[out, count = 1024] char* signature);
......
......@@ -176,11 +176,11 @@ int main(int argc, char *argv[]) {
const char *key = "4160780231445160889237664391382223604184857153814275770598"
"791864649971919844";
unsigned char* keyArray = calloc(128, 1);
char* keyArray = calloc(128, 1);
unsigned char* encryptedKey = calloc(1024, 1);
uint8_t* encryptedKey = calloc(1024, 1);
unsigned char* errMsg = calloc(1024,1);
char* errMsg = calloc(1024,1);
strncpy((char *)keyArray, (char*)key, 128);
......
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