1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-15 07:43:21 +00:00

Limit derivation key to 64 bytes since snapshot file path used as key may be longer

This commit is contained in:
Gilbert Chen
2018-01-20 23:52:35 -05:00
parent e5beb55336
commit d330f61d25

View File

@@ -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)