aws / aws-encryption-sdk-python

AWS Encryption SDK
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html
Apache License 2.0
236 stars 86 forks source link

AttributeError while running examples in this repo #58

Closed nbommu1 closed 5 years ago

nbommu1 commented 6 years ago

Hi,

when I'm running examples from this repo "Encryption and Decryption" , this gives me the following error.

Traceback (most recent call last):
  File "kms-multi.py", line 11, in <module>
    key_provider=kms_key_provider
  File "/home/nbommu/python/local/lib/python2.7/site-packages/aws_encryption_sdk/__init__.py", line 76, in encrypt
    ciphertext = encryptor.read()
  File "/home/nbommu/python/local/lib/python2.7/site-packages/aws_encryption_sdk/streaming_client.py", line 202, in read
    self._prep_message()
  File "/home/nbommu/python/local/lib/python2.7/site-packages/aws_encryption_sdk/streaming_client.py", line 405, in _prep_message
    request=encryption_materials_request
  File "/home/nbommu/python/local/lib/python2.7/site-packages/aws_encryption_sdk/materials_managers/default.py", line 78, in get_encryption_materials
    signing_key = self._generate_signing_key_and_update_encryption_context(algorithm, encryption_context)
  File "/home/nbommu/python/local/lib/python2.7/site-packages/aws_encryption_sdk/materials_managers/default.py", line 54, in _generate_signing_key_and_update_encryption_context
    if algorithm.signing_algorithm_info is None:
AttributeError: 'tuple' object has no attribute 'signing_algorithm_info'

Name: Python Version: 2.7.14 Name: boto3 Version: 1.7.48

mattsb42-aws commented 6 years ago

Could you provide the code that you ran when you got this error? This looks like it might have been caused by a malformed input parameter but it's hard to tell without seeing the code.

nbommu1 commented 6 years ago

this is the example code I'm using in my test.

import aws_encryption_sdk

kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids=[
    'arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222',
    'arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
])
my_plaintext = 'This is some super secret data!  Yup, sure is!'

my_ciphertext, encryptor_header = aws_encryption_sdk.encrypt(
    source=my_plaintext,
    key_provider=kms_key_provider
)

decrypted_plaintext, decryptor_header = aws_encryption_sdk.decrypt(
    source=my_ciphertext,
    key_provider=kms_key_provider
)
mattsb42-aws commented 6 years ago

Sorry for the delay.

This is a very odd error and seems like something going wrong deep inside somewhere; maybe something wrong with Enum34? Could you show the output of pip freeze and I can try to replicate this?

nbommu1 commented 6 years ago

sorry for the delay.

asn1crypto==0.24.0 attrs==18.1.0 aws-encryption-sdk==1.3.4 boto==2.48.0 boto3==1.7.48 botocore==1.10.48 certifi==2017.4.17 cffi==1.11.5 chardet==3.0.4 click==6.7 cryptography==2.2.2 docutils==0.14 enum==0.4.6 futures==3.2.0 idna==2.7 Jinja2==2.9.6 jmespath==0.9.3 MarkupSafe==1.0 ntlm-auth==1.0.5 ordereddict==1.1 pycparser==2.18 python-dateutil==2.7.3 pywinrm==0.2.2 PyYAML==3.12 requests==2.18.1 requests-ntlm==1.0.0 s3transfer==0.1.13 six==1.11.0 urllib3==1.21.1 wrapt==1.10.11 xmltodict==0.11.0

mattsb42-aws commented 5 years ago

Sorry, @nbommu1, this fell off my radar. Did you ever figure out the issue you were having? I tried installing that freeze file in a new virtualenv with CPython 2.7.14 and running the example code you specified, and it worked for me.

I wonder if something is odd in the configuration of your environment that might be causing this?

mattsb42-aws commented 5 years ago

Closing due to inactivity. If you are still having issues, @nbommu1, please feel free to re-open.