and now packages are able to be verified by signed hash
This commit is contained in:
parent
73758abf97
commit
1a255a51de
@ -497,8 +497,6 @@ TrustLevel Signing::trustLevelOf(const QString &keyID) const
|
|||||||
QString Signing::signerOf(const Package &package) const
|
QString Signing::signerOf(const Package &package) const
|
||||||
{
|
{
|
||||||
const QString contents = package.path() + "CONTENTS";
|
const QString contents = package.path() + "CONTENTS";
|
||||||
kDebug() << "gonna go in for" << package.path();
|
|
||||||
kDebug() << "hash is" << package.contentsHash();
|
|
||||||
|
|
||||||
if (!QFile::exists(contents)) {
|
if (!QFile::exists(contents)) {
|
||||||
kDebug() << "not contents hash for package at" << package.path();
|
kDebug() << "not contents hash for package at" << package.path();
|
||||||
@ -512,19 +510,14 @@ QString Signing::signerOf(const Package &package) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
char hash[10 * 1024];
|
const QByteArray hash = file.read(10 * 1024);
|
||||||
qint64 read = file.read(hash, 10 * 1024 - 1);
|
|
||||||
if (read < 1) {
|
|
||||||
kDebug() << "failed to read the CONTENTS file at" << contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
hash[read + 1] = '\0';
|
|
||||||
const QString actualHash = package.contentsHash();
|
const QString actualHash = package.contentsHash();
|
||||||
if (actualHash != hash) {
|
if (actualHash != hash) {
|
||||||
kDebug() << "CONTENTS does not match contents of package" << package.path();
|
kDebug() << "CONTENTS does not match contents of package" << package.path();
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Success!";
|
return d->verifySignature(contents, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Signing::signerOf(const KUrl &package, const KUrl &signature) const
|
QString Signing::signerOf(const KUrl &package, const KUrl &signature) const
|
||||||
|
1
tests/signedPackage/CONTENTS
Normal file
1
tests/signedPackage/CONTENTS
Normal file
@ -0,0 +1 @@
|
|||||||
|
f10e861114185f88a54b3a7bb7e2f7232c7b8835
|
BIN
tests/signedPackage/CONTENTS.sig
Normal file
BIN
tests/signedPackage/CONTENTS.sig
Normal file
Binary file not shown.
@ -26,6 +26,8 @@
|
|||||||
#include "plasma/applet.h"
|
#include "plasma/applet.h"
|
||||||
#include "plasma/remote/signing.h"
|
#include "plasma/remote/signing.h"
|
||||||
|
|
||||||
|
static const QString fingerprint("8B8B22090C6F7C47B1EAEE75D6B72EB1A7F1DB43");
|
||||||
|
|
||||||
SigningTest::SigningTest(QObject *parent)
|
SigningTest::SigningTest(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_signing(0),
|
m_signing(0),
|
||||||
@ -62,22 +64,22 @@ void SigningTest::missingFiles()
|
|||||||
|
|
||||||
void SigningTest::invalidSignature()
|
void SigningTest::invalidSignature()
|
||||||
{
|
{
|
||||||
QVERIFY(m_signing->signerOf(m_path, m_invalidSig).isEmpty());
|
QCOMPARE(m_signing->signerOf(m_path, m_invalidSig), QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SigningTest::validSignature()
|
void SigningTest::validSignature()
|
||||||
{
|
{
|
||||||
QVERIFY(!m_signing->signerOf(m_path, m_sig).isEmpty());
|
QCOMPARE(m_signing->signerOf(m_path, m_sig), fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SigningTest::validSignatureWithoutDefinedSigFile()
|
void SigningTest::validSignatureWithoutDefinedSigFile()
|
||||||
{
|
{
|
||||||
QVERIFY(!m_signing->signerOf(m_path).isEmpty());
|
QCOMPARE(m_signing->signerOf(m_path), fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SigningTest::validPackage()
|
void SigningTest::validPackage()
|
||||||
{
|
{
|
||||||
QVERIFY(!m_signing->signerOf(m_package).isEmpty());
|
QCOMPARE(m_signing->signerOf(m_package), fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SigningTest::confirmDtorPerformance()
|
void SigningTest::confirmDtorPerformance()
|
||||||
|
Loading…
Reference in New Issue
Block a user