From 943c25abd984e7c0692afb08b74ff1147d5fafb8 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Mon, 8 Jul 2024 15:43:38 +0200 Subject: [PATCH] fix(WebDav, GoogleDrive): Use new encryption Signed-off-by: Marcel Klehr --- src/lib/adapters/GoogleDrive.ts | 4 +++- src/lib/adapters/WebDav.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/adapters/GoogleDrive.ts b/src/lib/adapters/GoogleDrive.ts index 55582a405f..6403df428c 100644 --- a/src/lib/adapters/GoogleDrive.ts +++ b/src/lib/adapters/GoogleDrive.ts @@ -305,7 +305,9 @@ export default class GoogleDriveAdapter extends CachingAdapter { let xbel = createXBEL(this.bookmarksCache, this.highestId) if (this.server.password) { - xbel = await Crypto.encryptAES(this.server.password, xbel, this.server.bookmark_file) + const salt = Crypto.bufferToHexstr(Crypto.getRandomBytes(64)) + const ciphertext = await Crypto.encryptAES(this.server.password, xbel, salt) + xbel = JSON.stringify({ciphertext, salt}) } if (!this.fileId) { diff --git a/src/lib/adapters/WebDav.ts b/src/lib/adapters/WebDav.ts index 85297cfa59..f553c676bb 100644 --- a/src/lib/adapters/WebDav.ts +++ b/src/lib/adapters/WebDav.ts @@ -324,7 +324,9 @@ export default class WebDavAdapter extends CachingAdapter { const fullUrl = this.getBookmarkURL() let xbel = this.server.bookmark_file_type === 'xbel' ? createXBEL(this.bookmarksCache, this.highestId) : createHTML(this.bookmarksCache, this.highestId) if (this.server.passphrase) { - xbel = await Crypto.encryptAES(this.server.passphrase, xbel, this.server.bookmark_file) + const salt = Crypto.bufferToHexstr(Crypto.getRandomBytes(64)) + const ciphertext = await Crypto.encryptAES(this.server.passphrase, xbel, salt) + xbel = JSON.stringify({ciphertext, salt}) } await this.uploadFile(fullUrl, this.server.bookmark_file_type === 'xbel' ? 'application/xml' : 'text/html', xbel) } else {