diff --git a/LicenseManager/LicenseManager.cc b/LicenseManager/LicenseManager.cc index efd40a8a10fd9ec727af74996e2d03e8eede518b..8793f134809a14fa99eb58d586adcb7034419fe5 100644 --- a/LicenseManager/LicenseManager.cc +++ b/LicenseManager/LicenseManager.cc @@ -297,11 +297,16 @@ bool LicenseManager::authenticate() { else { QString text = "License check for plugin has failed.\n"; text += "Please get a valid License!\n"; - text += "Send the following Information to contact@openflipper.org:\n"; + text += "Send the following Information to " + CONTACTMAIL + "\n\n"; text += pluginFileName() +"\n"; text += coreHash +"\n"; text += pluginHash +"\n"; text += macHash +"\n"; + + QString keyRequest = saltPre + pluginFileName() + coreHash+pluginHash+macHash +saltPost; + QString requestSig = QCryptographicHash::hash ( keyRequest.toAscii() , QCryptographicHash::Sha1 ).toHex(); + text += requestSig + "\n"; + QMessageBox::warning ( 0, "Plugin License check failed", text ); std::cerr << "Authentication failed" << std::endl; authenticated_ = false; diff --git a/LicenseManager/keyGen/keygen.cc b/LicenseManager/keyGen/keygen.cc index dfdd20941bdefbd558bd471b1852c04769511d01..229e421e21b5ecaed94e101c2d913ab15a74f526 100644 --- a/LicenseManager/keyGen/keygen.cc +++ b/LicenseManager/keyGen/keygen.cc @@ -1,39 +1,86 @@ #include <qapplication.h> #include <QtGui> #include <QFile> +#include <QMessageBox> #include <iostream> +#include <OpenFlipper/LicenseManager/keyGen/keygenWidget.hh> #include "salt.hh" int main(int argc, char **argv) { QApplication a( argc, argv ); - if (argc == 2) { - std::cerr << " Call ./keygen <InfoFile> <Expiry date>" << std::endl; - std::cerr << "Date is of the form: YYYY-MM-DD" << std::endl; - exit(1); - } + // Get license information + QString name; + QString coreHash; + QString pluginHash; + QString macHash; + QString requestSig; - QFile file(argv[1]); + if (argc == 3) { + + QFile file(argv[1]); - if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) { - std::cerr << "Unable to open file " << std::endl; - return 1; - } + if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) { + std::cerr << "Unable to open file " << std::endl; + std::cerr << " Call ./keygen <InfoFile> <Expiry date>" << std::endl; + std::cerr << "Date is of the form: YYYY-MM-DD" << std::endl; + return 1; + } - // Get license information - QString name = file.readLine().simplified(); - QString coreHash = file.readLine().simplified(); - QString pluginHash = file.readLine().simplified(); - QString macHash = file.readLine().simplified(); + // Get license information + name = file.readLine().simplified(); + coreHash = file.readLine().simplified(); + pluginHash = file.readLine().simplified(); + macHash = file.readLine().simplified(); + requestSig = file.readLine().simplified(); - file.close(); + file.close(); - std::cerr << "Generating key for Plugin : " << name.toStdString() << std::endl; - std::cerr << "Core Hash : " << coreHash.toStdString() << std::endl; - std::cerr << "Plugin Hash : " << pluginHash.toStdString() << std::endl; - std::cerr << "macHash is : " << macHash.toStdString() << std::endl; + } else { + MainWindow* mainWindow = new MainWindow(); + mainWindow->show(); + + a.exec(); + + QString inputData = mainWindow->textEdit_->toPlainText(); + + QStringList data = inputData.split('\n'); + + if ( data.size() != 5 ) { + std::cerr << "Request data has to containe 5 lines!" << std::endl; + exit(1); + } + + // Clean strings + name = data[0].simplified(); + coreHash = data[1].simplified(); + pluginHash = data[2].simplified(); + macHash = data[3].simplified(); + requestSig = data[4].simplified(); + + } + + std::cerr << "Generating key for Plugin : " << name.toStdString() << std::endl; + std::cerr << "Core Hash : " << coreHash.toStdString() << std::endl; + std::cerr << "Plugin Hash : " << pluginHash.toStdString() << std::endl; + std::cerr << "macHash is : " << macHash.toStdString() << std::endl; + std::cerr << "requestSignature is : " << requestSig.toStdString() << std::endl; + + // Get the salts + QString saltPre; + ADD_SALT_PRE(saltPre); + QString saltPost; + ADD_SALT_POST(saltPost); + + QString keyRequest = saltPre + name + coreHash + pluginHash + macHash + saltPost; + QString requestSigCheck = QCryptographicHash::hash ( keyRequest.toAscii() , QCryptographicHash::Sha1 ).toHex(); + + if ( requestSig != requestSigCheck ) { + QMessageBox::critical(0,"Signature of request invalid","The signature of the request is not valid"); + return 1; + } std::cerr << "Writing License file to output : " << name.toStdString() << std::endl; QFile outFile(name + ".lic"); @@ -56,11 +103,7 @@ int main(int argc, char **argv) output << date.toString(Qt::ISODate) << "\n"; - // Get the salts - QString saltPre; - ADD_SALT_PRE(saltPre); - QString saltPost; - ADD_SALT_POST(saltPost); + // Sign the license file QString license = saltPre + name + coreHash + pluginHash + macHash + date.toString(Qt::ISODate) + saltPost; diff --git a/LicenseManager/keyGen/keygenWidget.cc b/LicenseManager/keyGen/keygenWidget.cc new file mode 100644 index 0000000000000000000000000000000000000000..b470622c55466a47bbf3491abffaea9533ef07fe --- /dev/null +++ b/LicenseManager/keyGen/keygenWidget.cc @@ -0,0 +1,15 @@ + +#include <QtGui> +#include "keygenWidget.hh" + +MainWindow::MainWindow() +{ + + textEdit_ = new QTextEdit(this); + setCentralWidget(textEdit_); + +} + +MainWindow::~MainWindow() { + +} diff --git a/LicenseManager/keyGen/keygenWidget.cc~ b/LicenseManager/keyGen/keygenWidget.cc~ new file mode 100644 index 0000000000000000000000000000000000000000..923a437d59dc8d706b8616261af9d768a7d62c33 --- /dev/null +++ b/LicenseManager/keyGen/keygenWidget.cc~ @@ -0,0 +1,15 @@ + +#include <QtGui> +#include "keygenWidget.hh" + +MainWindow::MainWindow() +{ + textEdit_ = new QTextEdit(); + setCentralWidget(textEdit_); + + +} + +MainWindow::~MainWindow() { + +} diff --git a/LicenseManager/keyGen/keygenWidget.hh b/LicenseManager/keyGen/keygenWidget.hh new file mode 100644 index 0000000000000000000000000000000000000000..e5ec7da5c2e69576900ee12cd42755a6c73b96bf --- /dev/null +++ b/LicenseManager/keyGen/keygenWidget.hh @@ -0,0 +1,22 @@ + + +#ifndef KEYGENWINDOW_HH +#define KEYGENWINDOW_HH + +#include <QMainWindow> +#include <QTextEdit> + + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(); + virtual ~MainWindow(); + + QTextEdit* textEdit_; + +}; + + #endif // KEYGENWINDOW_HH \ No newline at end of file diff --git a/LicenseManager/keyGen/keygenWidget.hh~ b/LicenseManager/keyGen/keygenWidget.hh~ new file mode 100644 index 0000000000000000000000000000000000000000..c63eaabb463db2d0dbc394e970d1bc2fc58bc608 --- /dev/null +++ b/LicenseManager/keyGen/keygenWidget.hh~ @@ -0,0 +1,27 @@ + + +#ifndef KEYGENWINDOW_HH +#define KEYGENWINDOW_HH + +#include <ui_keyWindow.hh> +#include <QTextEdit> + + +class MainWindow : public keyWindow +{ + Q_OBJECT + +public: + MainWindow(); + virtual ~MainWindow(); + + QTextEdit* textEdit_; +// private slots: +// void open(); +// bool save(); +// private: +// void loadFile(const QString &fileName); +// bool saveFile(const QString &fileName); +}; + + #endif // KEYGENWINDOW_HH \ No newline at end of file diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 77e1d61e9208e972b826093b742ee5a3be07c8e5..d6e26130d5d336fc0c5dfa3bec44d91b91f51565 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -121,8 +121,16 @@ macro (_plugin_licensemanagement) acg_append_files (keygen_hdr "*.hh" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen") acg_append_files (keygen_src "*.cc" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen") +# acg_append_files (keygen_ui "*.ui" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen") + + + acg_qt4_automoc (keygen_moc ${keygen_hdr}) - add_executable (Plugin-${plugin}-keygen ${keygen_hdr} ${keygen_src}) +# acg_qt4_autouic (keygen_uic ${keygen_ui}) + + #message(STATUS ${keygen_uic}) + + add_executable (Plugin-${plugin}-keygen ${keygen_hdr} ${keygen_src} ${keygen_moc}) target_link_libraries ( Plugin-${plugin}-keygen