Skip to content

Commit face173

Browse files
authored
Merge branch 'master' into custom-kms-client
2 parents de0e562 + d064bf8 commit face173

24 files changed

+118
-125
lines changed

.github/workflows/ci_decrypt-oracle.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
tests:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-python@v2
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-python@v4
1616
with:
1717
# The oracle runs in a Python 3.6 Lamba
1818
python-version: 3.6
@@ -38,8 +38,8 @@ jobs:
3838
- flake8-tests
3939
- pylint-tests
4040
steps:
41-
- uses: actions/checkout@v2
42-
- uses: actions/setup-python@v1
41+
- uses: actions/checkout@v3
42+
- uses: actions/setup-python@v4
4343
with:
4444
python-version: 3.8
4545
- run: |

.github/workflows/ci_static-analysis.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
- black-check
2828
- isort-check
2929
steps:
30-
- uses: actions/checkout@v2
31-
- uses: actions/setup-python@v2
30+
- uses: actions/checkout@v3
31+
- uses: actions/setup-python@v4
3232
with:
3333
python-version: 3.8
3434
- run: |

.github/workflows/ci_test-vector-handler.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
aws-access-key-id: ${{ secrets.INTEG_AWS_ACCESS_KEY_ID }}
4646
aws-secret-access-key: ${{ secrets.INTEG_AWS_SECRET_ACCESS_KEY }}
4747
aws-region: us-west-2
48-
- uses: actions/checkout@v2
49-
- uses: actions/setup-python@v2
48+
- uses: actions/checkout@v3
49+
- uses: actions/setup-python@v4
5050
with:
5151
python-version: ${{ matrix.python }}
5252
architecture: ${{ matrix.architecture }}
@@ -72,8 +72,8 @@ jobs:
7272
- flake8-tests
7373
- pylint-tests
7474
steps:
75-
- uses: actions/checkout@v2
76-
- uses: actions/setup-python@v1
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-python@v4
7777
with:
7878
python-version: 3.8
7979
- run: |

.github/workflows/ci_tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ jobs:
5050
- os: macos-latest
5151
architecture: x86
5252
steps:
53-
- uses: actions/checkout@v2
54-
- uses: actions/setup-python@v2
53+
- uses: actions/checkout@v3
54+
- uses: actions/setup-python@v4
5555
with:
5656
python-version: ${{ matrix.python }}
5757
architecture: ${{ matrix.architecture }}
@@ -71,8 +71,8 @@ jobs:
7171
- nocmk
7272
- test-upstream-requirements-py37
7373
steps:
74-
- uses: actions/checkout@v2
75-
- uses: actions/setup-python@v1
74+
- uses: actions/checkout@v3
75+
- uses: actions/setup-python@v4
7676
with:
7777
python-version: 3.7
7878
- run: |

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- name: Dependabot metadata
1717
id: metadata
18-
uses: dependabot/fetch-metadata@v1.2.1
18+
uses: dependabot/fetch-metadata@v1.3.0
1919
with:
2020
github-token: "${{ secrets.GITHUB_TOKEN }}"
2121
- name: Enable auto-merge for Dependabot PRs

.github/workflows/repo-sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
environment: repo-sync
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313
- uses: repo-sync/github-sync@v2
1414
name: Sync repo to branch
1515
with:

CHANGELOG.rst

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

5+
3.1.1 -- 2022-06-20
6+
===================
7+
8+
Maintenance
9+
-----------
10+
* Replace deprecated cryptography ``verify_interface`` with ``isinstance``
11+
`#467 <https://github.com/aws/aws-encryption-sdk-python/pull/467>`_
12+
513
3.1.0 -- 2021-11-10
614
===================
715

