-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Encryption at rest support #2424
Conversation
Fetch updates from facebook/rocksdb
Encryption
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thanks for your contribution! |
@ewoutp updated the pull request - view changes |
Import changes from facebook-master
@ewoutp updated the pull request - view changes |
@ewoutp updated the pull request - view changes |
@ewoutp updated the pull request - view changes |
@ewoutp updated the pull request - view changes |
Travis |
@sagar0 Shall I just wrap the entire file in |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@ewoutp updated the pull request - view changes |
@ewoutp updated the pull request - view changes |
Only java_test is failing. Have no clue how that is related. |
Thanks for fixing the lite build. Java test is a little flaky ... so we don't need to worry about it most of the time (we are working on making it less flaky though). I'll take a look. |
commit 19ee74c Author: Ewout Prangsma <ewout@prangsma.net> Date: Thu Jun 15 09:37:40 2017 +0200 Excluded headers on ROCKSDB_LITE commit c688186 Author: Ewout Prangsma <ewout@prangsma.net> Date: Thu Jun 15 08:21:34 2017 +0200 Exclude encryption implementation on ROCKSDB_LITE commit 28d8074 Author: Ewout Prangsma <ewout@prangsma.net> Date: Tue Jun 13 16:27:08 2017 +0200 Commented `std::cout` in test (see review facebook#2424 (review)) commit d677055 Author: Ewout Prangsma <ewout@prangsma.net> Date: Tue Jun 13 16:25:18 2017 +0200 db_encryption_test.cc to TARGETS file (see review facebook#2424 (review)) commit 47c909b Author: Ewout Prangsma <ewout@prangsma.net> Date: Tue Jun 13 16:22:50 2017 +0200 Removed unwanted likes (see review facebook#2424 (review)) commit 64fccc8 Merge: b452426 66a5ef2 Author: Ewout Prangsma <ewoutp@users.noreply.github.com> Date: Tue Jun 13 16:18:08 2017 +0200 Merge pull request facebook#5 from arangodb-helper/facebook-master Import changes from facebook-master commit 66a5ef2 Merge: b452426 5d5a28a Author: Ewout Prangsma <ewout@prangsma.net> Date: Tue Jun 13 15:39:25 2017 +0200 Imported changed from facebook-master commit b452426 Author: Ewout Prangsma <ewout@prangsma.net> Date: Tue Jun 13 15:27:51 2017 +0200 Added GenerateUniqueId override commit 9d446a6 Author: Ewout Prangsma <ewoutp@users.noreply.github.com> Date: Thu Jun 8 08:55:29 2017 +0200 Encryption (wip) (facebook#2) Encryption commit 8d846d8 Merge: fe18356 c2be434 Author: Ewout Prangsma <ewoutp@users.noreply.github.com> Date: Fri May 12 15:33:34 2017 +0200 Merge pull request facebook#1 from facebook/master Fetch updates from facebook/rocksdb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, and making the prior requested changes. This change looks good to me, and is ready to be accepted once the below few nits are fixed.
Could you run a "make format" once to adhere to the formatting rules.
Would it also be possible to contribute a small example to show how this API can be used? It can be done in a separate pull request, when time permits. |
@ewoutp updated the pull request - view changes |
Result of
|
As for sample code. Typically you would implement a class derived from
|
@ewoutp updated the pull request - view changes |
I am trying to import this PR on to Facebook's internal phabricator to run some tests, but unfortunately the import is failing. I am trying to figure out a way to move forward. |
@ewoutp updated the pull request - view changes |
@ewoutp Can you please rebase your changes on master? |
@sdwilsh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@sagar0 looks like it's already merged. If anything is still needed, let me know. |
Is this available through RocksDBJNI? |
What
This PR adds support for encrypting data stored by RocksDB when written to disk.
How
It adds an
EncryptedEnv
override of theEnv
class with matching overrides for sequential&random access files.The encryption itself is done through a configurable
EncryptionProvider
. This class creates is asked to createBlockAccessCipherStream
for a file. This is where the actual encryption/decryption is being done.Currently there is a Counter mode implementation of
BlockAccessCipherStream
with aROT13
block cipher (NOTE theROT13
is for demo purposes only!!).The Counter operation mode uses an initial counter & random initialization vector (IV).
Both are created randomly for each file and stored in a 4K (default size) block that is prefixed to that file. The
EncryptedEnv
implementation is such that clients of theEnv
class do not see this prefix (nor data, nor in filesize).The largest part of the prefix block is also encrypted, and there is room left for implementation specific settings/values/keys in there.
Testing
To test the encryption, the
DBTestBase
class has been extended to consider a new environment variable calledENCRYPTED_ENV
. If set, the test will setup a encrypted instance of theEnv
class to use for all tests.Typically you would run it like this:
There is also an added test that checks that some data inserted into the database is or is not "visible" on disk. With
ENCRYPTED_ENV
active it must not find plain text strings, withENCRYPTED_ENV
unset, it must find the plain text strings.