Browse Source

Prepare add-on for JSON-183: Not to protect subject for PGP partners if applicable.

master
Jörg Knobloch 9 months ago
parent
commit
7b603eecf8
5 changed files with 52 additions and 4 deletions
  1. +2
    -0
      addon/content/dialogs/options.js
  2. +15
    -0
      addon/content/modules/pEp.js
  3. +21
    -1
      addon/content/modules/pEpAdapter.js
  4. +3
    -0
      addon/content/pEpForThunderbird.js
  5. +11
    -3
      addon/content/pepmessengercompose.js

+ 2
- 0
addon/content/dialogs/options.js View File

@ -65,8 +65,10 @@ var pEpOptions = {
protectSubjectsChange() {
if (Services.prefs.getBoolPref("extensions.pEp.protectSubjects", true)) {
pEpController.enableprotectSubjects();
pEpController.protectSubjects = true;
} else {
pEpController.disableprotectSubjects();
pEpController.protectSubjects = false;
}
},


+ 15
- 0
addon/content/modules/pEp.js View File

@ -116,6 +116,21 @@ class pEp {
return this.adapter.outgoing_message_rating(message, preview);
}
async getOutgoingRatingWithPartnerInfo(from, to = [], cc) {
this.log.info("getOutgoingRatingWithPartnerInfo: ", from, to, cc);
if (to.length == 0 && (!cc || cc.length == 0)) return { rating: 0, onlyPEP: false };
const msgId = PEP_PREFIX + String(this.requestId++);
const message = new pEp.Message(msgId, "test", "test", from, to);
if (cc) {
message.setCc(cc);
}
return this.adapter.outgoing_message_rating_with_partner_info(message);
}
async cache_mime_decode_message(message) {
return this.adapter.cache_mime_decode_message(message, message.length);
}


+ 21
- 1
addon/content/modules/pEpAdapter.js View File

@ -9,6 +9,7 @@ const API_METHOD_CACHE_ENCRYPT_MESSAGE = "cache_encrypt_message";
const API_METHOD_CACHE_ENCRYPT_MESSAGE_FOR_SELF = "cache_encrypt_message_for_self";
const API_METHOD_OUTGOING_MESSAGE_RATING = "outgoing_message_rating";
const API_METHOD_OUTGOING_MESSAGE_RATING_PREVIEW = "outgoing_message_rating_preview";
const API_METHOD_OUTGOING_MESSAGE_RATING_WPI = "outgoing_message_rating_with_partner_info";
const API_METHOD_RE_EVALUATE_MESSAGE_RATING = "re_evaluate_message_rating";
const API_METHOD_IDENTITY_RATING = "identity_rating";
const API_METHOD_CACHE_MIME_DECODE_MESSAGE = "cache_mime_decode_message";
@ -157,7 +158,7 @@ class pEpAdapter {
async outgoing_message_rating(message, preview) {
this.log.info("pEpAdapter.js: outgoing_message_rating()");
const params = [message, "0"];
const params = [message, "OUT"];
return this.delegateCallPepAdapter(
SERVER_TYPE_CALL_FUNC,
preview ? API_METHOD_OUTGOING_MESSAGE_RATING_PREVIEW : API_METHOD_OUTGOING_MESSAGE_RATING,
@ -174,6 +175,25 @@ class pEpAdapter {
});
}
async outgoing_message_rating_with_partner_info(message) {
this.log.info("pEpAdapter.js: outgoing_message_rating_with_partner_info()");
const params = [message, "OUT", "OUT"];
return this.delegateCallPepAdapter(
SERVER_TYPE_CALL_FUNC,
API_METHOD_OUTGOING_MESSAGE_RATING_WPI,
params,
).then((response) => {
this.log.debug("pEpAdapter.js: outgoing_message_rating_with_partner_info()", response);
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
this.log.error(`returned status ${response.result.return.status}`);
}
return { rating: response.result.outParams[1].rating, onlyPEP: response.result.outParams[0] };
}).catch((err) => {
this.log.error(err.message);
throw err;
});
}
async re_evaluate_message_rating(message, keyList, oldRating) {
this.log.info("pEpAdapter.js: re_evaluate_message_rating()");
const params = [message, keyList, { rating: oldRating }, "OUT"];


+ 3
- 0
addon/content/pEpForThunderbird.js View File

@ -59,6 +59,7 @@ class pEpForThunderbird extends pEp {
this.newMessageKeys = [];
this.pollSession = null;
this.clientID = null;
this.protectSubjects = true;
this.MOZ_APP_VERSION = parseInt(AppConstants.MOZ_APP_VERSION, 10);
this.platform = AppConstants.platform;
@ -128,8 +129,10 @@ class pEpForThunderbird extends pEp {
// Setup protect subjects at startup
if (Services.prefs.getBoolPref("extensions.pEp.protectSubjects", true)) {
this.enableprotectSubjects();
this.protectSubjects = true;
} else {
this.disableprotectSubjects();
this.protectSubjects = false;
}
// Import keys from RNP starting at Thunderbird 78.


+ 11
- 3
addon/content/pepmessengercompose.js View File

@ -554,9 +554,17 @@ var pEpComposer = {
// This is a hack. We tell the engine whether we want protected subjects,
// but when we pass the MIME tree back in pEpMimeEncrypt.js, the engine-provided
// headers are just ignored. So we manipulate the header here manually which isn't ideal.
// We always hide the subject, even if the user chose not to protect subjects for
// PGP communication partners. To be revisited once JSON-183 is implemented.
compFields.subject = PEP_ENCRYPTED_SUBJECT;
if (true || pEpController.protectSubjects) { // else branch disabled pending JSON-183.
// We unconditionally replace the subject.
compFields.subject = PEP_ENCRYPTED_SUBJECT;
} else {
// We need to check whether there are any non-pEp comm partners.
let { dummy, onlyPEP } = pEpController.synchronise(
// eslint-disable-next-line comma-dangle
pEpController.getOutgoingRatingWithPartnerInfo(compSec.fromSender, compSec.toRecipients, compSec.ccRecipients)
);
if (onlyPEP) compFields.subject = PEP_ENCRYPTED_SUBJECT;
}
}
}
},


Loading…
Cancel
Save