[git] GpgOL - branch, master, updated. gpgol-1.4.0-229-g66ab616

by Andre Heinecke cvs at cvs.gnupg.org
Fri Dec 16 16:03:48 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  66ab61651831db028131a9b5dba3be3b0c0aec71 (commit)
       via  ee7e740a20b5c2d0e9dbaff06821e83fb60d7de1 (commit)
       via  439406a258c1d0c46c6517a011f5f46e2b185179 (commit)
      from  829c65658073aabc75c56442b85fe78296df6f9c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 66ab61651831db028131a9b5dba3be3b0c0aec71
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Dec 16 16:01:28 2016 +0100

    Handle button click for encrypted only mails
    
    * src/ribbon-callbacks.cpp (launch_cert_details): Handle
    the case were a mail is unsigned.

diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index 382fa2d..3817184 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -1609,6 +1609,27 @@ HRESULT launch_cert_details (LPDISPATCH ctrl)
       return S_OK;
     }
 
+  if (!mail->is_signed () && mail->is_encrypted ())
+    {
+      /* Encrypt only, no information but show something. because
+         we want the button to be active.
+
+         Aheinecke: I don't think we should show to which keys the message
+         is encrypted here. This would confuse users if they see keyids
+         of unknown keys and the information can't be "true" because the
+         sender could have sent the same information to other people or
+         used throw keyids etc.
+         */
+      char * buf;
+      gpgrt_asprintf (&buf, _("The message was not cryptographically signed.\n"
+                      "There is no additional information available if it "
+                      "was actually sent by '%s' or if someone faked the sender address."), mail->get_sender ().c_str());
+      MessageBox (NULL, buf, _("GpgOL"),
+                  MB_ICONINFORMATION|MB_OK);
+      xfree (buf);
+      return S_OK;
+    }
+
   char *uiserver = get_uiserver_name ();
   bool showError = false;
   if (uiserver)

commit ee7e740a20b5c2d0e9dbaff06821e83fb60d7de1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Dec 16 15:58:20 2016 +0100

    Use signed and encrypted again in tooltip
    
    * src/ribbon-callbacks.cpp (get_sig_ttip): Use signed
    and encrypted again.
    
    --
    This makes it more transparent and obvious for our existing
    users what the new UI language means by secure, signed but
    not secure etc.

diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index 079779f..382fa2d 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -1554,10 +1554,18 @@ HRESULT get_sig_ttip (LPDISPATCH ctrl, VARIANT *result)
   wchar_t *w_result;
   if (mail && (mail->is_signed () || mail->is_encrypted ()))
     {
-      char *buf;
-      gpgrt_asprintf (&buf, _("%s message"), mail->get_crypto_summary ().c_str());
-      w_result = utf8_to_wchar (buf);
-      xfree(buf);
+      if (mail->is_signed () && mail->is_encrypted ())
+        {
+          w_result = utf8_to_wchar (_("Signed and encrypted message"));
+        }
+      else if (mail->is_signed ())
+        {
+          w_result = utf8_to_wchar (_("Signed message"));
+        }
+      else if (mail->is_encrypted ())
+        {
+          w_result = utf8_to_wchar (_("Encrypted message"));
+        }
     }
   else
     {

commit 439406a258c1d0c46c6517a011f5f46e2b185179
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Dec 16 15:53:28 2016 +0100

    Implement direct trust handling
    
    * src/mail.cpp (level_4_check): Do the actual check for direct
    trust.
    (Mail::get_crypto_details): Handle level 4 subcases with different
    details.
    * src/parsecontroller.cpp (ParseController::parse): Fetch
    ultimately trusted keys if a sig was fully or ultimately valid.
    (ParseController::get_ultimate_keys): New Helper function
    to cache the ultimately valid keys.
    * src/parsecontroller.h: Update accordingly.

diff --git a/src/mail.cpp b/src/mail.cpp
index 42222f6..feb0ca4 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1388,28 +1388,81 @@ Mail::set_uuid()
   return 0;
 }
 
-/* Returns -1 if the mail was signed by a uid with ownertrust
-   ultimate and to which we have the secret key.
-   This basically means "mail was signed by yourself"
+/* Returns 1 if the userid is ultimately trusted.
 
-   Returns the number of the signature fromt the uid that belongs
-   made it ultimately or fully trusted if the mail was signed by some
-   ultimate key for which we don't have the secret key.
-   This is direct trust or CA Style PGP.
+   Returns 1 if the userid is fully trusted but has
+   a signature by a key for which we have a secret
+   and which is ultimately trusted. (Direct trust)
 
    0 otherwise */
 static int
 level_4_check (const UserID &uid)
 {
-  if (uid.validity() == UserID::Validity::Ultimate)
+  if (uid.isNull())
     {
-      /* TODO look for the signature that caused this
-         to be ultimate. And check if it is our own. */
-      return -1;
+      return 0;
     }
-  else if (uid.validity() == UserID::Validity::Full)
+  if (uid.validity () == UserID::Validity::Ultimate)
     {
-      return 1;
+      return 2;
+    }
+  if (uid.validity () == UserID::Validity::Full)
+    {
+      for (const auto sig: uid.signatures ())
+        {
+          const char *sigID = sig.signerKeyID ();
+          if (sig.isNull() || !sigID)
+            {
+              /* should not happen */
+              TRACEPOINT;
+              continue;
+            }
+          /* Direct trust information is not available
+             through gnupg so we cached the keys with ultimate
+             trust during parsing and now see if we find a direct
+             trust path.*/
+          for (const auto secKey: ParseController::get_ultimate_keys ())
+            {
+              /* Check that the Key id of the key matches */
+              const char *secKeyID = secKey.keyID ();
+              if (!secKeyID || strcmp (secKeyID, sigID))
+                {
+                  continue;
+                }
+              /* Check that the userID of the signature is the ultimately
+                 trusted one. */
+              const char *signed_uid_str = uid.id ();
+              if (!signed_uid_str)
+                {
+                  /* should not happen */
+                  TRACEPOINT;
+                  continue;
+                }
+              for (const auto signer_uid: secKey.userIDs ())
+                {
+                  if (signer_uid.validity() != UserID::Validity::Ultimate)
+                    {
+                      continue;
+                    }
+                  const char *signer_uid_str = uid.id ();
+                  if (!signer_uid_str)
+                    {
+                      /* should not happen */
+                      TRACEPOINT;
+                      continue;
+                    }
+                  if (!strcmp(signer_uid_str, signed_uid_str))
+                    {
+                      /* We have a match */
+                      log_debug ("%s:%s: classified %s as ultimate because "
+                                 "it was signed by uid %s of key %s",
+                                 SRCNAME, __func__, signed_uid_str, signer_uid_str,
+                                 secKeyID);
+                      return 1;
+                    }
+                }
+            }
+        }
     }
   return 0;
 }
