Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple key derivation from vault format #95

Closed
overheadhunter opened this issue Nov 20, 2020 · 0 comments · Fixed by #96
Closed

Decouple key derivation from vault format #95

overheadhunter opened this issue Nov 20, 2020 · 0 comments · Fixed by #96
Assignees
Milestone

Comments

@overheadhunter
Copy link
Member

overheadhunter commented Nov 20, 2020

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:

  • masterkey.cryptomator
    • contains the KDF-related params
    • contains a fake vault version of 999 (to prevent older versions from opening this vault)
  • vault.cryptomator
    • specifies what key to use
    • contains the real vault version
    • may contain other configuration params such as the cipher config (see Encrypt file contents using GCM #94) or a shortening threshold
    • is a JWT signed with HS256 using the 512 bit raw masterkey to prevent downgrade attacks (note: HMAC-SHA256 uses 512 bit block size, so a 512 bit key is the maximum possible key without the hash function weakening it)

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
  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
@overheadhunter overheadhunter added this to the 1.10.0 milestone Nov 20, 2020
@overheadhunter overheadhunter self-assigned this Nov 20, 2020
overheadhunter added a commit that referenced this issue Nov 20, 2020
overheadhunter added a commit that referenced this issue Nov 25, 2020
* Remove methods from CryptoFileSystemProvider that deal with password handling or key derivation (will be added to CryptoLib)
* Added generic `KeyLoader` interface to allow usage of keys from other sources than just password-based
* Added `VaultConfiguration` to deal with `vault.cryptomator` files

Related to #7, #95 and #94
@overheadhunter overheadhunter modified the milestones: 1.10.0, 2.0.0 Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant