HomePhabricator

Add an AES256 storage format for at-rest encryption

Description

Add an AES256 storage format for at-rest encryption

Summary:
Ref T11140. This doesn't do anything yet since there's no way to enable it and no way to store master keys.

Those are slightly tougher problems and I'm not totally satisfied that I have an approach I really like for either problem, so I may wait for a bit before tackling them. Once they're solved, this does the mechanical encrypt/decrypt stuff, though.

This design is substantially similar to the AWS S3 server-side encryption design, and intended as an analog for it. The decisions AWS has made in design generally seem reasonable to me.

Each block of file data is encrypted with a unique key and a unique IV, and then that key and IV are encrypted with the master key (and a distinct, unique IV). This is better than just encrypting with the master key directly because:

  • You can rotate the master key later and only need to re-encrypt a small amount of key data (about 48 bytes per file chunk), instead of re-encrypting all of the actual file data (up to 4MB per file chunk).
  • Instead of putting the master key on every server, you can put it on some dedicated keyserver which accepts encrypted keys, decrypts them, and returns plaintext keys, and can send it 32-byte keys for decryption instead of 4MB blocks of file data.
  • You have to compromise the master key, the database, AND the file store to get the file data. This is probably not much of a barrier realistically, but it does make attacks very slightly harder.

The "KeyRing" thing may change once I figure out how I want users to store master keys, but it was the simplest approach to get the unit tests working.

Test Plan:

  • Ran unit tests.
  • Dumped raw data, saw encrypted blob.
  • No way to actually use this in the real application yet so it can't be tested too extensively.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11140

Differential Revision: https://secure.phabricator.com/D16124

Details

Provenance
epriestleyAuthored on Jun 15 2016, 6:04 PM
epriestleyPushed on Jun 16 2016, 3:05 PM
Reviewer
chad
Differential Revision
D16124: Add an AES256 storage format for at-rest encryption
Parents
rPf9e31089386c: Fix an issue with AuthProviderConfig handles
Branches
Unknown
Tags
Unknown
Tasks
T11140: Support at-rest encryption in Files
Build Status
Buildable 12684
Build 16127: Run Core Tests