diff --git a/src/encoding/armor.js b/src/encoding/armor.js index daff2d4d..0e0aa5ae 100644 --- a/src/encoding/armor.js +++ b/src/encoding/armor.js @@ -128,24 +128,21 @@ function verifyHeaders(headers) { } /** - * Splits a message into two parts, the body and the checksum. This is an internal function - * @param {String} text - OpenPGP armored message part - * @returns {Object} An object with attribute "body" containing the body. - * and an attribute "checksum" containing the checksum. + * Remove the (optional) checksum from an armored message. + * @param {String} text - OpenPGP armored message + * @returns {String} The body of the armored message. * @private */ -function splitChecksum(text) { +function removeChecksum(text) { let body = text; - let checksum = ''; const lastEquals = text.lastIndexOf('='); if (lastEquals >= 0 && lastEquals !== text.length - 1) { // '=' as the last char means no checksum body = text.slice(0, lastEquals); - checksum = text.slice(lastEquals + 1).substr(0, 4); } - return { body: body, checksum: checksum }; + return body; } /** @@ -157,7 +154,7 @@ function splitChecksum(text) { * @async * @static */ -export function unarmor(input, config = defaultConfig) { +export function unarmor(input) { // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { try { @@ -170,8 +167,7 @@ export function unarmor(input, config = defaultConfig) { let headersDone; let text = []; let textDone; - let checksum; - let data = base64.decode(stream.transformPair(input, async (readable, writable) => { + const data = base64.decode(stream.transformPair(input, async (readable, writable) => { const reader = stream.getReader(readable); try { while (true) { @@ -236,9 +232,8 @@ export function unarmor(input, config = defaultConfig) { if (parts.length === 1) { throw new Error('Misformed armored text'); } - const split = splitChecksum(parts[0].slice(0, -1)); - checksum = split.checksum; - await writer.write(split.body); + const body = removeChecksum(parts[0].slice(0, -1)); + await writer.write(body); break; } } diff --git a/src/message.js b/src/message.js index 44d69a1c..2ce9f627 100644 --- a/src/message.js +++ b/src/message.js @@ -245,8 +245,8 @@ export class Message { const serialisedPKESK = pkeskPacket.write(); // make copies to be able to decrypt the PKESK packet multiple times await Promise.all(( expectedSymmetricAlgorithm ? - [expectedSymmetricAlgorithm] : - Array.from(config.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms) + [expectedSymmetricAlgorithm] : + Array.from(config.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms) ).map(async sessionKeyAlgorithm => { const pkeskPacketCopy = new PublicKeyEncryptedSessionKeyPacket(); pkeskPacketCopy.read(serialisedPKESK); diff --git a/src/packet/padding.js b/src/packet/padding.js index b60e1e4b..567ef2e5 100644 --- a/src/packet/padding.js +++ b/src/packet/padding.js @@ -37,7 +37,7 @@ class PaddingPacket { * Read a padding packet * @param {Uint8Array | ReadableStream} bytes */ - read(bytes) { + read(bytes) { // eslint-disable-line no-unused-vars // Padding packets are ignored, so this function is never called. } diff --git a/src/packet/sym_encrypted_integrity_protected_data.js b/src/packet/sym_encrypted_integrity_protected_data.js index 1718e214..8aedf18d 100644 --- a/src/packet/sym_encrypted_integrity_protected_data.js +++ b/src/packet/sym_encrypted_integrity_protected_data.js @@ -72,7 +72,7 @@ class SymEncryptedIntegrityProtectedDataPacket { this.version = await reader.readByte(); // - A one-octet version number with value 1 or 2. if (this.version !== 1 && this.version !== 2) { - throw new UnsupportedError(`Version ${version} of the SEIP packet is unsupported.`); + throw new UnsupportedError(`Version ${this.version} of the SEIP packet is unsupported.`); } if (this.version === 2) {