Bug 1675285 - OpenPGP: Composer key status should list undecided/rejected keys. r=PatrickBrunschwig a=wsmwk
Differential Revision:
https://phabricator.services.mozilla.com/D95859
--- 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);