Hi folks! When evaluating a solution for syncing of files via an untrusted host, I stumbled upon the “receive-encrypted” mode of Syncthing.
I read through Untrusted Device Encryption — Syncthing documentation and a few questions popped up (in no particular order). I hope feedback and (potentially stupid) questions are welcome in order to review and potentially improve the current in-beta design (and its docs). Note that I’m not a cryptographer, but I do have a little experience with the design of crypto protocols. Note also that I only looked at this documentation page, and not at the source code.
Key Derivation
- Which Scrypt parameters are actually used for key derivation? They aren’t listed in the docs.
- Can these parameters be upgraded, for example when you realize in a few years that the chosen parameters are considered insecure by then? (In my experience it’s important to store the parameters somewhere in a way that they can be upgraded by newer code without breaking old code.)
- Can the KDF itself be replaced in the future without breaking compatibility? (Could be solved by an “encryption format version” mechanism.)
- Why is HKDF used for the
fileKey
and Scrypt for thefolderKey
? - To derive the
passwordToken
from thefolderKey
, AES-SIV is used. I realize that this is probably fine because thefolderKey
has sufficiently high entropy, but if you need a KDF, would it hurt to use an actual KDF instead (especially if the same KDF is used consistently)? - Note: A switch from Scrypt/HKDF to Argon2id might be worth considering.
Encryption
- The docs mention: “The folder key is used to encrypt file names using AES-SIV without nonce”. However, as far as I understand it, AES-SIV does require a IV/nonce. Will a random nonce be generated and appended/prepended to the ciphertext, or something like that? Or os an empty or fixed IV/nonce used, in order to get deterministic ciphertext for a plaintext?
- AES-SIV should be one of the few modes that should be able to deal with that securely, but I’m not that familiar with SIV to know whether nonce reuse is perfectly OK.
- In RFC8452, the docs note: We stress that the nonce misuse-resistance property is not intended to be coupled with intentional nonce reuse; rather, such schemes provide the best possible security in the event of nonce reuse. Due to all of the above, it is RECOMMENDED that AES-GCM-SIV nonces be randomly generated.
- However, they also say: We stress that nonce misuse-resistant schemes guarantee that if a nonce repeats, then the only security loss is that identical plaintexts will produce identical ciphertexts.
- So it might be fine for your use case? If this was analyzed before, a short explanation in the encryption docs might be a good idea.
- Why is AES-SIV used in some cases, and XChaCha20-Poly1305 in other cases? Both are used to encrypt blocks (not streams), both are authenticated encryption algorithms. Often XChacha20-Poly1305 is used when hardware acceleration is not available, and AES otherwise.
- Is there an analysis of the max number of bytes that is expected to be encrypted with a certain algorithm? For example, for AES-GCM-256, if I remember correctly the max number of bytes that may be encrypted safely is around 64 GiB.
General
- A block diagram in the docs with inputs, key derivations and encryption functions would be great.