Unverified Commit 64bb9335 authored by kladko's avatar kladko

SKALE-3079-cleanup

parent 6942d96f
......@@ -180,7 +180,7 @@ void trustedSetSEK(std::shared_ptr<std::string> hex_encr_SEK) {
throw SGXException(INVALID_HEX, "Invalid encrypted SEK Hex");
}
status = trustedSetSEK(eid, &err_status, errMsg.data(), encr_SEK, len );
status = trustedSetSEK(eid, &err_status, errMsg.data(), encr_SEK );
if ( status != SGX_SUCCESS ) {
cerr << "RPCException thrown" << endl;
throw SGXException(status, errMsg.data()) ;
......
......@@ -21,7 +21,7 @@
@date 2019
*/
#define GMP_WITH_SGX
#define GMP_WITH_SGX 1
#include <string.h>
#include <cstdint>
......
......@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#define SAFE_FREE(__X__) if (__X__) {free(__X__); __X__ = NULL;}
#define SAFE_DELETE(__X__) if (__X__) {delete(__X__); __X__ = NULL;}
......@@ -179,8 +180,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
mpz_set(sig->r, r);
mpz_set(sig->s, s);
clean:
point_clear(Q);
......
......@@ -181,8 +181,7 @@ void get_global_random(unsigned char *_randBuff, uint64_t _size) {
CHECK_STATE(sgx_sha256_init(&shaStateHandle) == SGX_SUCCESS);
CHECK_STATE(sgx_sha256_update(globalRandom, 32, shaStateHandle) == SGX_SUCCESS);
CHECK_STATE(sgx_sha256_get_hash(shaStateHandle, globalRandom) == SGX_SUCCESS);
CHECK_STATE(sgx_sha256_get_hash(shaStateHandle, globalRandom) == SGX_SUCCESS);
CHECK_STATE(sgx_sha256_get_hash(shaStateHandle, (sgx_sha256_hash_t *)globalRandom) == SGX_SUCCESS);
CHECK_STATE(sgx_sha256_close(shaStateHandle) == SGX_SUCCESS);
memcpy(_randBuff, globalRandom, _size);
......@@ -201,7 +200,7 @@ void trustedGenerateSEK(int *errStatus, char *errString,
SAFE_CHAR_BUF(SEK_raw, SGX_AESGCM_KEY_SIZE);;
uint32_t hex_aes_key_length = SGX_AESGCM_KEY_SIZE * 2;
carray2Hex(SEK_raw, SGX_AESGCM_KEY_SIZE, SEK_hex);
carray2Hex((uint8_t*) SEK_raw, SGX_AESGCM_KEY_SIZE, SEK_hex);
uint32_t sealedLen = sgx_calc_sealed_data_size(0, hex_aes_key_length + 1);
......@@ -220,14 +219,17 @@ void trustedGenerateSEK(int *errStatus, char *errString,
;
}
void trustedSetSEK(int *errStatus, char *errString, uint8_t *encrypted_SEK, uint64_t encr_len) {
void trustedSetSEK(int *errStatus, char *errString, uint8_t *encrypted_SEK) {
LOG_INFO(__FUNCTION__);
INIT_ERROR_STATE
CHECK_STATE(encrypted_SEK);
SAFE_CHAR_BUF(aes_key_hex, BUF_LEN);
uint32_t dec_len;
sgx_status_t status = sgx_unseal_data(
(const sgx_sealed_data_t *) encrypted_SEK, NULL, 0, aes_key_hex, &encr_len);
(const sgx_sealed_data_t *) encrypted_SEK, NULL, 0,
(uint8_t *)aes_key_hex, &dec_len);
CHECK_STATUS2("sgx unseal SEK failed with status %d");
......
......@@ -23,8 +23,7 @@ enclave {
public void trustedSetSEK(
[out] int *errStatus,
[out, count = SMALL_BUF_SIZE] char *err_string,
[in, count = SMALL_BUF_SIZE] uint8_t *encrypted_SEK,
uint64_t encr_len);
[in, count = SMALL_BUF_SIZE] uint8_t *encrypted_SEK);
public void trustedSetSEK_backup(
[out] int *errStatus,
......
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