[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: [PATCH] Allow multiple keys per adress for encryption
From:       Ingo =?iso-8859-1?q?Kl=F6cker?= <ingo.kloecker () epost ! de>
Date:       2001-12-31 12:32:28
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 31 December 2001 12:35, Wolfgang Westphal wrote:
> Hi!
>
> I attached a little patch for libkdenetwork.
>
> I need to be able to encrypt messages to one adress with several PGP
> keys at once. So I modified kpgp that is now possible to assign more
> than one key to an email address. The key selection dialog presented
> to select the encryption keys now got extended selection mode (the
> default still is single selection though).
>
> Just have a look, maybe you find it useful.

Thanks for the patch! I'll have a look at it.

After having a first look at the patch I have a few remarks/suggestions:
- - Yesterday I commited several changes to getPublicKey. Please add these 
changes (validity and trust checking of keys, disable reloading of key 
list, changed strings) to the new getPublicKeys. (I've attached the 
relevant hunks.)
- - It makes sense to use selectKeys also for attaching several public 
keys at once (and later maybe also for certifying several keys at 
once). Therefore you should generalize this function (similar to 
selectKey).

Otherwise it looks pretty good.

Regards,
Ingo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8MFrcGnR+RTDgudgRAju9AKChQp5dXgUblpuDmfXw+0M75Wp80ACfYrm0
h2yo+aSDV+rW4bU2niYV5Z0=
=81TN
-----END PGP SIGNATURE-----

["getPublicKey.diff" (text/x-diff)]

@@ -676,12 +694,16 @@ Module::getPublicKey(const QString& pers
   // First look for this person in the address->key dictionary
   if ( addressKeyDict.contains(person) )
   {
-    QCString keyID = addressKeyDict[person];
-    kdDebug(5100) << "Trying key 0x" << keyID << " for " << person << endl;
+    QCString keyId = addressKeyDict[person];
+    kdDebug(5100) << "Trying key 0x" << keyId << " for " << person << endl;
 
-    // Check if we still have the key with this key id
-    Key *key;
-    if ( (key = publicKey(keyID)) != 0 )
+    // Check if we still have the key with this key id and if the key is
+    // a trusted and valid encryption key
+    keyTrust( keyId ); // this is called to make sure that the trust info
+                       // for this key is read
+    Key *key = publicKey( keyId );
+    if( ( key != 0 ) && ( key->isValidEncryptionKey() ) &&
+        ( key->keyTrust() >= KPGP_VALIDITY_MARGINAL ) )
       return key;
     else
       removeKeyForAddress(person);
@@ -691,14 +713,19 @@ Module::getPublicKey(const QString& pers
   KeyListIterator it(publicKeys);
   KeyList matchingKeys;
 
-  for (int tries = 0; tries < 2; ++tries)
+  //for (int tries = 0; tries < 2; ++tries)
   {
     // search all keys which match the complete address
     for (it.toFirst(); (*it); ++it)
-      // search case insensitively for person in the list of userIDs of
-      // this key
+      // search case insensitively in the list of userIDs of this key
       if((*it)->matchesUserID(person, false))
-        matchingKeys.append(*it);
+      {
+        keyTrust( (*it)->primaryKeyID() ); // this is called to make sure that
+                                           // the trust info for this key is read
+        if( ( (*it)->isValidEncryptionKey() ) &&
+            ( (*it)->keyTrust() >= KPGP_VALIDITY_MARGINAL ) )
+          matchingKeys.append(*it);
+      }
 
     // if no keys match the complete address look for keys which match
     // the canonical mail address
@@ -706,19 +733,24 @@ Module::getPublicKey(const QString& pers
     {
       QString address = canonicalAdress(person);
       for (it.toFirst(); (*it); ++it)
-        // search case insensitively for address in the list of userIDs of
-        // this key
+        // search case insensitively in the list of userIDs of this key
         if((*it)->matchesUserID(address, false))
-          matchingKeys.append(*it);
+        {
+          keyTrust( (*it)->primaryKeyID() ); // this is called to make sure that
+                                             // the trust info for this key is read
+          if( ( (*it)->isValidEncryptionKey() ) &&
+              ( (*it)->keyTrust() >= KPGP_VALIDITY_MARGINAL ) )
+            matchingKeys.append(*it);
+        }
     }
 
-    if (!matchingKeys.isEmpty())
-      break;
+    //if (!matchingKeys.isEmpty())
+    //  break;
 
     // reread the database, because no matching key was found...
     // FIXME: Add a "Re-read keys" option to the key selection dialog
-    if ( tries == 0 )
-      readPublicKeys( true );
+    //if ( tries == 0 )
+    //  readPublicKeys( true );
   }
 
   // no match until now, let the user choose the key
@@ -726,17 +758,18 @@ Module::getPublicKey(const QString& pers
   {
     // FIXME: let user set the key/ get from keyserver
     bool rememberChoice;
-    QCString keyID = selectKey( rememberChoice, publicKeys,
+    QCString keyId = selectKey( rememberChoice, publicKeys,
                                 i18n("Encryption Key Selection"),
-                                i18n("No OpenPGP key was found for \"%1\".\n\n"
+                                i18n("No valid and trusted OpenPGP key was "
+                                     "found for \"%1\".\n\n"
                                      "Select the key which should "
                                      "be used for this recipient."
                                      ).arg(person));
-    if (!keyID.isEmpty())
+    if (!keyId.isEmpty())
     {
       if (rememberChoice)
-        storeKeyForAddress ( person, keyID );
-      return publicKey( keyID );
+        storeKeyForAddress ( person, keyId );
+      return publicKey( keyId );
     }
   }
   // only one key matches
@@ -748,17 +781,17 @@ Module::getPublicKey(const QString& pers
   else
   {
     bool rememberChoice;
-    QCString keyID = selectKey( rememberChoice, matchingKeys,
+    QCString keyId = selectKey( rememberChoice, matchingKeys,
                                 i18n("Encryption Key Selection"),
                                 i18n("More than one key match \"%1\".\n\n"
                                      "Select the key which should "
                                      "be used for this recipient."
                                      ).arg(person));
-    if (!keyID.isEmpty())
+    if (!keyId.isEmpty())
     {
       if (rememberChoice)
-        storeKeyForAddress ( person, keyID );
-      return publicKey( keyID );
+        storeKeyForAddress ( person, keyId );
+      return publicKey( keyId );
     }
   }
 

_______________________________________________
kmail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic