Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AWS KMS Encryption Context #76

Merged
merged 6 commits into from
Aug 22, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
support encrpytion context for better access control by IAM policy
  • Loading branch information
dictcp committed Aug 3, 2016
commit f50e02d21cf08913aa4f2e1e669ebe30a411f74b
8 changes: 6 additions & 2 deletions sops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,8 +1068,10 @@ def get_key_from_kms(tree):
errors.append("no kms client could be obtained for entry %s" %
entry['arn'])
continue
context = entry['context'] if 'context' in entry else {}
try:
kms_response = kms.decrypt(CiphertextBlob=b64decode(enc))
kms_response = kms.decrypt(CiphertextBlob=b64decode(enc),
EncryptionContext=context)
except Exception as e:
errors.append("kms %s failed with error: %s " % (entry['arn'], e))
continue
Expand All @@ -1090,8 +1092,10 @@ def encrypt_key_with_kms(key, entry):
print("ERROR: failed to initialize AWS KMS client for entry: %s" % err,
file=sys.stderr)
return None
context = entry['context'] if 'context' in entry else {}
try:
kms_response = kms.encrypt(KeyId=entry['arn'], Plaintext=key)
kms_response = kms.encrypt(KeyId=entry['arn'], Plaintext=key,
EncryptionContext=context)
except Exception as e:
print("ERROR: failed to encrypt key using kms arn %s: %s" %
(entry['arn'], e), file=sys.stderr)
Expand Down