aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Brunschwig <[email protected]>2022-01-01 18:06:13 +0100
committerPatrick Brunschwig <[email protected]>2022-01-01 18:06:13 +0100
commitbce7f97b873aa2e6a42abad79f2629079ed9d8fe (patch)
tree8aaaaf0615063779e7e5daff979c953d03aa32ea
parent6480d0395866e6237a5d777b06952d1f87578f1c (diff)
downloadenigmail-bce7f97b873aa2e6a42abad79f2629079ed9d8fe.tar.gz
enigmail-bce7f97b873aa2e6a42abad79f2629079ed9d8fe.tar.bz2
enigmail-bce7f97b873aa2e6a42abad79f2629079ed9d8fe.zip
implemented remaining FIXMEs
-rw-r--r--package/cryptoAPI/pgpjs-crypto-main.jsm72
-rw-r--r--package/cryptoAPI/pgpjs-crypto-worker.js35
2 files changed, 66 insertions, 41 deletions
diff --git a/package/cryptoAPI/pgpjs-crypto-main.jsm b/package/cryptoAPI/pgpjs-crypto-main.jsm
index a391da25..634abe6c 100644
--- a/package/cryptoAPI/pgpjs-crypto-main.jsm
+++ b/package/cryptoAPI/pgpjs-crypto-main.jsm
@@ -49,16 +49,16 @@ var pgpjs_crypto = {
});
}
catch (ex) {
- EnigmailLog.DEBUG(`pgpjs-decrypt.jsm: processPgpMessage: ERROR: ${ex.toString()}\n`);
+ EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: processPgpMessage: ERROR: ${ex.toString()}\n`);
result.errorMsg = ex.toString();
result.exitCode = 1;
}
- return result;
+ return this.prepareResultText(result);
},
verify: async function(data, options) {
- EnigmailLog.DEBUG(`pgpjs-decrypt.jsm: verify(${data.length})\n`);
+ EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: verify(${data.length})\n`);
let result = {};
@@ -78,22 +78,22 @@ var pgpjs_crypto = {
}
}
catch (ex) {
- EnigmailLog.DEBUG(`pgpjs-decrypt.jsm: verify: ERROR: ${ex.toString()}\n`);
+ EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: verify: ERROR: ${ex.toString()}\n`);
result.errorMsg = ex.toString();
result.statusFlags = EnigmailConstants.UNVERIFIED_SIGNATURE;
}
- return result;
+ return this.prepareResultText(result);
},
verifyDetached: async function(data, signature, returnData = false) {
- EnigmailLog.DEBUG(`pgpjs-decrypt.jsm: verifyDetached(${data.length})\n`);
+ EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: verifyDetached(${data.length})\n`);
let result = await PgpJsWorkerParent.sendMessage("verifyDetached", {
data,
signature,
returnData
});
- return result;
+ return this.prepareResultText(result);
},
@@ -122,6 +122,8 @@ var pgpjs_crypto = {
let ret = await this.verifyDetached(data, sig, false);
+ ret = this.prepareResultText(ret);
+
if (ret.statusFlags & (EnigmailConstants.BAD_SIGNATURE | EnigmailConstants.UNVERIFIED_SIGNATURE)) {
throw ret.errorMsg ? ret.errorMsg : EnigmailLocale.getString("unverifiedSig") + " - " + EnigmailLocale.getString("msgSignedUnkownKey");
}
@@ -140,7 +142,7 @@ var pgpjs_crypto = {
* If null, message will not be signed.
*/
encryptData: async function(text, publicKeys, signingKey) {
- EnigmailLog.DEBUG(`pgpjs-encrypt.jsm: encryptData(${text.length})\n`);
+ EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: encryptData(${text.length})\n`);
const PgpJS = getOpenPGPLibrary();
let publicKeyPackets = new PgpJS.PacketList();
@@ -172,7 +174,7 @@ var pgpjs_crypto = {
* @param {Boolean} detachedSignature: Create a detached signature (true) or clearsigned message (false).
*/
signData: async function(text, signingKey, detachedSignature) {
- EnigmailLog.DEBUG(`pgpjs-encrypt.jsm: signData(${text.length})\n`);
+ EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: signData(${text.length})\n`);
const PgpJS = getOpenPGPLibrary();
@@ -187,6 +189,29 @@ var pgpjs_crypto = {
});
return result;
+ },
+
+ prepareResultText: function(resultData) {
+ if (resultData.statusMsg === "%MISSING_MDC") {
+ resultData.statusMsg = EnigmailLocale.getString("missingMdcError") + "\n";
+ }
+
+ let m = resultData.errorMsg.match(/^%(GOOD_SIG|BAD_SIG):(.*)/);
+ if (m && m.length >= 3) {
+ let str="";
+ switch (m[1]) {
+ case "GOOD_SIG":
+ str = "prefGood";
+ break;
+ case "BAD_SIG":
+ str = "prefBad";
+ break;
+ }
+
+ resultData.errorMsg = EnigmailLocale.getString(str, [m[2]]);
+ }
+
+ return resultData;
}
};
@@ -274,8 +299,35 @@ var WorkerRequestHandler = {
catch (x) {}
return PgpJS.armor(PgpJS.enums.armor.publicKey, packets.write());
- }
+ },
+ getKeydesc: function (pubKeyIds) {
+ EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: getKeydesc()\n`);
+ const EnigmailKeyRing = ChromeUtils.import("chrome://enigmail/content/modules/keyRing.jsm").EnigmailKeyRing;
+
+ if (pubKeyIds.length > 0) {
+ let encToArray = [];
+ // for each key also show an associated user ID if known:
+ for (let keyId of pubKeyIds) {
+ // except for ID 00000000, which signals hidden keys
+ if (keyId.search(/^0+$/) < 0) {
+ let localKey = EnigmailKeyRing.getKeyById("0x" + keyId);
+ if (localKey) {
+ encToArray.push(`0x${keyId} (${localKey.userId})`);
+ }
+ else {
+ encToArray.push(`0x${keyId}`);
+ }
+ }
+ else {
+ encToArray.push(EnigmailLocale.getString("hiddenKey"));
+ }
+ }
+ return "\n " + encToArray.join(",\n ") + "\n";
+ }
+
+ return "";
+ }
};
var pendingPromises = [];
diff --git a/package/cryptoAPI/pgpjs-crypto-worker.js b/package/cryptoAPI/pgpjs-crypto-worker.js
index 9be91f66..726e923d 100644
--- a/package/cryptoAPI/pgpjs-crypto-worker.js
+++ b/package/cryptoAPI/pgpjs-crypto-worker.js
@@ -107,7 +107,7 @@ var workerBody = {
let encToDetails = "";
try {
- encToDetails = getKeydesc(pubKeyIds);
+ encToDetails = await requestMessage("getKeydesc", pubKeyIds);
// get OpenPGP.js key objects for secret keys
let armoredSecretKeys = await requestMessage("getSecretKeysForIds", pubKeyIds);
@@ -188,7 +188,7 @@ var workerBody = {
catch (ex) {
if (("message" in ex) && ex.message.search(/(Message .*not authenticated|missing MDC|Modification detected)/) > 0) {
retData.statusFlags |= EnigmailConstants.MISSING_MDC;
- retData.statusMsg = "MDC ERROR\n"; // FIXME: EnigmailLocale.getString("missingMdcError") + "\n";
+ retData.statusMsg = "%MISSING_MDC";
}
else {
DEBUG_LOG(`decryptMessage: ERROR: ${ex.toString()}\n`);
@@ -468,10 +468,10 @@ var workerBody = {
}
if (result.statusFlags & EnigmailConstants.GOOD_SIGNATURE) {
- result.errorMsg = `Good signature from ${result.userId}`; // FIXME: EnigmailLocale.getString("prefGood", [result.userId]);
+ result.errorMsg = `%GOOD_SIG:${result.userId}`;
}
else if (result.statusFlags & EnigmailConstants.BAD_SIGNATURE) {
- result.errorMsg = `Invalid signature from ${result.userId}`; // FIXME: EnigmailLocale.getString("prefBad", [result.userId]);
+ result.errorMsg = `%BAD_SIG:${result.userId}`;
}
}
catch (ex) {
@@ -597,33 +597,6 @@ function readFromStream(reader) {
});
}
-function getKeydesc(pubKeyIds) {
- DEBUG_LOG(`getKeydesc()\n`);
- // const EnigmailKeyRing = ChromeUtils.import("chrome://enigmail/content/modules/keyRing.jsm").EnigmailKeyRing;
-
- // if (pubKeyIds.length > 0) {
- // let encToArray = [];
- // // for each key also show an associated user ID if known:
- // for (let keyId of pubKeyIds) {
- // // except for ID 00000000, which signals hidden keys
- // if (keyId.search(/^0+$/) < 0) {
- // let localKey = EnigmailKeyRing.getKeyById("0x" + keyId);
- // if (localKey) {
- // encToArray.push(`0x${keyId} (${localKey.userId})`);
- // }
- // else {
- // encToArray.push(`0x${keyId}`);
- // }
- // }
- // else {
- // encToArray.push(EnigmailLocale.getString("hiddenKey"));
- // }
- // }
- // return "\n " + encToArray.join(",\n ") + "\n";
- // }
-
- return "";
-}
function getReturnObj() {
return {