SKALE-2794 clean up code

parent fc1458a2
......@@ -119,7 +119,7 @@ bool hex2carray(const char *_hex, uint64_t *_bin_len,
bool hex2carray2(const char *_hex, uint64_t *_bin_len,
uint8_t *_bin, const int _max_length) {
int len = strnlen(_hex, _max_length);//2 * BUF_LEN);
int len = strnlen(_hex, _max_length);
if (len == 0 && len % 2 == 1)
......@@ -161,13 +161,6 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
strncpy(_sig, sigShareStr->c_str(), BUF_LEN);
//string sigShareStr = keyShare->signWithHelperSGXstr(hash, _signerIndex);
//strncpy(_sig, sigShareStr.c_str(), BUF_LEN);
// string test_sig = "8175162913343900215959836578795929492705714455632345516427532159927644835012:15265825550804683171644566522808807137117748565649051208189914766494241035855:9810286616503120081238481858289626967170509983220853777870754480048381194141:5";
// auto sig_ptr = make_shared<string>(test_sig);
// strncpy(_sig, sig_ptr->c_str(), BUF_LEN);
return true;
}
......@@ -269,44 +262,18 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
spdlog::debug("errStatus is {}", *errStatus);
spdlog::debug(" errMsg is ", errMsg->data());
if (*errStatus != 0) {
throw SGXException(-666, errMsg->data());
}
if (status != SGX_SUCCESS) {
*errStatus = -1;
return nullptr;
}
if (*errStatus != 0) {
throw SGXException(-666, errMsg->data());
}
char *result = (char *) calloc(2 * BUF_LEN, 1);
carray2Hex(encryptedKey->data(), encryptedLen, result);
return result;
}
char *decryptBLSKeyShareFromHex(int *errStatus, char *errMsg, const char *_encryptedKey) {
*errStatus = -1;
uint64_t decodedLen = 0;
uint8_t decoded[BUF_LEN];
if (!(hex2carray(_encryptedKey, &decodedLen, decoded))) {
return nullptr;
}
char *plaintextKey = (char *) calloc(BUF_LEN, 1);
status = trustedDecryptKeyAES(eid, errStatus, errMsg, decoded, decodedLen, plaintextKey);
if (status != SGX_SUCCESS) {
return nullptr;
}
if (*errStatus != 0) {
return nullptr;
}
return plaintextKey;
}
......@@ -48,6 +48,4 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
char * encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key);
char *decryptBLSKeyShareFromHex(int *errStatus, char *errMsg, const char *_encryptedKey);
#endif //SGXWALLET_BLSCRYPTO_H
......@@ -29,13 +29,11 @@
#include "BLSPrivateKeyShare.h"
class BLSPrivateKeyShareSGX {
size_t requiredSigners;
size_t totalSigners;
std::shared_ptr<std::string> encryptedKeyHex;
public:
std::shared_ptr<BLSSigShare>
signWithHelperSGX(std::shared_ptr<std::array<uint8_t, 32>> _hash,
......@@ -47,8 +45,6 @@ public:
BLSPrivateKeyShareSGX(std::shared_ptr<std::string> _encryptedKeyHex,
size_t _requiredSigners, size_t _totalSigners);
};
#endif // LIBBLS_BLSPRIVATEKEYSHARE_H
......@@ -21,29 +21,21 @@
@date 2019
*/
#include <iostream>
#include <fstream>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include "CSRManagerServer.h"
#include "SGXException.h"
#include "sgxwallet_common.h"
#include "Log.h"
#include "common.h"
shared_ptr<CSRManagerServer> CSRManagerServer::cs = nullptr;
shared_ptr<jsonrpc::HttpServer> CSRManagerServer::hs3 = nullptr;
CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
serverVersion_t type) : abstractCSRManagerServer(connector, type) {}
......@@ -113,7 +105,6 @@ Json::Value signByHashImpl(const string &hash, int status) {
return result;
}
Json::Value CSRManagerServer::getUnsignedCSRs() {
LOCK(m)
return getUnsignedCSRsImpl();
......
......@@ -47,9 +47,6 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex);
vector<string> mult_G2(const string& x);
bool TestCreateBLSShare( const char * s_shares);
#endif //SGXD_DKGCRYPTO_H
......@@ -24,14 +24,11 @@
#ifndef SGXD_SEKMANAGER_H
#define SGXD_SEKMANAGER_H
#ifdef __cplusplus
#include <string>
#include <memory>
#endif
void gen_SEK();
#ifdef __cplusplus
......@@ -48,5 +45,4 @@ EXTERNC void enter_SEK();
EXTERNC void initSEK();
#endif //SGXD_SEKMANAGER_H
......@@ -24,7 +24,6 @@
#ifndef SGXD_DRIVE_KEY_DKG_H
#define SGXD_DRIVE_KEY_DKG_H
//void gen_session_keys(mpz_t skey, char* pub_key);
void gen_session_key(char* skey, char* pub_keyB, char* common_key);
void session_key_recover(const char *skey_str, const char* sshare, char* common_key);
......@@ -33,5 +32,4 @@ void xor_encrypt(char* key, char* message, char* cypher);
void xor_decrypt(char* key, char* cypher, char* message);
#endif //SGXD_DRIVE_KEY_DKG_H
......@@ -24,20 +24,14 @@
#ifndef SGXWALLET_ENCLAVECOMMON_H
#define SGXWALLET_ENCLAVECOMMON_H
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
//#include <stdint.h>
EXTERNC void check_key(int *errStatus, char *err_string, const char* _keyString);
EXTERNC bool enclave_sign(const char *_keyString, const char* _hashXString, const char* _hashYString, char* _sig);
EXTERNC int char2int(char _input);
......@@ -49,16 +43,12 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
uint8_t* _bin, const int _max_length );
EXTERNC void enclave_init();
EXTERNC void LOG_INFO(char* msg);
EXTERNC void LOG_WARN(char* _msg);
EXTERNC void LOG_ERROR(char* _msg);
EXTERNC void LOG_DEBUG(char* _msg);
EXTERNC void LOG_TRACE(char* _msg);
extern uint32_t globalLogLevel_;
#endif //SGXWALLET_ENCLAVECOMMON_H
......@@ -58,7 +58,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
uint8_t decryptedDkgPoly[DKG_BUFER_LENGTH];
void *(*gmp_realloc_func)(void *, size_t, size_t);
void *(*oc_realloc_func)(void *, size_t, size_t);
......@@ -71,16 +70,11 @@ void *reallocate_function(void *, size_t, size_t);
void free_function(void *, size_t);
void trustedEnclaveInit(uint32_t _logLevel) {
LOG_DEBUG (__FUNCTION__);
globalLogLevel_ = _logLevel;
oc_realloc_func = &reallocate_function;
oc_free_func = &free_function;
......@@ -136,7 +130,6 @@ void trustedEMpzDiv(mpz_t *c_un, mpz_t *a_un, mpz_t *b_un) {}
void trustedEMpfDiv(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un) {}
void trustedGenerateEcdsaKey(int *errStatus, char *errString,
uint8_t *encryptedPrivateKey, uint32_t *enc_len, char *pub_key_x, char *pub_key_y) {
LOG_DEBUG (__FUNCTION__);
......
This diff is collapsed.
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