fix #706 - if ignore_mdc_error is set to false then MDC is required for all symmetrically encrypted data
This commit is contained in:
parent
6efcce1069
commit
33d5b158f8
|
@ -77,12 +77,9 @@ SymmetricallyEncrypted.prototype.write = function () {
|
||||||
*/
|
*/
|
||||||
SymmetricallyEncrypted.prototype.decrypt = async function (sessionKeyAlgorithm, key) {
|
SymmetricallyEncrypted.prototype.decrypt = async function (sessionKeyAlgorithm, key) {
|
||||||
const decrypted = crypto.cfb.decrypt(sessionKeyAlgorithm, key, this.encrypted, true);
|
const decrypted = crypto.cfb.decrypt(sessionKeyAlgorithm, key, this.encrypted, true);
|
||||||
// for modern cipher (blocklength != 64 bit, except for Twofish) MDC is required
|
// If MDC errors are not being ignored, all missing MDC packets in symmetrically encrypted data should throw an error
|
||||||
if (!this.ignore_mdc_error &&
|
if (!this.ignore_mdc_error) {
|
||||||
(sessionKeyAlgorithm === 'aes128' ||
|
throw new Error('Decryption failed due to missing MDC.');
|
||||||
sessionKeyAlgorithm === 'aes192' ||
|
|
||||||
sessionKeyAlgorithm === 'aes256')) {
|
|
||||||
throw new Error('Decryption failed due to missing MDC in combination with modern cipher.');
|
|
||||||
}
|
}
|
||||||
this.packets.read(decrypted);
|
this.packets.read(decrypted);
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ describe("Packet", function() {
|
||||||
|
|
||||||
const msg2 = new openpgp.packet.List();
|
const msg2 = new openpgp.packet.List();
|
||||||
msg2.read(message.write());
|
msg2.read(message.write());
|
||||||
await expect(msg2[0].decrypt(algo, key)).to.eventually.be.rejectedWith('Decryption failed due to missing MDC in combination with modern cipher.');
|
await expect(msg2[0].decrypt(algo, key)).to.eventually.be.rejectedWith('Decryption failed due to missing MDC.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sym. encrypted integrity protected packet', async function() {
|
it('Sym. encrypted integrity protected packet', async function() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user