Repository navigation
Conversation
Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue links the Java version of this check, so I followed that behaviour and kept the Python change small, though I haven't tried it against every caller.
Issue #, if available: #135
Description of changes:
With a signed algorithm suite,
DefaultCryptoMaterialsManagerstores the message verification key in the encryption context underaws-crypto-public-key. If the caller's context already had that key, it was overwritten without any error. This change raisesActionNotAllowedErrorin that case, as the issue asks and as the linked JavaDefaultCryptoMaterialsManagerdoes. Unsigned suites are not affected: the context is not modified for them, so nothing is rejected.The check is in
_generate_signing_key_and_update_encryption_context, before the signer is created, and the caller's dictionary is left unchanged when it raises. I pickedActionNotAllowedErrorbecause the module already uses it for an encrypt request that is not permitted. The issue does not name an exception type, so I am happy to switch to another one if you prefer.Tests: two cases in
test/unit/test_material_managers_default.py(reserved key with a signed suite raises and does not create a signer or change the context; reserved key with an unsigned suite is left alone). The signed-suite test fails when the source change is reverted.pytest test/unitin a fresh Python 3.14 venv: 4231 passed, 20 skipped. I also ran a realEncryptionSDKClient.encryptwith a raw AES key provider: a normal context works, and passing back the context returned by a previous encrypt (which contains the key) now raises.That last case is the compatibility point to weigh: a caller that re-encrypts with a context taken from an earlier message header and a signed suite used to succeed, and will now get the error. I did not check how widely that pattern is used. I did not run the integration, accept or MPL test suites, and
black --checkreports a docstring blank-line difference indefault.pythat is already onmasterand is not part of this change.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Refs #135