do not fail when missing armor checksum | #563

This commit is contained in:
Tom James Holub 2017-07-21 10:13:33 -07:00
parent b3077235f9
commit c27725782c
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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) + "'");
}