@@ -1484,17 +1537,16 @@ Mail::get_crypto_details()
       /* level 4 check for direct trust */
       int four_check = level_4_check (m_uid);
 
-      if (four_check == -1)
+      if (four_check == 1 && m_sig.key().hasSecret ())
         {
           message = _("You signed this message.");
         }
-      else if (four_check >= 0)
+      else if (four_check == 1)
+        {
+          message = _("The sender is allowed to manage your mail trust.");
+        }
+      else if (four_check == 2)
         {
-          /* TODO
-            And you certified the identity of the sender.
-            And <uid with ultimate trust> certified the identity
-            of the sender.
-          */
           message = _("The senders identity was certified by yourself.");
         }
       else
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 2752fad..60e03a7 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -320,6 +320,13 @@ ParseController::parse()
   for (const auto sig: m_verify_result.signatures())
     {
       sig.key(true, true);
+      if (sig.validity() == Signature::Validity::Full ||
+          sig.validity() == Signature::Validity::Ultimate)
+        {
+          /* Ensure that we have the keys with ultimate
+             trust cached for the ui. */
+          get_ultimate_keys ();
+        }
     }
 
   if (opt.enable_debug)
@@ -401,3 +408,63 @@ ParseController::get_attachments() const
       return std::vector<std::shared_ptr<Attachment> >();
     }
 }
+
+GPGRT_LOCK_DEFINE(keylist_lock);
+/* static */
+std::vector<Key>
+ParseController::get_ultimate_keys()
+{
+  static bool s_keys_listed;
+  static std::vector<Key> s_ultimate_keys;
+  gpgrt_lock_lock (&keylist_lock);
+  if (s_keys_listed)
+    {
+      gpgrt_lock_unlock (&keylist_lock);
+      return s_ultimate_keys;
+    }
+  log_debug ("%s:%s: Starting keylisting.",
+             SRCNAME, __func__);
+  auto ctx = Context::createForProtocol (OpenPGP);
+  if (!ctx)
+    {
+      /* Maybe PGP broken and not S/MIME */
+      log_error ("%s:%s: broken installation no ctx.",
+                 SRCNAME, __func__);
+      gpgrt_lock_unlock (&keylist_lock);
+      return s_ultimate_keys;
+    }
+  ctx->setKeyListMode (KeyListMode::Local);
+  Error err;
+  if ((err = ctx->startKeyListing ()))
+    {
+      log_error ("%s:%s: Failed to start keylisting err: %i: %s",
+                 SRCNAME, __func__, err.code (), err.asString());
+      delete ctx;
+      gpgrt_lock_unlock (&keylist_lock);
+      return s_ultimate_keys;
+    }
+  while (!err)
+    {
+      const auto key = ctx->nextKey(err);
+      if (key.isNull() || err)
+        {
+          break;
+        }
+      for (const auto uid: key.userIDs())
+        {
+          if (uid.validity() == UserID::Validity::Ultimate)
+            {
+              s_ultimate_keys.push_back (key);
+              log_debug ("adding ultimate uid: %s", uid.id());
+              break;
+            }
+        }
+    }
+  delete ctx;
+  log_debug ("%s:%s: keylisting done.",
+             SRCNAME, __func__);
+
+  s_keys_listed = true;
+  gpgrt_lock_unlock (&keylist_lock);
+  return s_ultimate_keys;
+}
diff --git a/src/parsecontroller.h b/src/parsecontroller.h
index 19d622f..ec45982 100644
--- a/src/parsecontroller.h
+++ b/src/parsecontroller.h
@@ -61,6 +61,13 @@ public:
 
   ~ParseController();
 
+  /* Get a list of ultimately keys where at least one
+     userid has ultimate trust. This list
+     will be initialized only once when the first signature
+     is validity full or ultimate is encountered. */
+  static std::vector<GpgME::Key> get_ultimate_keys();
+
+
   /** Main entry point. After execution getters will become
   valid. */
   void parse();

-----------------------------------------------------------------------

Summary of changes:
 src/mail.cpp             | 92 +++++++++++++++++++++++++++++++++++++-----------
 src/parsecontroller.cpp  | 67 +++++++++++++++++++++++++++++++++++
 src/parsecontroller.h    |  7 ++++
 src/ribbon-callbacks.cpp | 37 ++++++++++++++++---
 4 files changed, 179 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list