changed constructors
parent
35777ad309
commit
8a905d2d95
|
|
@ -6,8 +6,7 @@
|
||||||
class IntegretyCheck {
|
class IntegretyCheck {
|
||||||
public:
|
public:
|
||||||
IntegretyCheck();
|
IntegretyCheck();
|
||||||
IntegretyCheck(const std::string &appPath, const std::string &keyFile,
|
IntegretyCheck(const std::string &appPath, bool genKeyPair);
|
||||||
const std::string &hashList);
|
|
||||||
|
|
||||||
bool loadKeyFile(const std::string &app);
|
bool loadKeyFile(const std::string &app);
|
||||||
bool saveKeyFile(const std::string &app);
|
bool saveKeyFile(const std::string &app);
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,23 @@ std::string string_to_hex(const std::string &input) {
|
||||||
|
|
||||||
IntegretyCheck::IntegretyCheck() {}
|
IntegretyCheck::IntegretyCheck() {}
|
||||||
|
|
||||||
IntegretyCheck::IntegretyCheck(const std::string &appPath,
|
IntegretyCheck::IntegretyCheck(const std::string &appPath, bool genKeyPair) {
|
||||||
const std::string &keyFile,
|
if (genKeyPair) {
|
||||||
const std::string &hashList) {
|
|
||||||
generateKeyPair();
|
generateKeyPair();
|
||||||
saveKeyFile(appPath);
|
} else {
|
||||||
std::string hashlist = generateHashList(appPath);
|
loadKeyFile(appPath);
|
||||||
signHashList(hashlist);
|
}
|
||||||
// loadHashList(hashList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntegretyCheck::loadKeyFile(const std::string &app) {
|
bool IntegretyCheck::loadKeyFile(const std::string &app) {
|
||||||
fs::path appPath(app);
|
fs::path appPath(app);
|
||||||
|
if (fs::exists(appPath / KEY_FILE)) {
|
||||||
CryptoPP::FileSource input((appPath / KEY_FILE).c_str(), true);
|
CryptoPP::FileSource input((appPath / KEY_FILE).c_str(), true);
|
||||||
m_publicKey.BERDecode(input);
|
m_publicKey.BERDecode(input);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool IntegretyCheck::saveKeyFile(const std::string &app) {
|
bool IntegretyCheck::saveKeyFile(const std::string &app) {
|
||||||
///@todo https://github.com/noloader/cryptopp-pem
|
///@todo https://github.com/noloader/cryptopp-pem
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue