[Kde-pim] QgpgME

Matthias Fuchs mat69 at gmx.net
Fri Oct 2 19:48:01 BST 2009


Hi,

I want to verify a file (kernel.gz) with kernel.gz.sign, to see if that file was 
signed with that signature, but I'm doing something wrong. I'm not completely 
sure what will tell me if I was successful, the output I get is not that 
satisfying.

Can someone please look at this code sample and tell me where my error lies?

const KUrl fileUrl = mFile->url();
    const KUrl sigUrl = mSig->url();

    if (fileUrl.isEmpty() || sigUrl.isEmpty()) {
        return;
    }

    GpgME::Context *context = 
GpgME::Context::createForProtocol(GpgME::OpenPGP);
    if (!context) {
        return;
    }

    boost::shared_ptr<QFile> qFile(new QFile(fileUrl.pathOrUrl()));
    qFile->open(QIODevice::ReadOnly);
    QGpgME::QIODeviceDataProvider *file = new 
QGpgME::QIODeviceDataProvider(qFile);

    boost::shared_ptr<QFile> qSign(new QFile(sigUrl.pathOrUrl()));
    qSign->open(QIODevice::ReadOnly);
    QGpgME::QIODeviceDataProvider *sign = new 
QGpgME::QIODeviceDataProvider(qSign);

    GpgME::Data dFile(file);//e.g. kernel.gz
    GpgME::Data dSign(sign);//e.g. kernel.gz.sign
    kDebug() << "Data correct:" << !dFile.isNull() << ' ' << !dSign.isNull() 
<< ' ' << dFile.impl() << ' ' << dSign.impl();

    GpgME::VerificationResult result = context->verifyDetachedSignature(dSign, 
dFile);
//     GpgME::VerificationResult result = context->verifyOpaqueSignature(dFile, 
dSign);
    GpgME::Error error = result.error();
    kDebug() << "Error:" << error.source() << ' ' << error.asString();
    for (uint i = 0; i < result.numSignatures(); ++i) {
        GpgME::Signature signature = result.signature(i);
        kDebug() << "Validity:" << signature.validity() << ' ' << 
signature.validityAsString() << ' ' << 
signature.nonValidityReason().asString() << ' ' << 
signature.isVerifiedUsingChainModel() << signature.summary() << 
signature.pkaStatus();
    }
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list