do not fail when missing armor checksum | #563
This commit is contained in:
parent
b3077235f9
commit
c27725782c
|
@ -40,6 +40,7 @@ export default {
|
||||||
aead_protect: false, // use Authenticated Encryption with Additional Data (AEAD) protection for symmetric encryption
|
aead_protect: false, // use Authenticated Encryption with Additional Data (AEAD) protection for symmetric encryption
|
||||||
integrity_protect: true, // use integrity 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
|
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,
|
rsa_blinding: true,
|
||||||
use_native: true, // use native node.js crypto and Web Crypto apis (if available)
|
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
|
zero_copy: false, // use transferable objects between the Web Worker and main thread
|
||||||
|
|
|
@ -247,6 +247,9 @@ function splitChecksum(text) {
|
||||||
if (lastEquals >= 0) {
|
if (lastEquals >= 0) {
|
||||||
body = text.slice(0, lastEquals);
|
body = text.slice(0, lastEquals);
|
||||||
checksum = text.slice(lastEquals + 1);
|
checksum = text.slice(lastEquals + 1);
|
||||||
|
if (checksum.substr(0, 6) === '\n-----') {
|
||||||
|
checksum = ''; // missing armor checksum
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { body: body, checksum: checksum };
|
return { body: body, checksum: checksum };
|
||||||
|
@ -311,10 +314,9 @@ function dearmor(text) {
|
||||||
|
|
||||||
checksum = checksum.substr(0, 4);
|
checksum = checksum.substr(0, 4);
|
||||||
|
|
||||||
if (!verifyCheckSum(result.data, checksum)) {
|
if (!verifyCheckSum(result.data, checksum) && (checksum || config.checksum_required)) {
|
||||||
throw new Error("Ascii armor integrity check on message failed: '" +
|
// will NOT throw error if checksum is empty AND checksum is not required (GPG compatibility)
|
||||||
checksum +
|
throw new Error("Ascii armor integrity check on message failed: '" + checksum + "' should be '" +
|
||||||
"' should be '" +
|
|
||||||
getCheckSum(result.data) + "'");
|
getCheckSum(result.data) + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user