SUPPORT_POLICY.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ This table describes the current support status of each major version of the AWS
2222
- Next status
2323
- Next status date
2424
* - 1.x
25-
- Maintenance
2625
- End of Support
27-
- 2022-06-30
26+
-
27+
-
2828
* - 2.x
29-
- Maintenance
3029
- End of Support
31-
- 2022-07-01
30+
-
31+
-
3232
* - 3.x
3333
- General Availability
3434
-

codebuild/release/prod-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ env:
44
variables:
55
BRANCH: "master"
66
secrets-manager:
7-
TWINE_USERNAME: PyPiAdmin:username
8-
TWINE_PASSWORD: PyPiAdmin:password
7+
TWINE_USERNAME: PyPiAPIToken:username
8+
TWINE_PASSWORD: PyPiAPIToken:password
99

1010
phases:
1111
install:

codebuild/release/test-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ env:
44
variables:
55
BRANCH: "master"
66
secrets-manager:
7-
TWINE_USERNAME: TestPyPiCryptoTools:username
8-
TWINE_PASSWORD: TestPyPiCryptoTools:password
7+
TWINE_USERNAME: TestPyPiAPIToken:username
8+
TWINE_PASSWORD: TestPyPiAPIToken:password
99

1010
phases:
1111
install:

decrypt_oracle/test/pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ disable =
55
missing-docstring, # we don't write docstrings for tests
66
bad-continuation, # we let black handle this
77
ungrouped-imports, # we let isort handle this
8-
consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation
8+
consider-using-f-string, # disable until 2022-05-05; 6 months after 3.5 deprecation
9+
missing-timeout # disabling until we come up with a reasonable number
910

1011
[FORMAT]
1112
max-line-length = 120
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
bandit==1.7.3
2-
black==22.1.0
1+
bandit==1.7.4
2+
black==22.3.0
33
doc8==0.10.1
44
flake8==4.0.1
5-
flake8-bugbear==22.1.11
5+
flake8-bugbear==22.9.11
66
flake8-docstrings==1.6.0
77
flake8-print==4.0.0
88
isort==5.10.1
99
pyflakes==2.4.0
10-
pylint==2.12.2
11-
readme_renderer==32.0
10+
pylint==2.13.5
11+
readme_renderer==34.0
1212
seed-isort-config==2.2.0
13-
vulture==2.3
13+
vulture==2.3
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pypi-parker==0.1.2
2-
setuptools==60.9.3
3-
twine==3.8.0
2+
setuptools==62.0.0
3+
twine==4.0.1
44
wheel==0.37.1

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
boto3>=1.10.0
2-
cryptography>=2.5.0
2+
cryptography>=3.4.0
33
attrs>=17.4.0
44
wrapt>=1.10.11

src/aws_encryption_sdk/identifiers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# We only actually need these imports when running the mypy checks
2828
pass
2929

30-
__version__ = "3.1.0"
30+
__version__ = "3.1.1"
3131
USER_AGENT_SUFFIX = "AwsEncryptionSdkPython/{}".format(__version__)
3232

3333

src/aws_encryption_sdk/internal/crypto/authentication.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from cryptography.hazmat.primitives import hashes, serialization
1919
from cryptography.hazmat.primitives.asymmetric import ec
2020
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
21-
from cryptography.utils import InterfaceNotImplemented, verify_interface
2221

