cryptomator / cryptofs

Java Filesystem Provider with integrated encryption
GNU Affero General Public License v3.0
93 stars 35 forks source link

Separate Shortening Threshold and Max Cleartext Name Length #102

Closed overheadhunter closed 3 years ago

overheadhunter commented 3 years ago

Currently, there is a file system property that sets an upper limit for the length of .c9r files:

https://github.com/cryptomator/cryptofs/blob/19fd7fe5b15d3125ce324dc64739c581079b1f7a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProperties.java#L47-L54

This property has been causing confusion, as its default value (220) serves both, as a hard limit for ciphertext name length as well as the threshold from which onward file names need to be shortened.

While closely related, these values have separate meanings and can deviate:

The shortening threshold needs to be constant across all devices that access a vault. Beginning with vault format 8, it is configured in the vault.cryptomator file (see #95). On previous versions it was a hard-coded constant.

The name length limit, on the other hand, can be device-specific: The default Windows WebDAV client eats up more of the available path length than the macOS one. Regardless of the shortening threshold, some files need to be blocked on such devices.

While cleaning this up, we should also change the ciphertext name limit (which obviously is applied after shortening) to a cleartext name limit. Otherwise we get an odd gap in between "short filenames" and "shortened long filenames" where medium filenames are rejected as they exceed the limit (see cryptomator/cryptomator#1617).