So I'm trying to create two sha256 hashes in intel sgx using their cyrpto library. Currently, if I run the following:
sgx_sha256_hash_t *hash1;
int first = 1;
sgx_status_t = stat;
stat = sgx_sha256_msg( ( uint8_t * ) &first, 8, hash1 );
I have no problems, and I properly get hash1, however if I try
sgx_sha256_hash_t *hash1;
sgx_sha256_hash_t *hash2;
int first = 1;
int second = 2;
sgx_status_t = stat;
stat = sgx_sha256_msg( ( uint8_t * ) &first, 8, hash1 );
stat = sgx_sha256_msg( ( uint8_t * ) &second, 8, hash2 );
I get a segmentation fault. I tried doing this with the sha init, update, get_hash and close method instead, but with no imporved results, does anyone know why this might be? I was thinking I might be running out of memory in the enclave, if that's true, is there a way to expand my enclave?
You are writing your hashes to a random location in memory through those two uninitialised pointers, hence the segfaults. Also, your
src_len
parameters are incorrect, and for completeness the first parameter should beconst
.So, what you want is: