简体   繁体   English

数据加密密钥轮换过程——旧密钥与新密钥

[英]Data encryption key rotation process - Old key vs New key

Iam using .NET 6.0 and need to encrypt some configuration strings that are stored in the database.我正在使用 .NET 6.0,需要加密存储在数据库中的一些配置字符串。

Due to security compliance, I also need to rotate the encryption key (for every 60 days) as well.由于安全合规性,我还需要轮换加密密钥(每 60 天)。 I can rotate the key using Keys - Rotation policy in Azure Key Vault.我可以使用 Keys - Azure Key Vault 中的轮换策略来轮换密钥。

But if the key is rotated (new key is generated) what about the existing encrypted data (using the old key) in the database?但是如果密钥被轮换(生成新密钥),数据库中现有的加密数据(使用旧密钥)怎么办?

Re-encrypting the whole data using the new key is not feasible options in my case.在我的案例中,使用新密钥重新加密整个数据不是可行的选择。

Any solutions to handle this case?处理这种情况的任何解决方案?

UPDATE更新

I found this article on Envelope Encryption我在信封加密上找到了这篇文章

I have seen an approach somewhere that is getting a key pair as the key which needs to be rotated.我在某处看到了一种将密钥对作为需要轮换的密钥的方法。

Then a symmetric key is generated for encrypting the data itself.然后生成一个对称密钥用于加密数据本身。 This second key is stored next to the data, encrypted by the original key.第二个密钥存储在数据旁边,由原始密钥加密。 When you need to rotate the key, you can simply:当您需要轮换密钥时,您可以简单地:

  1. Decrypt the symmetric key解密对称密钥
  2. Rotate the key pair轮换密钥对
  3. Encrypt the symmetric key with the new key用新密钥加密对称密钥
  4. Overwrite the encrypted symmetric key with the new one用新的对称密钥覆盖加密的对称密钥

Since the symmetric key is not rotated, the whole database can remain as is, just one record is changed.由于对称密钥没有轮换,整个数据库可以保持原样,只更改一条记录。

Envelope Encryption will not meet Audit requirements.信封加密将不符合审计要求。 This is Shallow encryption.这是浅层加密。 If a hacker has access to Data Encryption Key, DEK which is not rotated, does not matter if Master key (KEK) is rotated, they can get to all rows in database.如果黑客可以访问未轮换的数据加密密钥 DEK,则无论主密钥 (KEK) 是否轮换,他们都可以访问数据库中的所有行。

The true solution is to have a background process and re-encrypt all data with newly generated DEK and encrypt DEK with rotated KEK真正的解决方案是拥有一个后台进程并使用新生成的 DEK 重新加密所有数据并使用旋转的 KEK 加密 DEK

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM