Commit d7558164 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Added function to keygen that allows mangling new plugin fingerprints into...

Added function to keygen that allows mangling new plugin fingerprints into existing hardware hashes.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17433 383ad7c9-94d9-4d36-a494-682f7c89f535
parent abc0193b
This diff is collapsed.
......@@ -64,18 +64,25 @@ KeyGen::KeyGen(QString n, QString cHash, QString pHash, QString cpHash, QString
requestSig = request;
}
QString KeyGen::computeSignature() const {
// Get the salts
QString saltPre;
ADD_SALT_PRE(saltPre);
QString saltPost;
ADD_SALT_POST(saltPost);
QString keyRequest = saltPre + name + coreHash + pluginHash + cpuHash
+ productHash + macHashes.join("") + saltPost;
QString requestSigCheck =
QCryptographicHash::hash(keyRequest.toAscii(),
QCryptographicHash::Sha1).toHex();
return requestSigCheck;
}
bool KeyGen::isValid() const
{
// Get the salts
QString saltPre;
ADD_SALT_PRE(saltPre);
QString saltPost;
ADD_SALT_POST(saltPost);
QString keyRequest = saltPre + name + coreHash + pluginHash + cpuHash + productHash + macHashes.join("") + saltPost;
QString requestSigCheck = QCryptographicHash::hash ( keyRequest.toAscii() , QCryptographicHash::Sha1 ).toHex();
return requestSig == requestSigCheck;
return requestSig == computeSignature();
}
QString KeyGen::Generate(QString expiryDate) const
......@@ -174,6 +181,11 @@ KeyGenWidget::KeyGenWidget(QMainWindow *parent)
connect(months,SIGNAL(valueChanged(int)),this,SLOT(slotDate()));
connect(years ,SIGNAL(valueChanged(int)),this,SLOT(slotDate()));
/*
* Mangle Tab
*/
connect(mangle_pb, SIGNAL(clicked()), this, SLOT(slotMangle()));
// Automatically set expire date to current date
// For security reasons no default span is set here!
expires->setDate( QDate::currentDate());
......@@ -182,6 +194,35 @@ KeyGenWidget::KeyGenWidget(QMainWindow *parent)
generateAllButton->setVisible(false);
}
void KeyGenWidget::slotMangle() {
const QString hardwareHash_raw = hardwareHashDump_te->toPlainText();
const QString pluginHashes_raw = pluginHashDump_te->toPlainText();
const std::vector<KeyGen> hardwareKeygens = KeyGen::CreateFromMessyString(hardwareHash_raw);
if (hardwareKeygens.empty()) {
QMessageBox::critical(this, tr("Unable to Mangle"), tr("No valid request found in hardware textbox."));
return;
}
KeyGen hardwareKeygen = hardwareKeygens.front();
std::vector<KeyGen> pluginKeygens = KeyGen::CreateFromMessyString(pluginHashes_raw);
if (pluginKeygens.empty()) {
QMessageBox::critical(this, tr("Unable to Mangle"), tr("No valid request found in plugins textbox."));
return;
}
QString generatedRequest;
for (std::vector<KeyGen>::iterator it = pluginKeygens.begin(), it_end = pluginKeygens.end();
it != it_end; ++it) {
it->copyHardwareHashesFrom(hardwareKeygen);
generatedRequest += it->generateRequest();
}
requestData->setPlainText(generatedRequest);
}
void KeyGenWidget::slotDate() {
QDate today = QDate::currentDate();
today = today.addDays(days->value());
......
......@@ -61,8 +61,25 @@ class KeyGen
//returns string containing the key
QString Generate(QString expiryDate) const;
//finds all occurrences of info in messy string
QString computeSignature() const;
bool isValid() const;
void copyHardwareHashesFrom(const KeyGen &rhs) {
cpuHash = rhs.cpuHash;
macHashes = rhs.macHashes;
}
QString generateRequest() {
return QString("%1\n%2\n%3\n%4\n%5\n%6\n%7\n\n")
.arg(name)
.arg(coreHash)
.arg(pluginHash)
.arg(cpuHash)
.arg(productHash)
.arg(macHashes.join("\n"))
.arg(computeSignature());
}
static std::vector<KeyGen> CreateFromMessyString(QString info);
static QString filterString(QString in);
......@@ -92,6 +109,8 @@ public slots:
void handleSelectionChanged(const QItemSelection& selection);
void slotMangle();
private:
void toFile(const KeyGen* gen);
......
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