EncryptIfNeeded encrypts the provided SOPS data key, if it has not been encrypted yet.
(dataKey []byte)
| 209 | // EncryptIfNeeded encrypts the provided SOPS data key, if it has not been |
| 210 | // encrypted yet. |
| 211 | func (key *MasterKey) EncryptIfNeeded(dataKey []byte) error { |
| 212 | if key.EncryptedKey == "" { |
| 213 | return key.Encrypt(dataKey) |
| 214 | } |
| 215 | return nil |
| 216 | } |
| 217 | |
| 218 | // Decrypt decrypts the EncryptedKey field with GCP KMS and returns |
| 219 | // the result. |