diff --git a/src/backupformat/rsync.js b/src/backupformat/rsync.js index 0af5d114b..19d61671d 100644 --- a/src/backupformat/rsync.js +++ b/src/backupformat/rsync.js @@ -196,7 +196,7 @@ async function downloadDir(backupConfig, backupFilePath, dataLayout, progressCal assert(dataLayout instanceof DataLayout, 'dataLayout must be a DataLayout'); assert.strictEqual(typeof progressCallback, 'function'); - debug(`downloadDir: ${backupFilePath} to ${dataLayout.toString()}`); + debug(`downloadDir: ${backupFilePath} to ${dataLayout.toString()}. encryption filenames: ${backupConfig.encryptedFilenames} content: ${backupConfig.encryption}`); async function downloadFile(entry) { let relativePath = path.relative(backupFilePath, entry.fullPath); diff --git a/src/backuptask.js b/src/backuptask.js index d4acfc54b..91ed433cf 100644 --- a/src/backuptask.js +++ b/src/backuptask.js @@ -99,7 +99,7 @@ async function download(backupConfig, remotePath, format, dataLayout, progressCa assert(dataLayout instanceof DataLayout, 'dataLayout must be a DataLayout'); assert.strictEqual(typeof progressCallback, 'function'); - debug(`download: Downloading ${remotePath} of format ${format} to ${dataLayout.toString()}`); + debug(`download: Downloading ${remotePath} of format ${format} (encrypted: ${!!backupConfig.encryption}) to ${dataLayout.toString()}`); await backupFormat.api(format).download(backupConfig, remotePath, dataLayout, progressCallback); } @@ -120,7 +120,7 @@ async function restore(backupConfig, remotePath, progressCallback) { await database.importFromFile(`${dataLayout.localRoot()}/box.mysqldump`); debug('restore: database imported'); - await locks.releaseAll(); + await locks.releaseAll(); // clear the locks table in database } async function downloadApp(app, restoreConfig, progressCallback) { diff --git a/src/hush.js b/src/hush.js index 63b3b97ff..11d7b1d88 100644 --- a/src/hush.js +++ b/src/hush.js @@ -70,7 +70,7 @@ class DecryptStream extends TransformStream { this._header = Buffer.concat([this._header, chunk.subarray(0, needed)]); if (this._header.length !== 20) return callback(); - if (!this._header.subarray(0, 4).equals(new Buffer.from('CBV2'))) return callback(new BoxError(BoxError.CRYPTO_ERROR, 'Invalid magic in header')); + if (!this._header.subarray(0, 4).equals(new Buffer.from('CBV2'))) return callback(new BoxError(BoxError.CRYPTO_ERROR, 'Decryption error. Invalid magic in header')); const iv = this._header.subarray(4); this._decipher = crypto.createDecipheriv('aes-256-cbc', this._key, iv); @@ -87,20 +87,20 @@ class DecryptStream extends TransformStream { this._buffer = this._buffer.subarray(-32); callback(null, plainText); } catch (error) { - callback(new BoxError(BoxError.CRYPTO_ERROR, `Decryption error: ${error.message}`)); + callback(new BoxError(BoxError.CRYPTO_ERROR, `Decryption error. ${error.message}`)); } } _flush (callback) { - if (this._buffer.length !== 32) return callback(new BoxError(BoxError.CRYPTO_ERROR, 'Invalid password or tampered file (not enough data)')); + if (this._buffer.length !== 32) return callback(new BoxError(BoxError.CRYPTO_ERROR, 'Decryption error. Invalid password or tampered file (not enough data)')); try { - if (!this._hmac.digest().equals(this._buffer)) return callback(new BoxError(BoxError.CRYPTO_ERROR, 'Invalid password or tampered file (mac mismatch)')); + if (!this._hmac.digest().equals(this._buffer)) return callback(new BoxError(BoxError.CRYPTO_ERROR, 'Decryption error. Invalid password or tampered file (mac mismatch)')); const plainText = this._decipher.final(); callback(null, plainText); } catch (error) { - callback(new BoxError(BoxError.CRYPTO_ERROR, `Invalid password or tampered file: ${error.message}`)); + callback(new BoxError(BoxError.CRYPTO_ERROR, `Decryption error. Invalid password or tampered file: ${error.message}`)); } } } @@ -140,12 +140,12 @@ function decryptFilePath(filePath, encryption) { const plainText = decrypt.update(buffer.subarray(16)); const plainTextString = Buffer.concat([ plainText, decrypt.final() ]).toString('utf8'); const hmac = crypto.createHmac('sha256', Buffer.from(encryption.filenameHmacKey, 'hex')); - if (!hmac.update(plainTextString).digest().subarray(0, 16).equals(iv)) return { error: new BoxError(BoxError.CRYPTO_ERROR, `mac error decrypting part ${part} of path ${filePath}`) }; + if (!hmac.update(plainTextString).digest().subarray(0, 16).equals(iv)) return { error: new BoxError(BoxError.CRYPTO_ERROR, `Decryption error. HMAC error decrypting part ${part} of path ${filePath}`) }; decryptedParts.push(plainTextString); } catch (error) { debug(`Error decrypting part ${part} of path ${filePath}: %o`, error); - return { error: new BoxError(BoxError.CRYPTO_ERROR, `Error decrypting part ${part} of path ${filePath}: ${error.message}`) }; + return { error: new BoxError(BoxError.CRYPTO_ERROR, `Decryption error. ${part} of path ${filePath}: ${error.message}`) }; } }