add functionality to sign and verify buttons
parent
0ca8f4e68c
commit
728bc6457a
|
|
@ -18,9 +18,11 @@ public slots:
|
||||||
void onAppFolderSelect_click();
|
void onAppFolderSelect_click();
|
||||||
void onPublicKeySelect_click();
|
void onPublicKeySelect_click();
|
||||||
|
|
||||||
|
void onSign_click();
|
||||||
|
void onVerify_click();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Ui::MainWindow> ui;
|
std::shared_ptr<Ui::MainWindow> ui;
|
||||||
|
|
||||||
const QString checkPublicKey(const QString &path);
|
const QString checkPublicKey(const QString &path);
|
||||||
IntegretyCheck integretyCheck;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ AppWindow::AppWindow() : QMainWindow(nullptr), ui(new Ui::MainWindow()) {
|
||||||
&AppWindow::onAppFolderSelect_click);
|
&AppWindow::onAppFolderSelect_click);
|
||||||
connect(ui->btnSelectPublicKey, &QToolButton::clicked, this,
|
connect(ui->btnSelectPublicKey, &QToolButton::clicked, this,
|
||||||
&AppWindow::onPublicKeySelect_click);
|
&AppWindow::onPublicKeySelect_click);
|
||||||
|
connect(ui->btnSign, &QPushButton::clicked, this, &AppWindow::onSign_click);
|
||||||
|
connect(ui->btnVerify, &QPushButton::clicked, this,
|
||||||
|
&AppWindow::onVerify_click);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppWindow::onAppFolderSelect_click() {
|
void AppWindow::onAppFolderSelect_click() {
|
||||||
|
|
@ -29,14 +32,6 @@ void AppWindow::onAppFolderSelect_click() {
|
||||||
if (!pubKey.isEmpty()) {
|
if (!pubKey.isEmpty()) {
|
||||||
ui->txtPublicKey->setText(pubKey);
|
ui->txtPublicKey->setText(pubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
integretyCheck.generateKeyPair();
|
|
||||||
integretyCheck.saveKeyFile(dir.toStdString());
|
|
||||||
std::string hList = integretyCheck.generateHashList(dir.toStdString());
|
|
||||||
integretyCheck.signHashList(hList);
|
|
||||||
std::cout << hList << std::endl;
|
|
||||||
|
|
||||||
integretyCheck.verifyHashList(hList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppWindow::onPublicKeySelect_click() {
|
void AppWindow::onPublicKeySelect_click() {
|
||||||
|
|
@ -49,6 +44,36 @@ void AppWindow::onPublicKeySelect_click() {
|
||||||
ui->txtPublicKey->setText(fileName);
|
ui->txtPublicKey->setText(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppWindow::onSign_click() {
|
||||||
|
std::string dir = ui->txtFolderPath->text().toStdString();
|
||||||
|
IntegretyCheck integretyCheck(dir, true);
|
||||||
|
|
||||||
|
integretyCheck.saveKeyFile(dir);
|
||||||
|
std::string hList = integretyCheck.generateHashList(dir);
|
||||||
|
integretyCheck.signHashList(hList);
|
||||||
|
std::cout << hList << std::endl;
|
||||||
|
integretyCheck.saveHashList(dir, hList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppWindow::onVerify_click() {
|
||||||
|
std::string dir = ui->txtFolderPath->text().toStdString();
|
||||||
|
IntegretyCheck integretyCheck(dir, false);
|
||||||
|
|
||||||
|
std::string newHashList, hList;
|
||||||
|
hList = integretyCheck.loadHashList(dir);
|
||||||
|
std::cout << hList << std::endl;
|
||||||
|
if (integretyCheck.verifyHashList(hList, newHashList)) {
|
||||||
|
if (integretyCheck.checkHashList(newHashList, dir)) {
|
||||||
|
std::cout << "App verified!" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr << "/!\\ App modified, one or more hashes invalid!"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "/!\\ App modified, signature invalid!" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QString AppWindow::checkPublicKey(const QString &path) {
|
const QString AppWindow::checkPublicKey(const QString &path) {
|
||||||
QString pubKeyFile = path + QDir::separator() +
|
QString pubKeyFile = path + QDir::separator() +
|
||||||
QString::fromStdString(IntegretyCheck::KEY_FILE);
|
QString::fromStdString(IntegretyCheck::KEY_FILE);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue