SKALE-2977 clean up

parent 1e558175
...@@ -85,7 +85,7 @@ vector <string> genECDSAKey() { ...@@ -85,7 +85,7 @@ vector <string> genECDSAKey() {
return keys; return keys;
} }
string getECDSAPubKey(const char *_encryptedKeyHex) { string getECDSAPubKey(const std::string& _encryptedKeyHex) {
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
vector<char> pubKeyX(BUF_LEN, 0); vector<char> pubKeyX(BUF_LEN, 0);
vector<char> pubKeyY(BUF_LEN, 0); vector<char> pubKeyY(BUF_LEN, 0);
...@@ -94,7 +94,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) { ...@@ -94,7 +94,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
int errStatus = 0; int errStatus = 0;
uint64_t enc_len = 0; uint64_t enc_len = 0;
if (!hex2carray(_encryptedKeyHex, &enc_len, encrPrKey.data())) { if (!hex2carray(_encryptedKeyHex.c_str(), &enc_len, encrPrKey.data())) {
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
} }
...@@ -159,7 +159,7 @@ bool verifyECDSASig(string& pubKeyStr, const char *hashHex, const char *signatur ...@@ -159,7 +159,7 @@ bool verifyECDSASig(string& pubKeyStr, const char *hashHex, const char *signatur
return true; return true;
} }
vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, int base) { vector <string> ecdsaSignHash(const std::string& encryptedKeyHex, const char *hashHex, int base) {
vector <string> signatureVector(3); vector <string> signatureVector(3);
vector<char> errMsg(1024, 0); vector<char> errMsg(1024, 0);
...@@ -174,9 +174,11 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, ...@@ -174,9 +174,11 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
shared_ptr<SGXException> exception = NULL; shared_ptr<SGXException> exception = NULL;
if (!hex2carray(encryptedKeyHex, &decLen, encryptedKey.data())) { spdlog::debug("BEFORE HEX2CARRAY");
if (!hex2carray(encryptedKeyHex.c_str(), &decLen, encryptedKey.data())) {
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
} }
spdlog::debug("AFTER HEX2CARRAY");
status = trustedEcdsaSignAES(eid, &errStatus, status = trustedEcdsaSignAES(eid, &errStatus,
errMsg.data(), encryptedKey.data(), decLen, (unsigned char *) hashHex, errMsg.data(), encryptedKey.data(), decLen, (unsigned char *) hashHex,
......
...@@ -31,9 +31,9 @@ using namespace std; ...@@ -31,9 +31,9 @@ using namespace std;
vector<string> genECDSAKey(); vector<string> genECDSAKey();
string getECDSAPubKey(const char* _encryptedKeyHex); string getECDSAPubKey(const std::string& _encryptedKeyHex);
vector<string> ecdsaSignHash(const char* encryptedKeyHex, const char* hashHex, int base); vector<string> ecdsaSignHash(const std::string& encryptedKeyHex, const char* hashHex, int base);
#endif //SGXD_ECDSACRYPTO_H #endif //SGXD_ECDSACRYPTO_H
...@@ -54,7 +54,6 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) { ...@@ -54,7 +54,6 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
spdlog::debug("key to read from db: {}", _key); spdlog::debug("key to read from db: {}", _key);
auto status = db->Get(readOptions, _key, result.get()); auto status = db->Get(readOptions, _key, result.get());
spdlog::debug("SUCCESS READING");
throwExceptionOnError(status); throwExceptionOnError(status);
......
...@@ -332,7 +332,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_ ...@@ -332,7 +332,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
result["signature_r"] = ""; result["signature_r"] = "";
result["signature_s"] = ""; result["signature_s"] = "";
vector <string> signatureVector(3); vector<string> signatureVector(3);
try { try {
string hashTmp = _messageHash; string hashTmp = _messageHash;
...@@ -353,9 +353,9 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_ ...@@ -353,9 +353,9 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
throw SGXException(-22, "Invalid base"); throw SGXException(-22, "Invalid base");
} }
shared_ptr <string> encryptedKey = readFromDb(_keyName); shared_ptr<string> encryptedKey = readFromDb(_keyName);
signatureVector = ecdsaSignHash(encryptedKey->c_str(), hashTmp.c_str(), _base); signatureVector = ecdsaSignHash(*encryptedKey, hashTmp.c_str(), _base);
if (signatureVector.size() != 3) { if (signatureVector.size() != 3) {
throw SGXException(INVALID_ECSDA_SIGNATURE, "Invalid ecdsa signature"); throw SGXException(INVALID_ECSDA_SIGNATURE, "Invalid ecdsa signature");
} }
......
...@@ -32,13 +32,10 @@ using namespace std; ...@@ -32,13 +32,10 @@ using namespace std;
#include <map> #include <map>
#include <memory> #include <memory>
#include <gmp.h> #include <gmp.h>
#include "secure_enclave/Verify.h" #include "secure_enclave/Verify.h"
#include "InvalidStateException.h" #include "InvalidStateException.h"
#define SAFE_FREE(__POINTER__) {if (__POINTER__) {free(__POINTER__); __POINTER__ = NULL;}} #define SAFE_FREE(__POINTER__) {if (__POINTER__) {free(__POINTER__); __POINTER__ = NULL;}}
inline std::string className(const std::string &prettyFunction) { inline std::string className(const std::string &prettyFunction) {
...@@ -51,12 +48,11 @@ inline std::string className(const std::string &prettyFunction) { ...@@ -51,12 +48,11 @@ inline std::string className(const std::string &prettyFunction) {
return prettyFunction.substr(begin, end); return prettyFunction.substr(begin, end);
} }
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ ) #define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
#define CHECK_STATE(_EXPRESSION_) \ #define CHECK_STATE(_EXPRESSION_) \
if (!(_EXPRESSION_)) { \ if (!(_EXPRESSION_)) { \
auto __msg__ = string("State check failed::") + #_EXPRESSION_ + " " + string(__FILE__) + ":" + to_string(__LINE__); \ auto __msg__ = std::string("State check failed::") + #_EXPRESSION_ + " " + std::string(__FILE__) + ":" + std::to_string(__LINE__); \
throw InvalidStateException(__msg__, __CLASS_NAME__);} throw InvalidStateException(__msg__, __CLASS_NAME__);}
......
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