简体   繁体   English

GCP Cloud KMS - 自定义密钥,可以进行灾难恢复吗?

[英]GCP Cloud KMS - custom key, disaster recovery possible?

we are currently getting our heads around gcp cloud kms and how to cater for disaster recovery.我们目前正在研究 gcp 云 kms 以及如何应对灾难恢复。 this is our current test setup:这是我们当前的测试设置:

Java using Spring boot + Google Tink using KMSEnvelopeAead + AesGcmJce (ie generated DEK by tink that will be encrypted via kms (KEK) and stored alongside the ciphertext), symmetric Java 使用 Spring 启动 + Google Tink 使用 KMSEnvelopeAead + AesGcmJce(即由 tink 生成的 DEK,将通过 kms (KEK) 加密并与密文一起存储),对称

  1. project "A" (the initial project before disaster recovery)项目“A”(灾难恢复前的初始项目)

    -> KMS -> keyring "keyringABC" -> key "keyABC" -> imported custom key via import job. -> KMS -> 密钥环“keyringABC” -> 密钥“keyABC” -> 通过导入作业导入的自定义密钥。 i can successfully encrypt/decrypt some text - all fine, all good我可以成功地加密/解密一些文本 - 一切都好,一切都好

resource: projects/A/locations/eur3/keyRings/keyringABC/cryptoKeys/keyABC/cryptoKeyVersions/1
  1. project "B" (the disaster recovery project) or same project "A" with a new key + keyring (names would be different)项目“B”(灾难恢复项目)或具有新密钥 + 密钥环的相同项目“A”(名称可能不同)

    -> KMS -> keyring "keyringABC" -> key "keyABC" -> imported custom key via import job -> KMS -> 密钥环“keyringABC” -> 密钥“keyABC” -> 通过导入作业导入自定义密钥

    i reimport the custom key material that i already imported into project "A" before that was used to encrypt the data in project "A".我重新导入了之前已导入项目“A”的自定义密钥材料,用于加密项目“A”中的数据。 the newly created key mimics the same structure as in project "A".新创建的密钥模仿了与项目“A”中相同的结构。 the only difference is, that it resided in project "B"唯一的区别是,它位于项目“B”中

resource: projects/B/locations/eur3/keyRings/keyringABC/cryptoKeys/keyABC/cryptoKeyVersions/1

Now, when i try to decrypt the data with the newly created key from project "B" that was encrypted in project "A" i does not work.现在,当我尝试使用在项目“A”中加密的项目“B”中新创建的密钥解密数据时,我不起作用。 looking into the cloud logging logs i can see the following error message查看云日志记录我可以看到以下错误消息

Decryption failed: verify that 'name' refers to the correct CryptoKey.

My assumption is (when reading the docs) that the ciphertext, in this case the DEK generated by tink via cloud kms, also contains the exact resource identifer pointing to the key of project "A" and hence the encrypted DEK can't be decrypted anymore when using the newly created key in project "B".我的假设是(在阅读文档时)密文,在这种情况下是 tink 通过云 kms 生成的 DEK,还包含指向项目“A”的密钥的确切资源标识符,因此加密的 DEK 不能被解密在项目“B”中使用新创建的密钥时不再使用。 This would mean that there is no way to recover data in another project even if the underlying (imported) custom key material is the same.这意味着即使底层(导入的)自定义密钥材料相同,也无法恢复另一个项目中的数据。

Can anybody shed some light on this?任何人都可以对此有所了解吗? any help appreciated.任何帮助表示赞赏。

cheers marcel干杯马塞尔

PS: from the google kms docs PS:来自 google kms 文档

when data is encrypted using a symmetric Cloud KMS or Cloud HSM key, extra metadata about the encryption key version is saved, encrypted, along with the encrypted data.当使用对称 Cloud KMS 或 Cloud HSM 密钥加密数据时,有关加密密钥版本的额外元数据将与加密数据一起保存、加密。 This metadata is not present in data encrypted outside of Cloud KMS.在 Cloud KMS 之外加密的数据中不存在此元数据。

and

Symmetric keys will always have a primary version.对称密钥总是有一个主版本。 This version is used for encrypting by default.此版本默认用于加密。 When Cloud KMS performs decryption using symmetric keys, it automatically identifies which key version is needed to perform the decryption.当 Cloud KMS 使用对称密钥执行解密时,它会自动识别执行解密所需的密钥版本。

Yes, it has to be the exact same key with the exact same resource id including project id.The ciphertext for decryption should be exactly as returned from the encrypt call.是的,它必须是完全相同的密钥,具有完全相同的资源 id,包括项目 id。解密的密文应该与 encrypt 调用返回的完全相同。 So, you need to make sure it matches the project in which you created the KMS key.因此,您需要确保它与您在其中创建 KMS 密钥的项目相匹配。 When you try to decrypt the data with the newly created key from project-B that was encrypted in project-A , it fails.当您尝试使用在project-A中加密的project-B中新创建的密钥解密数据时,它会失败。

In your use-case the ciphertext you're trying to decrypt was encrypted using a different key.在您的用例中,您尝试解密的密文是使用不同的密钥加密的。 You should use the same key for both encryption and decryption, else KMS tells you that it could not find the key while actually the key was found.您应该对加密和解密使用相同的密钥,否则 KMS 会告诉您它无法找到密钥,而实际上已找到密钥。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以将非对称密钥作为您自己的密钥 (BYOK) 提供给任何云提供商的云 KMS(密钥管理服务)? - Is it possible to provide asymmetric keys as your own keys (BYOK) to a cloud KMS (key management service) for any cloud providers? 使用 helm 和 gcp_kms 加密 secrets.yml 文件时密钥的权限被拒绝 - Permission denied on key when encrypting secrets.yml file with helm and gcp_kms Google Cloud KMS 与 libsodium 的互操作性 - Google Cloud KMS interoperability with libsodium 是否可以使用 AWS KMS 进行密钥管理,但将密钥保存在内存中以在本地加密/解密(无需进一步调用 api)? - Is it possible to use AWS KMS for key management but keep the keys in memory to encrypt / decrypt locally (without further api calls)? 是否可以使用 aws-encryption-sdk-python 并使用 KMS 中存在的非对称客户密钥来加密/解密文本? - Is it possible to encrypt/decrypt a text with aws-encryption-sdk-python and using an asymmetric customer key present in KMS? 如何通过自定义 kms 密钥启用服务器端加密将文件上传到 s3 - how to upload files to s3 with server side encryption enabled by custom kms key 节点 Google Cloud KMS 加密似乎有效但解密失败 - Node Google Cloud KMS encryption seems to work but decryption fails 密码恢复和密码派生密钥加密 - Password recovery and password derived key encryption 在S3存储桶策略中要求具有特定密钥ID的KMS加密 - Require KMS encryption with specific key ID in S3 bucket policy 通过AWS KMS插件静态进行MariaDB加密-密钥旋转不起作用? - MariaDB Encryption at Rest via AWS KMS Plugin - Key Rotation Not Working?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM