From d330f61d251f12c24cdd38b77d143cbb716913da Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Sat, 20 Jan 2018 23:52:35 -0500 Subject: [PATCH] Limit derivation key to 64 bytes since snapshot file path used as key may be longer --- src/duplicacy_snapshotmanager.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/duplicacy_snapshotmanager.go b/src/duplicacy_snapshotmanager.go index 287bc32..a7f0816 100644 --- a/src/duplicacy_snapshotmanager.go +++ b/src/duplicacy_snapshotmanager.go @@ -2292,6 +2292,10 @@ func (manager *SnapshotManager) DownloadFile(path string, derivationKey string) return nil } + if len(derivationKey) > 64 { + derivationKey = derivationKey[len(derivationKey) - 64:] + } + err = manager.fileChunk.Decrypt(manager.config.FileKey, derivationKey) if err != nil { LOG_ERROR("DOWNLOAD_DECRYPT", "Failed to decrypt the file %s: %v", path, err) @@ -2322,6 +2326,10 @@ func (manager *SnapshotManager) UploadFile(path string, derivationKey string, co } } + if len(derivationKey) > 64 { + derivationKey = derivationKey[len(derivationKey) - 64:] + } + err := manager.fileChunk.Encrypt(manager.config.FileKey, derivationKey) if err != nil { LOG_ERROR("UPLOAD_File", "Failed to encrypt the file %s: %v", path, err)