cryptomator / cryptofs

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

Decouple key derivation from vault format #95

Closed overheadhunter closed 3 years ago

overheadhunter commented 3 years ago

In order to allow features like externally managed masterkeys (#7), we need to distinguish key derivation from vault decryption. If key derivation is a separate process that feeds into the decryption, it can be replaced by other modules that produce raw keys.

We'd need two different files:

Migration

To migrate from vault version 7 to vault version 8, the following steps are required:

  1. read old masterkey.cryptomator (vault format should still be 7)
  2. derive key; concat old encKey + hmacKey to single 512 bit raw masterkey
  3. write vault.cryptomator in JWT format
    • set header alg to HS256
    • set header kid=masterkeyfile:masterkey.cryptomator (RFC 7515 kid header field; allow other values eventually - see #7, #97)
    • add claim jti={RANDOM_UUID} to uniquely identify the vault
    • add claim format=8
    • add claim ciphercombo=SIV_CTRMAC (only possible config in vault format 7; eventually allow other values such as SIV_GCM - see #94)
    • add claim shorteningThreshold=220
    • sign with full 512 bit masterkey
  4. write new masterkey.cryptomator
    • set version to 999 (to prevent older versions from attempting to unlock this)
    • keep all other params

Opening a vault with format 8

  1. decode vault.cryptomator
  2. read kid header and, depending on its value, retrieve the masterkey from the user/system/keystore/...
  3. verify the JWT signature (or throw "wrong key" exception)
  4. make sure format is supported
  5. init cryptor with correct ciphercombo
  6. construct file system