Bug 1675285 - OpenPGP: Composer key status should list undecided/rejected keys. r=PatrickBrunschwig a=wsmwk
authorKai Engert <kaie@kuix.de>
Wed, 04 Nov 2020 15:54:09 +0100
changeset 40035 d2373639e30fcf38ec44ffa01dc46b6859f2d566
parent 40034 d946f1c609c5deec01b82cebd11a551b38eb48c9
child 40036 eec8c8a0d2e3ddb5103aba3a6db6dc19ba4aaaf2
push id106
push userkaie@kuix.de
push dateFri, 13 Nov 2020 10:41:12 +0000
treeherdercomm-esr78@eec8c8a0d2e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPatrickBrunschwig, wsmwk
bugs1675285
Bug 1675285 - OpenPGP: Composer key status should list undecided/rejected keys. r=PatrickBrunschwig a=wsmwk Differential Revision: https://phabricator.services.mozilla.com/D95859
mail/extensions/openpgp/content/modules/keyRing.jsm
--- a/mail/extensions/openpgp/content/modules/keyRing.jsm
+++ b/mail/extensions/openpgp/content/modules/keyRing.jsm
@@ -1007,35 +1007,16 @@ var EnigmailKeyRing = {
     if (!uidMatch) {
       return -2;
     }
     // key valid for encryption?
     if (!keyObj.keyUseFor.includes("E")) {
       return -2;
     }
 
-    let acceptanceLevel;
-    if (keyObj.secretAvailable) {
-      let isPersonal = await PgpSqliteDb2.isAcceptedAsPersonalKey(keyObj.fpr);
-      if (isPersonal) {
-        acceptanceLevel = 3;
-      } else {
-        acceptanceLevel = -1; // rejected
-      }
-    } else {
-      acceptanceLevel = await this.getKeyAcceptanceLevelForEmail(
-        keyObj,
-        emailAddr
-      );
-    }
-
-    if (acceptanceLevel < 1) {
-      return acceptanceLevel;
-    }
-
     // Ensure we have at least one key usable for encryption
     // that is not expired/revoked.
 
     // We already checked above, the primary key is not revoked/expired
     let foundGoodEnc = keyObj.keyUseFor.match(/e/);
     if (!foundGoodEnc) {
       for (let aSub of keyObj.subKeys) {
         switch (aSub.keyTrust) {
@@ -1049,16 +1030,31 @@ var EnigmailKeyRing = {
         }
       }
     }
 
     if (!foundGoodEnc) {
       return -2;
     }
 
+    let acceptanceLevel;
+    if (keyObj.secretAvailable) {
+      let isPersonal = await PgpSqliteDb2.isAcceptedAsPersonalKey(keyObj.fpr);
+      if (isPersonal) {
+        acceptanceLevel = 3;
+      } else {
+        acceptanceLevel = -1; // rejected
+      }
+    } else {
+      acceptanceLevel = await this.getKeyAcceptanceLevelForEmail(
+        keyObj,
+        emailAddr
+      );
+    }
+
     return acceptanceLevel;
   },
 
   /**
    * try to find valid key for encryption to passed email address
    *
    * @param details if not null returns error in details.msg
    *
@@ -1286,17 +1282,17 @@ var EnigmailKeyRing = {
     let k = this.getAllKeys(null, null);
     let keyList = k.keyList;
 
     for (let keyObj of keyList) {
       let acceptanceLevel = await this.isValidKeyForRecipient(
         keyObj,
         emailAddr
       );
-      if (acceptanceLevel < 1) {
+      if (acceptanceLevel < -1) {
         continue;
       }
       if (!keyObj.secretAvailable) {
         keyObj.acceptance = this.getAcceptanceStringFromAcceptanceLevel(
           acceptanceLevel
         );
       }
       found.push(keyObj);