2

I've been trying to work out an effective database backup encryption scheme lately.
I have a Postgres 9.4 server, I have most of the backup scheme fleshed out I think. Backups will be stored in a standard .sql file, gzipped and then ran through AES-CBC with OpenSSL.

The only part I'm having trouble with is keys. I don't want to use a single master key, I want some kind of key rotation or generation. Something where all backups (or at least most) have different keys, but also keys that I can easily find/generate and use if I ever need to. I've had a look on Google but can't find any clear solution.

I am willing to evaluate entirely different encryption solutions too, I'm not tied to AES-CBC/OpenSSL.

Any solution will be greatly appreciated.
Thanks.

2 Answers 2

5

Use gpg (GnuPG).

You'll be able to generate multiple keys and encrypt a file for decryption with any key from chosen list. Also GPG keys are not symmetric — your server only need public keys for encryption. Private keys, used for decryption, might be securely stored somewhere else.

You can for example print one private key as QRcode for your director and another for storing in a physical safe.

2
  • Can you elaborate about generating multiple keys? Would we just encrypt with multiple --recipient statements? Jul 16, 2015 at 16:17
  • 1
    Yes. Then any recipient would be able to decrypt. It also does not make encrypted file significantly larger.
    – Tometzky
    Jul 16, 2015 at 17:06
1

The scheme that is implemented in at least one commercial DBMS that I know uses two keys, let's call them the master key and the database key.

The master key is used to encrypt the database key. The database key, which could be of a higher grade, is used to encrypt and decrypt the backup images.

The master key can be safely rotated, because it only requires that you decrypt and re-encrypt the database key.

Since the database key itself remains unchanged it can always be used to decrypt and restore a backup no matter how old.

If you were to rotate the database key instead, you would need to decrypt and re-encrypt all backups that you keep, which in many cases would be impractical.

You can apply the approach suggested by @Tometzky to encrypting the database key (although it appears that it's more like key addition than key rotation).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .