Unverified Commit b7a233bb authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #133 from skalenetwork/SKALE-3067-remove-use-check

Skale 3067 remove use check
parents 0ff442ae db6a4749
......@@ -35,6 +35,8 @@
#include "third_party/spdlog/spdlog.h"
#include "common.h"
vector<string> splitString(const char *coeffs, const char symbol) {
string str(coeffs);
string delim;
......
......@@ -29,8 +29,29 @@
#include "AESUtils.h"
int AES_encrypt(char *message, uint8_t *encr_message) {
int AES_encrypt(char *message, uint8_t *encr_message, uint64_t encrLen) {
if (!message) {
LOG_ERROR("Null message in AES_encrypt");
return -1;
}
if (!encr_message) {
LOG_ERROR("Null encr message in AES_encrypt");
return -2;
}
auto len = strlen(message);
if (len + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE > encrLen ) {
LOG_ERROR("Output buffer too small");
return -3;
}
sgx_read_rand(encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE);
auto msgLen = strlen(message);
sgx_status_t status = sgx_rijndael128GCM_encrypt(&AES_key, (uint8_t*)message, strlen(message),
encr_message + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE,
encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE,
......@@ -40,9 +61,23 @@ int AES_encrypt(char *message, uint8_t *encr_message) {
return status;
}
int AES_decrypt(uint8_t *encr_message, uint64_t length, char *message) {
int AES_decrypt(uint8_t *encr_message, uint64_t length, char *message, uint64_t msgLen) {
if (length < SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE) {
LOG_ERROR("length < SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE");
return -1;
}
uint64_t len = length - SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE;
if (msgLen < len) {
LOG_ERROR("Output buffer not large enough");
return -2;
}
sgx_status_t status = sgx_rijndael128GCM_decrypt(&AES_key,
encr_message + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE, len,
message,
......
......@@ -26,8 +26,8 @@
sgx_aes_gcm_128bit_key_t AES_key;
int AES_encrypt(char *message, uint8_t *encr_message);
int AES_encrypt(char *message, uint8_t *encr_message, uint64_t encrLen);
int AES_decrypt(uint8_t *encr_message, uint64_t length, char *message);
int AES_decrypt(uint8_t *encr_message, uint64_t length, char *message, uint64_t msgLen) ;
#endif //SGXD_AESUTILS_H
......@@ -36,6 +36,14 @@
using namespace std;
thread_local uint8_t decryptedDkgPoly[DKG_BUFER_LENGTH];
uint8_t* getThreadLocalDecryptedDkgPoly() {
return decryptedDkgPoly;
}
string *stringFromKey(libff::alt_bn128_Fr *_key) {
mpz_t t;
mpz_init(t);
......
......@@ -47,6 +47,8 @@ EXTERNC void enclave_init();
void get_global_random(unsigned char* _randBuff, uint64_t size);
EXTERNC uint8_t* getThreadLocalDecryptedDkgPoly();
EXTERNC void LOG_INFO(const char* msg);
EXTERNC void LOG_WARN(const char* _msg);
EXTERNC void LOG_ERROR(const char* _msg);
......
This diff is collapsed.
<EnclaveConfiguration>
<ProdID>0</ProdID>
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x100000</StackMaxSize>
<HeapMaxSize>0x1000000</HeapMaxSize>
<TCSNum>16</TCSNum>
<TCSMaxNum>16</TCSMaxNum>
<TCSPolicy>1</TCSPolicy>
<StackMaxSize>0x1000000</StackMaxSize>
<HeapMaxSize>0x100000000</HeapMaxSize>
<TCSNum>128</TCSNum>
<TCSMaxNum>128</TCSMaxNum>
<TCSMinPool>128</TCSMinPool>
<TCSPolicy>0</TCSPolicy>
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
......
This diff is collapsed.
......@@ -342,11 +342,12 @@ TEST_CASE_METHOD(TestFixture, "DKG AES gen test", "[dkg-aes-gen]") {
vector<char> secret(2490, 0);
vector<char> errMsg1(BUF_LEN, 0);
status = trustedDecryptDkgSecretAES(eid, &errStatus, errMsg1.data(), encryptedDKGSecret.data(),
/*status = trustedDecryptDkgSecretAES(eid, &errStatus, errMsg1.data(), encryptedDKGSecret.data(),
(uint8_t *) secret.data(), &encLen);
REQUIRE(status == SGX_SUCCESS);
REQUIRE(errStatus == SGX_SUCCESS);
*/
}
TEST_CASE_METHOD(TestFixture, "DKG public shares test", "[dkg-pub-shares]") {
......
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