Skip to content

feat(test_vector_handlers): TestVectors test with MPL constructs #650

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

Merged
merged 381 commits into from
May 8, 2024

Conversation

lucasmcdonald3
Copy link
Contributor

@lucasmcdonald3 lucasmcdonald3 commented Mar 7, 2024

Issue #, if available:

Description of changes:

  • Modify test vector suite for all supported Python versions:
    • Add test decrypting generated test vectors from the most recent successful run of ESDK-Dafny "Daily CI": current most recent
      • "most recent" will update daily, so the vectors used will update daily
    • Add test decrypting required encryption context CMM manifest: link
      • For Python <3.10, MPL is not supported, and required encryption context CMM is not supported. However, this manifest also has "Default" CMM scenarios. As part of these changes, test vector runners without the MPL installed will filter out scenarios with the required encryption context CMM, and only test the "Default" CMM scenarios.
    • Add test generating decrypt vectors with master key constructs, then decrypting them with Python master key constructs and the JS decrypt oracle.
    • Add test encrypting vectors with master key constructs.
    • Remove running awses_local; this test is now redundant by the additions above.
      • This consisted of 2 tests: 1) "test encrypt"; 2) "test generate decrypt vectors, then decrypt those vectors". These are now covered by the above.
  • Add test vectors if the MPL is installed:
    • Add test generating decrypt vectors with keyring constructs, then decrypting them with Python keyrings, Python master keys, and the JS decrypt oracle.
    • Add test decrypting the master key-generated vectors with keyrings.
    • Add test encrypting vectors with keyring constructs.

Out of Scope

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

@lucasmcdonald3 lucasmcdonald3 changed the title Lucmcdon/mpl testvectors feat: MPL TestVectors Mar 7, 2024
@lucasmcdonald3 lucasmcdonald3 changed the title feat: MPL TestVectors feat: TestVectors test against MPL constructs Mar 7, 2024
@lucasmcdonald3 lucasmcdonald3 changed the title feat(test_vector_handlers): TestVectors test against MPL constructs feat(test_vector_handlers): TestVectors test with MPL constructs Mar 20, 2024
@lucasmcdonald3 lucasmcdonald3 marked this pull request as ready for review March 20, 2024 23:50
@lucasmcdonald3 lucasmcdonald3 requested a review from a team as a code owner March 20, 2024 23:50
)
)

# Weird hack #2:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird hack #2 is NOT present in Java.
Java test vectors use a modified keys.json file from other manifests: https://github.com/aws/aws-encryption-sdk-java/blob/master/src/test/resources/keys.json#L45
This is changed from "key-id": "rsa-4096-private" to "key-id": "rsa-4096"; similarly on the public key.
This allows the edk.keyProviderInfo == keyring.keyName check to pass, and the keyring "works".
But (afaik) all of these vector suites provide their own keys.json that still have key-ids that specify private/public, so Java would not work with those vector suites.

This code should probably be in the TestVectors Dafny. It's only here because I debugged this in Python, and want some feedback before changing the Dafny.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm following, I follow up.
This sounds like these hacks are fighting. The name of the key and the name of the key info are not the same thing.

Copy link
Contributor Author

@lucasmcdonald3 lucasmcdonald3 Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd describe it as "coordinating" rather than fighting :)
The primary evidence for this is that the test vectors pass with this change

I think the plan of action here SHOULD be some combination of 1) editing key manifests going forward, so the key name of a public/private key pair is the same; 2) add a "legacy" check in TestVectors to align the key name of any keys with names "rsa-4096-private" and "rsa-4096-public"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this plan of action going to happen here or is this happening somewhere else?

Copy link
Contributor

@seebees seebees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we generate with master key, and then decrypt with JS and master key.
How do we test keyring? Does the master key target do both?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in the MPL Test vectors project?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it isn't already, I think that's a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted with Jose, it's a good idea to put this in the test vector framework.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I resolve this? If this is done, just resolve the conversation plz :)

)
)

# Weird hack #2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm following, I follow up.
This sounds like these hacks are fighting. The name of the key and the name of the key info are not the same thing.

@lucasmcdonald3
Copy link
Contributor Author

lucasmcdonald3 commented Mar 27, 2024

So we generate with master key, and then decrypt with JS and master key.
How do we test keyring? Does the master key target do both?

That is correct for Python <3.11.
For Python 3.11 and 3.12, the matrix is

Generate: [master key, keyring]
Decrypt: [master key, keyring, JS]

Base automatically changed from lucmcdon/mpl-requiredec to mpl-reviewed April 26, 2024 17:47
Copy link
Contributor

@seebees seebees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! So many commits!

@@ -40,7 +40,8 @@ def get_requirements():
license="Apache License 2.0",
install_requires=get_requirements(),
# pylint: disable=fixme
# TODO: Point at MPL main branch once Python MPL is merged into main.
# TODO-MPL: Point at PyPI once MPL is released.
# This blocks releasing ESDK-Python MPL integration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering do we have a way to enforce this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! PyPI will not let you publish a package that uses GitHub directly. We MUST refer to the published MPL to publish the new ESDK-Python.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 367 to 242
@patch("aws_encryption_sdk.streaming_client.derive_data_encryption_key")
@patch("aws_encryption_sdk.streaming_client.DecryptionMaterialsRequest")
@patch("aws_encryption_sdk.streaming_client.Verifier")
# Given: no MPL
@pytest.mark.skipif(HAS_MPL, reason="Test should only be executed without MPL in installation")
def test_GIVEN_decrypt_config_has_ec_WHEN_read_header_THEN_calls_decrypt_materials_with_reproduced_ec(
self,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why we are deleting these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a diff issue... let me double check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! This was a merge conflict issue. I committed this test when I shouldn't have.
The behavior from this test is no longer valid.
This test would assert that encryption context on decrypt works for native (ESDK-Python) CMMs.
We decided that encryption context on decrypt would not be supported in this thread.
The new behavior validating encryption context on decrypt raises an exception is present here.

@lucasmcdonald3 lucasmcdonald3 merged commit 986f54c into mpl-reviewed May 8, 2024
151 checks passed
@lucasmcdonald3 lucasmcdonald3 deleted the lucmcdon/mpl-testvectors branch May 9, 2024 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants