aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Brunschwig <[email protected]>2022-01-05 07:47:29 +0100
committerPatrick Brunschwig <[email protected]>2022-01-05 07:47:29 +0100
commit779cfd561dc71645262035a031b10a01c9c90983 (patch)
treeb6c3b2a143c1c7469d05f31a0eaab6c2496feb62
parentae37aedf2fdeb84cef88b3f619735884bdd8d85f (diff)
downloadenigmail-779cfd561dc71645262035a031b10a01c9c90983.tar.gz
enigmail-779cfd561dc71645262035a031b10a01c9c90983.tar.bz2
enigmail-779cfd561dc71645262035a031b10a01c9c90983.zip
fixed failed test cases
-rw-r--r--package/cryptoAPI/pgpjs-crypto-main.jsm59
-rw-r--r--package/cryptoAPI/pgpjs-crypto-worker.js2
-rw-r--r--package/tests/pgpjs-crypto-test.js6
3 files changed, 35 insertions, 32 deletions
diff --git a/package/cryptoAPI/pgpjs-crypto-main.jsm b/package/cryptoAPI/pgpjs-crypto-main.jsm
index 131a5b09..7d37e5fe 100644
--- a/package/cryptoAPI/pgpjs-crypto-main.jsm
+++ b/package/cryptoAPI/pgpjs-crypto-main.jsm
@@ -60,13 +60,14 @@ var pgpjs_crypto = {
verify: async function(data, options) {
EnigmailLog.DEBUG(`pgpjs-crypto-main.jsm: verify(${data.length})\n`);
- let result = {};
+ let result = {
+ statusFlags: 0,
+ exitCode: 1,
+ decryptedData: ""
+ };
let blocks = EnigmailArmor.locateArmoredBlocks(data);
- result.statusFlags = 0;
- result.exitCode = 1;
-
try {
if (blocks && blocks.length > 0) {
if (blocks[0].blocktype === "SIGNED MESSAGE") {
@@ -198,14 +199,14 @@ var pgpjs_crypto = {
let m = resultData.errorMsg.match(/^%(GOOD_SIG|BAD_SIG):(.*)/);
if (m && m.length >= 3) {
- let str="";
+ let str = "";
switch (m[1]) {
- case "GOOD_SIG":
- str = "prefGood";
- break;
- case "BAD_SIG":
- str = "prefBad";
- break;
+ case "GOOD_SIG":
+ str = "prefGood";
+ break;
+ case "BAD_SIG":
+ str = "prefBad";
+ break;
}
resultData.errorMsg = EnigmailLocale.getString(str, [m[2]]);
@@ -305,30 +306,30 @@ var WorkerRequestHandler = {
return "";
},
- getKeydesc: function (pubKeyIds) {
+ 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}`);
- }
+ 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(EnigmailLocale.getString("hiddenKey"));
+ encToArray.push(`0x${keyId}`);
}
}
- return "\n " + encToArray.join(",\n ") + "\n";
+ else {
+ encToArray.push(EnigmailLocale.getString("hiddenKey"));
+ }
}
+ return "\n " + encToArray.join(",\n ") + "\n";
+ }
return "";
}
diff --git a/package/cryptoAPI/pgpjs-crypto-worker.js b/package/cryptoAPI/pgpjs-crypto-worker.js
index e71caea3..188d9341 100644
--- a/package/cryptoAPI/pgpjs-crypto-worker.js
+++ b/package/cryptoAPI/pgpjs-crypto-worker.js
@@ -212,6 +212,7 @@ var workerBody = {
result.statusFlags = 0;
result.exitCode = 1;
+ result.decryptedData = "";
try {
let msg = await PgpJS.readCleartextMessage({
@@ -289,6 +290,7 @@ var workerBody = {
return {
exitCode: 1,
statusFlags: EnigmailConstants.NO_PUBKEY,
+ decryptedData: "",
errorMsg: ex.toString()
};
}
diff --git a/package/tests/pgpjs-crypto-test.js b/package/tests/pgpjs-crypto-test.js
index fe210ca7..1d7a5277 100644
--- a/package/tests/pgpjs-crypto-test.js
+++ b/package/tests/pgpjs-crypto-test.js
@@ -45,7 +45,7 @@ test(withTestGpgHome(asyncTest(async function testDecrypt() {
let pgpMsg = EnigmailArmor.splitArmoredBlocks(fileData)[0];
let result = await pgpjs_crypto.processPgpMessage(pgpMsg, {});
- Assert.equal(result.statusFlags, EnigmailConstants.DECRYPTION_FAILED);
+ Assert.equal(result.statusFlags, EnigmailConstants.DECRYPTION_FAILED | EnigmailConstants.NO_SECKEY);
const pubKeyFile = do_get_file("resources/dev-strike.sec", false);
fileData = EnigmailFiles.readBinaryFile(pubKeyFile);
@@ -194,7 +194,7 @@ iD8DBQE+yUcu4mZch0nhy8kRAuh/AKDM1Xc49BKVfJIFg/btWGfbF/pgcwCgw0Zk
`;
result = await pgpjs_crypto.verify(packetV3, {});
- Assert.equal(result.statusFlags, EnigmailConstants.UNVERIFIED_SIGNATURE);
+ Assert.equal(result.statusFlags, EnigmailConstants.NO_PUBKEY);
Assert.equal(result.exitCode, 1);
Assert.equal(result.decryptedData, "");
}
@@ -216,7 +216,7 @@ test(withTestGpgHome(asyncTest(async function testVerifyFile() {
Assert.ok(false, "Should not obtain a valid verification");
}
catch (err) {
- Assert.assertContains(String(err), "Error during parsing");
+ Assert.assertContains(String(err), "Unverified signature - signed with unknown key");
}
let keyData = EnigmailFiles.readBinaryFile(pubKeyFile);