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