static QGpgMEVerifyOpaqueJob::result_type verify_opaque( Context * ctx, QThread * thread, const weak_ptr<QIODevice> & signedData_, const weak_ptr<QIODevice> & plainText_ ) {

  const shared_ptr<QIODevice> plainText = plainText_.lock();
  const shared_ptr<QIODevice> signedData = signedData_.lock();

  const _detail::ToThreadMover ptMover( plainText,  thread );
  const _detail::ToThreadMover sdMover( signedData, thread );

  QGpgME::QIODeviceDataProvider in( signedData );
  const Data indata( &in );

  if ( !plainText ) {
    QGpgME::QByteArrayDataProvider out;
    Data outdata( &out );

    const VerificationResult res = ctx->verifyOpaqueSignature( indata, outdata );
    Error ae;
    const QString log = _detail::audit_log_as_html( ctx, ae );
    return make_tuple( res, out.data(), log, ae );
  } else {
    QGpgME::QIODeviceDataProvider out( plainText );
    Data outdata( &out );

    const VerificationResult res = ctx->verifyOpaqueSignature( indata, outdata );
    Error ae;
    const QString log = _detail::audit_log_as_html( ctx, ae );
    return make_tuple( res, QByteArray(), log, ae );
  }

}
예제 #2
0
void VCardXXPort::addKey( KABC::Addressee &addr, KABC::Key::Types type )
{
  QString fingerprint = addr.custom( "KADDRESSBOOK",
                                     (type == KABC::Key::PGP ? "OPENPGPFP" : "SMIMEFP") );
  if ( fingerprint.isEmpty() )
    return;

  GpgME::Context * context = GpgME::Context::createForProtocol( GpgME::Context::OpenPGP );
  if ( !context ) {
    kdError() << "No context available" << endl;
    return;
  }

  context->setArmor( false );
  context->setTextMode( false );

  QGpgME::QByteArrayDataProvider dataProvider;
  GpgME::Data dataObj( &dataProvider );
  GpgME::Error error = context->exportPublicKeys( fingerprint.latin1(), dataObj );
  delete context;

  if ( error ) {
    kdError() << error.asString() << endl;
    return;
  }

  KABC::Key key;
  key.setType( type );
  key.setBinaryData( dataProvider.data() );

  addr.insertKey( key );
}
static QGpgMEDownloadJob::result_type download_qsl( Context * ctx, const QStringList & pats ) {
  QGpgME::QByteArrayDataProvider dp;
  Data data( &dp );

  const _detail::PatternConverter pc( pats );

  const Error err= ctx->exportPublicKeys( pc.patterns(), data );
  Error ae;
  const QString log = _detail::audit_log_as_html( ctx, ae );
  return make_tuple( err, dp.data(), log, ae );
}
예제 #4
0
static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread *thread,
                                                          const std::weak_ptr<QIODevice> &cipherText_,
                                                          const std::weak_ptr<QIODevice> &plainText_)
{

    qCDebug(GPGPME_BACKEND_LOG);

    const std::shared_ptr<QIODevice> cipherText = cipherText_.lock();
    const std::shared_ptr<QIODevice> plainText = plainText_.lock();

    const _detail::ToThreadMover ctMover(cipherText, thread);
    const _detail::ToThreadMover ptMover(plainText,  thread);

    QGpgME::QIODeviceDataProvider in(cipherText);
    const Data indata(&in);

    if (!plainText) {
        QGpgME::QByteArrayDataProvider out;
        Data outdata(&out);

        const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
        Error ae;
        const QString log = _detail::audit_log_as_html(ctx, ae);
        qCDebug(GPGPME_BACKEND_LOG) << "End no plainText. Error: " << ae;
        return std::make_tuple(res.first, res.second, out.data(), log, ae);
    } else {
        QGpgME::QIODeviceDataProvider out(plainText);
        Data outdata(&out);

        const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
        Error ae;
        const QString log = _detail::audit_log_as_html(ctx, ae);
        qCDebug(GPGPME_BACKEND_LOG) << "End plainText. Error: " << ae;
        return std::make_tuple(res.first, res.second, QByteArray(), log, ae);
    }

}