Hi, here is a synchronization problem.
I have a list of files. Each is encrypted using a AES block cipher in CTR (counter) mode with its own password, a salt and an initialisation vector, where the latter two are randomly chosen at the time of encryption. What that means is that E(A, k1)_t0 is going to look very different from E(A, k2)_t1 even though A has not changed (where E(M, k)_t is the AES CTR mode encryption of plaintext M at time t with some encryption key k).
If the file has actually changed from A to A + delta_A, then it is not easy to detect the delta change in the encrypted domain. This is because the initialisation vector and salt are different every time, resulting in a ciphertext that is entirely different even for a single bit change. Thus, one cannot just patch separate blocks of the ciphertext and expect the decryption to work.
Assuming the file names on both the local and the Dropbox server side are the same, what I could do:
- Compute the Dropbox content hash on the local file.
- Request the metadata of the remote file (without downloading it), and obtain the remote content hash.
- If the two content hashes mismatch, then compare the local write time with the ServerModifed time on the remote metadata.
- If the local write time is newer than the remote version then upload the file to Dropbox.
- If the local write time is older then overwrite the local version with the remote version.
The strategies in 3.1 and 3.2 create a problem when the Dropbox version is say, A + delta1_A and the local version is A + delta2_A, i.e., both sides have been modified but we cannot tell how to merge the deltas in the encrypted domain. One constraint here: decrypting both files locally and comparing and applying deltas is not an option I am willing to take, for various application specific reasons.
Question 1: Is my only synchronisation strategy to ask the user in both cases, which copy the user wants to keep?
Question 2: Is there a better way to compare files to detect the newer one instead of comparing with their write times when the content hashes mismatch? Can I compare Dropbox file revisions numerically? How can I compute the local revision of a file? Or, is comparing local write time and ServerModified time a reasonable idea?
Thank you!