diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-07-18 19:55:53 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-07-18 19:55:53 +0000 |
commit | b651d31ff58494346785a5db9940558961ebe19a (patch) | |
tree | c1d01e837517a82d66230d41b79cfbbedd648e61 | |
parent | added class for verifyinfo (diff) | |
download | gpg4usb-b651d31ff58494346785a5db9940558961ebe19a.tar.gz gpg4usb-b651d31ff58494346785a5db9940558961ebe19a.zip |
verify returns gpgme_op_verify_result
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@502 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | context.cpp | 86 | ||||
-rw-r--r-- | context.h | 2 | ||||
-rw-r--r-- | gpg4usb.pro | 6 | ||||
-rw-r--r-- | gpgwin.cpp | 21 | ||||
-rw-r--r-- | verifyinfo.cpp | 25 | ||||
-rw-r--r-- | verifyinfo.h | 22 |
6 files changed, 24 insertions, 138 deletions
diff --git a/context.cpp b/context.cpp index f54417d..f849640 100644 --- a/context.cpp +++ b/context.cpp @@ -498,7 +498,7 @@ void Context::executeGpgCommand(QStringList arguments, QByteArray *stdOut, QByte * -> list of sigs * -> valid */ -int Context::verify(QByteArray inBuffer) { +gpgme_signature_t Context::verify(QByteArray inBuffer) { int error=0; gpgme_data_t in; @@ -513,14 +513,14 @@ int Context::verify(QByteArray inBuffer) { error = checkErr(err); if (error != 0) { - return 1; + return NULL; } result = gpgme_op_verify_result (mCtx); sign = result->signatures; - while (sign) { +/* while (sign) { qDebug() << "sig summary: " << sign->summary; qDebug() << "sig fingerprint: " << sign->fpr; qDebug() << "sig status: " << sign->status << " - " << gpg_err_code(sign->status) << " - " << gpg_strerror(sign->status); @@ -531,86 +531,8 @@ int Context::verify(QByteArray inBuffer) { qDebug() << "sig validity reason: " << sign->validity_reason << " - " << gpg_err_code(sign->validity_reason) << " - " << gpgme_strerror(sign->validity_reason); sign = sign->next; } - - /* - static const char test_text1[] = "Just GNU it!\n"; - static const char test_sig1[] = - "-----BEGIN PGP SIGNATURE-----\n" - "Version: GnuPG v1.0.4-2 (GNU/Linux)\n" - "Comment: For info see http://www.gnupg.org\n" - "\n" - "iJcEABECAFcFAjoS8/E1FIAAAAAACAAkZm9vYmFyLjF0aGlzIGlzIGEgbm90YXRp\n" - "b24gZGF0YSB3aXRoIDIgbGluZXMaGmh0dHA6Ly93d3cuZ3Uub3JnL3BvbGljeS8A\n" - "CgkQLXJ8x2hpdzQLyQCbBW/fgU8ZeWSlWPM1F8umHX17bAAAoIfSNDSp5zM85XcG\n" - "iwxMrf+u8v4r\n" - "=88Zo\n" - "-----END PGP SIGNATURE-----\n"; - - gpgme_error_t err; - gpgme_data_t sig, text; - gpgme_verify_result_t result; - - err = gpgme_data_new_from_mem(&text, test_text1, strlen (test_text1), 0); - checkErr(err); - err = gpgme_data_new_from_mem(&sig, test_sig1, strlen (test_sig1), 0); - checkErr(err); -*/ - /** gpgme_op_verify (gpgme_ctx_t CTX, - gpgme_data_t SIG, gpgme_data_t SIGNED_TEXT, - gpgme_data_t PLAIN) - -If SIG is a detached - signature, then the signed text should be provided in SIGNED_TEXT - and PLAIN should be a null pointer. Otherwise, if SIG is a normal - (or cleartext) signature, SIGNED_TEXT should be a null pointer and - PLAIN should be a writable data object - * - */ - -/* err = gpgme_op_verify (mCtx, sig, text, NULL); - result = gpgme_op_verify_result (mCtx); - - gpgme_signature_t sign; - sign = result->signatures; - - qDebug() << "sig summary: " << sign->summary; - qDebug() << "sig fingerprint: " << sign->fpr; - qDebug() << "sig status: " << sign->status << " - " << gpg_err_code(sign->status) << " - " << gpg_strerror(sign->status); - qDebug() << "sig validity: " << sign->validity; - qDebug() << "sig validity reason: " << sign->validity_reason << " - " << gpg_err_code(sign->validity_reason) << " - " << gpgme_strerror(sign->validity_reason); - - qDebug() << "GPGME_VALIDITY_UNKNOWN (for validity) : " << GPGME_VALIDITY_UNKNOWN; - // GPG_ERR_BAD_SIGNATURE GPGME_SIGSUM_RED GPG_ERR_BAD_DATA - qDebug() << "GPG_ERR_NO_ERROR (for validity-reason) : " << GPG_ERR_NO_ERROR; - - static const char test_sig2[] = - "-----BEGIN PGP MESSAGE-----\n" - "\n" - "owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n" - "GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n" - "y1kvP4y+8D5a11ang0udywsA\n" - "=Crq6\n" - "-----END PGP MESSAGE-----\n"; - - err = gpgme_data_new_from_mem (&sig, test_sig2, strlen (test_sig2), 0); - checkErr(err); - err = gpgme_data_new (&text); - checkErr(err); - err = gpgme_op_verify (mCtx, sig, NULL, text); - checkErr(err); - - result = gpgme_op_verify_result (mCtx); - - sign = result->signatures; - - qDebug() << "sig summary: " << sign->summary; - qDebug() << "sig fingerprint: " << sign->fpr; - qDebug() << "sig status: " << sign->status << " - " << gpg_err_code(sign->status) << " - " << gpg_strerror(sign->status); - qDebug() << "sig validity: " << sign->validity; - qDebug() << "sig validity reason: " << sign->validity_reason << " - " << gpg_err_code(sign->validity_reason) << " - " << gpgme_strerror(sign->validity_reason); - */ - return error; + return sign; } /*** @@ -70,7 +70,7 @@ public: void clearPasswordCache(); void exportSecretKey(QString uid, QByteArray *outBuffer); gpgme_key_t getKeyDetails(QString uid); - int verify(QByteArray in); + gpgme_signature_t verify(QByteArray in); void decryptVerify(QByteArray in); void sign(const QByteArray &inBuffer, QByteArray *outBuffer); bool sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray *outBuffer ); diff --git a/gpg4usb.pro b/gpg4usb.pro index 116d9e7..dc50340 100644 --- a/gpg4usb.pro +++ b/gpg4usb.pro @@ -29,8 +29,7 @@ HEADERS += attachments.h \ textedit.h \ editorpage.h \ quitdialog.h \ - keyserverimportdialog.h \ - verifyinfo.h + keyserverimportdialog.h SOURCES += attachments.cpp \ context.cpp \ gpgwin.cpp \ @@ -46,8 +45,7 @@ SOURCES += attachments.cpp \ textedit.cpp \ editorpage.cpp \ quitdialog.cpp \ - keyserverimportdialog.cpp \ - verifyinfo.cpp + keyserverimportdialog.cpp RC_FILE = gpg4usb.rc # comment out line below for static building @@ -713,12 +713,25 @@ void GpgWin::verify() QByteArray text = edit->curTextPage()->toPlainText().toAscii(); // TODO: toUtf8() here? preventNoDataErr(&text); - int error = mCtx->verify(text); - if (error == 0) { - edit->curPage()->showVerifyLabel(true); - } else { + gpgme_signature_t sign = mCtx->verify(text); + if (sign == NULL) { edit->curPage()->showVerifyLabel(false); + return; } + + while (sign) { + qDebug() << "sig summary: " << sign->summary; + qDebug() << "sig fingerprint: " << sign->fpr; + qDebug() << "sig status: " << sign->status << " - " << gpg_err_code(sign->status) << " - " << gpg_strerror(sign->status); + qDebug() << "sig validity: " << sign->validity; + qDebug() << "sig validity reason: " << sign->validity_reason << " - " << gpg_err_code(sign->validity_reason) << " - " << gpgme_strerror(sign->validity_reason); + if (gpg_err_code(sign->status) == 9) { + qDebug() << "kein passender Schlüssel gefunden. Vom Schlüsselserver importieren?"; + } + sign = sign->next; + } + + } void GpgWin::importKeyDialog() diff --git a/verifyinfo.cpp b/verifyinfo.cpp deleted file mode 100644 index 13fe3e5..0000000 --- a/verifyinfo.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -#include "verifyinfo.h" - -int VerifyInfo::getKeyId() -{ - return 0; -} -void VerifyInfo::setKeyId(int keyId) -{ -} -int VerifyInfo::getStatus() -{ - return 0; -} -void VerifyInfo::setStatus(int status) -{ -} -QString VerifyInfo::getSummary() -{ - return NULL; -} -void VerifyInfo::setSummary(QString summary) -{ -} - diff --git a/verifyinfo.h b/verifyinfo.h deleted file mode 100644 index bc6b92c..0000000 --- a/verifyinfo.h +++ /dev/null @@ -1,22 +0,0 @@ -class QString; -#include <QtGui> - -class VerifyInfo -{ - Q_OBJECT - -public: - int getKeyId(); - void setKeyId(int keyId); - int getStatus(); - void setStatus(int status); - QString getSummary(); - void setSummary(QString summary); - -private: - QString *keyid; - int status; - int summary; - -}; - |