Skip to content

Commit 998575c

Browse files
authored
Merge head of master into keyring (#195)
* Update PR template * Added a check for max_age being greater than 0 (#172) * Added a check for max_age being greater than 0 * Fixed flake8 by adding missing pydocstyle dependency * Added the dependency to decrypt_oracle as well * Added test for max_age<=0 ValueError * Updated test for max_age<=0.0 ValueError * Added negative test case * Fixed KMS master key provider tests when default AWS region is configured (#179) * Fixed KMS master key provider tests for users who have their default AWS region configured * created fixture for botocore session with no region set * add auto-used fixture in KMS master key provider unit tests to test against both with and without default region * Wrote example and test for using one kms cmk with an unsigned algorithm * Update one_kms_cmk_unsigned.py * Update examples/src/one_kms_cmk_unsigned.py Co-Authored-By: Matt Bullock <bullocm@amazon.com> * isort-check now succeeds * [issue-190] Regional clients modify default botocore session (#193) * [issue-190] Creation of regional clients modifies default botocore session's region * update changelog with changes for 1.4.1 release * bump version to 1.4.1 * Updates to handle new pylint requirements (#196) * pylint max-attributes appears to be ratcheted down recently * remove unnecessary comprehensions * whitelist some pylint use-constant-test false-positives * reorganize backwards compatibility test requirements definitions attrs==19.2.0 removed a deprecated feature that aws-encryption-sdk==1.3.3 depended on. This reorganization lets us define specific requirements bounds for old versions of aws-encryption-sdk that will probably continue to be necessary as these old versions age. * remove unnecessary comprehensions * add newlines to the end of all requirements files * help pylint ignore mypy type use
1 parent 2e85bfd commit 998575c

32 files changed

+208
-35
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44

55

66
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
7+
8+
# Check any applicable:
9+
- [ ] Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.
10+

CHANGELOG.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
Changelog
33
*********
44

5+
1.4.1 -- 2019-09-20
6+
===================
7+
8+
Bugfixes
9+
--------
10+
11+
* Fix region configuration override in botocore sessions.
12+
`#190 <https://github.com/aws/aws-encryption-sdk-python/issues/190>`_
13+
`#193 <https://github.com/aws/aws-encryption-sdk-python/pull/193>`_
14+
15+
Minor
16+
-----
17+
18+
* Caching CMM must require that max age configuration value is greater than 0.
19+
`#147 <https://github.com/aws/aws-encryption-sdk-python/issues/147>`_
20+
`#172 <https://github.com/aws/aws-encryption-sdk-python/pull/172>`_
21+
522
1.4.0 -- 2019-05-23
623
===================
724

decrypt_oracle/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_version():
2222
def get_requirements():
2323
"""Read the requirements file."""
2424
requirements = read("requirements-actual.txt")
25-
return [r for r in requirements.strip().splitlines()]
25+
return list(requirements.strip().splitlines())
2626

2727

2828
setup(

decrypt_oracle/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ basepython = python3
156156
deps =
157157
flake8
158158
flake8-docstrings
159-
pydocstyle < 4.0.0
159+
pydocstyle<4.0.0
160160
# https://github.com/JBKahn/flake8-print/pull/30
161161
flake8-print>=3.1.0
162162
commands =

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sphinx>=1.3.0
2-
sphinx_rtd_theme
2+
sphinx_rtd_theme

examples/src/one_kms_cmk_unsigned.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""Example showing basic encryption and decryption of a value already in memory
14+
using one KMS CMK with an unsigned algorithm.
15+
"""
16+
from aws_encryption_sdk import KMSMasterKeyProvider, decrypt, encrypt
17+
from aws_encryption_sdk.identifiers import Algorithm
18+
19+
20+
def encrypt_decrypt(key_arn, source_plaintext, botocore_session=None):
21+
"""Encrypts and then decrypts a string under one KMS customer master key (CMK) with an unsigned algorithm.
22+
23+
:param str key_arn: Amazon Resource Name (ARN) of the KMS CMK
24+
:param bytes source_plaintext: Data to encrypt
25+
:param botocore_session: existing botocore session instance
26+
:type botocore_session: botocore.session.Session
27+
"""
28+
kwargs = dict(key_ids=[key_arn])
29+
30+
if botocore_session is not None:
31+
kwargs["botocore_session"] = botocore_session
32+
33+
# Create master key provider using the ARN of the key and the session (botocore_session)
34+
kms_key_provider = KMSMasterKeyProvider(**kwargs)
35+
36+
# Encrypt the plaintext using the AWS Encryption SDK. It returns the encrypted message and the header
37+
ciphertext, encrypted_message_header = encrypt(
38+
algorithm=Algorithm.AES_256_GCM_IV12_TAG16_HKDF_SHA256, source=source_plaintext, key_provider=kms_key_provider
39+
)
40+
41+
# Decrypt the encrypted message using the AWS Encryption SDK. It returns the decrypted message and the header
42+
plaintext, decrypted_message_header = decrypt(source=ciphertext, key_provider=kms_key_provider)
43+
44+
# Check if the original message and the decrypted message are the same
45+
assert source_plaintext == plaintext
46+
47+
# Check if the headers of the encrypted message and decrypted message match
48+
assert all(
49+
pair in encrypted_message_header.encryption_context.items()
50+
for pair in decrypted_message_header.encryption_context.items()
51+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""Unit test suite for the encryption and decryption using one KMS CMK with an unsigned algorithm example."""
14+
15+
import botocore.session
16+
import pytest
17+
18+
from ..src.one_kms_cmk_unsigned import encrypt_decrypt
19+
from .examples_test_utils import get_cmk_arn
20+
from .examples_test_utils import static_plaintext
21+
22+
23+
pytestmark = [pytest.mark.examples]
24+
25+
26+
def test_one_kms_cmk_unsigned():
27+
plaintext = static_plaintext
28+
cmk_arn = get_cmk_arn()
29+
encrypt_decrypt(key_arn=cmk_arn, source_plaintext=plaintext, botocore_session=botocore.session.Session())

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ six
22
boto3>=1.4.4
33
cryptography>=1.8.1
44
attrs>=19.1.0
5-
wrapt>=1.10.11
5+
wrapt>=1.10.11

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_version():
2222
def get_requirements():
2323
"""Reads the requirements file."""
2424
requirements = read("requirements.txt")
25-
return [r for r in requirements.strip().splitlines()]
25+
return list(requirements.strip().splitlines())
2626

2727

2828
setup(

src/aws_encryption_sdk/caches/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class CryptoMaterialsCacheEntryHints(object):
143143

144144
@attr.s(hash=False)
145145
class CryptoMaterialsCacheEntry(object):
146+
# pylint: disable=too-many-instance-attributes
146147
"""Value and metadata store for cryptographic materials cache entries.
147148
148149
:param bytes cache_key: Identifier for entries in cache

0 commit comments

Comments
 (0)