2322
from ...exceptions import NotSupportedError
2423
from .elliptic_curve import (
@@ -47,11 +46,9 @@ def __init__(self, algorithm, key):
4746

4847
def _set_signature_type(self):
4948
"""Ensures that the algorithm signature type is a known type and sets a reference value."""
50-
try:
51-
verify_interface(ec.EllipticCurve, self.algorithm.signing_algorithm_info)
52-
return ec.EllipticCurve
53-
except InterfaceNotImplemented:
49+
if not isinstance(self.algorithm.signing_algorithm_info, type(ec.EllipticCurve)):
5450
raise NotSupportedError("Unsupported signing algorithm info")
51+
return ec.EllipticCurve
5552

5653
def _build_hasher(self):
5754
"""Builds the hasher instance which will calculate the digest of all passed data.

src/aws_encryption_sdk/internal/crypto/elliptic_curve.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
from cryptography.hazmat.backends import default_backend
1919
from cryptography.hazmat.primitives.asymmetric import ec
2020
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed, decode_dss_signature, encode_dss_signature
21-
from cryptography.utils import InterfaceNotImplemented, int_to_bytes, verify_interface
21+
from cryptography.utils import int_to_bytes
2222

2323
from ...exceptions import NotSupportedError
2424
from ..str_ops import to_bytes
2525

2626
_LOGGER = logging.getLogger(__name__)
2727

28-
2928
# Curve parameter values are included strictly as a temporary measure
3029
# until they can be rolled into the cryptography.io library.
3130
# Expanded values from http://www.secg.org/sec2-v2.pdf
@@ -44,10 +43,10 @@
4443
order=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973,
4544
),
4645
"secp521r1": _ECCCurveParameters(
47-
p=0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, # noqa pylint: disable=line-too-long
48-
a=0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC, # noqa pylint: disable=line-too-long
49-
b=0x0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00, # noqa pylint: disable=line-too-long
50-
order=0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409, # noqa pylint: disable=line-too-long
46+
p=0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, # noqa pylint: disable=line-too-long
47+
a=0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC, # noqa pylint: disable=line-too-long
48+
b=0x0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00, # noqa pylint: disable=line-too-long
49+
order=0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409, # noqa pylint: disable=line-too-long
5150
),
5251
}
5352

@@ -182,8 +181,6 @@ def generate_ecc_signing_key(algorithm):
182181
:returns: Generated signing key
183182
:raises NotSupportedError: if signing algorithm is not supported on this platform
184183
"""
185-
try:
186-
verify_interface(ec.EllipticCurve, algorithm.signing_algorithm_info)
187-
return ec.generate_private_key(curve=algorithm.signing_algorithm_info(), backend=default_backend())
188-
except InterfaceNotImplemented:
184+
if not isinstance(algorithm.signing_algorithm_info, type(ec.EllipticCurve)):
189185
raise NotSupportedError("Unsupported signing algorithm info")
186+
return ec.generate_private_key(curve=algorithm.signing_algorithm_info(), backend=default_backend())

src/aws_encryption_sdk/streaming_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ def seek(self, offset, whence=0):
299299

300300
def readline(self):
301301
"""Read a chunk of the output"""
302-
_LOGGER.info("reading line")
302+
_LOGGER.debug("reading line")
303303
line = self.read(self.line_length)
304304
if len(line) < self.line_length:
305-
_LOGGER.info("all lines read")
305+
_LOGGER.debug("all lines read")
306306
return line
307307

308308
def readlines(self):

test/unit/test_crypto_authentication_signer.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def patch_default_backend(mocker):
3030
yield aws_encryption_sdk.internal.crypto.authentication.default_backend
3131

3232

33+
@pytest.fixture
34+
def patch_ec(mocker):
35+
mocker.patch.object(aws_encryption_sdk.internal.crypto.authentication, "ec")
36+
yield aws_encryption_sdk.internal.crypto.authentication.ec
37+
38+
3339
@pytest.fixture
3440
def patch_serialization(mocker):
3541
mocker.patch.object(aws_encryption_sdk.internal.crypto.authentication, "serialization")
@@ -71,8 +77,10 @@ def test_f_signer_key_bytes():
7177
assert test.key_bytes() == VALUES["ecc_private_key_prime_private_bytes"]
7278

7379

74-
def test_signer_from_key_bytes(patch_default_backend, patch_serialization, patch_build_hasher):
75-
_algorithm = MagicMock()
80+
def test_signer_from_key_bytes(patch_default_backend, patch_serialization, patch_build_hasher, patch_ec):
81+
mock_algorithm_info = MagicMock(return_value=sentinel.algorithm_info, spec=patch_ec.EllipticCurve)
82+
_algorithm = MagicMock(signing_algorithm_info=mock_algorithm_info)
83+
7684
signer = Signer.from_key_bytes(algorithm=_algorithm, key_bytes=sentinel.key_bytes)
7785

7886
patch_serialization.load_der_private_key.assert_called_once_with(
@@ -83,9 +91,11 @@ def test_signer_from_key_bytes(patch_default_backend, patch_serialization, patch
8391
assert signer.key is patch_serialization.load_der_private_key.return_value
8492

8593

86-
def test_signer_key_bytes(patch_default_backend, patch_serialization, patch_build_hasher):
94+
def test_signer_key_bytes(patch_default_backend, patch_serialization, patch_build_hasher, patch_ec):
95+
mock_algorithm_info = MagicMock(return_value=sentinel.algorithm_info, spec=patch_ec.EllipticCurve)
96+
algorithm = MagicMock(signing_algorithm_info=mock_algorithm_info)
8797
private_key = MagicMock()
88-
signer = Signer(MagicMock(), key=private_key)
98+
signer = Signer(algorithm, key=private_key)
8999

90100
test = signer.key_bytes()
91101

@@ -98,30 +108,41 @@ def test_signer_key_bytes(patch_default_backend, patch_serialization, patch_buil
98108

99109

100110
def test_signer_encoded_public_key(
101-
patch_default_backend, patch_serialization, patch_build_hasher, patch_ecc_encode_compressed_point, patch_base64
111+
patch_default_backend,
112+
patch_serialization,
113+
patch_build_hasher,
114+
patch_ecc_encode_compressed_point,
115+
patch_base64,
116+
patch_ec
102117
):
103118
patch_ecc_encode_compressed_point.return_value = sentinel.compressed_point
104119
patch_base64.b64encode.return_value = sentinel.encoded_point
105120
private_key = MagicMock()
106121

107-
signer = Signer(MagicMock(), key=private_key)
122+
mock_algorithm_info = MagicMock(return_value=sentinel.algorithm_info, spec=patch_ec.EllipticCurve)
123+
algorithm = MagicMock(signing_algorithm_info=mock_algorithm_info)
124+
125+
signer = Signer(algorithm, key=private_key)
108126
test_key = signer.encoded_public_key()
109127

110128
patch_ecc_encode_compressed_point.assert_called_once_with(private_key)
111129
patch_base64.b64encode.assert_called_once_with(sentinel.compressed_point)
112130
assert test_key == sentinel.encoded_point
113131

114132

115-
def test_signer_update(patch_default_backend, patch_serialization, patch_build_hasher):
116-
signer = Signer(MagicMock(), key=MagicMock())
133+
def test_signer_update(patch_default_backend, patch_serialization, patch_build_hasher, patch_ec):
134+
mock_algorithm_info = MagicMock(return_value=sentinel.algorithm_info, spec=patch_ec.EllipticCurve)
135+
algorithm = MagicMock(signing_algorithm_info=mock_algorithm_info)
136+
signer = Signer(algorithm, key=MagicMock())
117137
signer.update(sentinel.data)
118138
patch_build_hasher.return_value.update.assert_called_once_with(sentinel.data)
119139

120140

121141
def test_signer_finalize(
122-
patch_default_backend, patch_serialization, patch_build_hasher, patch_ecc_static_length_signature
142+
patch_default_backend, patch_serialization, patch_build_hasher, patch_ecc_static_length_signature, patch_ec
123143
):
124-
algorithm = MagicMock()
144+
mock_algorithm_info = MagicMock(return_value=sentinel.algorithm_info, spec=patch_ec.EllipticCurve)
145+
algorithm = MagicMock(signing_algorithm_info=mock_algorithm_info)
125146
private_key = MagicMock()
126147

127148
signer = Signer(algorithm, key=private_key)

0 commit comments

Comments
 (0)