I need to store sensitive data in a particular column in my database (Postgres). I'm hosting with AWS, so I'm planning on using KMS to use envelope encryption. For example:
To encrypt a secret:
- Generate a 256-bit plaintext data key.
- Generate a 256-bit random IV.
- Encrypt the secret with AES-256-CBC using the plaintext data key, and the IV.
- Using KMS, encrypt the data key.
- Throw away the plaintext data key.
- Encode the IV, the ciphertext secret, and the ciphertext data key in the column.
To decrypt a payload from the column:
- Decode the IV, ciphertext secret, and the ciphertext data key from the column.
- Using KMS, decrypt the ciphertext data key.
- Decrypt the ciphertext secret with AES-256-CBC using the plaintext data key, and the IV.
With this in place, should I encrypt-then-MAC the message? I found this answer about using a MAC with a HSM, but I'm not sure if it still applies in the case of data stored in a database:
For checking data integrity, isn't this already covered by our database? For checking authenticity, we are the only ones who consume the ciphertext. For example, we do not exchange the ciphertext with a client where it could be modified.
Is applying a MAC to the encrypted data unnecessary overhead?