SKALE-2977 clean up

parent 1e558175
......@@ -85,7 +85,7 @@ vector <string> genECDSAKey() {
return keys;
}
string getECDSAPubKey(const char *_encryptedKeyHex) {
string getECDSAPubKey(const std::string& _encryptedKeyHex) {
vector<char> errMsg(BUF_LEN, 0);
vector<char> pubKeyX(BUF_LEN, 0);
vector<char> pubKeyY(BUF_LEN, 0);
......@@ -94,7 +94,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
int errStatus = 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");
}
......@@ -159,7 +159,7 @@ bool verifyECDSASig(string& pubKeyStr, const char *hashHex, const char *signatur
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<char> errMsg(1024, 0);
......@@ -174,9 +174,11 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
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");
}
spdlog::debug("AFTER HEX2CARRAY");
status = trustedEcdsaSignAES(eid, &errStatus,
errMsg.data(), encryptedKey.data(), decLen, (unsigned char *) hashHex,
......
......@@ -31,9 +31,9 @@ using namespace std;
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
......@@ -54,7 +54,6 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
spdlog::debug("key to read from db: {}", _key);
auto status = db->Get(readOptions, _key, result.get());
spdlog::debug("SUCCESS READING");
throwExceptionOnError(status);
......
......@@ -332,7 +332,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
result["signature_r"] = "";
result["signature_s"] = "";
vector <string> signatureVector(3);
vector<string> signatureVector(3);
try {
string hashTmp = _messageHash;
......@@ -353,9 +353,9 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
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) {
throw SGXException(INVALID_ECSDA_SIGNATURE, "Invalid ecdsa signature");
}
......
......@@ -32,13 +32,10 @@ using namespace std;
#include <map>
#include <memory>
#include <gmp.h>
#include "secure_enclave/Verify.h"
#include "InvalidStateException.h"
#define SAFE_FREE(__POINTER__) {if (__POINTER__) {free(__POINTER__); __POINTER__ = NULL;}}
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);
}
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
#define CHECK_STATE(_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__);}
......
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