diff --git a/inc/integretychecker.h b/inc/integretychecker.h index 1a5b1ca..8ffd7b0 100644 --- a/inc/integretychecker.h +++ b/inc/integretychecker.h @@ -6,8 +6,7 @@ class IntegretyCheck { public: IntegretyCheck(); - IntegretyCheck(const std::string &appPath, const std::string &keyFile, - const std::string &hashList); + IntegretyCheck(const std::string &appPath, bool genKeyPair); bool loadKeyFile(const std::string &app); bool saveKeyFile(const std::string &app); diff --git a/src/integretychecker.cpp b/src/integretychecker.cpp index d008bd5..65df18a 100644 --- a/src/integretychecker.cpp +++ b/src/integretychecker.cpp @@ -32,21 +32,22 @@ std::string string_to_hex(const std::string &input) { IntegretyCheck::IntegretyCheck() {} -IntegretyCheck::IntegretyCheck(const std::string &appPath, - const std::string &keyFile, - const std::string &hashList) { - generateKeyPair(); - saveKeyFile(appPath); - std::string hashlist = generateHashList(appPath); - signHashList(hashlist); - // loadHashList(hashList); +IntegretyCheck::IntegretyCheck(const std::string &appPath, bool genKeyPair) { + if (genKeyPair) { + generateKeyPair(); + } else { + loadKeyFile(appPath); + } } bool IntegretyCheck::loadKeyFile(const std::string &app) { fs::path appPath(app); - CryptoPP::FileSource input((appPath / KEY_FILE).c_str(), true); - m_publicKey.BERDecode(input); - return true; + if (fs::exists(appPath / KEY_FILE)) { + CryptoPP::FileSource input((appPath / KEY_FILE).c_str(), true); + m_publicKey.BERDecode(input); + return true; + } + return false; } bool IntegretyCheck::saveKeyFile(const std::string &app) {