Context
I am following GCP's instructions for Storing Secrets in Storage Bucket. KMS is used for file encryption before it's being uploaded to Storage Bucket.
Since data encryption happens outside of Google's storage I am a bit confused with one aspect of key rotation.
Scenario
Let's consider a specific scenario:
- On 2017-01-01 I create a keyring and a key
A
(which is in factA_ver1
because the keys are versioned). Also, the key rotation policy is set up to trigger rotation yearly. - On 2017-01-15 I run a command to encrypt
some_file.txt
withA_ver1
:curl -s -X POST "https://cloudkms.googleapis.com/v1/projects/my-project/<...>" \ -d "{\"plaintext\":\"<...SOME_FILE_CONTENT...>\"}" \ -H "Authorization:Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type:application/json"
. - I immediately save the result of encryption to Storage Bucket as
some_file.txt.encrypted
. - I don't do anything, and on 2018-01-01 the key rotation happens. As I understand,
,A_ver1
gets disabledA_ver2
is generated and activated.These two events happen quasi-simulataneously. - On 2018-06-01 I realize that I need to unencrypt
some_file.txt.encrypted
. I am downloading the file, then trying to run a command to unencrypt the file using theA_ver2
...
Questions
Question 1: What is going to happen when I try to unencrypt the file with A_ver2
if it was encrypted with the earlier version A_ver1
?
Question 2: If the unencryption fails, what am I supposed to do in the first place to prevent it?