aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-12-15 22:49:38 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-12-15 22:49:38 +0000
commite5ab12795e4f0a42a8ce18cace5a57a83a255c37 (patch)
tree03866aa970498d82325e922e1e14c578b8f0e030
parentset quoted printable decoding in settings checked per default (diff)
downloadgpg4usb-e5ab12795e4f0a42a8ce18cace5a57a83a255c37.tar.gz
gpg4usb-e5ab12795e4f0a42a8ce18cace5a57a83a255c37.zip
start playing with verify, till now mainly copyed from gpgme-test - more to come ;-)
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@403 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--context.cpp113
-rw-r--r--context.h3
-rw-r--r--gpgwin.cpp3
3 files changed, 119 insertions, 0 deletions
diff --git a/context.cpp b/context.cpp
index 323a18e..ebdb042 100644
--- a/context.cpp
+++ b/context.cpp
@@ -491,6 +491,119 @@ void Context::executeGpgCommand(QStringList arguments, QByteArray *stdOut, QByte
*stdErr = gpg.readAllStandardError();
}
+
+/***
+ * return type should contain:
+ * -> list of sigs
+ * -> valid
+ */
+void Context::verify(QByteArray in) {
+
+ 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 type should contain:
+ * -> list of sigs
+ * -> valid
+ * -> decrypted message
+ */
+void Context::decryptVerify(QByteArray in) {
+
+/* gpgme_error_t err;
+ gpgme_data_t in, out;
+
+ gpgme_decrypt_result_t decrypt_result;
+ gpgme_verify_result_t verify_result;
+
+ err = gpgme_op_decrypt_verify (mCtx, in, out);
+ decrypt_result = gpgme_op_decrypt_result (mCtx);
+
+ verify_result = gpgme_op_verify_result (mCtx);
+ */
+
+}
+
+void Context::sign(const QByteArray &inBuffer, QByteArray *outBuffer) {
+
+}
+
}
diff --git a/context.h b/context.h
index a023ce0..5d553ff 100644
--- a/context.h
+++ b/context.h
@@ -70,6 +70,9 @@ public:
void clearPasswordCache();
void exportSecretKey(QString uid, QByteArray *outBuffer);
gpgme_key_t getKeyDetails(QString uid);
+ void verify(QByteArray in);
+ void decryptVerify(QByteArray in);
+ void sign(const QByteArray &inBuffer, QByteArray *outBuffer);
signals:
void keyDBChanged();
diff --git a/gpgwin.cpp b/gpgwin.cpp
index da6af8a..36c75d5 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -688,6 +688,9 @@ void GpgWin::importKeyFromFile()
void GpgWin::openKeyManagement()
{
+
+ mCtx->verify(QByteArray());
+
if (!keyMgmt) {
keyMgmt = new KeyMgmt(mCtx, iconPath);
// keyMgmt->resize(800, 400);