简体   繁体   English

如何使用 aws encryption cli 进行解密?

[英]How do I use the aws encryption cli to decrypt?

I have used the aws encryption cli to encrypt a zip file (a database backup actually) as follows:我使用 aws 加密 cli 加密了一个 zip 文件(实际上是一个数据库备份),如下所示:

aws-encryption-cli -vv --encrypt \
  --input "backup.zip" \
  --wrapping-keys key=caf...854 region=us-east-1 \
  --encryption-context purpose=dbbackup \
  --metadata-output backup.metadata \
  --output backup.zip.enc

This works great, and produces the encrypted backup file.这很好用,并生成加密的备份文件。 However I can't seem to decrypt using the same basic pattern.但是我似乎无法使用相同的基本模式进行解密

aws-encryption-cli \
  -vv \
  --decrypt \
  --input backup.zip.enc \
  --wrapping-keys key=caf...854 region=us-east-1 \
  --output backup.zip \
  --metadata-output backup.zip.metadatadec

Produces an error:产生错误:

2020-11-13 15:04:04,580 - MainThread - aws_encryption_sdk.key_providers.base - DEBUG - IncorrectMasterKeyError("Provided data key provider MasterKeyInfo(provider_id='aws-kms', key_info=b'arn:aws:kms:us-east-1:...:key/caf...854') does not match Master Key provider MasterKeyInfo(provider_id='aws-kms', key_info=b'caf...854')",) raised when attempting to decrypt data key with master key MasterKeyInfo(provider_id='aws-kms', key_info=b'caf...854')

It looks to me like it's complaining that the KMS key ID doesn't match because on decryption it uses the full ARN (arn:aws:kms:us-east-1...) when on encryption it only used the ID (caf...854).在我看来,它在抱怨 KMS 密钥 ID 不匹配,因为在解密时它使用完整的 ARN (arn:aws:kms:us-east-1...) 在加密时它只使用 ID (caf ...854). I'm not sure how to change the behavior to use the same thing on both cases, or if something else is the problem?我不确定如何更改行为以在两种情况下使用相同的东西,或者是否有其他问题?

FWIW, this seems to work if I specify the full ARN for the wrapping key key when I encrypt and decrypt. FWIW,如果我在加密和解密时为包装密钥指定完整的 ARN,这似乎有效。 I'm not sure why it would succeed on the encryption but fail on decryption when I use only the ID - this feels like a bug (should either fail for both or work for both).我不确定为什么当我只使用 ID 时它会在加密时成功但在解密时失败 - 这感觉像是一个错误(应该对两者都失败或对两者都有效)。

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

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