diff --git a/src/config/config.js b/src/config/config.js index 78bb1f96..131205d3 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -40,6 +40,7 @@ export default { aead_protect: false, // use Authenticated Encryption with Additional Data (AEAD) protection for symmetric encryption integrity_protect: true, // use integrity protection for symmetric encryption ignore_mdc_error: false, // fail on decrypt if message is not integrity protected + checksum_required: false, // do not throw error when armor is missing a checksum rsa_blinding: true, use_native: true, // use native node.js crypto and Web Crypto apis (if available) zero_copy: false, // use transferable objects between the Web Worker and main thread diff --git a/src/encoding/armor.js b/src/encoding/armor.js index 9dcbe891..70eb8545 100644 --- a/src/encoding/armor.js +++ b/src/encoding/armor.js @@ -247,6 +247,9 @@ function splitChecksum(text) { if (lastEquals >= 0) { body = text.slice(0, lastEquals); checksum = text.slice(lastEquals + 1); + if (checksum.substr(0, 6) === '\n-----') { + checksum = ''; // missing armor checksum + } } return { body: body, checksum: checksum }; @@ -311,10 +314,9 @@ function dearmor(text) { checksum = checksum.substr(0, 4); - if (!verifyCheckSum(result.data, checksum)) { - throw new Error("Ascii armor integrity check on message failed: '" + - checksum + - "' should be '" + + if (!verifyCheckSum(result.data, checksum) && (checksum || config.checksum_required)) { + // will NOT throw error if checksum is empty AND checksum is not required (GPG compatibility) + throw new Error("Ascii armor integrity check on message failed: '" + checksum + "' should be '" + getCheckSum(result.data) + "'"); }