From c6f40656c878ae75c42c597518c5bd045ab8f5bf Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 17 May 2024 12:22:26 -0700 Subject: [PATCH 01/33] chore: performance tests for ESDK-python --- .gitignore | 2 + performance_tests/README.md | 1 + performance_tests/__init__.py | 3 + performance_tests/consolidate_results.py | 41 ++++++ performance_tests/requirements.txt | 5 + performance_tests/requirements_mpl.txt | 1 + performance_tests/setup.cfg | 41 ++++++ performance_tests/setup.py | 34 +++++ .../__init__.py | 4 + .../keyrings/__init__.py | 3 + .../keyrings/aws_kms_keyring.py | 87 ++++++++++++ .../keyrings/pylintrc | 45 ++++++ .../master_key_providers/__init__.py | 3 + .../aws_kms_key_provider.py | 70 ++++++++++ .../master_key_providers/pylintrc | 45 ++++++ .../utils/__init__.py | 3 + .../utils/parse_pstats.py | 19 +++ .../utils/pylintrc | 45 ++++++ .../utils/util.py | 21 +++ performance_tests/src/pylintrc | 45 ++++++ performance_tests/test/keyrings/__init__.py | 3 + performance_tests/test/keyrings/pylintrc | 45 ++++++ .../test/keyrings/test_aws_kms_keyring.py | 131 ++++++++++++++++++ .../test/master_key_providers/__init__.py | 3 + .../test/master_key_providers/pylintrc | 45 ++++++ .../test_aws_kms_master_key_provider.py | 131 ++++++++++++++++++ performance_tests/test/resources/__init__.py | 3 + .../test/resources/ciphertext-data-empty.ct | Bin 0 -> 587 bytes .../test/resources/ciphertext-data-large.ct | Bin 0 -> 2761 bytes .../test/resources/ciphertext-data-medium.ct | Bin 0 -> 687 bytes .../test/resources/ciphertext-data-small.ct | Bin 0 -> 592 bytes .../test/resources/plaintext-data-empty.dat | 0 .../test/resources/plaintext-data-large.dat | 26 ++++ .../test/resources/plaintext-data-medium.dat | 2 + .../test/resources/plaintext-data-small.dat | 1 + performance_tests/test/resources/pylintrc | 45 ++++++ 36 files changed, 953 insertions(+) create mode 100644 performance_tests/README.md create mode 100644 performance_tests/__init__.py create mode 100644 performance_tests/consolidate_results.py create mode 100644 performance_tests/requirements.txt create mode 100644 performance_tests/requirements_mpl.txt create mode 100644 performance_tests/setup.cfg create mode 100644 performance_tests/setup.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/__init__.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/pylintrc create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/__init__.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/utils/__init__.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py create mode 100644 performance_tests/src/pylintrc create mode 100644 performance_tests/test/keyrings/__init__.py create mode 100644 performance_tests/test/keyrings/pylintrc create mode 100644 performance_tests/test/keyrings/test_aws_kms_keyring.py create mode 100644 performance_tests/test/master_key_providers/__init__.py create mode 100644 performance_tests/test/master_key_providers/pylintrc create mode 100644 performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py create mode 100644 performance_tests/test/resources/__init__.py create mode 100644 performance_tests/test/resources/ciphertext-data-empty.ct create mode 100644 performance_tests/test/resources/ciphertext-data-large.ct create mode 100644 performance_tests/test/resources/ciphertext-data-medium.ct create mode 100644 performance_tests/test/resources/ciphertext-data-small.ct create mode 100644 performance_tests/test/resources/plaintext-data-empty.dat create mode 100644 performance_tests/test/resources/plaintext-data-large.dat create mode 100644 performance_tests/test/resources/plaintext-data-medium.dat create mode 100644 performance_tests/test/resources/plaintext-data-small.dat create mode 100644 performance_tests/test/resources/pylintrc diff --git a/.gitignore b/.gitignore index 24df397ed..0dea8718c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,8 @@ __pycache__ .pytest_cache # Ignore key materials generated by examples or tests test_keyrings/ +# Ignore results of performance test +performance_tests/results/* # PyCharm .idea/ diff --git a/performance_tests/README.md b/performance_tests/README.md new file mode 100644 index 000000000..78c80b7cd --- /dev/null +++ b/performance_tests/README.md @@ -0,0 +1 @@ +# Performance Tests for ESDK Python diff --git a/performance_tests/__init__.py b/performance_tests/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/consolidate_results.py b/performance_tests/consolidate_results.py new file mode 100644 index 000000000..1f95dcf38 --- /dev/null +++ b/performance_tests/consolidate_results.py @@ -0,0 +1,41 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Script for consolidating results for execution times""" + +import csv +import sys + + +def calculate_statistics(_csv_file): + """Calculate min, max and average statistics for execution times in a CSV file.""" + with open(_csv_file, 'r', encoding='utf-8') as file: + reader = csv.reader(file) + data = [float(row[0]) for row in reader] + + # Calculate statistics + if data: + _total_entries = len(data) + _average = sum(data) / _total_entries + _minimum = min(data) + _maximum = max(data) + return _total_entries, _average, _minimum, _maximum + + return None + + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python consolidate_results.py ") + sys.exit(1) + + csv_file = sys.argv[1] + statistics = calculate_statistics(csv_file) + if statistics: + total_entries, average, minimum, maximum = statistics + print("CSV File:", csv_file) + print("Total Entries:", total_entries) + print("Average:", average) + print("Minimum:", minimum) + print("Maximum:", maximum) + else: + print("No data found in the CSV file.") diff --git a/performance_tests/requirements.txt b/performance_tests/requirements.txt new file mode 100644 index 000000000..0b879647f --- /dev/null +++ b/performance_tests/requirements.txt @@ -0,0 +1,5 @@ +attrs >= 17.4.0 +aws-encryption-sdk>=2.3.0 +pytest>=3.3.1 +tqdm +click diff --git a/performance_tests/requirements_mpl.txt b/performance_tests/requirements_mpl.txt new file mode 100644 index 000000000..c7927a851 --- /dev/null +++ b/performance_tests/requirements_mpl.txt @@ -0,0 +1 @@ +amazon-cryptographic-material-providers-test-vectors @ git+https://github.com/aws/aws-cryptographic-material-providers-library.git@lucmcdon/python-mpl#subdirectory=TestVectorsAwsCryptographicMaterialProviders/runtimes/python \ No newline at end of file diff --git a/performance_tests/setup.cfg b/performance_tests/setup.cfg new file mode 100644 index 000000000..c584a25bd --- /dev/null +++ b/performance_tests/setup.cfg @@ -0,0 +1,41 @@ +[wheel] +universal = 1 + +[metadata] +license_file = LICENSE + +[coverage:run] +branch = True + +[coverage:report] +show_missing = True + +[mypy] +ignore_missing_imports = True + +[flake8] +max_complexity = 10 +max_line_length = 120 +import_order_style = google +application_import_names = aws_encryption_sdk_cli +builtins = raw_input +ignore = + # Ignoring D205 and D400 because of false positives + D205, D400, + # E203 is not PEP8 compliant https://github.com/ambv/black#slices + E203, + # W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators + W503 + +[doc8] +max-line-length = 120 + +[isort] +line_length = 120 +# https://github.com/timothycrosley/isort#multi-line-output-modes +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +combine_as_imports = True +not_skip = __init__.py +known_third_party = attr,aws_encryption_sdk,pytest,setuptools,six diff --git a/performance_tests/setup.py b/performance_tests/setup.py new file mode 100644 index 000000000..702813509 --- /dev/null +++ b/performance_tests/setup.py @@ -0,0 +1,34 @@ +"""Performance test for the AWS Encryption SDK for Python.""" +import os +import re + +from setuptools import find_packages, setup + +VERSION_RE = re.compile(r"""__version__ = ['"]([0-9.]+)['"]""") +HERE = os.path.abspath(os.path.dirname(__file__)) + + +def read(*args): + """Read complete file contents.""" + return open(os.path.join(HERE, *args), encoding="utf-8").read() # pylint: disable=consider-using-with + + +def get_version(): + """Read the version from this module.""" + init = read("src", "aws_encryption_sdk_performance_tests", "__init__.py") + return VERSION_RE.search(init).group(1) + + +setup( + name="aws-encryption-sdk-performance-tests", + packages=find_packages("src"), + package_dir={"": "src"}, + author="Amazon Web Services", + maintainer="Amazon Web Services", + author_email="aws-cryptools@amazon.com", + url="https://github.com/awslabs/aws-encryption-sdk-python", + description="Performance tests for the AWS Encryption SDK for Python", + keywords="aws-encryption-sdk aws kms encryption", + license="Apache License 2.0", + version=get_version(), +) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py b/performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py new file mode 100644 index 000000000..bbfe61296 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" +__version__ = "0.0.0" diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/__init__.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py new file mode 100644 index 000000000..a0d8ee50f --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py @@ -0,0 +1,87 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Performance tests for the AWS KMS keyring.""" + +import aws_encryption_sdk +import boto3 +from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders +from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig +from aws_cryptographic_materialproviders.mpl.models import CreateAwsKmsKeyringInput +from aws_cryptographic_materialproviders.mpl.references import IKeyring +from aws_encryption_sdk import CommitmentPolicy + + +def create_keyring( + kms_key_id: str +): + """Demonstrate how to create an AWS KMS keyring. + + Usage: create_keyring(kms_key_id) + :param kms_key_id: KMS Key identifier for the KMS key you want to use. + :type kms_key_id: string + + For more information on KMS Key identifiers, see + https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id + """ + # Create a boto3 client for KMS. + kms_client = boto3.client('kms', region_name="us-west-2") + + # Create a KMS keyring + mat_prov: AwsCryptographicMaterialProviders = AwsCryptographicMaterialProviders( + config=MaterialProvidersConfig() + ) + + keyring_input: CreateAwsKmsKeyringInput = CreateAwsKmsKeyringInput( + kms_key_id=kms_key_id, + kms_client=kms_client + ) + + keyring: IKeyring = mat_prov.create_aws_kms_keyring( + input=keyring_input + ) + + return keyring + + +def encrypt_using_keyring( + plaintext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to encrypt plaintext data using an AWS KMS keyring. + + Usage: encrypt_using_keyring(plaintext_data, keyring) + :param plaintext_data: plaintext data you want to encrypt + :type: bytes + :param keyring: Keyring to use for encryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient( + commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT + ) + + _, _ = client.encrypt( + source=plaintext_data, + keyring=keyring + ) + + +def decrypt_using_keyring( + ciphertext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to decrypt ciphertext data using an AWS KMS keyring. + + Usage: decrypt_using_keyring(ciphertext_data, keyring) + :param ciphertext_data: ciphertext data you want to decrypt + :type: bytes + :param keyring: Keyring to use for decryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient( + commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT + ) + + _, _ = client.decrypt( + source=ciphertext_data, + keyring=keyring + ) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/pylintrc b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/pylintrc new file mode 100644 index 000000000..8ed5cb105 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/pylintrc @@ -0,0 +1,45 @@ +[MESSAGE CONTROL] +# Disabling messages that either we don't care about we intentionally break. +disable = + import-error, # ignore mpl import errors + invalid-name, # we prefer long, descriptive, names for examples + bad-continuation, # we let black handle this + ungrouped-imports, # we let isort handle this + no-member, # breaks with attrs + no-self-use, # interesting to keep in mind for later refactoring, but not blocking + useless-object-inheritance, # we need to support Python 2, so no, not useless + duplicate-code, # some examples may be similar + too-few-public-methods, # does not allow value stores + too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code + no-else-return, # we omit this on purpose for brevity where it would add no value + attribute-defined-outside-init, # breaks with attrs_post_init + abstract-method, # throws false positives on io.BaseIO grandchildren + redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + +[BASIC] +# Allow function names up to 50 characters +function-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow method names up to 50 characters +method-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow class attribute names up to 50 characters +# Whitelist class attribute names: iv +class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) +# Whitelist attribute names: iv +attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) +# Whitelist argument names: iv, b +argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) +# Whitelist variable names: iv, b, _b, x, y, r, s +variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) + +[VARIABLES] +additional-builtins = raw_input + +[DESIGN] +max-args = 10 + +[FORMAT] +max-line-length = 120 + +[REPORTS] +msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/__init__.py b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py new file mode 100644 index 000000000..731c0ecd3 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py @@ -0,0 +1,70 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Performance tests for the AWS KMS master key provider.""" + +import aws_encryption_sdk +from aws_encryption_sdk import CommitmentPolicy + + +def create_key_provider( + kms_key_id: str +): + """Demonstrate how to create an AWS KMS master key-provider. + + Usage: create_key_provider(kms_key_id) + :param kms_key_id: KMS Key identifier for the KMS key you want to use. + :type kms_key_id: string + + For more information on KMS Key identifiers, see + https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id + """ + # Create a KMS master key-provider. + key_provider = aws_encryption_sdk.StrictAwsKmsMasterKeyProvider(key_ids=[ + kms_key_id, + ]) + + return key_provider + + +def encrypt_using_key_provider( + plaintext_data: bytes, + key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider +): + """Demonstrate how to encrypt plaintext data using an AWS KMS master key-provider. + + Usage: encrypt_using_key_provider(plaintext_data, key_provider) + :param plaintext_data: plaintext data you want to encrypt + :type: bytes + :param key_provider: Master key provider to use for encryption. + :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider + """ + client = aws_encryption_sdk.EncryptionSDKClient( + commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT + ) + + _, _ = client.encrypt( + source=plaintext_data, + key_provider=key_provider + ) + + +def decrypt_using_key_provider( + ciphertext_data: bytes, + key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider +): + """Demonstrate how to decrypt ciphertext data using an AWS KMS master key-provider. + + Usage: decrypt_using_key_provider(ciphertext_data, key_provider) + :param ciphertext_data: ciphertext data you want to decrypt + :type: bytes + :param key_provider: Master key provider to use for decryption. + :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider + """ + client = aws_encryption_sdk.EncryptionSDKClient( + commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT + ) + + _, _ = client.decrypt( + source=ciphertext_data, + key_provider=key_provider + ) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc new file mode 100644 index 000000000..8ed5cb105 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc @@ -0,0 +1,45 @@ +[MESSAGE CONTROL] +# Disabling messages that either we don't care about we intentionally break. +disable = + import-error, # ignore mpl import errors + invalid-name, # we prefer long, descriptive, names for examples + bad-continuation, # we let black handle this + ungrouped-imports, # we let isort handle this + no-member, # breaks with attrs + no-self-use, # interesting to keep in mind for later refactoring, but not blocking + useless-object-inheritance, # we need to support Python 2, so no, not useless + duplicate-code, # some examples may be similar + too-few-public-methods, # does not allow value stores + too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code + no-else-return, # we omit this on purpose for brevity where it would add no value + attribute-defined-outside-init, # breaks with attrs_post_init + abstract-method, # throws false positives on io.BaseIO grandchildren + redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + +[BASIC] +# Allow function names up to 50 characters +function-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow method names up to 50 characters +method-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow class attribute names up to 50 characters +# Whitelist class attribute names: iv +class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) +# Whitelist attribute names: iv +attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) +# Whitelist argument names: iv, b +argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) +# Whitelist variable names: iv, b, _b, x, y, r, s +variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) + +[VARIABLES] +additional-builtins = raw_input + +[DESIGN] +max-args = 10 + +[FORMAT] +max-line-length = 120 + +[REPORTS] +msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/__init__.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py new file mode 100644 index 000000000..196e849a3 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py @@ -0,0 +1,19 @@ +import pstats +import sys + +if __name__ == '__main__': + if len(sys.argv) != 2: + print("Usage: python3 parse_pstats.py ") + sys.exit(1) + + pstats_filename = sys.argv[1] + + # Load the .pstats file + stats = pstats.Stats(pstats_filename) + + # Get the total runtime + total_runtime = stats.total_tt + + # stats.sort_stats('cumtime').print_stats() + # print(stats.get_stats_profile()) + print('total_runtime', total_runtime) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc new file mode 100644 index 000000000..8ed5cb105 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc @@ -0,0 +1,45 @@ +[MESSAGE CONTROL] +# Disabling messages that either we don't care about we intentionally break. +disable = + import-error, # ignore mpl import errors + invalid-name, # we prefer long, descriptive, names for examples + bad-continuation, # we let black handle this + ungrouped-imports, # we let isort handle this + no-member, # breaks with attrs + no-self-use, # interesting to keep in mind for later refactoring, but not blocking + useless-object-inheritance, # we need to support Python 2, so no, not useless + duplicate-code, # some examples may be similar + too-few-public-methods, # does not allow value stores + too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code + no-else-return, # we omit this on purpose for brevity where it would add no value + attribute-defined-outside-init, # breaks with attrs_post_init + abstract-method, # throws false positives on io.BaseIO grandchildren + redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + +[BASIC] +# Allow function names up to 50 characters +function-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow method names up to 50 characters +method-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow class attribute names up to 50 characters +# Whitelist class attribute names: iv +class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) +# Whitelist attribute names: iv +attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) +# Whitelist argument names: iv, b +argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) +# Whitelist variable names: iv, b, _b, x, y, r, s +variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) + +[VARIABLES] +additional-builtins = raw_input + +[DESIGN] +max-args = 10 + +[FORMAT] +max-line-length = 120 + +[REPORTS] +msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py new file mode 100644 index 000000000..2b7682bf6 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py @@ -0,0 +1,21 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Utility functions for AWS Encryption SDK performance tests.""" + + +class PerfTestUtils: + """Utility functions for AWS Encryption SDK performance tests.""" + DEFAULT_N_ITERS = 100 + + @staticmethod + def read_file(filename): + """Returns the contents of the file.""" + with open(filename, 'rb') as file: + return file.read() + + @staticmethod + def print_time_list_to_csv(time_list, filename): + """Prints the time list to a CSV file.""" + with open('results/' + filename + '.csv', 'w', encoding='utf-8') as myfile: + for time in time_list: + myfile.write(str(time) + '\n') diff --git a/performance_tests/src/pylintrc b/performance_tests/src/pylintrc new file mode 100644 index 000000000..8ed5cb105 --- /dev/null +++ b/performance_tests/src/pylintrc @@ -0,0 +1,45 @@ +[MESSAGE CONTROL] +# Disabling messages that either we don't care about we intentionally break. +disable = + import-error, # ignore mpl import errors + invalid-name, # we prefer long, descriptive, names for examples + bad-continuation, # we let black handle this + ungrouped-imports, # we let isort handle this + no-member, # breaks with attrs + no-self-use, # interesting to keep in mind for later refactoring, but not blocking + useless-object-inheritance, # we need to support Python 2, so no, not useless + duplicate-code, # some examples may be similar + too-few-public-methods, # does not allow value stores + too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code + no-else-return, # we omit this on purpose for brevity where it would add no value + attribute-defined-outside-init, # breaks with attrs_post_init + abstract-method, # throws false positives on io.BaseIO grandchildren + redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + +[BASIC] +# Allow function names up to 50 characters +function-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow method names up to 50 characters +method-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow class attribute names up to 50 characters +# Whitelist class attribute names: iv +class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) +# Whitelist attribute names: iv +attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) +# Whitelist argument names: iv, b +argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) +# Whitelist variable names: iv, b, _b, x, y, r, s +variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) + +[VARIABLES] +additional-builtins = raw_input + +[DESIGN] +max-args = 10 + +[FORMAT] +max-line-length = 120 + +[REPORTS] +msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/test/keyrings/__init__.py b/performance_tests/test/keyrings/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/test/keyrings/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/test/keyrings/pylintrc b/performance_tests/test/keyrings/pylintrc new file mode 100644 index 000000000..8ed5cb105 --- /dev/null +++ b/performance_tests/test/keyrings/pylintrc @@ -0,0 +1,45 @@ +[MESSAGE CONTROL] +# Disabling messages that either we don't care about we intentionally break. +disable = + import-error, # ignore mpl import errors + invalid-name, # we prefer long, descriptive, names for examples + bad-continuation, # we let black handle this + ungrouped-imports, # we let isort handle this + no-member, # breaks with attrs + no-self-use, # interesting to keep in mind for later refactoring, but not blocking + useless-object-inheritance, # we need to support Python 2, so no, not useless + duplicate-code, # some examples may be similar + too-few-public-methods, # does not allow value stores + too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code + no-else-return, # we omit this on purpose for brevity where it would add no value + attribute-defined-outside-init, # breaks with attrs_post_init + abstract-method, # throws false positives on io.BaseIO grandchildren + redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + +[BASIC] +# Allow function names up to 50 characters +function-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow method names up to 50 characters +method-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow class attribute names up to 50 characters +# Whitelist class attribute names: iv +class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) +# Whitelist attribute names: iv +attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) +# Whitelist argument names: iv, b +argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) +# Whitelist variable names: iv, b, _b, x, y, r, s +variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) + +[VARIABLES] +additional-builtins = raw_input + +[DESIGN] +max-args = 10 + +[FORMAT] +max-line-length = 120 + +[REPORTS] +msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py new file mode 100644 index 000000000..1137be79c --- /dev/null +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -0,0 +1,131 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""This is a performance test for creating the AWS KMS keyring.""" + +import time + +import click +from tqdm import tqdm + +from aws_encryption_sdk_performance_tests.keyrings.aws_kms_keyring import ( + create_keyring, + decrypt_using_keyring, + encrypt_using_keyring, +) +from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils + + +@click.group() +def create_kms_keyring(): + """Click group helper function""" + + +@create_kms_keyring.command() +@click.option('--kms_key_id', + default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='kms_keyring_create') +def create( + kms_key_id: str, + n_iters: int, + output_file: str +): + """Performance test for the create_keyring function.""" + time_list = [] + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + create_keyring(kms_key_id) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.print_time_list_to_csv(time_list, output_file) + + +@click.group() +def encrypt_kms_keyring(): + """Click group helper function""" + + +@encrypt_kms_keyring.command() +@click.option('--plaintext_data_filename', + prompt='Filename containing plaintext data you want to encrypt') +@click.option('--kms_key_id', + default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='kms_keyring_encrypt') +def encrypt( + plaintext_data_filename: str, + kms_key_id: str, + n_iters: int, + output_file: str +): + """Performance test for the encrypt_using_keyring function.""" + plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) + + keyring = create_keyring(kms_key_id) + time_list = [] + + for _ in range(n_iters): + curr_time = time.time() + + encrypt_using_keyring(plaintext_data, keyring) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.print_time_list_to_csv(time_list, output_file) + + +@click.group() +def decrypt_kms_keyring(): + """Click group helper function""" + + +@decrypt_kms_keyring.command() +@click.option('--ciphertext_data_filename', + prompt='Filename containing ciphertext data you want to decrypt') +@click.option('--kms_key_id', + default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='kms_keyring_decrypt') +def decrypt( + ciphertext_data_filename: str, + kms_key_id: str, + n_iters: int, + output_file: str +): + """Performance test for the decrypt_using_keyring function.""" + ciphertext_data = PerfTestUtils.read_file(ciphertext_data_filename) + + keyring = create_keyring(kms_key_id) + time_list = [] + + for _ in range(n_iters): + curr_time = time.time() + + decrypt_using_keyring(ciphertext_data, keyring) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.print_time_list_to_csv(time_list, output_file) + + +kms_keyring_test = click.CommandCollection(sources=[create_kms_keyring, + encrypt_kms_keyring, + decrypt_kms_keyring]) + + +if __name__ == "__main__": + kms_keyring_test() diff --git a/performance_tests/test/master_key_providers/__init__.py b/performance_tests/test/master_key_providers/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/test/master_key_providers/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/test/master_key_providers/pylintrc b/performance_tests/test/master_key_providers/pylintrc new file mode 100644 index 000000000..8ed5cb105 --- /dev/null +++ b/performance_tests/test/master_key_providers/pylintrc @@ -0,0 +1,45 @@ +[MESSAGE CONTROL] +# Disabling messages that either we don't care about we intentionally break. +disable = + import-error, # ignore mpl import errors + invalid-name, # we prefer long, descriptive, names for examples + bad-continuation, # we let black handle this + ungrouped-imports, # we let isort handle this + no-member, # breaks with attrs + no-self-use, # interesting to keep in mind for later refactoring, but not blocking + useless-object-inheritance, # we need to support Python 2, so no, not useless + duplicate-code, # some examples may be similar + too-few-public-methods, # does not allow value stores + too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code + no-else-return, # we omit this on purpose for brevity where it would add no value + attribute-defined-outside-init, # breaks with attrs_post_init + abstract-method, # throws false positives on io.BaseIO grandchildren + redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + +[BASIC] +# Allow function names up to 50 characters +function-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow method names up to 50 characters +method-rgx = [a-z_][a-z0-9_]{2,50}$ +# Allow class attribute names up to 50 characters +# Whitelist class attribute names: iv +class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) +# Whitelist attribute names: iv +attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) +# Whitelist argument names: iv, b +argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) +# Whitelist variable names: iv, b, _b, x, y, r, s +variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) + +[VARIABLES] +additional-builtins = raw_input + +[DESIGN] +max-args = 10 + +[FORMAT] +max-line-length = 120 + +[REPORTS] +msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py new file mode 100644 index 000000000..8189862e9 --- /dev/null +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -0,0 +1,131 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""This is a performance test for creating the AWS KMS Master key-provider.""" + +import time + +import click +from tqdm import tqdm + +from aws_encryption_sdk_performance_tests.master_key_providers.aws_kms_key_provider import ( + create_key_provider, + decrypt_using_key_provider, + encrypt_using_key_provider, +) +from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils + + +@click.group() +def create_kms_key_provider(): + """Click group helper function""" + + +@create_kms_key_provider.command() +@click.option('--kms_key_id', + default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='kms_key_provider_create') +def create( + kms_key_id: str, + n_iters: int, + output_file: str +): + """Performance test for the create_key_provider function.""" + time_list = [] + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + create_key_provider(kms_key_id) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.print_time_list_to_csv(time_list, output_file) + + +@click.group() +def encrypt_kms_key_provider(): + """Click group helper function""" + + +@encrypt_kms_key_provider.command() +@click.option('--plaintext_data_filename', + prompt='Filename containing plaintext data you want to encrypt') +@click.option('--kms_key_id', + default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='kms_key_provider_encrypt') +def encrypt( + plaintext_data_filename: str, + kms_key_id: str, + n_iters: int, + output_file: str +): + """Performance test for the encrypt_using_key_provider function.""" + plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) + + key_provider = create_key_provider(kms_key_id) + time_list = [] + + for _ in range(n_iters): + curr_time = time.time() + + encrypt_using_key_provider(plaintext_data, key_provider) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.print_time_list_to_csv(time_list, output_file) + + +@click.group() +def decrypt_kms_key_provider(): + """Click group helper function""" + + +@decrypt_kms_key_provider.command() +@click.option('--ciphertext_data_filename', + prompt='Filename containing ciphertext data you want to decrypt') +@click.option('--kms_key_id', + default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='kms_key_provider_decrypt') +def decrypt( + ciphertext_data_filename: str, + kms_key_id: str, + n_iters: int, + output_file: str +): + """Performance test for the decrypt_using_key_provider function.""" + ciphertext_data = PerfTestUtils.read_file(ciphertext_data_filename) + + key_provider = create_key_provider(kms_key_id) + time_list = [] + + for _ in range(n_iters): + curr_time = time.time() + + decrypt_using_key_provider(ciphertext_data, key_provider) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.print_time_list_to_csv(time_list, output_file) + + +kms_key_provider_test = click.CommandCollection(sources=[create_kms_key_provider, + encrypt_kms_key_provider, + decrypt_kms_key_provider]) + + +if __name__ == "__main__": + kms_key_provider_test() diff --git a/performance_tests/test/resources/__init__.py b/performance_tests/test/resources/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/test/resources/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/test/resources/ciphertext-data-empty.ct b/performance_tests/test/resources/ciphertext-data-empty.ct new file mode 100644 index 0000000000000000000000000000000000000000..2455c0796d2b185e7d8f5f656a18088ca5a31872 GIT binary patch literal 587 zcmZQ#t#~)@Ukk&D_q=LtF_w%R8OD?L9$Nq3o9Taj_E1hxh9@I=Be4{1`$OmP61V=dCA4v+S*3N-jzY7u2rd) z8D^g8WnK{#g;l9;j!9v;shLjt!68v){w0b2X6d%JK;zj##%JdiGk7N!^E8I#jEsy76%LwVdKf8T70CYMd5W@hNosjmtC98Ckx0<+3`P7n$oDAs( zsZ53p8#I4r7S^3yC%e|-rpxq0Q?)*aeX(%(yG^ulyRLBg`2&+QD>$conX%%dcGm)~ z?db|k2AMm>76_HA8(%5;^r>mmT-Uo1Aujvu4lUndWAJ`)dSq>-xXtqK~Ygb`Zc|k)~N^xv)O=omUS7my3O-NIEL2gEGb8<6n zXJ<+`N@8~_IAuXpbYnw#aYt@KT4ix!a&9(mG&n;=cRf7-0RRVKcXKUkZF2xiVRCLd zVRv&nYi)Bnb#pCuWpi{bGCDRjI5{;oHZU+aGc!7CWqB`RGc_|eWo9ugWH@AFEi^Yc zFfBP|HDN6^H8(dlV`5@5W;bR4rvU*00C+(2j3-_(33L|02PsidR~cljqw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5ha$(s5WeNI8%7$=x ztU{)tvEa({Uid9!@Cj$T#9r8o{q$UETj>aGbQ@TU)91=o8 zutp7@$4Wf37#@khvZ`?J{<5k)G}Y|51+4cPNRju3Oh>#%YD^NtWKY6Ty31>B^6S-w z7{2d!mU_Htv&q+j8Kk~R#1xMyZH>ywm1SC688K142{y($@*!W}Y60Whv+th`r~USC zq(j1Hhh{?`+)*qKAfECuK`o-=yiiLXTVy!YY}qU$JaxnF8IgNJ*Y5!ayjaYtZGj&% z8Xzu<#`&|Kmupraisk+CWL}H3V+8=rv&~PCU=orxCxqM}TbIke3OK|mhG_0~lT=jj zp%g`B@IN^Y2^ClU;KQw`Wdy`Xw5(efs33Bjw=g4*rwh4SMV!!W`ynIhBQBECm7BNL zWc>2p=N$R_WB`@hipz8CpbCn_$bmrE7%|%Li2)8c&A>|Lq~Vp1Eu3i8#kR>MXH9wU zUhZi4`%c?RCsH=^qwiwXKL0M~Kg6=g|4@>zy?dFk$!@EdgZ}h?qcjG7p0Jl^WzX|w zqDzUsiTX6lddw%l>nZl(=p$?=J)%+9_ubI&O|j&FImQ}b$oX^Lq17$AU~>b(3uvPK zL(-8tTMVyAxfaWG{Q~IwFRw%krx0RXTcGAncJr>ZK3&&J{!-+qSq zYiRV>E!l%D<;qcINk8Z*KVtn#9qnGWY`Ne)TCVh@cuAy$NQGg?g?gk+2K39z72=n3 z^m)VhuaJQOw;JKh)JP_XY}PqQ(SMkdQb{$K(W_0)C)o9 z@KwA}OmpyCOE$&;XE0>~Fi-U=wB#fO$7^#~$?NZ!Bpof*L?$G;4UP*Usk3?|pc6Jt z?4e(zzcEHWL<`Yb&H^z2z_%||dRh(s^TM~fl^@0jn|?fUJ&@!<>1NX4reG{+cC;dx PL|r+#3>%QJdZvY2m&6|! literal 0 HcmV?d00001 diff --git a/performance_tests/test/resources/ciphertext-data-medium.ct b/performance_tests/test/resources/ciphertext-data-medium.ct new file mode 100644 index 0000000000000000000000000000000000000000..c59bdacb7ecafa208fcb1cd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|W8kH!W&X(i3k(*{s3UZ&lS~c|6Py5H7KVJvhKlHi% zqtM&X!}enC#tpAlu^;-M`C^wwlr0kjg8;+!wB~o8&rLb|KyVSa)<;IM$OTD`K4w#T zfAc=+v@r8{=5_w}mappRiz|Oj?un4ASo9wVfKF!wVi*9iSvNem*U$NN#;19~!5!&r zT^AqDl=1w+kZzF5WXQ0~=dRv+)mQl}o(_~Tr5UGq9z-`^DZ zK0#dInKbL;xf}C0Z)7q^Hm*B!xxLlp_7bH>rtf%8o7Dt2P5kTMW950jr0`L*jq@S( SO2zJQR) Date: Fri, 17 May 2024 13:20:40 -0700 Subject: [PATCH 02/33] Added README --- .gitignore | 2 + performance_tests/README.md | 133 ++++++++++++++++++ .../utils/parse_pstats.py | 19 --- 3 files changed, 135 insertions(+), 19 deletions(-) delete mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py diff --git a/.gitignore b/.gitignore index 0dea8718c..3184add64 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ __pycache__ test_keyrings/ # Ignore results of performance test performance_tests/results/* +# Ignore the memory profile logs +mprofile_* # PyCharm .idea/ diff --git a/performance_tests/README.md b/performance_tests/README.md index 78c80b7cd..7db6c217a 100644 --- a/performance_tests/README.md +++ b/performance_tests/README.md @@ -1 +1,134 @@ # Performance Tests for ESDK Python + +## License + +This project is licensed under the Apache-2.0 License. + +## Overview + +Here are the keyrings / master key-providers that we plan to test: + +1. KMS Keyring / KMS Master Key Provider +2. Raw AES Keyring / AES Master Key Provider +3. HKeyring / caching CMM example ("old" caching solution vs the (current) "new" caching solution) +4. Raw RSA Keyring / RSA Master Key Provider + +For each test on the above keyrings / master key-providers, we measure the execution time and memory consumption in each test. + +For each keyring / master key-provider, we test the execution time and memory consumption time for three operations: +1. Create keyring / master key-provider +2. Encrypt +3. Decrypt + +We demonstrate the usage of the performance tests through an [AWS KMS Keyring](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html). However, the procedure is the same for any keyring / master key-provider. + +The results for the performance test will be available in the results folder in the performance_tests directory. + +## Usage: Execution Time + +### Create Keyring +To run the performance test for execution time, please use the following commands in the performance_tests directory +``` +python test/keyrings/test_aws_kms_keyring.py create +``` + +#### Optional Arguments +* kms_key_id: The KMS key ID you want to use +* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the create_keyring method 100 times and report the execution time of each of the calls. +* output_file: The output file for execution times for each function call, default='kms_keyring_create' in the results folder + +#### Consolidate Results + +In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: +``` +python consolidate_results.py results/kms_keyring_create.csv +``` + +### Encrypt +To run the performance test for execution time, please use the following commands in the performance_tests directory +``` +python test/keyrings/test_aws_kms_keyring.py encrypt +``` + +Here, you will receive a prompt on the terminal to specify the plaintext file you want to encrypt. Some example plaintext data files are present in the 'test/resources' directory. + +Alternatively, if you want to provide the arguments as flags without using the interactive CLI, you can run the command in the following manner: + +``` +python test/keyrings/test_aws_kms_keyring.py encrypt --plaintext_data_filename test/resources/plaintext-data-medium.dat +``` + +You can choose to use any other plaintext file as well. + +#### Arguments +* plaintext_data_filename: Filename containing plaintext data you want to encrypt + +#### Optional Arguments +* kms_key_id: The KMS key ID you want to use to encrypt the data +* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the encrypt method 100 times and report the execution time of each of the calls. +* output_file: The output file for execution times for each function call, default='kms_keyring_encrypt' + +#### Consolidate Results + +In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: +``` +python consolidate_results.py results/kms_keyring_encrypt.csv +``` + +### Decrypt +To run the performance test for execution time, please use the following commands in the performance_tests directory +``` +python test/keyrings/test_aws_kms_keyring.py decrypt +``` + +Here, you will receive a prompt on the terminal to specify the ciphertext file you want to decrypt. Some example ciphertext data files are present in the 'test/resources' directory. + +Alternatively, if you want to provide the arguments as flags without using the interactive CLI, you can run the command in the following manner: + +``` +python test/keyrings/test_aws_kms_keyring.py decrypt --ciphertext_data_filename test/resources/ciphertext-data-medium.ct +``` + +You can choose to use any other ciphertext file as well. + +#### Arguments +* ciphertext_data_filename: Filename containing ciphertext data you want to decrypt + +#### Optional Arguments +* kms_key_id: The KMS key ID you want to use to decrypt the data +* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the decrypt method 100 times and report the execution time of each of the calls. +* output_file: The output file for execution times for each function call, default='kms_keyring_decrypt' + +#### Consolidate Results + +In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: +``` +python consolidate_results.py results/kms_keyring_decrypt.csv +``` + +## Usage: Memory Consumption +To get the memory consumption, simply use 'mprof run' instead of 'python' in the previously mentioned commands. + +For example, if you want to calculate the memory consumption of the encrypt function of a AWS KMS Keyring, simply write: +``` +mprof run test/keyrings/test_aws_kms_keyring.py encrypt --plaintext_data_filename test/resources/plaintext-data-medium.dat +``` + +This should generate an mprofile log file in your current directory. To plot the memory consumption with time, please use the following command from the same directory +``` +mprof plot +``` + +This 'mprof plot' command will plot the most recent mprofile log file. + +## Usage: Performance Graph +To generate a performance graph, please use the following command to generate the pstats log file by specifying the output pstats file path. Here, we use 'results/kms_keyring_create.pstats' as the output file. + +``` +python -m cProfile -o results/kms_keyring_create.pstats test/keyrings/test_aws_kms_keyring.py create +``` + +After generating the pstats file, please run the following command to generate the performance graph. The output performance graph will be a .png file that you specify. Here, we use 'results/kms_keyring_create.png' as the output file. +``` +gprof2dot -f pstats results/kms_keyring_create.pstats | dot -Tpng -o results/kms_keyring_create.png && eog results/kms_keyring_create.png +``` diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py deleted file mode 100644 index 196e849a3..000000000 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/parse_pstats.py +++ /dev/null @@ -1,19 +0,0 @@ -import pstats -import sys - -if __name__ == '__main__': - if len(sys.argv) != 2: - print("Usage: python3 parse_pstats.py ") - sys.exit(1) - - pstats_filename = sys.argv[1] - - # Load the .pstats file - stats = pstats.Stats(pstats_filename) - - # Get the total runtime - total_runtime = stats.total_tt - - # stats.sort_stats('cumtime').print_stats() - # print(stats.get_stats_profile()) - print('total_runtime', total_runtime) From 5ab94c64449ee7a232a3f0f4d2d94e96c1dd03b2 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 17 May 2024 16:26:50 -0700 Subject: [PATCH 03/33] return plaintext and ciphertext for ease of verification --- .../keyrings/aws_kms_keyring.py | 8 ++++++-- .../master_key_providers/aws_kms_key_provider.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py index a0d8ee50f..9510d2da4 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py @@ -59,11 +59,13 @@ def encrypt_using_keyring( commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT ) - _, _ = client.encrypt( + ciphertext_data, _ = client.encrypt( source=plaintext_data, keyring=keyring ) + return ciphertext_data + def decrypt_using_keyring( ciphertext_data: bytes, @@ -81,7 +83,9 @@ def decrypt_using_keyring( commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT ) - _, _ = client.decrypt( + decrypted_plaintext_data, _ = client.decrypt( source=ciphertext_data, keyring=keyring ) + + return decrypted_plaintext_data diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py index 731c0ecd3..2a31ebb42 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py @@ -42,11 +42,13 @@ def encrypt_using_key_provider( commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT ) - _, _ = client.encrypt( + ciphertext_data, _ = client.encrypt( source=plaintext_data, key_provider=key_provider ) + return ciphertext_data + def decrypt_using_key_provider( ciphertext_data: bytes, @@ -64,7 +66,9 @@ def decrypt_using_key_provider( commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT ) - _, _ = client.decrypt( + decrypted_plaintext_data, _ = client.decrypt( source=ciphertext_data, key_provider=key_provider ) + + return decrypted_plaintext_data From cb3b6f82870190b3d845f7f6ca461eeb6519c4e2 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Tue, 21 May 2024 14:27:25 -0700 Subject: [PATCH 04/33] updated readme, pylintrc, plaintext sizes --- performance_tests/README.md | 4 +- performance_tests/consolidate_results.py | 23 +++++---- .../keyrings => }/pylintrc | 0 performance_tests/requirements_mpl.txt | 2 +- .../keyrings/aws_kms_keyring.py | 9 +--- .../aws_kms_key_provider.py | 9 +--- .../master_key_providers/pylintrc | 45 ----------------- .../utils/pylintrc | 45 ----------------- performance_tests/src/pylintrc | 45 ----------------- performance_tests/test/keyrings/pylintrc | 45 ----------------- .../test/master_key_providers/pylintrc | 45 ----------------- .../test/resources/ciphertext-data-empty.ct | Bin 587 -> 587 bytes .../test/resources/ciphertext-data-large.ct | Bin 2761 -> 8619 bytes .../test/resources/ciphertext-data-medium.ct | Bin 687 -> 4587 bytes .../test/resources/ciphertext-data-small.ct | Bin 592 -> 623 bytes .../test/resources/plaintext-data-large.dat | 47 ++++++++---------- .../test/resources/plaintext-data-medium.dat | 13 ++++- .../test/resources/plaintext-data-small.dat | 2 +- performance_tests/test/resources/pylintrc | 45 ----------------- 19 files changed, 53 insertions(+), 326 deletions(-) rename performance_tests/{src/aws_encryption_sdk_performance_tests/keyrings => }/pylintrc (100%) delete mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc delete mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc delete mode 100644 performance_tests/src/pylintrc delete mode 100644 performance_tests/test/keyrings/pylintrc delete mode 100644 performance_tests/test/master_key_providers/pylintrc delete mode 100644 performance_tests/test/resources/pylintrc diff --git a/performance_tests/README.md b/performance_tests/README.md index 7db6c217a..4cc44a5f6 100644 --- a/performance_tests/README.md +++ b/performance_tests/README.md @@ -6,7 +6,7 @@ This project is licensed under the Apache-2.0 License. ## Overview -Here are the keyrings / master key-providers that we plan to test: +Here are the keyrings / master key-providers that we are testing: 1. KMS Keyring / KMS Master Key Provider 2. Raw AES Keyring / AES Master Key Provider @@ -20,7 +20,7 @@ For each keyring / master key-provider, we test the execution time and memory co 2. Encrypt 3. Decrypt -We demonstrate the usage of the performance tests through an [AWS KMS Keyring](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html). However, the procedure is the same for any keyring / master key-provider. +We demonstrate the usage of the performance tests through an [AWS KMS Keyring](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html). However, the procedure is the same for any keyring / master key-provider, with slight change in the input arguments. The results for the performance test will be available in the results folder in the performance_tests directory. diff --git a/performance_tests/consolidate_results.py b/performance_tests/consolidate_results.py index 1f95dcf38..642543443 100644 --- a/performance_tests/consolidate_results.py +++ b/performance_tests/consolidate_results.py @@ -3,11 +3,12 @@ """Script for consolidating results for execution times""" import csv -import sys +import argparse +import numpy as np def calculate_statistics(_csv_file): - """Calculate min, max and average statistics for execution times in a CSV file.""" + """Calculate min, max, average and p99 statistics for execution times in a CSV file.""" with open(_csv_file, 'r', encoding='utf-8') as file: reader = csv.reader(file) data = [float(row[0]) for row in reader] @@ -18,24 +19,26 @@ def calculate_statistics(_csv_file): _average = sum(data) / _total_entries _minimum = min(data) _maximum = max(data) - return _total_entries, _average, _minimum, _maximum + _perc_99 = np.percentile(data, 99) + return _total_entries, _average, _minimum, _maximum, _perc_99 return None if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: python consolidate_results.py ") - sys.exit(1) + parser = argparse.ArgumentParser() + parser.add_argument('csv_file', + help='csv file containing the outputs of execution times for n_iter iterations') + args = parser.parse_args() - csv_file = sys.argv[1] - statistics = calculate_statistics(csv_file) + statistics = calculate_statistics(args.csv_file) if statistics: - total_entries, average, minimum, maximum = statistics - print("CSV File:", csv_file) + total_entries, average, minimum, maximum, perc_99 = statistics + print("CSV File:", args.csv_file) print("Total Entries:", total_entries) print("Average:", average) print("Minimum:", minimum) print("Maximum:", maximum) + print("99th percentile:", perc_99) else: print("No data found in the CSV file.") diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/pylintrc b/performance_tests/pylintrc similarity index 100% rename from performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/pylintrc rename to performance_tests/pylintrc diff --git a/performance_tests/requirements_mpl.txt b/performance_tests/requirements_mpl.txt index c7927a851..209e10f2c 100644 --- a/performance_tests/requirements_mpl.txt +++ b/performance_tests/requirements_mpl.txt @@ -1 +1 @@ -amazon-cryptographic-material-providers-test-vectors @ git+https://github.com/aws/aws-cryptographic-material-providers-library.git@lucmcdon/python-mpl#subdirectory=TestVectorsAwsCryptographicMaterialProviders/runtimes/python \ No newline at end of file +aws-cryptographic-material-providers @ git+https://github.com/aws/aws-cryptographic-material-providers-library.git@lucmcdon/python-mpl#subdirectory=AwsCryptographicMaterialProviders/runtimes/python \ No newline at end of file diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py index 9510d2da4..51d49d34f 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py @@ -8,7 +8,6 @@ from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig from aws_cryptographic_materialproviders.mpl.models import CreateAwsKmsKeyringInput from aws_cryptographic_materialproviders.mpl.references import IKeyring -from aws_encryption_sdk import CommitmentPolicy def create_keyring( @@ -55,9 +54,7 @@ def encrypt_using_keyring( :param keyring: Keyring to use for encryption. :type keyring: IKeyring """ - client = aws_encryption_sdk.EncryptionSDKClient( - commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT - ) + client = aws_encryption_sdk.EncryptionSDKClient() ciphertext_data, _ = client.encrypt( source=plaintext_data, @@ -79,9 +76,7 @@ def decrypt_using_keyring( :param keyring: Keyring to use for decryption. :type keyring: IKeyring """ - client = aws_encryption_sdk.EncryptionSDKClient( - commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT - ) + client = aws_encryption_sdk.EncryptionSDKClient() decrypted_plaintext_data, _ = client.decrypt( source=ciphertext_data, diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py index 2a31ebb42..c3136a5c7 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py @@ -3,7 +3,6 @@ """Performance tests for the AWS KMS master key provider.""" import aws_encryption_sdk -from aws_encryption_sdk import CommitmentPolicy def create_key_provider( @@ -38,9 +37,7 @@ def encrypt_using_key_provider( :param key_provider: Master key provider to use for encryption. :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider """ - client = aws_encryption_sdk.EncryptionSDKClient( - commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT - ) + client = aws_encryption_sdk.EncryptionSDKClient() ciphertext_data, _ = client.encrypt( source=plaintext_data, @@ -62,9 +59,7 @@ def decrypt_using_key_provider( :param key_provider: Master key provider to use for decryption. :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider """ - client = aws_encryption_sdk.EncryptionSDKClient( - commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT - ) + client = aws_encryption_sdk.EncryptionSDKClient() decrypted_plaintext_data, _ = client.decrypt( source=ciphertext_data, diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc deleted file mode 100644 index 8ed5cb105..000000000 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/pylintrc +++ /dev/null @@ -1,45 +0,0 @@ -[MESSAGE CONTROL] -# Disabling messages that either we don't care about we intentionally break. -disable = - import-error, # ignore mpl import errors - invalid-name, # we prefer long, descriptive, names for examples - bad-continuation, # we let black handle this - ungrouped-imports, # we let isort handle this - no-member, # breaks with attrs - no-self-use, # interesting to keep in mind for later refactoring, but not blocking - useless-object-inheritance, # we need to support Python 2, so no, not useless - duplicate-code, # some examples may be similar - too-few-public-methods, # does not allow value stores - too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code - no-else-return, # we omit this on purpose for brevity where it would add no value - attribute-defined-outside-init, # breaks with attrs_post_init - abstract-method, # throws false positives on io.BaseIO grandchildren - redefined-outer-name, # we do this on purpose in multiple places - consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation - -[BASIC] -# Allow function names up to 50 characters -function-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow method names up to 50 characters -method-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow class attribute names up to 50 characters -# Whitelist class attribute names: iv -class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) -# Whitelist attribute names: iv -attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) -# Whitelist argument names: iv, b -argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) -# Whitelist variable names: iv, b, _b, x, y, r, s -variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) - -[VARIABLES] -additional-builtins = raw_input - -[DESIGN] -max-args = 10 - -[FORMAT] -max-line-length = 120 - -[REPORTS] -msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc deleted file mode 100644 index 8ed5cb105..000000000 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/pylintrc +++ /dev/null @@ -1,45 +0,0 @@ -[MESSAGE CONTROL] -# Disabling messages that either we don't care about we intentionally break. -disable = - import-error, # ignore mpl import errors - invalid-name, # we prefer long, descriptive, names for examples - bad-continuation, # we let black handle this - ungrouped-imports, # we let isort handle this - no-member, # breaks with attrs - no-self-use, # interesting to keep in mind for later refactoring, but not blocking - useless-object-inheritance, # we need to support Python 2, so no, not useless - duplicate-code, # some examples may be similar - too-few-public-methods, # does not allow value stores - too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code - no-else-return, # we omit this on purpose for brevity where it would add no value - attribute-defined-outside-init, # breaks with attrs_post_init - abstract-method, # throws false positives on io.BaseIO grandchildren - redefined-outer-name, # we do this on purpose in multiple places - consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation - -[BASIC] -# Allow function names up to 50 characters -function-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow method names up to 50 characters -method-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow class attribute names up to 50 characters -# Whitelist class attribute names: iv -class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) -# Whitelist attribute names: iv -attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) -# Whitelist argument names: iv, b -argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) -# Whitelist variable names: iv, b, _b, x, y, r, s -variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) - -[VARIABLES] -additional-builtins = raw_input - -[DESIGN] -max-args = 10 - -[FORMAT] -max-line-length = 120 - -[REPORTS] -msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/src/pylintrc b/performance_tests/src/pylintrc deleted file mode 100644 index 8ed5cb105..000000000 --- a/performance_tests/src/pylintrc +++ /dev/null @@ -1,45 +0,0 @@ -[MESSAGE CONTROL] -# Disabling messages that either we don't care about we intentionally break. -disable = - import-error, # ignore mpl import errors - invalid-name, # we prefer long, descriptive, names for examples - bad-continuation, # we let black handle this - ungrouped-imports, # we let isort handle this - no-member, # breaks with attrs - no-self-use, # interesting to keep in mind for later refactoring, but not blocking - useless-object-inheritance, # we need to support Python 2, so no, not useless - duplicate-code, # some examples may be similar - too-few-public-methods, # does not allow value stores - too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code - no-else-return, # we omit this on purpose for brevity where it would add no value - attribute-defined-outside-init, # breaks with attrs_post_init - abstract-method, # throws false positives on io.BaseIO grandchildren - redefined-outer-name, # we do this on purpose in multiple places - consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation - -[BASIC] -# Allow function names up to 50 characters -function-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow method names up to 50 characters -method-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow class attribute names up to 50 characters -# Whitelist class attribute names: iv -class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) -# Whitelist attribute names: iv -attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) -# Whitelist argument names: iv, b -argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) -# Whitelist variable names: iv, b, _b, x, y, r, s -variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) - -[VARIABLES] -additional-builtins = raw_input - -[DESIGN] -max-args = 10 - -[FORMAT] -max-line-length = 120 - -[REPORTS] -msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/test/keyrings/pylintrc b/performance_tests/test/keyrings/pylintrc deleted file mode 100644 index 8ed5cb105..000000000 --- a/performance_tests/test/keyrings/pylintrc +++ /dev/null @@ -1,45 +0,0 @@ -[MESSAGE CONTROL] -# Disabling messages that either we don't care about we intentionally break. -disable = - import-error, # ignore mpl import errors - invalid-name, # we prefer long, descriptive, names for examples - bad-continuation, # we let black handle this - ungrouped-imports, # we let isort handle this - no-member, # breaks with attrs - no-self-use, # interesting to keep in mind for later refactoring, but not blocking - useless-object-inheritance, # we need to support Python 2, so no, not useless - duplicate-code, # some examples may be similar - too-few-public-methods, # does not allow value stores - too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code - no-else-return, # we omit this on purpose for brevity where it would add no value - attribute-defined-outside-init, # breaks with attrs_post_init - abstract-method, # throws false positives on io.BaseIO grandchildren - redefined-outer-name, # we do this on purpose in multiple places - consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation - -[BASIC] -# Allow function names up to 50 characters -function-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow method names up to 50 characters -method-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow class attribute names up to 50 characters -# Whitelist class attribute names: iv -class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) -# Whitelist attribute names: iv -attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) -# Whitelist argument names: iv, b -argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) -# Whitelist variable names: iv, b, _b, x, y, r, s -variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) - -[VARIABLES] -additional-builtins = raw_input - -[DESIGN] -max-args = 10 - -[FORMAT] -max-line-length = 120 - -[REPORTS] -msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/test/master_key_providers/pylintrc b/performance_tests/test/master_key_providers/pylintrc deleted file mode 100644 index 8ed5cb105..000000000 --- a/performance_tests/test/master_key_providers/pylintrc +++ /dev/null @@ -1,45 +0,0 @@ -[MESSAGE CONTROL] -# Disabling messages that either we don't care about we intentionally break. -disable = - import-error, # ignore mpl import errors - invalid-name, # we prefer long, descriptive, names for examples - bad-continuation, # we let black handle this - ungrouped-imports, # we let isort handle this - no-member, # breaks with attrs - no-self-use, # interesting to keep in mind for later refactoring, but not blocking - useless-object-inheritance, # we need to support Python 2, so no, not useless - duplicate-code, # some examples may be similar - too-few-public-methods, # does not allow value stores - too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code - no-else-return, # we omit this on purpose for brevity where it would add no value - attribute-defined-outside-init, # breaks with attrs_post_init - abstract-method, # throws false positives on io.BaseIO grandchildren - redefined-outer-name, # we do this on purpose in multiple places - consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation - -[BASIC] -# Allow function names up to 50 characters -function-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow method names up to 50 characters -method-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow class attribute names up to 50 characters -# Whitelist class attribute names: iv -class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) -# Whitelist attribute names: iv -attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) -# Whitelist argument names: iv, b -argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) -# Whitelist variable names: iv, b, _b, x, y, r, s -variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) - -[VARIABLES] -additional-builtins = raw_input - -[DESIGN] -max-args = 10 - -[FORMAT] -max-line-length = 120 - -[REPORTS] -msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/performance_tests/test/resources/ciphertext-data-empty.ct b/performance_tests/test/resources/ciphertext-data-empty.ct index 2455c0796d2b185e7d8f5f656a18088ca5a31872..18f1696874059d7bc64600dfae68f89a2a262f9e 100644 GIT binary patch delta 416 zcmX@ja+;-{iM3*pt!K{`W!|9vvx{nUOM1Sa{r8@KhVnudq5MyVoZFwyV~A&9WDrd( zFV;;isw^nU*DWYb%E?UD%}%XkaB;NIPAc~cC`eDWaP=~;(9d!)3<@)fsz`Sv%vb9>jbTwPESkjyFAzG zjMzkroSHpLbx&<*{9>%%!ouHU>2xTIZp7 zRIqJRuj$>%SL+|lc^kQY%BN%XM|A!J0Rscjrw9OMyV`^~N^jsRyO}xhtW`{z6GOT| zDw83@S>rE%Ht8JL*~Rg&yEiQ2LwkW^YRqDl($|j9KS}&`Y4kKWY_X`M_v6IE)#j)A zx7#ooWSzgCJ2NRpXSePB?rmlP+bUSsx^_rhaIBpCJV@kgM}N&lTzIGW(mQPi)#=uOS>Z=T^D5qb;w4 z0TZJ@gLMn9XjQAz6`m#*4(H-V*N37;!H=ttJ#%FAyEHw=&*4O+=LSFjb$g_^9-C+D zI=AkxmtbW2q!jzjpllBl1A_pASBKYaoAMx;EmN+44k_h#Q0zL-{4x4&W0*ifV%(4D zd!|i0mi4S*+uFC@J-}D0{_5NRK)}EN^eF;>*$HXSTe3)rlus?0$jOjykjiAp zutD=@W?|jQb+T(MZn{iAG*#!mFGk0`KOD}3L zcuQh(ba6pMQZZR>Q+a7>SVMSbP;5DDV@h>bZew>yS5ILAF>sNAxPSOi1{ecRsX6+& z8Q1~=5P&=ITk*dX>U=e9C9airQ*?*{+mRrhzU`$A1`9TEc7~l@-j~JBu_`29;rc8{ zhf%1#4TyhdJr~aw+t|JeO{Ret{xZbbiq=OQ0YqfTVeoKl z2|}MNf%z1)Qg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vaxsmhRN4yl<7F^ z##R2_iGj$hEeRy$Kc2j0>7u1*cYn9hTx;51P#vn6>%O3W7#8lsDDu7^RWy- z(h*zXHts4qrQB*$ZU{^nM2GUiP8twC>%z5}A&lSHp!QCR>LoJLqm~POg0KZ76p#u8 zXT|Y~fGr9Nvn3hiZz6zlOYlaD$o%Pvo|u_@!mXpr4sv1H0%ZyMibG6LWGokyGQZR= z@Qj#zk%;tJX7IAyDWlWEB!6*8Qgjw~p)#sFuMLH)XPdm?mQT6Rv2lv=Ovh_h@DD>o;r{8$mlc~UQGnbl}>tz7SNe(zxAzVCOI zdc0|~$=8Azq`pbS6n~E?ZH>ywm1SC688K142{y($@*!W}Y60Whv+th`r~USCq(j1H zhh{?`+)*qKAfECuK`o-=yiiLXTVy!YY}qU$JaxnF8IgNJ*Y5!ayjaYtZGj&%8Xzu< z#`&|Kmupraisk+CWL}H3V+8=rv&~PCU=orxCxqM}TbIke3V%4nDTZk7c9T?8@Szk% zW$-^a4ha=k{ouo`sAUAiNVKe57pNd|oVPF|kEaW{T1A}DZTlf3>LV_a(v_RH)@1zh z-sc?o`(yx>+ltF`?4SyY#K?g_*cdU|@QDEqIL*LH=A_}3k1d>N)y1~SC1*`}?_Ta` z`1?-VN+(h_^M9l7V%0wXF6TeQvdI5XlCQmcnXt)jtC)lS^nar?27aEfmuF?q^Jbz; ziN1;YG|PI-C&23|_TlIwY$rXUQP=m~(C|&M z@KwA}OmpyCOE$&;XE0>~Fi-U=wB#fO$7^#~$?NZ!Bpof*L?$G;4UP*Usk3?|pc6Jt z?4e(zzcEHWL<`Yb&H^z2z_%||dRh(s^TM~fl_MX<2b+F8ay^jbLFs1F;HF?KXm+$B Qm_%JUxeObSuzIG2TL{MaQUCw| diff --git a/performance_tests/test/resources/ciphertext-data-medium.ct b/performance_tests/test/resources/ciphertext-data-medium.ct index c59bdacb7ecafa208fcb1cd1e5577576877465df..a954c7134cf35f43723c446ecd912460ba8213ec 100644 GIT binary patch delta 4446 zcmV-k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ggg``L(eo!cr|F%xR7o=WOfe?saxm{Un4Pb!a; zkkY$D{n`eetPFcf=7^DUf*!G&hI=&k;?NX5N{2Lvel4MsaOz#;L$H?u2c3DDv52sZ zx|a7M|9?&ihTfvnrYucvh34$hE2_WS?Kn2)O9P%7trcoEh{VyRW{yh?$NecT^krY> z$+<+tq8{z=WLt@=M1KyNopGAyHFif-a5HulK9iVM2o(O1bEN?$f}6kl6-h{<6>{ju z>6i%O{&OBTq<}u5PJm8T~x2Sd@FNsqN*BSmz z=g;=A=kRQCOpQj}xWeLW^~FhHqnc@N$UuAA8N_ZF^2 z1XIpLPe1W0B=x7J%4p2Fuwb#r@=B`xe-uED7MA!c-xUHe0M=6nC6kR#grP=9hM9FG k@?_nrW-0A$VZ@x|pfHSCvExX4&~*%(SKv_%kQ2vuKm_WR_W%F@ delta 515 zcmV+e0{s2!Bd-O20tI-KVmrAZ4Q7BYV@SBGZ#SLW~Tyg51%!=J;qo7UjP9B z6=8RCEn{+daCC1iaCKsAX=5#GWqANZL3dG7SZFtRL2qMud31GHGjKOSV{LX)XjDZs zV>C5)HA^vPD@b=%Ia*eCS}{0cNMcWRHZ*c?LqStdGgnjsG%=BZxPRd&QGp_o9b6M> zs~Q3U5P&->KZ+GF#=|!?(ElO}@s}d98GE;&oY|jtnM3|OeMP7&(~K>z-GlLNDJmuw z{0!`h%I9h^P{_wT!8-x~01yDjaou5;8L$fa8E>MIM=e3-N6B85i9)CF%gsbXYMHZ> zhP@_xtw%(-y;6B)N`FGV|NsC0000010000000000000010001FMF9vyuE|dX5Ij7r zvWM{s8JkH+AA9N7jhQXn&uWE2l9Q-qrgc;OvBy*c^`{ zs~>(6-6R9nWIjT+u#sV?E2~pF)`|cC diff --git a/performance_tests/test/resources/ciphertext-data-small.ct b/performance_tests/test/resources/ciphertext-data-small.ct index 6824a6a04bda0c8601cd4635082ad9075a3c2bf4..473e914e6505cb48631f6f33121b1657c67c09bc 100644 GIT binary patch delta 451 zcmV;!0X+WD1n&fY0tI*$8O9u_Hs+_up$u;U352HQnvT;Y|ETVKj*Dda7d zWo}DpHF#7(Y;`M3SZsPxX-qakbZc^McT`j}cvNLYN^3;|Xl;>!xPLrqRL|P^PHKqi znV|v!5P&;Ud|{b5$(WvHH_L0!8VgiiDG3aKl3)D7?71BsG{rV}+6D~j(0^D~#7fC8 z|8rDIv|T7!=g5+3)usXf01yBKT|A}<-4`zkfisn*8~1ihV*^+ ziN<|b;rLjUE?tfJMJJl&k&X4-K$EW*5Jyew60i-Kq)e;b$1rIq0B0~|0x&%>rnT)z z#7|5)Qa(5mTo7VGZ%daxg1STSfu&Yw0dP{C$uY;`!yK>busA}OKP~72F#yPHdU`t` t=c3#bwho6KkmU#90RVC*Xi8P`r0K1keP30tI-o3FPji#kU~e_L<6AxY`90)QLRPb{U)}#uCz;hFiJ-UjP9B z6=8RCEn{+daCC1iaCKsAX=5#GWqANZL2@y6D`+xVGHGK?XJ&I%LR2<-IBYjRWy1 z$EE@S5P&-(Si0e_MiJ9|Bw8$qgvV`JvYL`oN1Ll9RoeMK<4O7JQ9t2K+xT%yF-Sep zZLzTGst3aVY3RBrT0H^)01yDTW`pkY&XmpI5uyt!@c|ZDpkhHxHk6I~4djV9Hb~}5 z&-=9XCugI1_>+uS9)EbE|NsC00000100000000000000100005u;AX03H6xro>NnZ zX9kMV;h7vs^Z;itWdbn(x=h_J?6YP8wKN?v2U}n0x)AUe$3N{g+$w=BH}gf49hlrQ-YEGPZ^9lN#AsF;)6Ux!Y6ql Oi&q6e;*id8^YVb}bGeuR diff --git a/performance_tests/test/resources/plaintext-data-large.dat b/performance_tests/test/resources/plaintext-data-large.dat index 2d22c2d64..22bad9f3f 100644 --- a/performance_tests/test/resources/plaintext-data-large.dat +++ b/performance_tests/test/resources/plaintext-data-large.dat @@ -1,26 +1,21 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. -Praesent non feugiat leo. Aenean iaculis tellus ut velit consectetur, -quis convallis orci eleifend. Sed eu dictum sapien. Nulla facilisi. Suspendisse potenti. -Proin vehicula vehicula maximus. Donec varius et elit vel rutrum. Nulla lacinia neque turpis -quis consequat orci pharetra et. Etiam consequat ullamcorper mauris. Vivamus molestie mollis -mauris a gravida. Curabitur sed bibendum nisl. Cras varius tortor non erat sodales, quis congu -tellus laoreet. Etiam fermentum purus eu diam sagittis, vitae commodo est vehicula. -Nulla feugiat viverra orci vel interdum. Quisque pulvinar elit eget nulla facilisis varius. -Mauris at suscipit sem. Aliquam in purus ut velit fringilla volutpat id non mi. -Curabitur quis nunc eleifend, ornare lectus non, fringilla quam. Nam maximus volutpat placerat. -Nulla ullamcorper lorem velit, nec sagittis ex tristique posuere. Aliquam fringilla magna commod -libero faucibus tempor. Vestibulum non ligula tincidunt, finibus sapien in, sollicitudin -ex. Pellentesque congue laoreet mi in condimentum. Cras convallis nisi ac nunc tincidunt -venenatis. Suspendisse urna elit, cursus eu lacus a, aliquet porttitor mi. -Nulla vel congue nibh, sed condimentum dui. Ut ante ligula, blandit eu finibus nec, -scelerisque quis eros. Maecenas gravida odio eget nibh dictum, dictum varius lacus interdum. -Integer quis nulla vulputate, rhoncus diam vitae, mollis mauris. Sed ut porttitor dolor. -Fusce ut justo a ex bibendum imperdiet nec sit amet magna. Sed ullamcorper luctus augue, -tempor viverra elit interdum sed. Cras sit amet arcu eu turpis molestie sollicitudin. -Curabitur fermentum varius nibh, ut aliquet nisi. Aliquam id tempus tellus. -Nulla porttitor nulla at nibh interdum, quis sollicitudin erat egestas. -Ut blandit mauris quis efficitur efficitur. Morbi neque sapien, posuere ut aliquam eget, -aliquam at velit. Morbi sit amet rhoncus felis, et hendrerit sem. Nulla porta dictum ligula -eget iaculis. Cras lacinia ligula quis risus ultrices, sed consectetur metus imperdiet. -Nullam id enim vestibulum nibh ultricies auctor. Morbi neque lacus, faucibus vitae commodo quis, -malesuada sed velit. \ No newline at end of file +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Et netus et malesuada fames. Bibendum enim facilisis gravida neque convallis. Tortor consequat id porta nibh venenatis cras. Lacus sed viverra tellus in hac habitasse platea dictumst. Ipsum dolor sit amet consectetur adipiscing elit pellentesque. Risus pretium quam vulputate dignissim suspendisse in. Ante in nibh mauris cursus mattis molestie a iaculis at. Nulla porttitor massa id neque aliquam vestibulum morbi blandit. Urna et pharetra pharetra massa massa ultricies mi quis. Leo duis ut diam quam nulla porttitor massa id. Vitae suscipit tellus mauris a diam maecenas sed enim ut. + +Non nisi est sit amet facilisis magna etiam tempor. Mi bibendum neque egestas congue quisque egestas diam in arcu. Volutpat est velit egestas dui id ornare arcu odio ut. Amet tellus cras adipiscing enim eu turpis egestas. Tortor dignissim convallis aenean et tortor at risus viverra. Interdum consectetur libero id faucibus nisl tincidunt eget. In eu mi bibendum neque egestas congue quisque egestas. Pellentesque habitant morbi tristique senectus et netus et malesuada fames. Leo vel orci porta non pulvinar. Amet massa vitae tortor condimentum. Malesuada fames ac turpis egestas maecenas pharetra. Feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Quam elementum pulvinar etiam non quam lacus. Accumsan in nisl nisi scelerisque eu ultrices. Pretium aenean pharetra magna ac placerat vestibulum. Dui faucibus in ornare quam viverra orci sagittis eu volutpat. Amet venenatis urna cursus eget nunc scelerisque viverra mauris in. Penatibus et magnis dis parturient montes nascetur ridiculus mus mauris. Quis commodo odio aenean sed adipiscing diam donec adipiscing tristique. + +Leo a diam sollicitudin tempor id. Tempor orci eu lobortis elementum nibh. Sit amet commodo nulla facilisi nullam vehicula. Hendrerit gravida rutrum quisque non tellus. Diam vulputate ut pharetra sit. Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tempus iaculis urna id volutpat lacus laoreet non curabitur gravida. Porttitor lacus luctus accumsan tortor posuere ac ut consequat semper. Tortor vitae purus faucibus ornare. Risus viverra adipiscing at in tellus integer. Suspendisse potenti nullam ac tortor vitae purus faucibus ornare suspendisse. Facilisis sed odio morbi quis commodo odio aenean sed. At auctor urna nunc id. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Suspendisse interdum consectetur libero id faucibus nisl. Tellus id interdum velit laoreet id. Mus mauris vitae ultricies leo integer. Metus vulputate eu scelerisque felis imperdiet proin. + +Venenatis cras sed felis eget velit aliquet sagittis id. Turpis cursus in hac habitasse. Magna fringilla urna porttitor rhoncus dolor purus non. In tellus integer feugiat scelerisque varius morbi. Tortor consequat id porta nibh venenatis cras sed. Ut sem viverra aliquet eget sit amet tellus cras. Semper risus in hendrerit gravida. Libero enim sed faucibus turpis in. Ultricies leo integer malesuada nunc vel risus commodo. Ipsum dolor sit amet consectetur adipiscing elit pellentesque habitant. Varius duis at consectetur lorem donec massa sapien faucibus et. Ornare arcu dui vivamus arcu felis bibendum ut tristique et. + +Diam quis enim lobortis scelerisque fermentum dui faucibus in. Cursus mattis molestie a iaculis at erat. Diam sit amet nisl suscipit adipiscing. Ultrices dui sapien eget mi proin sed libero. Purus ut faucibus pulvinar elementum integer enim neque. Ultricies mi quis hendrerit dolor magna eget. Morbi tincidunt ornare massa eget. Mauris cursus mattis molestie a iaculis at erat pellentesque. Phasellus vestibulum lorem sed risus. Sodales ut etiam sit amet nisl purus in. Habitant morbi tristique senectus et netus et. Consectetur lorem donec massa sapien faucibus et molestie. + +Montes nascetur ridiculus mus mauris vitae ultricies. Lectus urna duis convallis convallis. Pulvinar proin gravida hendrerit lectus. Semper auctor neque vitae tempus quam pellentesque nec. Donec pretium vulputate sapien nec. Id aliquet lectus proin nibh nisl. Enim ut sem viverra aliquet eget sit amet tellus. Vel orci porta non pulvinar neque laoreet suspendisse interdum consectetur. Feugiat vivamus at augue eget arcu dictum varius. Venenatis tellus in metus vulputate eu. Aliquam vestibulum morbi blandit cursus risus at ultrices mi tempus. Id venenatis a condimentum vitae. Lorem mollis aliquam ut porttitor leo a diam sollicitudin tempor. Rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt lobortis. + +Nisi scelerisque eu ultrices vitae. Eu feugiat pretium nibh ipsum consequat nisl vel pretium. Commodo ullamcorper a lacus vestibulum sed arcu non odio. Sit amet cursus sit amet dictum. Fermentum iaculis eu non diam. Quis imperdiet massa tincidunt nunc pulvinar. Tempor commodo ullamcorper a lacus vestibulum sed. Venenatis urna cursus eget nunc scelerisque viverra mauris in. Vulputate mi sit amet mauris commodo quis imperdiet massa. Non nisi est sit amet facilisis magna etiam tempor orci. Consectetur libero id faucibus nisl tincidunt eget nullam. Sit amet risus nullam eget felis eget nunc. Aliquet porttitor lacus luctus accumsan. Vitae congue eu consequat ac felis donec. Vehicula ipsum a arcu cursus vitae congue mauris rhoncus. Fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate. + +Massa eget egestas purus viverra. Nunc sed augue lacus viverra vitae congue eu consequat. Lectus quam id leo in. Augue eget arcu dictum varius duis. Nulla facilisi cras fermentum odio eu feugiat pretium. Adipiscing diam donec adipiscing tristique risus. Imperdiet dui accumsan sit amet. Volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque. Dolor sit amet consectetur adipiscing elit duis. In fermentum et sollicitudin ac orci phasellus egestas tellus rutrum. Ridiculus mus mauris vitae ultricies leo integer malesuada. Nulla pharetra diam sit amet nisl. Nec dui nunc mattis enim ut tellus. Morbi non arcu risus quis varius quam quisque. Ac auctor augue mauris augue neque gravida in fermentum et. Morbi tincidunt augue interdum velit euismod. Sem viverra aliquet eget sit amet tellus cras adipiscing enim. Volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque. Odio facilisis mauris sit amet. Amet mattis vulputate enim nulla aliquet. + +Nisi vitae suscipit tellus mauris a diam maecenas sed enim. Venenatis urna cursus eget nunc scelerisque viverra. Neque egestas congue quisque egestas diam in. Adipiscing vitae proin sagittis nisl. Sodales neque sodales ut etiam sit. Non consectetur a erat nam at. Ac felis donec et odio. Adipiscing tristique risus nec feugiat in fermentum posuere urna. Ultrices in iaculis nunc sed augue lacus viverra vitae. Enim sit amet venenatis urna. Amet consectetur adipiscing elit pellentesque. + +Venenatis a condimentum vitae sapien pellentesque. Ut faucibus pulvinar elementum integer enim neque. Nisl nunc mi ipsum faucibus vitae aliquet. Netus et malesuada fames ac. Et odio pellentesque diam volutpat commodo sed egestas egestas fringilla. Ut diam quam nulla porttitor massa id. Id donec ultrices tincidunt arcu non sodales neque sodales ut. Viverra ipsum nunc aliquet bibendum enim. Lacus vestibulum sed arcu non odio. Lobortis mattis aliquam faucibus purus in massa tempor. Tortor at auctor urna nunc id cursus metus aliquam eleifend. Ornare suspendisse sed nisi lacus sed viverra tellus in. Tristique magna sit amet purus gravida quis. At ultrices mi tempus imperdiet nulla malesuada. Erat imperdiet sed euismod nisi. Eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada. Fermentum dui faucibus in ornare quam viverra orci sagittis. Nec dui nunc mattis enim ut tellus elementum sagittis. + +Suspendisse interdum consectetur libero id faucibus nisl. Bibendum enim facilisis gravida neque convallis. Nisi vitae suscipit tellus mauris a. Massa ultricies mi quis hendreri. \ No newline at end of file diff --git a/performance_tests/test/resources/plaintext-data-medium.dat b/performance_tests/test/resources/plaintext-data-medium.dat index e727ad026..3313ba519 100644 --- a/performance_tests/test/resources/plaintext-data-medium.dat +++ b/performance_tests/test/resources/plaintext-data-medium.dat @@ -1,2 +1,11 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. -Praesent non feugiat leo. Aenean iaculis te \ No newline at end of file +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Et netus et malesuada fames. Bibendum enim facilisis gravida neque convallis. Tortor consequat id porta nibh venenatis cras. Lacus sed viverra tellus in hac habitasse platea dictumst. Ipsum dolor sit amet consectetur adipiscing elit pellentesque. Risus pretium quam vulputate dignissim suspendisse in. Ante in nibh mauris cursus mattis molestie a iaculis at. Nulla porttitor massa id neque aliquam vestibulum morbi blandit. Urna et pharetra pharetra massa massa ultricies mi quis. Leo duis ut diam quam nulla porttitor massa id. Vitae suscipit tellus mauris a diam maecenas sed enim ut. + +Non nisi est sit amet facilisis magna etiam tempor. Mi bibendum neque egestas congue quisque egestas diam in arcu. Volutpat est velit egestas dui id ornare arcu odio ut. Amet tellus cras adipiscing enim eu turpis egestas. Tortor dignissim convallis aenean et tortor at risus viverra. Interdum consectetur libero id faucibus nisl tincidunt eget. In eu mi bibendum neque egestas congue quisque egestas. Pellentesque habitant morbi tristique senectus et netus et malesuada fames. Leo vel orci porta non pulvinar. Amet massa vitae tortor condimentum. Malesuada fames ac turpis egestas maecenas pharetra. Feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Quam elementum pulvinar etiam non quam lacus. Accumsan in nisl nisi scelerisque eu ultrices. Pretium aenean pharetra magna ac placerat vestibulum. Dui faucibus in ornare quam viverra orci sagittis eu volutpat. Amet venenatis urna cursus eget nunc scelerisque viverra mauris in. Penatibus et magnis dis parturient montes nascetur ridiculus mus mauris. Quis commodo odio aenean sed adipiscing diam donec adipiscing tristique. + +Leo a diam sollicitudin tempor id. Tempor orci eu lobortis elementum nibh. Sit amet commodo nulla facilisi nullam vehicula. Hendrerit gravida rutrum quisque non tellus. Diam vulputate ut pharetra sit. Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tempus iaculis urna id volutpat lacus laoreet non curabitur gravida. Porttitor lacus luctus accumsan tortor posuere ac ut consequat semper. Tortor vitae purus faucibus ornare. Risus viverra adipiscing at in tellus integer. Suspendisse potenti nullam ac tortor vitae purus faucibus ornare suspendisse. Facilisis sed odio morbi quis commodo odio aenean sed. At auctor urna nunc id. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Suspendisse interdum consectetur libero id faucibus nisl. Tellus id interdum velit laoreet id. Mus mauris vitae ultricies leo integer. Metus vulputate eu scelerisque felis imperdiet proin. + +Venenatis cras sed felis eget velit aliquet sagittis id. Turpis cursus in hac habitasse. Magna fringilla urna porttitor rhoncus dolor purus non. In tellus integer feugiat scelerisque varius morbi. Tortor consequat id porta nibh venenatis cras sed. Ut sem viverra aliquet eget sit amet tellus cras. Semper risus in hendrerit gravida. Libero enim sed faucibus turpis in. Ultricies leo integer malesuada nunc vel risus commodo. Ipsum dolor sit amet consectetur adipiscing elit pellentesque habitant. Varius duis at consectetur lorem donec massa sapien faucibus et. Ornare arcu dui vivamus arcu felis bibendum ut tristique et. + +Diam quis enim lobortis scelerisque fermentum dui faucibus in. Cursus mattis molestie a iaculis at erat. Diam sit amet nisl suscipit adipiscing. Ultrices dui sapien eget mi proin sed libero. Purus ut faucibus pulvinar elementum integer enim neque. Ultricies mi quis hendrerit dolor magna eget. Morbi tincidunt ornare massa eget. Mauris cursus mattis molestie a iaculis at erat pellentesque. Phasellus vestibulum lorem sed risus. Sodales ut etiam sit amet nisl purus in. Habitant morbi tristique senectus et netus et. Consectetur lorem donec massa sapien faucibus et molestie. + +Montes nascetur ridiculus mus mauris vitae ultricies. Lectus urna duis convallis convallis. Pulvinar pr. \ No newline at end of file diff --git a/performance_tests/test/resources/plaintext-data-small.dat b/performance_tests/test/resources/plaintext-data-small.dat index 77aaba021..b8475e61f 100644 --- a/performance_tests/test/resources/plaintext-data-small.dat +++ b/performance_tests/test/resources/plaintext-data-small.dat @@ -1 +1 @@ -Lorem \ No newline at end of file +Lorem ipsum dolor sit amet, consect. \ No newline at end of file diff --git a/performance_tests/test/resources/pylintrc b/performance_tests/test/resources/pylintrc deleted file mode 100644 index 8ed5cb105..000000000 --- a/performance_tests/test/resources/pylintrc +++ /dev/null @@ -1,45 +0,0 @@ -[MESSAGE CONTROL] -# Disabling messages that either we don't care about we intentionally break. -disable = - import-error, # ignore mpl import errors - invalid-name, # we prefer long, descriptive, names for examples - bad-continuation, # we let black handle this - ungrouped-imports, # we let isort handle this - no-member, # breaks with attrs - no-self-use, # interesting to keep in mind for later refactoring, but not blocking - useless-object-inheritance, # we need to support Python 2, so no, not useless - duplicate-code, # some examples may be similar - too-few-public-methods, # does not allow value stores - too-many-locals, # examples may sometimes have more locals defined for clarity than would be appropriate in code - no-else-return, # we omit this on purpose for brevity where it would add no value - attribute-defined-outside-init, # breaks with attrs_post_init - abstract-method, # throws false positives on io.BaseIO grandchildren - redefined-outer-name, # we do this on purpose in multiple places - consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation - -[BASIC] -# Allow function names up to 50 characters -function-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow method names up to 50 characters -method-rgx = [a-z_][a-z0-9_]{2,50}$ -# Allow class attribute names up to 50 characters -# Whitelist class attribute names: iv -class-attribute-rgx = (([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$)|(^iv$) -# Whitelist attribute names: iv -attr-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$) -# Whitelist argument names: iv, b -argument-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$) -# Whitelist variable names: iv, b, _b, x, y, r, s -variable-rgx = ([a-z_][a-z0-9_]{2,30}$)|(^iv$)|(^b$)|(^_b$)|(^x$)|(^y$)|(^r$)|(^s$) - -[VARIABLES] -additional-builtins = raw_input - -[DESIGN] -max-args = 10 - -[FORMAT] -max-line-length = 120 - -[REPORTS] -msg-template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} From f25a390baa03dea608b6d6dfb07623d611c74130 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 22 May 2024 15:20:47 -0700 Subject: [PATCH 05/33] update --- .../utils/util.py | 12 +++++ .../test/keyrings/test_aws_kms_keyring.py | 6 ++- .../test_aws_kms_master_key_provider.py | 6 ++- .../kms}/ciphertext-data-empty.ct | Bin .../kms}/ciphertext-data-large.ct | Bin .../kms}/ciphertext-data-medium.ct | Bin .../kms}/ciphertext-data-small.ct | Bin .../raw_aes/ciphertext-data-empty.ct | Bin 0 -> 454 bytes .../raw_aes/ciphertext-data-large.ct | Bin 0 -> 8486 bytes .../raw_aes/ciphertext-data-medium.ct | Bin 0 -> 4454 bytes .../raw_aes/ciphertext-data-small.ct | Bin 0 -> 490 bytes .../keys/user_rsa_private_key_file_name.pem | 51 ++++++++++++++++++ .../keys/user_rsa_public_key_file_name.pem | 14 +++++ .../{ => plaintext}/plaintext-data-empty.dat | 0 .../{ => plaintext}/plaintext-data-large.dat | 0 .../{ => plaintext}/plaintext-data-medium.dat | 0 .../{ => plaintext}/plaintext-data-small.dat | 0 17 files changed, 85 insertions(+), 4 deletions(-) rename performance_tests/test/resources/{ => ciphertext/kms}/ciphertext-data-empty.ct (100%) rename performance_tests/test/resources/{ => ciphertext/kms}/ciphertext-data-large.ct (100%) rename performance_tests/test/resources/{ => ciphertext/kms}/ciphertext-data-medium.ct (100%) rename performance_tests/test/resources/{ => ciphertext/kms}/ciphertext-data-small.ct (100%) create mode 100644 performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-empty.ct create mode 100644 performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-large.ct create mode 100644 performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-medium.ct create mode 100644 performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-small.ct create mode 100644 performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem create mode 100644 performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem rename performance_tests/test/resources/{ => plaintext}/plaintext-data-empty.dat (100%) rename performance_tests/test/resources/{ => plaintext}/plaintext-data-large.dat (100%) rename performance_tests/test/resources/{ => plaintext}/plaintext-data-medium.dat (100%) rename performance_tests/test/resources/{ => plaintext}/plaintext-data-small.dat (100%) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py index 2b7682bf6..22f717828 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py @@ -6,6 +6,7 @@ class PerfTestUtils: """Utility functions for AWS Encryption SDK performance tests.""" DEFAULT_N_ITERS = 100 + DEFAULT_FILE_SIZE = 'small' @staticmethod def read_file(filename): @@ -13,6 +14,17 @@ def read_file(filename): with open(filename, 'rb') as file: return file.read() + @staticmethod + def get_rsa_key_from_file(filename): + """Returns the RSA key""" + with open(filename, "r", encoding='utf-8') as f: + key = f.read() + + # Convert the key from a string to bytes + key = bytes(key, 'utf-8') + + return key + @staticmethod def print_time_list_to_csv(time_list, filename): """Prints the time list to a CSV file.""" diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 1137be79c..de6fea8a2 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -53,6 +53,7 @@ def encrypt_kms_keyring(): @encrypt_kms_keyring.command() @click.option('--plaintext_data_filename', + default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @@ -72,7 +73,7 @@ def encrypt( keyring = create_keyring(kms_key_id) time_list = [] - for _ in range(n_iters): + for _ in tqdm(range(n_iters)): curr_time = time.time() encrypt_using_keyring(plaintext_data, keyring) @@ -91,6 +92,7 @@ def decrypt_kms_keyring(): @decrypt_kms_keyring.command() @click.option('--ciphertext_data_filename', + default='test/resources/ciphertext/kms/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @@ -110,7 +112,7 @@ def decrypt( keyring = create_keyring(kms_key_id) time_list = [] - for _ in range(n_iters): + for _ in tqdm(range(n_iters)): curr_time = time.time() decrypt_using_keyring(ciphertext_data, keyring) diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py index 8189862e9..959129a33 100644 --- a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -53,6 +53,7 @@ def encrypt_kms_key_provider(): @encrypt_kms_key_provider.command() @click.option('--plaintext_data_filename', + default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @@ -72,7 +73,7 @@ def encrypt( key_provider = create_key_provider(kms_key_id) time_list = [] - for _ in range(n_iters): + for _ in tqdm(range(n_iters)): curr_time = time.time() encrypt_using_key_provider(plaintext_data, key_provider) @@ -91,6 +92,7 @@ def decrypt_kms_key_provider(): @decrypt_kms_key_provider.command() @click.option('--ciphertext_data_filename', + default='test/resources/ciphertext/kms/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @@ -110,7 +112,7 @@ def decrypt( key_provider = create_key_provider(kms_key_id) time_list = [] - for _ in range(n_iters): + for _ in tqdm(range(n_iters)): curr_time = time.time() decrypt_using_key_provider(ciphertext_data, key_provider) diff --git a/performance_tests/test/resources/ciphertext-data-empty.ct b/performance_tests/test/resources/ciphertext/kms/ciphertext-data-empty.ct similarity index 100% rename from performance_tests/test/resources/ciphertext-data-empty.ct rename to performance_tests/test/resources/ciphertext/kms/ciphertext-data-empty.ct diff --git a/performance_tests/test/resources/ciphertext-data-large.ct b/performance_tests/test/resources/ciphertext/kms/ciphertext-data-large.ct similarity index 100% rename from performance_tests/test/resources/ciphertext-data-large.ct rename to performance_tests/test/resources/ciphertext/kms/ciphertext-data-large.ct diff --git a/performance_tests/test/resources/ciphertext-data-medium.ct b/performance_tests/test/resources/ciphertext/kms/ciphertext-data-medium.ct similarity index 100% rename from performance_tests/test/resources/ciphertext-data-medium.ct rename to performance_tests/test/resources/ciphertext/kms/ciphertext-data-medium.ct diff --git a/performance_tests/test/resources/ciphertext-data-small.ct b/performance_tests/test/resources/ciphertext/kms/ciphertext-data-small.ct similarity index 100% rename from performance_tests/test/resources/ciphertext-data-small.ct rename to performance_tests/test/resources/ciphertext/kms/ciphertext-data-small.ct diff --git a/performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-empty.ct b/performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-empty.ct new file mode 100644 index 0000000000000000000000000000000000000000..3eb401da72257e223e20b9aa3fd7dddb13135457 GIT binary patch literal 454 zcmZQ#tvIu1XUz(!J0YKrDBKFxZt37|n{sv0f{69^+Ar?1%KG(^A)bMeK{T z)ipT4GTp;0E2^l(rOY*|D8n(zG{7*(+}$j)xYW_s7G!*Ier~ElZem_ydTNS7QDV6Q z(DY&kecwt2BU3Zoq|6cpN7rD5@}k6og3P>hkSqfOLjw@=gty-7zcQZF~shgG~>LdHBC5c}slAnzeSyucXe45jW2m33>M}komKHK{yiw zg8;+w^e5+iISi!N@4huXRAlm<*+)JqE?jdjq?aL6zT_)s!=!a<9D<`y*`0jT6uPuG zI_f_V0Ig;OVi*9k_iQznYX7d$sy;c$nTt4wEJ$#u_e!RjN@Kq z%*oOEzgPQcLCEJkuPA=%yn1$cP}?p`}qHQcP!Nej@PY5YvmoGUNR9BIn39VFr`t119r0096MVRv&a zV{&qK~XfRrAZ(2t~Yb#@FM?zM3V?}LPIazOLGiz^hdRbyu zXEt+aQgByGPBdvbbYWI%LuOV*Xh(H0Zf#_3bTdjeQ9V5X0RRATl*JEn;bOAVEb_Aa`n+afB*mh3@`7Tgqm}s z`Z1N@;{Y&V3i2xVq&i*c!^#;)6+v;WRIF_qz1%hP*ZsDSrh$v}X+);|iZ zJ;;k{HeLN@Y~pdDwtR1!Abq<=GYLc2v)iWbK*%5RfYu^sVQEI@8DCf>$!0u~Ka2ANm$M|YLh#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<8rRu52a?l_^V4VM!;m=0PWfK&5q^~^~?<}OtBzfcbjkJ*^7D0i^!q}+&F!w+q{NM`Cn&Kc=e1bYga@B$yBl*U0^E}i zS3}vUYTtof#M&?Pj*l^+xKp1?TiSi$xBs@M#)F@lSF5w>o(LhI6)d#d+MF;8Vvs6G zg=B^ml3s79p+#BaR&T&?f72$bY7b&v%=jZEY9WJ$fns3*lQy<036blc<0{b_p^E;F zsf;0MFeghWtC?eHKN@G30B0~|0x=M<7`OFg7;N8bkyEU8U;LUP?zFxfy-=5r^1cMmjI?P_yKB UqpSaVSDwuHE*52Gm|5trYCM)!R{#J2 literal 0 HcmV?d00001 diff --git a/performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-medium.ct b/performance_tests/test/resources/ciphertext/raw_aes/ciphertext-data-medium.ct new file mode 100644 index 0000000000000000000000000000000000000000..e62387249c756424277b3029e6db0ad58591826f GIT binary patch literal 4454 zcmV-s5t;4+1$Yw{{ts}sCFsTUNLf1Af0V}r7mhVx!S`DW(lB|@hF$<)0096MVRv&a zV{&qK~c4BQyZ&gDwYjIabLV7P`NmFBTLUTAqM`|@fQ%E^+ zYeP|TLn~!YHa1CBG&E^tW_36@a$ATl*JEn;bOAVEb_Aa`n+afB*mh35S`Ee(a(p5CW@-b(;NU_S^ zKn&jZ$cEFi5mSqAdIvo&c@Wg&3v`d@N{&2yxJ#TG3Atx98IX2}Kecc7EAI$D-;)hz z&bzZ;cTxBNHP=1KEa02|WDA+;L0Eev7!y4Qm>yeG6fz*a1|n#4b0M=gMV=$(t>HwE z-xcj=S<>i+qKzHVs9H&U5qEOlOKFO^=lP*2*J`}_lzudtDXbXIj{{e^!ouQIlc+{q zgYV|`ei-&#cDnbYm~msNFi72Z(%pI0f)vim0&(pC=)}WOClhfs`*OATpPoG9;IcWF z%s}Af^jL>U&WbSAm;B8BWA`?(#u4YnxRaC+c-|P`jHAxqArpC2R6U)pH%i%KrBA!c z5j#DJkmFBJ)pNK;(Wc%?D?xpE~?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k?5Ar1 zQU8GeXf-1c!vKh_vax2#ku`4}4`gh4r}^A%-wizj4Gz)2XLi3yxy~cINdK;uz~5~r zY4yzk4A^*|@o!#QZ7_3s9`H}7EfxUcjmj(l literal 0 HcmV?d00001 diff --git a/performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem b/performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem new file mode 100644 index 000000000..2d649570a --- /dev/null +++ b/performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJJwIBAAKCAgEAwEkp2yRpTAgZa4MDNxq8eQ7rkaVw9QTdJr9NFAtjUpM/6UQA +RJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWyE2nm4MCHED62mEEbjbDwtLmiWK0g +iZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnfMpode5IQY3AZM3unIVFA043oD3ZP +RsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKhf7ivmhVAKxwacXTb2yIynGljEgZZ +fkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruvgaE6vArdndBQcUV/NAOBeDegsfAs +ic7OC9FD/3MFgLo2g72WYY3BuCNMDj8L3lWK+vyC/S66cIvp1P2GzsccHSfcK0MC +09ojnCbKF6D7tv5pIKhtvZRC7xcNv1ctS/fbUbMy4tH+8iwvJlTRGZuuEYDwoBFo +wNS1oHxeO1PI1im93inAYt5GhkMuaZKLaY64xe51LJNcP1ovAhHaMG8UGfeCiNBR +jGEP3pMG8sgLyw9k3gqMVzX4MUfPlXQh503k3bVE/eymdsdZ1kAlMLR26IoQ6muA +Htn0cy00RjRPy0hIQ2Z+ACog0ge91AyWgXjn0WYI3AUOzVRZAoqS7ymf2zQfyb3W +VYBMfyYT9IhUZlAWq8uzEkoFs47r0LKrv6DALX8MCeTVUP6ELg4Inaz8UDECAwEA +AQKCAgBYJXH9lox6oT/d7DoeGbCKok9U/g1xFOC4cXvJE4tdgE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Q9frEjMCEoD2bIlO +cWxVaXMP39rnLUPzg8D2TcjiQ2NBL4FDYXudZCUh4b1x70Gp2GiP7GxZwv2/SQhD +j7cc4oNwaE1hkiMhAYbPgWUU06JQwWPcD8UmKUgdp2ET+eUEwfV0GVtNOSfGoenf +ZqdaYcE8c3ft37JM5AsKo5h+G3qHOBRMEYHtQDybuvvFsg+hJ0BuxYt4mFubWZYL +V/tu4K1kmEZXgTvNZWSsZaIY2xBus2Ol2rKTahA0d9ffGeUhRj+UQrWpxg== +-----END RSA PRIVATE KEY----- diff --git a/performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem b/performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem new file mode 100644 index 000000000..78cdbbfa6 --- /dev/null +++ b/performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwEkp2yRpTAgZa4MDNxq8 +eQ7rkaVw9QTdJr9NFAtjUpM/6UQARJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWy +E2nm4MCHED62mEEbjbDwtLmiWK0giZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnf +Mpode5IQY3AZM3unIVFA043oD3ZPRsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKh +f7ivmhVAKxwacXTb2yIynGljEgZZfkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruv +gaE6vArdndBQcUV/NAOBeDegsfAsic7OC9FD/3MFgLo2g72WYY3BuCNMDj8L3lWK ++vyC/S66cIvp1P2GzsccHSfcK0MC09ojnCbKF6D7tv5pIKhtvZRC7xcNv1ctS/fb +UbMy4tH+8iwvJlTRGZuuEYDwoBFowNS1oHxeO1PI1im93inAYt5GhkMuaZKLaY64 +xe51LJNcP1ovAhHaMG8UGfeCiNBRjGEP3pMG8sgLyw9k3gqMVzX4MUfPlXQh503k +3bVE/eymdsdZ1kAlMLR26IoQ6muAHtn0cy00RjRPy0hIQ2Z+ACog0ge91AyWgXjn +0WYI3AUOzVRZAoqS7ymf2zQfyb3WVYBMfyYT9IhUZlAWq8uzEkoFs47r0LKrv6DA +LX8MCeTVUP6ELg4Inaz8UDECAwEAAQ== +-----END PUBLIC KEY----- diff --git a/performance_tests/test/resources/plaintext-data-empty.dat b/performance_tests/test/resources/plaintext/plaintext-data-empty.dat similarity index 100% rename from performance_tests/test/resources/plaintext-data-empty.dat rename to performance_tests/test/resources/plaintext/plaintext-data-empty.dat diff --git a/performance_tests/test/resources/plaintext-data-large.dat b/performance_tests/test/resources/plaintext/plaintext-data-large.dat similarity index 100% rename from performance_tests/test/resources/plaintext-data-large.dat rename to performance_tests/test/resources/plaintext/plaintext-data-large.dat diff --git a/performance_tests/test/resources/plaintext-data-medium.dat b/performance_tests/test/resources/plaintext/plaintext-data-medium.dat similarity index 100% rename from performance_tests/test/resources/plaintext-data-medium.dat rename to performance_tests/test/resources/plaintext/plaintext-data-medium.dat diff --git a/performance_tests/test/resources/plaintext-data-small.dat b/performance_tests/test/resources/plaintext/plaintext-data-small.dat similarity index 100% rename from performance_tests/test/resources/plaintext-data-small.dat rename to performance_tests/test/resources/plaintext/plaintext-data-small.dat From 6573a4699cd205423a6240380d4ce6cfcef93f5d Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Thu, 23 May 2024 16:08:29 -0700 Subject: [PATCH 06/33] chore(aws_kms): AWS KMS keyring / key-provider test --- performance_tests/consolidate_results.py | 9 ++-- .../keyrings/aws_kms_keyring.py | 43 +++++++++++++++++++ .../test/keyrings/test_aws_kms_keyring.py | 35 +++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/performance_tests/consolidate_results.py b/performance_tests/consolidate_results.py index 642543443..cb1abd558 100644 --- a/performance_tests/consolidate_results.py +++ b/performance_tests/consolidate_results.py @@ -15,12 +15,14 @@ def calculate_statistics(_csv_file): # Calculate statistics if data: + data = np.sort(data) _total_entries = len(data) _average = sum(data) / _total_entries + _trimmed_average_99 = np.mean(data[0:int(0.99 * len(data))]) _minimum = min(data) _maximum = max(data) - _perc_99 = np.percentile(data, 99) - return _total_entries, _average, _minimum, _maximum, _perc_99 + _perc_99 = np.percentile(data, 99) + return _total_entries, _average, _trimmed_average_99, _minimum, _maximum, _perc_99 return None @@ -33,10 +35,11 @@ def calculate_statistics(_csv_file): statistics = calculate_statistics(args.csv_file) if statistics: - total_entries, average, minimum, maximum, perc_99 = statistics + total_entries, average, trimmend_average_99, minimum, maximum, perc_99 = statistics print("CSV File:", args.csv_file) print("Total Entries:", total_entries) print("Average:", average) + print("99th percentile trimmed average:", trimmend_average_99) print("Minimum:", minimum) print("Maximum:", maximum) print("99th percentile:", perc_99) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py index 51d49d34f..184bdd436 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py @@ -42,6 +42,49 @@ def create_keyring( return keyring +def create_kms_client(): + """Create an AWS KMS client. + + Usage: create_kms_client() + """ + # Create a boto3 client for KMS. + kms_client = boto3.client('kms', region_name="us-west-2") + + return kms_client + + +def create_keyring_given_kms_client( + kms_key_id: str, + kms_client: boto3.client, +): + """Demonstrate how to create an AWS KMS keyring with given KMS client. + + Usage: create_keyring(kms_key_id, kms_client) + :param kms_key_id: KMS Key identifier for the KMS key you want to use. + :type kms_key_id: string + :param kms_client: boto3 client for KMS. + :type kms_client: boto3.client + + For more information on KMS Key identifiers, see + https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id + """ + # Create a KMS keyring + mat_prov: AwsCryptographicMaterialProviders = AwsCryptographicMaterialProviders( + config=MaterialProvidersConfig() + ) + + keyring_input: CreateAwsKmsKeyringInput = CreateAwsKmsKeyringInput( + kms_key_id=kms_key_id, + kms_client=kms_client + ) + + keyring: IKeyring = mat_prov.create_aws_kms_keyring( + input=keyring_input + ) + + return keyring + + def encrypt_using_keyring( plaintext_data: bytes, keyring: IKeyring diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index de6fea8a2..4d8907c81 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -9,6 +9,8 @@ from aws_encryption_sdk_performance_tests.keyrings.aws_kms_keyring import ( create_keyring, + create_kms_client, + create_keyring_given_kms_client, decrypt_using_keyring, encrypt_using_keyring, ) @@ -46,6 +48,38 @@ def create( PerfTestUtils.print_time_list_to_csv(time_list, output_file) +@click.group() +def create_kms_keyring_given_kms_client(): + """Click group helper function""" + + +@create_kms_keyring_given_kms_client.command() +@click.option('--kms_key_id', + default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='kms_keyring_create_given_kms_client') +def create_given_kms_client( + kms_key_id: str, + n_iters: int, + output_file: str +): + """Performance test for the create_keyring function.""" + kms_client = create_kms_client() + time_list = [] + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + create_keyring_given_kms_client(kms_key_id, kms_client) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.print_time_list_to_csv(time_list, output_file) + + @click.group() def encrypt_kms_keyring(): """Click group helper function""" @@ -125,6 +159,7 @@ def decrypt( kms_keyring_test = click.CommandCollection(sources=[create_kms_keyring, + create_kms_keyring_given_kms_client, encrypt_kms_keyring, decrypt_kms_keyring]) From 8bfb71e08a440315d40e3f2f5786ab953d6df61f Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 24 May 2024 13:12:01 -0700 Subject: [PATCH 07/33] fix --- performance_tests/README.md | 19 ++--- performance_tests/consolidate_results.py | 12 ++-- ...ider.py => aws_kms_master_key_provider.py} | 0 .../utils/util.py | 72 ++++++++++++++++++- .../test/keyrings/test_aws_kms_keyring.py | 2 +- .../test_aws_kms_master_key_provider.py | 2 +- 6 files changed, 88 insertions(+), 19 deletions(-) rename performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/{aws_kms_key_provider.py => aws_kms_master_key_provider.py} (100%) diff --git a/performance_tests/README.md b/performance_tests/README.md index 4cc44a5f6..aefb11e01 100644 --- a/performance_tests/README.md +++ b/performance_tests/README.md @@ -1,4 +1,4 @@ -# Performance Tests for ESDK Python +# aws-encryption-sdk performance tests ## License @@ -6,21 +6,22 @@ This project is licensed under the Apache-2.0 License. ## Overview -Here are the keyrings / master key-providers that we are testing: +This library tests the following keyrings / master key-providers: 1. KMS Keyring / KMS Master Key Provider 2. Raw AES Keyring / AES Master Key Provider -3. HKeyring / caching CMM example ("old" caching solution vs the (current) "new" caching solution) -4. Raw RSA Keyring / RSA Master Key Provider +3. Raw RSA Keyring / RSA Master Key Provider +4. Hierarchy Keyring +5. Caching CMM -For each test on the above keyrings / master key-providers, we measure the execution time and memory consumption in each test. +For each test on the above keyrings / master key-providers, this package measures the execution time and memory consumption. -For each keyring / master key-provider, we test the execution time and memory consumption time for three operations: +For each keyring / master key-provider, the execution time and memory consumption time is measured for three operations: 1. Create keyring / master key-provider 2. Encrypt 3. Decrypt -We demonstrate the usage of the performance tests through an [AWS KMS Keyring](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html). However, the procedure is the same for any keyring / master key-provider, with slight change in the input arguments. +The usage of the performance tests is demonstrated through an [AWS KMS Keyring](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html). However, the procedure is the same for any keyring / master key-provider, with slight change in the input arguments. The results for the performance test will be available in the results folder in the performance_tests directory. @@ -122,13 +123,13 @@ mprof plot This 'mprof plot' command will plot the most recent mprofile log file. ## Usage: Performance Graph -To generate a performance graph, please use the following command to generate the pstats log file by specifying the output pstats file path. Here, we use 'results/kms_keyring_create.pstats' as the output file. +To generate a performance graph, please use the following command to generate the pstats log file by specifying the output pstats file path. Here, 'results/kms_keyring_create.pstats' is set as the default output file. ``` python -m cProfile -o results/kms_keyring_create.pstats test/keyrings/test_aws_kms_keyring.py create ``` -After generating the pstats file, please run the following command to generate the performance graph. The output performance graph will be a .png file that you specify. Here, we use 'results/kms_keyring_create.png' as the output file. +After generating the pstats file, please run the following command to generate the performance graph. The output performance graph will be a .png file that you specify. Here, 'results/kms_keyring_create.png' is set as the default output file. ``` gprof2dot -f pstats results/kms_keyring_create.pstats | dot -Tpng -o results/kms_keyring_create.png && eog results/kms_keyring_create.png ``` diff --git a/performance_tests/consolidate_results.py b/performance_tests/consolidate_results.py index cb1abd558..3a246b3a3 100644 --- a/performance_tests/consolidate_results.py +++ b/performance_tests/consolidate_results.py @@ -8,7 +8,7 @@ def calculate_statistics(_csv_file): - """Calculate min, max, average and p99 statistics for execution times in a CSV file.""" + """Calculate average, trimmed average, minimum, maximum and p99 statistics for execution times in a CSV file.""" with open(_csv_file, 'r', encoding='utf-8') as file: reader = csv.reader(file) data = [float(row[0]) for row in reader] @@ -17,12 +17,12 @@ def calculate_statistics(_csv_file): if data: data = np.sort(data) _total_entries = len(data) - _average = sum(data) / _total_entries - _trimmed_average_99 = np.mean(data[0:int(0.99 * len(data))]) + _average = np.mean(data) + _trimmed_average_99_bottom = np.mean(data[0:int(0.99 * len(data))]) _minimum = min(data) _maximum = max(data) _perc_99 = np.percentile(data, 99) - return _total_entries, _average, _trimmed_average_99, _minimum, _maximum, _perc_99 + return _total_entries, _average, _trimmed_average_99_bottom, _minimum, _maximum, _perc_99 return None @@ -35,11 +35,11 @@ def calculate_statistics(_csv_file): statistics = calculate_statistics(args.csv_file) if statistics: - total_entries, average, trimmend_average_99, minimum, maximum, perc_99 = statistics + total_entries, average, trimmend_average_99_bottom, minimum, maximum, perc_99 = statistics print("CSV File:", args.csv_file) print("Total Entries:", total_entries) print("Average:", average) - print("99th percentile trimmed average:", trimmend_average_99) + print("Bottom 99th percentile trimmed average:", trimmend_average_99_bottom) print("Minimum:", minimum) print("Maximum:", maximum) print("99th percentile:", perc_99) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_master_key_provider.py similarity index 100% rename from performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_key_provider.py rename to performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/aws_kms_master_key_provider.py diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py index 22f717828..96097c833 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py @@ -7,6 +7,74 @@ class PerfTestUtils: """Utility functions for AWS Encryption SDK performance tests.""" DEFAULT_N_ITERS = 100 DEFAULT_FILE_SIZE = 'small' + DEFAULT_AES_256_STATIC_KEY = \ + b'_\xcf"\x82\x03\x12\x9d\x00\x8a\xed\xaf\xe4\x80\x1d\x00t\xa6P\xac\xb6\xfe\xc5\xf6/{\xe7\xaaO\x01\x13W\x85' + DEFAULT_RSA_PUBLIC_KEY = bytes("-----BEGIN PUBLIC KEY-----\n" + + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwEkp2yRpTAgZa4MDNxq8" + + "eQ7rkaVw9QTdJr9NFAtjUpM/6UQARJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWy" + + "E2nm4MCHED62mEEbjbDwtLmiWK0giZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnf" + + "Mpode5IQY3AZM3unIVFA043oD3ZPRsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKh" + + "f7ivmhVAKxwacXTb2yIynGljEgZZfkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruv" + + "gaE6vArdndBQcUV/NAOBeDegsfAsic7OC9FD/3MFgLo2g72WYY3BuCNMDj8L3lWK" + + "+vyC/S66cIvp1P2GzsccHSfcK0MC09ojnCbKF6D7tv5pIKhtvZRC7xcNv1ctS/fb" + + "UbMy4tH+8iwvJlTRGZuuEYDwoBFowNS1oHxeO1PI1im93inAYt5GhkMuaZKLaY64" + + "xe51LJNcP1ovAhHaMG8UGfeCiNBRjGEP3pMG8sgLyw9k3gqMVzX4MUfPlXQh503k" + + "3bVE/eymdsdZ1kAlMLR26IoQ6muAHtn0cy00RjRPy0hIQ2Z+ACog0ge91AyWgXjn" + + "0WYI3AUOzVRZAoqS7ymf2zQfyb3WVYBMfyYT9IhUZlAWq8uzEkoFs47r0LKrv6DA" + + "LX8MCeTVUP6ELg4Inaz8UDECAwEAAQ==" + + "\n-----END PUBLIC KEY-----", 'utf-8') + + DEFAULT_RSA_PRIVATE_KEY = bytes("-----BEGIN RSA PRIVATE KEY-----\n" + + "MIIJJwIBAAKCAgEAwEkp2yRpTAgZa4MDNxq8eQ7rkaVw9QTdJr9NFAtjUpM/6UQA" + + "RJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWyE2nm4MCHED62mEEbjbDwtLmiWK0g" + + "iZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnfMpode5IQY3AZM3unIVFA043oD3ZP" + + "RsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKhf7ivmhVAKxwacXTb2yIynGljEgZZ" + + "fkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruvgaE6vArdndBQcUV/NAOBeDegsfAs" + + "ic7OC9FD/3MFgLo2g72WYY3BuCNMDj8L3lWK+vyC/S66cIvp1P2GzsccHSfcK0MC" + + "09ojnCbKF6D7tv5pIKhtvZRC7xcNv1ctS/fbUbMy4tH+8iwvJlTRGZuuEYDwoBFo" +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HDgEjvSTc0yOr38vdk" + + "Miwul/gR2/EG3qGuI6OnnPp8tYWLYMkDjjYC5mcQXBnHT5BAmAIDEgC7Fi0O9+hM" + + "5fCy7/8admovUJZcOX8q+urs1LNakcLuusA0CGB9KJvNvIwOuMnhaVvaFXTf2oZ8" + + "55itKyoG6Ca/AR5aNuUO6YnL+rEQaYsKsreYwB1B8B0UTxgVl12YtJWZkG3SHAKR" + + "RQeqrZQPtIUgN5hk6dX0vzv4fvooGT162PrWckriqSKag4lxJnOp6DO0NyEGwf+4" + + "FaEItex7PFUMuwKCAQEAzgrvL+56sqhKho0Z3J/PYj4f4LNElE1hQ7sHd2QtfyYS" + + "Ig4qKiUJIKjfC9LrFjtyqRiH5OTs63eorO+757DTFWjXCSVUwppPcLyOyr5mrULL" + + "T2PE8LE0GBw2PnIkfMCuDlvxKp/Arb1Co5uRCWrSPHEcY+hSlp5SJYwNhs3HyNBZ" + + "soKmjnUtP+HX5KlBoMQEo8kKnlfBTSVl2WAeu5UaM4Z0Q8ZxgCMnhDx2lVmMohUw" + + "/qBDw+uA51vgSCSRQLamrlEZQ6jqUzD/9kNbqioMKuPCOZWIKBZvBJNe2hmF+JKb" + + "epSrtKIor229l98UbfYhhiAw0//qon+pGXANNyneAwKCAQAd5VMUBnvZJiHmnCSX" + + "bASpcxzCpBtuv8vTBXm6T97/VSjVBGXUdmpFATausfHHnrHrRoP6knymTqMR/0f0" + + "1ud+KotJCGysFyhN6sUzOlRIknewb0s7yzoGuc1reCz8Lr06nC7YVOhyiblKkQi1" + + "srnzAq3NwB0XwxgZ0cvOm68WDYE1XyWqVDzdkEUzWIftkEHtF2//v36X2KIq2Zp9" + + "qIOUV0EAx48jKEwvNcMRAgY3sQPbXo3mxyzIbQIeq+a1CldqHGQDf0rAcaIpEHMa" + + "quIKMvbF0DFNUOrasOEdr3TU/CajrL1KXvso5KUVI7oqRXYSw/49fouBoWIeqdYO" + + "CbKLAoIBAC9lzIgWMBuRIzO4mc5q5OYQrHygQJJtCobuK1WHsf+h3mH/KCvxwRvG" + + "PSkXKAVBP6sufXRmRSoVqLO/olY2ExjFuVHdSJZLsSKZ/a8eBbituN9WcCN+YCF7" + + "u+65izM3j9K1y9CmV0igVQgV7VNhQ2OsEX/aHcWQPg1tHl94TxEe/MNX0sDKq9Ia" + + "PfPYC8TT0s1qngq23TzF8ZwDxI4aSqC3uV8t80Yq0BhXYGAS7YsLnO22KGCVeF3A" + + "gOOXpeJhIg7PkSRDY0Qn7XnVHO0UJyBmrHNatquiHX/L9vHtFSiNcT7NnII9G2bf" + + "s9GP+78f865LEXBzWqJvA5Nad2/NLckCggEANWMjb5QcJqTSXn0f2UqJ7AicWoqQ" + + "dMjpY79N+2iz2tlNFD9/BC/l6QGhM4YMVLNDwM2Aak37P8ZnQ9frEjMCEoD2bIlO" + + "cWxVaXMP39rnLUPzg8D2TcjiQ2NBL4FDYXudZCUh4b1x70Gp2GiP7GxZwv2/SQhD" + + "j7cc4oNwaE1hkiMhAYbPgWUU06JQwWPcD8UmKUgdp2ET+eUEwfV0GVtNOSfGoenf" + + "ZqdaYcE8c3ft37JM5AsKo5h+G3qHOBRMEYHtQDybuvvFsg+hJ0BuxYt4mFubWZYL" + + "V/tu4K1kmEZXgTvNZWSsZaIY2xBus2Ol2rKTahA0d9ffGeUhRj+UQrWpxg==" + + "\n-----END RSA PRIVATE KEY-----", "utf-8") @staticmethod def read_file(filename): @@ -26,8 +94,8 @@ def get_rsa_key_from_file(filename): return key @staticmethod - def print_time_list_to_csv(time_list, filename): - """Prints the time list to a CSV file.""" + def write_time_list_to_csv(time_list, filename): + """Writes the time list to a CSV file.""" with open('results/' + filename + '.csv', 'w', encoding='utf-8') as myfile: for time in time_list: myfile.write(str(time) + '\n') diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 4d8907c81..fb393ee38 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -9,8 +9,8 @@ from aws_encryption_sdk_performance_tests.keyrings.aws_kms_keyring import ( create_keyring, - create_kms_client, create_keyring_given_kms_client, + create_kms_client, decrypt_using_keyring, encrypt_using_keyring, ) diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py index 959129a33..bc74ad558 100644 --- a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -7,7 +7,7 @@ import click from tqdm import tqdm -from aws_encryption_sdk_performance_tests.master_key_providers.aws_kms_key_provider import ( +from aws_encryption_sdk_performance_tests.master_key_providers.aws_kms_master_key_provider import ( create_key_provider, decrypt_using_key_provider, encrypt_using_key_provider, From e62cbc294bf1091a280a815b8db9ff425d9f3c04 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 24 May 2024 13:21:17 -0700 Subject: [PATCH 08/33] added performance tests to CI --- tox.ini | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 8d4af1d2d..0c0e493ca 100644 --- a/tox.ini +++ b/tox.ini @@ -17,10 +17,10 @@ envlist = # The `mpl` prefix specifies a separate target, # i.e. `mpllocal` instead of `local`. # `mplXXX` contains tests using MPL components. - py{311,312}-mpl{local,examples}-mpl + py{311,312}-mpl{local,examples,performance_tests}-mpl nocmk, bandit, doc8, readme, docs, - {flake8,pylint}{,-tests,-examples}, + {flake8,pylint}{,-tests,-examples,-performance_tests}, isort-check, black-check, # prone to false positives vulture @@ -92,6 +92,7 @@ commands = examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples # MPL keyring examples require a special IAM role; run these separately under a separate set of permissions mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/ + performance_tests: {[testenv:base-command]commands} performance_tests/test/keyrings/ performance_tests/test/master_key_providers/ all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/ mplall: {[testenv:base-command]commands} test/ examples/test/ manual: {[testenv:base-command]commands} @@ -175,6 +176,18 @@ commands = --ignore D103,E203,W503 \ examples/test/ +[testenv:flake8-performance_tests] +basepython = {[testenv:flake8]basepython} +deps = {[testenv:flake8]deps} +commands = + flake8 performance_tests/src/ + flake8 \ + # Ingore D103 missing docstring errors in tests (test names should be self-documenting) + # E203 is not PEP8 compliant https://github.com/ambv/black#slices + # W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators + --ignore D103,E203,W503 \ + performance_tests/test/ + [testenv:pylint] basepython = python3 deps = @@ -195,6 +208,13 @@ commands = pylint --rcfile=examples/src/pylintrc examples/src/ pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/ +[testenv:pylint-performance_tests] +basepython = {[testenv:pylint]basepython} +deps = {[testenv:pylint]deps} +commands = + pylint --rcfile=performance_tests/pylintrc performance_tests/src/ + pylint --rcfile=performance_tests/pylintrc performance_tests/test/ + [testenv:pylint-tests] basepython = {[testenv:pylint]basepython} deps = {[testenv:pylint]deps} @@ -215,6 +235,7 @@ commands = doc/conf.py \ test/ \ examples/ \ + performance_tests/ \ {posargs} @@ -245,6 +266,8 @@ commands = isort -rc \ test \ # We do not include examples/test because of the need to modify sys.path for some imports examples/src/ \ + performance_tests/src/ \ + performance_tests/test/ \ doc \ setup.py \ {posargs} From e5f72217c74c5ac38131cc6a94ce5bb45c430e82 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 24 May 2024 15:14:08 -0700 Subject: [PATCH 09/33] adding files for aes and rsa keyring / mkp --- .../keyrings/raw_aes_keyring.py | 85 ++++++++++++ .../keyrings/raw_rsa_keyring.py | 79 +++++++++++ .../raw_aes_master_key_provider.py | 101 ++++++++++++++ .../raw_rsa_master_key_provider.py | 101 ++++++++++++++ .../utils/util.py | 129 ++++++++--------- .../test/keyrings/test_aws_kms_keyring.py | 8 +- .../test/keyrings/test_raw_aes_keyring.py | 124 +++++++++++++++++ .../test/keyrings/test_raw_rsa_keyring.py | 131 ++++++++++++++++++ .../test_aws_kms_master_key_provider.py | 6 +- .../test_raw_aes_master_key_provider.py | 124 +++++++++++++++++ .../test_raw_rsa_master_key_provider.py | 124 +++++++++++++++++ .../raw_rsa/ciphertext-data-empty.ct | Bin 0 -> 899 bytes .../raw_rsa/ciphertext-data-large.ct | Bin 0 -> 8931 bytes .../raw_rsa/ciphertext-data-medium.ct | Bin 0 -> 4899 bytes .../raw_rsa/ciphertext-data-small.ct | Bin 0 -> 935 bytes .../keys/user_rsa_private_key_file_name.pem | 51 ------- .../keys/user_rsa_public_key_file_name.pem | 14 -- tox.ini | 27 +--- 18 files changed, 943 insertions(+), 161 deletions(-) create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_aes_keyring.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_rsa_keyring.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_aes_master_key_provider.py create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_rsa_master_key_provider.py create mode 100644 performance_tests/test/keyrings/test_raw_aes_keyring.py create mode 100644 performance_tests/test/keyrings/test_raw_rsa_keyring.py create mode 100644 performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py create mode 100644 performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py create mode 100644 performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-empty.ct create mode 100644 performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-large.ct create mode 100644 performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-medium.ct create mode 100644 performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-small.ct delete mode 100644 performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem delete mode 100644 performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_aes_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_aes_keyring.py new file mode 100644 index 000000000..a849b1a7f --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_aes_keyring.py @@ -0,0 +1,85 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Performance tests for the Raw AES keyring.""" + +import aws_encryption_sdk +from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders +from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig +from aws_cryptographic_materialproviders.mpl.models import AesWrappingAlg, CreateRawAesKeyringInput +from aws_cryptographic_materialproviders.mpl.references import IKeyring + +from ..utils.util import PerfTestUtils + + +def create_keyring(): + """Demonstrate how to create a Raw AES keyring. + + Usage: create_keyring() + """ + key_name_space = "Some managed raw keys" + key_name = "My 256-bit AES wrapping key" + + # Here, the input to secrets.token_bytes() = 32 bytes = 256 bits + # We fix the static key in order to make the test deterministic + static_key = PerfTestUtils.DEFAULT_AES_256_STATIC_KEY + + mat_prov: AwsCryptographicMaterialProviders = AwsCryptographicMaterialProviders( + config=MaterialProvidersConfig() + ) + + keyring_input: CreateRawAesKeyringInput = CreateRawAesKeyringInput( + key_namespace=key_name_space, + key_name=key_name, + wrapping_key=static_key, + wrapping_alg=AesWrappingAlg.ALG_AES256_GCM_IV12_TAG16 + ) + + keyring: IKeyring = mat_prov.create_raw_aes_keyring( + input=keyring_input + ) + + return keyring + + +def encrypt_using_keyring( + plaintext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to encrypt plaintext data using a Raw AES keyring. + + Usage: encrypt_using_keyring(plaintext_data, keyring) + :param plaintext_data: plaintext data you want to encrypt + :type: bytes + :param keyring: Keyring to use for encryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + ciphertext_data, _ = client.encrypt( + source=plaintext_data, + keyring=keyring + ) + + return ciphertext_data + + +def decrypt_using_keyring( + ciphertext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to decrypt ciphertext data using a Raw AES keyring. + + Usage: decrypt_using_keyring(ciphertext_data, keyring) + :param ciphertext_data: ciphertext data you want to decrypt + :type: bytes + :param keyring: Keyring to use for decryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + decrypted_plaintext_data, _ = client.decrypt( + source=ciphertext_data, + keyring=keyring + ) + + return decrypted_plaintext_data diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_rsa_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_rsa_keyring.py new file mode 100644 index 000000000..6eed281bd --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/raw_rsa_keyring.py @@ -0,0 +1,79 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Performance tests for the Raw RSA keyring.""" +import aws_encryption_sdk +from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders +from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig +from aws_cryptographic_materialproviders.mpl.models import CreateRawRsaKeyringInput, PaddingScheme +from aws_cryptographic_materialproviders.mpl.references import IKeyring + + +def create_keyring(public_key, private_key): + """Demonstrate how to create a Raw RSA keyring using the key pair. + + Usage: create_keyring(public_key, private_key) + """ + key_name_space = "Some managed raw keys" + key_name = "My 4096-bit RSA wrapping key" + + mat_prov: AwsCryptographicMaterialProviders = AwsCryptographicMaterialProviders( + config=MaterialProvidersConfig() + ) + + keyring_input: CreateRawRsaKeyringInput = CreateRawRsaKeyringInput( + key_namespace=key_name_space, + key_name=key_name, + padding_scheme=PaddingScheme.OAEP_SHA256_MGF1, + public_key=public_key, + private_key=private_key + ) + + keyring: IKeyring = mat_prov.create_raw_rsa_keyring( + input=keyring_input + ) + + return keyring + + +def encrypt_using_keyring( + plaintext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to encrypt plaintext data using a Raw RSA keyring. + + Usage: encrypt_using_keyring(plaintext_data, keyring) + :param plaintext_data: plaintext data you want to encrypt + :type: bytes + :param keyring: Keyring to use for encryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + ciphertext_data, _ = client.encrypt( + source=plaintext_data, + keyring=keyring + ) + + return ciphertext_data + + +def decrypt_using_keyring( + ciphertext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to decrypt ciphertext data using a Raw RSA keyring. + + Usage: decrypt_using_keyring(ciphertext_data, keyring) + :param ciphertext_data: ciphertext data you want to decrypt + :type: bytes + :param keyring: Keyring to use for decryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + decrypted_plaintext_data, _ = client.decrypt( + source=ciphertext_data, + keyring=keyring + ) + + return decrypted_plaintext_data diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_aes_master_key_provider.py b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_aes_master_key_provider.py new file mode 100644 index 000000000..42d071dcf --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_aes_master_key_provider.py @@ -0,0 +1,101 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Performance tests for the Raw AES master key provider.""" + +import aws_encryption_sdk +from aws_encryption_sdk.identifiers import EncryptionKeyType, WrappingAlgorithm +from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey +from aws_encryption_sdk.key_providers.raw import RawMasterKeyProvider + +from ..utils.util import PerfTestUtils + + +class StaticRandomMasterKeyProvider(RawMasterKeyProvider): + """Generates 256-bit keys for each unique key ID.""" + + # The Provider ID (or Provider) field in the JceMasterKey and RawMasterKey is + # equivalent to key namespace in the Raw keyrings + provider_id = "Some managed raw keys" + + def __init__(self, **kwargs): # pylint: disable=unused-argument + """Initialize empty map of keys.""" + self._static_keys = {} + + def _get_raw_key(self, key_id): + """Returns a static, randomly-generated symmetric key for the specified key ID. + + :param str key_id: Key ID + :returns: Wrapping key that contains the specified static key + :rtype: :class:`aws_encryption_sdk.internal.crypto.WrappingKey` + """ + try: + static_key = self._static_keys[key_id] + except KeyError: + # We fix the static key in order to make the test deterministic + # In practice, you should get this key from a secure key management system such as an HSM. + static_key = PerfTestUtils.DEFAULT_AES_256_STATIC_KEY + self._static_keys[key_id] = static_key + return WrappingKey( + wrapping_algorithm=WrappingAlgorithm.AES_256_GCM_IV12_TAG16_NO_PADDING, + wrapping_key=static_key, + wrapping_key_type=EncryptionKeyType.SYMMETRIC, + ) + + +def create_key_provider(): + """Demonstrate how to create a Raw AES master key-provider. + + Usage: create_key_provider() + """ + # Create a Raw AES master key-provider. + + # The Key ID field in the JceMasterKey and RawMasterKey is equivalent to key name in the Raw keyrings + key_id = "My 256-bit AES wrapping key" + key_provider = StaticRandomMasterKeyProvider() + key_provider.add_master_key(key_id) + + return key_provider + + +def encrypt_using_key_provider( + plaintext_data: bytes, + key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider +): + """Demonstrate how to encrypt plaintext data using a Raw AES master key-provider. + + Usage: encrypt_using_key_provider(plaintext_data, key_provider) + :param plaintext_data: plaintext data you want to encrypt + :type: bytes + :param key_provider: Master key provider to use for encryption. + :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + ciphertext_data, _ = client.encrypt( + source=plaintext_data, + key_provider=key_provider + ) + + return ciphertext_data + + +def decrypt_using_key_provider( + ciphertext_data: bytes, + key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider +): + """Demonstrate how to decrypt ciphertext data using a Raw AES master key-provider. + + Usage: decrypt_using_key_provider(ciphertext_data, key_provider) + :param ciphertext_data: ciphertext data you want to decrypt + :type: bytes + :param key_provider: Master key provider to use for decryption. + :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + decrypted_plaintext_data, _ = client.decrypt( + source=ciphertext_data, + key_provider=key_provider + ) + + return decrypted_plaintext_data diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_rsa_master_key_provider.py b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_rsa_master_key_provider.py new file mode 100644 index 000000000..b52b78735 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/master_key_providers/raw_rsa_master_key_provider.py @@ -0,0 +1,101 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Performance tests for the Raw RSA master key provider.""" + +import aws_encryption_sdk +from aws_encryption_sdk.identifiers import EncryptionKeyType, WrappingAlgorithm +from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey +from aws_encryption_sdk.key_providers.raw import RawMasterKeyProvider + +from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils + + +class StaticRandomMasterKeyProvider(RawMasterKeyProvider): + """Randomly generates and provides 4096-bit RSA keys consistently per unique key id.""" + + # The Provider ID (or Provider) field in the JceMasterKey and RawMasterKey is + # equivalent to key namespace in the Raw keyrings + provider_id = "Some managed raw keys" + + def __init__(self, **kwargs): # pylint: disable=unused-argument + """Initialize empty map of keys.""" + self._static_keys = {} + + def _get_raw_key(self, key_id): + """Retrieves a static, randomly generated, RSA key for the specified key id. + + :param str key_id: User-defined ID for the static key + :returns: Wrapping key that contains the specified static key + :rtype: :class:`aws_encryption_sdk.internal.crypto.WrappingKey` + """ + try: + static_key = self._static_keys[key_id] + except KeyError: + # We fix the static key in order to make the test deterministic + # In practice, you should get this key from a secure key management system such as an HSM. + static_key = PerfTestUtils.DEFAULT_RSA_PRIVATE_KEY + self._static_keys[key_id] = static_key + return WrappingKey( + wrapping_algorithm=WrappingAlgorithm.RSA_OAEP_SHA256_MGF1, + wrapping_key=static_key, + wrapping_key_type=EncryptionKeyType.PRIVATE, + ) + + +def create_key_provider(): + """Demonstrate how to create a Raw RSA master key-provider. + + Usage: create_key_provider() + """ + # Create a Raw RSA master key-provider. + + # The Key ID field in the JceMasterKey and RawMasterKey is equivalent to key name in the Raw keyrings + key_id = "My 4096-bit RSA wrapping key" + key_provider = StaticRandomMasterKeyProvider() + key_provider.add_master_key(key_id) + + return key_provider + + +def encrypt_using_key_provider( + plaintext_data: bytes, + key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider +): + """Demonstrate how to encrypt plaintext data using a Raw RSA master key-provider. + + Usage: encrypt_using_key_provider(plaintext_data, key_provider) + :param plaintext_data: plaintext data you want to encrypt + :type: bytes + :param key_provider: Master key provider to use for encryption. + :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + ciphertext_data, _ = client.encrypt( + source=plaintext_data, + key_provider=key_provider + ) + + return ciphertext_data + + +def decrypt_using_key_provider( + ciphertext_data: bytes, + key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider +): + """Demonstrate how to decrypt ciphertext data using a Raw RSA master key-provider. + + Usage: decrypt_using_key_provider(ciphertext_data, key_provider) + :param ciphertext_data: ciphertext data you want to decrypt + :type: bytes + :param key_provider: Master key provider to use for decryption. + :type key_provider: aws_encryption_sdk.key_providers.base.MasterKeyProvider + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + decrypted_plaintext_data, _ = client.decrypt( + source=ciphertext_data, + key_provider=key_provider + ) + + return decrypted_plaintext_data diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py index 96097c833..9d640b687 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py @@ -10,71 +10,72 @@ class PerfTestUtils: DEFAULT_AES_256_STATIC_KEY = \ b'_\xcf"\x82\x03\x12\x9d\x00\x8a\xed\xaf\xe4\x80\x1d\x00t\xa6P\xac\xb6\xfe\xc5\xf6/{\xe7\xaaO\x01\x13W\x85' DEFAULT_RSA_PUBLIC_KEY = bytes("-----BEGIN PUBLIC KEY-----\n" - + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwEkp2yRpTAgZa4MDNxq8" - + "eQ7rkaVw9QTdJr9NFAtjUpM/6UQARJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWy" - + "E2nm4MCHED62mEEbjbDwtLmiWK0giZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnf" - + "Mpode5IQY3AZM3unIVFA043oD3ZPRsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKh" - + "f7ivmhVAKxwacXTb2yIynGljEgZZfkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruv" - + "gaE6vArdndBQcUV/NAOBeDegsfAsic7OC9FD/3MFgLo2g72WYY3BuCNMDj8L3lWK" - + "+vyC/S66cIvp1P2GzsccHSfcK0MC09ojnCbKF6D7tv5pIKhtvZRC7xcNv1ctS/fb" - + "UbMy4tH+8iwvJlTRGZuuEYDwoBFowNS1oHxeO1PI1im93inAYt5GhkMuaZKLaY64" - + "xe51LJNcP1ovAhHaMG8UGfeCiNBRjGEP3pMG8sgLyw9k3gqMVzX4MUfPlXQh503k" - + "3bVE/eymdsdZ1kAlMLR26IoQ6muAHtn0cy00RjRPy0hIQ2Z+ACog0ge91AyWgXjn" - + "0WYI3AUOzVRZAoqS7ymf2zQfyb3WVYBMfyYT9IhUZlAWq8uzEkoFs47r0LKrv6DA" - + "LX8MCeTVUP6ELg4Inaz8UDECAwEAAQ==" - + "\n-----END PUBLIC KEY-----", 'utf-8') + + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxwWEEtEofjwaoo3WO79D\n" + + "hntoPf2APlY5yzlqm6ZvMyaazlwetkAzLSn5GB4hjKZaf043BfADJEdwXMHn8/UN\n" + + "up0BfUj8PfGn/b8cL78CTnvFZd/7WxQh6tUnfLX7BMiccHMb9OHhRy5PrTSuj6Um\n" + + "wwhBadL+Lc23DGl2cyN9SjGuYWWQ1IHGFA4/2EQr+Ez4LpebZqwXgv0iLuApte1q\n" + + "vGl6zOhByxi1N/ORVEscLT82+L+F3STgeTYA1CaoLFQ0y9ybx+7UUfEfKxhGoGEO\n" + + "XEOTuRBdLE2Jm8xaBODLqfiXr0z62VhTpRs4CYYTGHTLFCJHqeH7R2fwvwoG1nIg\n" + + "QzWSyyapK7d5MLn3rF3ManjZhvlyHK1wqa7nWVpo+jq1Py+HWLAtU8FY0br6wnOR\n" + + "3jjPGk0N4//iDnxNN+kpDxFnHEvxe3eJKWnbw0GR9+BGj32O+wRMtGyfRTzkoD/E\n" + + "EqIRlDzdtYCAtFW0HUsdQwL+ssDjEQ0+lqvEQrwTU1WBZiBQhEmzksAowHAcNIT+\n" + + "Fz7mvIlpEETNOQbsJkoXdEkhJXljh5UYmH1cB5al1MJf/5ea5Xb2HfH5WkMy4+eS\n" + + "V68V+tXv3ZthTe2bCk9rQTH9FWKLIYJyZfv8WAIxSWEEsyk5b+7WUGmvtm/nPJ4Z\n" + + "RfzkXoBJqJiSiPYCM0+jG4sCAwEAAQ==\n" + + "-----END PUBLIC KEY-----\n", 'utf-8') - DEFAULT_RSA_PRIVATE_KEY = bytes("-----BEGIN RSA PRIVATE KEY-----\n" - + "MIIJJwIBAAKCAgEAwEkp2yRpTAgZa4MDNxq8eQ7rkaVw9QTdJr9NFAtjUpM/6UQA" - + "RJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWyE2nm4MCHED62mEEbjbDwtLmiWK0g" - + "iZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnfMpode5IQY3AZM3unIVFA043oD3ZP" - + "RsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKhf7ivmhVAKxwacXTb2yIynGljEgZZ" - + "fkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruvgaE6vArdndBQcUV/NAOBeDegs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3rrsJKI/64/lqgfU3A7GqAgQz" - + "2dfrnf0UPVSjJjuCs/TKBXSDxghzhFAQ5rjH4laazzQdqrQUPQKCAQEA7uhWcnxM" - + "B62vjJDQ4cVhKGrTooE8PehrOGKKR2i1BrddvwwbXy8wlbHDgEjvSTc0yOr38vdk" - + "Miwul/gR2/EG3qGuI6OnnPp8tYWLYMkDjjYC5mcQXBnHT5BAmAIDEgC7Fi0O9+hM" - + "5fCy7/8admovUJZcOX8q+urs1LNakcLuusA0CGB9KJvNvIwOuMnhaVvaFXTf2oZ8" - + "55itKyoG6Ca/AR5aNuUO6YnL+rEQaYsKsreYwB1B8B0UTxgVl12YtJWZkG3SHAKR" - + "RQeqrZQPtIUgN5hk6dX0vzv4fvooGT162PrWckriqSKag4lxJnOp6DO0NyEGwf+4" - + "FaEItex7PFUMuwKCAQEAzgrvL+56sqhKho0Z3J/PYj4f4LNElE1hQ7sHd2QtfyYS" - + "Ig4qKiUJIKjfC9LrFjtyqRiH5OTs63eorO+757DTFWjXCSVUwppPcLyOyr5mrULL" - + "T2PE8LE0GBw2PnIkfMCuDlvxKp/Arb1Co5uRCWrSPHEcY+hSlp5SJYwNhs3HyNBZ" - + "soKmjnUtP+HX5KlBoMQEo8kKnlfBTSVl2WAeu5UaM4Z0Q8ZxgCMnhDx2lVmMohUw" - + "/qBDw+uA51vgSCSRQLamrlEZQ6jqUzD/9kNbqioMKuPCOZWIKBZvBJNe2hmF+JKb" - + "epSrtKIor229l98UbfYhhiAw0//qon+pGXANNyneAwKCAQAd5VMUBnvZJiHmnCSX" - + "bASpcxzCpBtuv8vTBXm6T97/VSjVBGXUdmpFATausfHHnrHrRoP6knymTqMR/0f0" - + "1ud+KotJCGysFyhN6sUzOlRIknewb0s7yzoGuc1reCz8Lr06nC7YVOhyiblKkQi1" - + "srnzAq3NwB0XwxgZ0cvOm68WDYE1XyWqVDzdkEUzWIftkEHtF2//v36X2KIq2Zp9" - + "qIOUV0EAx48jKEwvNcMRAgY3sQPbXo3mxyzIbQIeq+a1CldqHGQDf0rAcaIpEHMa" - + "quIKMvbF0DFNUOrasOEdr3TU/CajrL1KXvso5KUVI7oqRXYSw/49fouBoWIeqdYO" - + "CbKLAoIBAC9lzIgWMBuRIzO4mc5q5OYQrHygQJJtCobuK1WHsf+h3mH/KCvxwRvG" - + "PSkXKAVBP6sufXRmRSoVqLO/olY2ExjFuVHdSJZLsSKZ/a8eBbituN9WcCN+YCF7" - + "u+65izM3j9K1y9CmV0igVQgV7VNhQ2OsEX/aHcWQPg1tHl94TxEe/MNX0sDKq9Ia" - + "PfPYC8TT0s1qngq23TzF8ZwDxI4aSqC3uV8t80Yq0BhXYGAS7YsLnO22KGCVeF3A" - + "gOOXpeJhIg7PkSRDY0Qn7XnVHO0UJyBmrHNatquiHX/L9vHtFSiNcT7NnII9G2bf" - + "s9GP+78f865LEXBzWqJvA5Nad2/NLckCggEANWMjb5QcJqTSXn0f2UqJ7AicWoqQ" - + "dMjpY79N+2iz2tlNFD9/BC/l6QGhM4YMVLNDwM2Aak37P8ZnQ9frEjMCEoD2bIlO" - + "cWxVaXMP39rnLUPzg8D2TcjiQ2NBL4FDYXudZCUh4b1x70Gp2GiP7GxZwv2/SQhD" - + "j7cc4oNwaE1hkiMhAYbPgWUU06JQwWPcD8UmKUgdp2ET+eUEwfV0GVtNOSfGoenf" - + "ZqdaYcE8c3ft37JM5AsKo5h+G3qHOBRMEYHtQDybuvvFsg+hJ0BuxYt4mFubWZYL" - + "V/tu4K1kmEZXgTvNZWSsZaIY2xBus2Ol2rKTahA0d9ffGeUhRj+UQrWpxg==" - + "\n-----END RSA PRIVATE KEY-----", "utf-8") + DEFAULT_RSA_PRIVATE_KEY = bytes("-----BEGIN PRIVATE KEY-----\n" + + "MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDHBYQS0Sh+PBqi\n" + + "jdY7v0OGe2g9/YA+VjnLOWqbpm8zJprOXB62QDMtKfkYHiGMplp/TjcF8AMkR3B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PA101ll1KPom1ECI/F6ku5b2H2vnewy2TNzsY\n" + + "QX0R4NFofQLxAoIBAG2af/pbO+naMXKSL2nxighmmFfATAsuV8k4DxGBS+1Pb516\n" + + "jq5pR781fAY5o2n2hKjtJ1S1x80XrS3xXTi7Dqqkssq256TnwJeF5cbMvJswbOpZ\n" + + "mxFjFK3yqhCOa3zAxCL09cd83kb7TJbWN4woYLcJj5WKBTdd1cK2xxVeyHbZtXaZ\n" + + "z6jlmcG2qStRt8K6sswTkGolYkpwy+oWeLGMYR/cFxed0ExvT34aJK+Jb6nQSkSp\n" + + "dJ67Ad91f7j6WcyvhEYdRbQvEwHNbGLAmwgBan1eQfoe1Famwt1A7sfOnq0tkkzg\n" + + "5+PizKvPgr+YS+3nlwBac9joUlqPZgi/cGaMSPcCggEBALbTLZ4sJyM5RhFtJXoG\n" + + "j6/86F4cbk1HRwDmSY5snsepBQ8duGzMldY6qrlFQq2expgQQKrUCfEcZIg+yIOK\n" + + "RrApGEez3ke+02ZaEifsI20k4Y4WI8UuvhdTfX7xd76UMyRQ1N7+GTDyIVB+AfXz\n" + + "fYVGmya0TPY+meMsvwMXB8EHwpikid/nqHoRYNxD0vk30R7g2CqtLnaTPK58URdt\n" + + "5Y0TP1LnbBypQ0y3k1z3AbqCgJaHDrDTCE4SOUKLjLKtCaqgDG0BaQtkrsKkldrQ\n" + + "sbCk+OE//LRyA4mfHjssrs3EQz4D6JKvpPdrApsrbmihEDWaIzVXFzcRogUkrNqX\n" + + "b5ECggEBAKGW7doJEm0MjyvrJj/Tj4Zx3S8UjMgheBEIUZtMjewtNL0pn70O2AxN\n" + + "aEa4zHaNS0yTgMdbObImzYgat+asJbmFcv0UJy/e4CN+rrZlCHW2D9v9U+O0wKLB\n" + + "e5AmmFwaT/vVIy4gmBTcKGxV90ZF799gmKSoHAlrgjPFSRB/WcJsMwsGEyXl/C4Z\n" + + "4/xCqJgr0VJvuwrCiWf1QKn9AHuytit27E2R52n4FjU5nJ+CJEQqU1XDgF0x+txw\n" + + "PXUuRjOxKO6MzldzqJSUrTir8uqCwBIR9x9GOrGDp//ZbRw2TK4EbkyjNYO7KtOF\n" + + "A/DHJmMI5bKETJyj1GhBE9LqypAI1Bo=\n" + + "-----END PRIVATE KEY-----\n", "utf-8") @staticmethod def read_file(filename): diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index fb393ee38..2f8c7cddd 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -45,7 +45,7 @@ def create( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - PerfTestUtils.print_time_list_to_csv(time_list, output_file) + PerfTestUtils.write_time_list_to_csv(time_list, output_file) @click.group() @@ -77,7 +77,7 @@ def create_given_kms_client( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - PerfTestUtils.print_time_list_to_csv(time_list, output_file) + PerfTestUtils.write_time_list_to_csv(time_list, output_file) @click.group() @@ -116,7 +116,7 @@ def encrypt( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - PerfTestUtils.print_time_list_to_csv(time_list, output_file) + PerfTestUtils.write_time_list_to_csv(time_list, output_file) @click.group() @@ -155,7 +155,7 @@ def decrypt( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - PerfTestUtils.print_time_list_to_csv(time_list, output_file) + PerfTestUtils.write_time_list_to_csv(time_list, output_file) kms_keyring_test = click.CommandCollection(sources=[create_kms_keyring, diff --git a/performance_tests/test/keyrings/test_raw_aes_keyring.py b/performance_tests/test/keyrings/test_raw_aes_keyring.py new file mode 100644 index 000000000..cd593ed8e --- /dev/null +++ b/performance_tests/test/keyrings/test_raw_aes_keyring.py @@ -0,0 +1,124 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""This is a performance test for creating the Raw AES keyring.""" + +import time + +import click +from tqdm import tqdm + +from aws_encryption_sdk_performance_tests.keyrings.raw_aes_keyring import ( + create_keyring, + decrypt_using_keyring, + encrypt_using_keyring, +) +from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils + + +@click.group() +def create_raw_aes_keyring(): + """Click group helper function""" + + +@create_raw_aes_keyring.command() +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_aes_keyring_create') +def create( + n_iters: int, + output_file: str +): + """Performance test for the create_keyring function.""" + time_list = [] + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + create_keyring() + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def encrypt_raw_aes_keyring(): + """Click group helper function""" + + +@encrypt_raw_aes_keyring.command() +@click.option('--plaintext_data_filename', + default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + prompt='Filename containing plaintext data you want to encrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_aes_keyring_encrypt') +def encrypt( + plaintext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the encrypt_using_keyring function.""" + plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) + + keyring = create_keyring() + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + encrypt_using_keyring(plaintext_data, keyring) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def decrypt_raw_aes_keyring(): + """Click group helper function""" + + +@decrypt_raw_aes_keyring.command() +@click.option('--ciphertext_data_filename', + default='test/resources/ciphertext/raw_aes/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + prompt='Filename containing ciphertext data you want to decrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_aes_keyring_decrypt') +def decrypt( + ciphertext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the decrypt_using_keyring function.""" + ciphertext_data = PerfTestUtils.read_file(ciphertext_data_filename) + + keyring = create_keyring() + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + decrypt_using_keyring(ciphertext_data, keyring) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +raw_aes_keyring_test = click.CommandCollection(sources=[create_raw_aes_keyring, + encrypt_raw_aes_keyring, + decrypt_raw_aes_keyring]) + + +if __name__ == "__main__": + raw_aes_keyring_test() diff --git a/performance_tests/test/keyrings/test_raw_rsa_keyring.py b/performance_tests/test/keyrings/test_raw_rsa_keyring.py new file mode 100644 index 000000000..ac690e760 --- /dev/null +++ b/performance_tests/test/keyrings/test_raw_rsa_keyring.py @@ -0,0 +1,131 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""This is a performance test for creating the Raw RSA keyring.""" + +import time + +import click +from tqdm import tqdm + +from aws_encryption_sdk_performance_tests.keyrings.raw_rsa_keyring import ( + create_keyring, + decrypt_using_keyring, + encrypt_using_keyring, +) +from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils + + +@click.group() +def create_raw_rsa_keyring(): + """Click group helper function""" + + +@create_raw_rsa_keyring.command() +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_rsa_keyring_create') +def create( + n_iters: int, + output_file: str +): + """Performance test for the create_keyring function.""" + public_key = PerfTestUtils.DEFAULT_RSA_PUBLIC_KEY + private_key = PerfTestUtils.DEFAULT_RSA_PRIVATE_KEY + + time_list = [] + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + create_keyring(public_key, private_key) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def encrypt_raw_rsa_keyring(): + """Click group helper function""" + + +@encrypt_raw_rsa_keyring.command() +@click.option('--plaintext_data_filename', + default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + prompt='Filename containing plaintext data you want to encrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_rsa_keyring_encrypt') +def encrypt( + plaintext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the encrypt_using_keyring function.""" + public_key = PerfTestUtils.DEFAULT_RSA_PUBLIC_KEY + private_key = PerfTestUtils.DEFAULT_RSA_PRIVATE_KEY + plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) + + keyring = create_keyring(public_key, private_key) + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + encrypt_using_keyring(plaintext_data, keyring) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def decrypt_raw_rsa_keyring(): + """Click group helper function""" + + +@decrypt_raw_rsa_keyring.command() +@click.option('--ciphertext_data_filename', + default='test/resources/ciphertext/raw_rsa/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + prompt='Filename containing ciphertext data you want to decrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_rsa_keyring_decrypt') +def decrypt( + ciphertext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the decrypt_using_keyring function.""" + public_key = PerfTestUtils.DEFAULT_RSA_PUBLIC_KEY + private_key = PerfTestUtils.DEFAULT_RSA_PRIVATE_KEY + ciphertext_data = PerfTestUtils.read_file(ciphertext_data_filename) + + keyring = create_keyring(public_key, private_key) + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + decrypt_using_keyring(ciphertext_data, keyring) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +raw_rsa_keyring_test = click.CommandCollection(sources=[create_raw_rsa_keyring, + encrypt_raw_rsa_keyring, + decrypt_raw_rsa_keyring]) + + +if __name__ == "__main__": + raw_rsa_keyring_test() diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py index bc74ad558..ef1377d44 100644 --- a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -43,7 +43,7 @@ def create( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - PerfTestUtils.print_time_list_to_csv(time_list, output_file) + PerfTestUtils.write_time_list_to_csv(time_list, output_file) @click.group() @@ -82,7 +82,7 @@ def encrypt( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - PerfTestUtils.print_time_list_to_csv(time_list, output_file) + PerfTestUtils.write_time_list_to_csv(time_list, output_file) @click.group() @@ -121,7 +121,7 @@ def decrypt( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - PerfTestUtils.print_time_list_to_csv(time_list, output_file) + PerfTestUtils.write_time_list_to_csv(time_list, output_file) kms_key_provider_test = click.CommandCollection(sources=[create_kms_key_provider, diff --git a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py new file mode 100644 index 000000000..22f8787ef --- /dev/null +++ b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py @@ -0,0 +1,124 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""This is a performance test for creating the Raw AES Master key-provider.""" + +import time + +import click +from tqdm import tqdm + +from aws_encryption_sdk_performance_tests.master_key_providers.raw_aes_master_key_provider import ( + create_key_provider, + decrypt_using_key_provider, + encrypt_using_key_provider, +) +from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils + + +@click.group() +def create_raw_aes_key_provider(): + """Click group helper function""" + + +@create_raw_aes_key_provider.command() +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_aes_key_provider_create') +def create( + n_iters: int, + output_file: str +): + """Performance test for the create_key_provider function.""" + time_list = [] + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + create_key_provider() + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def encrypt_raw_aes_key_provider(): + """Click group helper function""" + + +@encrypt_raw_aes_key_provider.command() +@click.option('--plaintext_data_filename', + default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + prompt='Filename containing plaintext data you want to encrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_aes_key_provider_encrypt') +def encrypt( + plaintext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the encrypt_using_key_provider function.""" + plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) + + key_provider = create_key_provider() + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + encrypt_using_key_provider(plaintext_data, key_provider) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def decrypt_raw_aes_key_provider(): + """Click group helper function""" + + +@decrypt_raw_aes_key_provider.command() +@click.option('--ciphertext_data_filename', + default='test/resources/ciphertext/raw_aes/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + prompt='Filename containing ciphertext data you want to decrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_aes_key_provider_decrypt') +def decrypt( + ciphertext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the decrypt_using_key_provider function.""" + ciphertext_data = PerfTestUtils.read_file(ciphertext_data_filename) + + key_provider = create_key_provider() + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + decrypt_using_key_provider(ciphertext_data, key_provider) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +raw_aes_key_provider_test = click.CommandCollection(sources=[create_raw_aes_key_provider, + encrypt_raw_aes_key_provider, + decrypt_raw_aes_key_provider]) + + +if __name__ == "__main__": + raw_aes_key_provider_test() diff --git a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py new file mode 100644 index 000000000..3b8e4c89b --- /dev/null +++ b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py @@ -0,0 +1,124 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""This is a performance test for creating the Raw RSA Master key-provider.""" + +import time + +import click +from tqdm import tqdm + +from aws_encryption_sdk_performance_tests.master_key_providers.raw_rsa_master_key_provider import ( + create_key_provider, + decrypt_using_key_provider, + encrypt_using_key_provider, +) +from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils + + +@click.group() +def create_raw_rsa_key_provider(): + """Click group helper function""" + + +@create_raw_rsa_key_provider.command() +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_rsa_key_provider_create') +def create( + n_iters: int, + output_file: str +): + """Performance test for the create_key_provider function.""" + time_list = [] + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + create_key_provider() + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def encrypt_raw_rsa_key_provider(): + """Click group helper function""" + + +@encrypt_raw_rsa_key_provider.command() +@click.option('--plaintext_data_filename', + default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + prompt='Filename containing plaintext data you want to encrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_rsa_key_provider_encrypt') +def encrypt( + plaintext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the encrypt_using_key_provider function.""" + plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) + + key_provider = create_key_provider() + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + encrypt_using_key_provider(plaintext_data, key_provider) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +@click.group() +def decrypt_raw_rsa_key_provider(): + """Click group helper function""" + + +@decrypt_raw_rsa_key_provider.command() +@click.option('--ciphertext_data_filename', + default='test/resources/ciphertext/raw_rsa/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + prompt='Filename containing ciphertext data you want to decrypt') +@click.option('--n_iters', + default=PerfTestUtils.DEFAULT_N_ITERS) +@click.option('--output_file', + default='raw_rsa_key_provider_decrypt') +def decrypt( + ciphertext_data_filename: str, + n_iters: int, + output_file: str +): + """Performance test for the decrypt_using_key_provider function.""" + ciphertext_data = PerfTestUtils.read_file(ciphertext_data_filename) + + key_provider = create_key_provider() + time_list = [] + + for _ in tqdm(range(n_iters)): + curr_time = time.time() + + decrypt_using_key_provider(ciphertext_data, key_provider) + + # calculate elapsed time in milliseconds + elapsed_time = (time.time() - curr_time) * 1000 + time_list.append(elapsed_time) + + PerfTestUtils.write_time_list_to_csv(time_list, output_file) + + +raw_rsa_key_provider_test = click.CommandCollection(sources=[create_raw_rsa_key_provider, + encrypt_raw_rsa_key_provider, + decrypt_raw_rsa_key_provider]) + + +if __name__ == "__main__": + raw_rsa_key_provider_test() diff --git a/performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-empty.ct b/performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-empty.ct new file mode 100644 index 0000000000000000000000000000000000000000..202643e9a47c3d902e31641767e837dbab65aaaa GIT binary patch literal 899 zcmV-}1AP1f1$a;k*Y6C|%Vu~O9PME8#TMGv-D56&of(URe4oUhO)&sp0096MVRv&a zV{&qK~dUZK(NlRj9I7%>bPEKiKNH=6ectT_^S4Ar}YDY3h zD`rGTX*5}6c5G-yWi(-7M=>ixVMc3Xd16;raCJ&yQ9V5X0RRVQ_G1Zf78CWqASsUpQlUu^)lm4R@Xf z3()wGI&o41BK?E3)<7oi^$-i}~GmK=OFN?HzBcx4;+(`3b@*q0?IB4*n5? z>9V$X=XZUpek$EzX&HROH09VgaGQY%PeoC{IMv&rDxyR(gC9tKIdcJ!@x9>?NU2ma zxF6|b+RLMB%Uu1@*L|9USt6u}NFiZL5ZQBwY*X;@T_-}I1%b{ZJP6cwyD$Du0}6Ub3(Gb$GZz}CX7^U? zN6SYN#JbaH(HM@Ffm?F5W|bxjOR}~7>e$$X8WnblyBzJYuidn-vzg@u#OcHqJEXRrfQ8q!b*QKi36DF~>EC^s z5>($+#m=(GPG46}z^aY*wc^nS&YJnlT2#!}-$qum)QPd>;_>sNL%y{O{{ktH;aBa0 zj8;i|0kc`yjGG7Wnit~6)?RL>tS9|^enhQy*94~+0ssII0I8@V{w5l%yy=9znPr}4 z(CW?RNfD!_?Vwv%cmW|R^O-LUpXR@Mp4PBCzlA6xXaE2I{{R300RR910000000000 z0RR910PvOk%5-wF>4(^>4Dnz@AOL4DWdbn(nI{|Z=WlyJzsROUf%}!7NJDYF5tf_- za^SO;L`WdC%_g6;r^9HSV{j@1$F+cl0x*4r?|Sl{+298nR<-|k#Esi>(tjA=Y#&$k Z4Q=Y&cGne<@Mn1}3)%96i?ANx>G00Sq__Y8 literal 0 HcmV?d00001 diff --git a/performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-large.ct b/performance_tests/test/resources/ciphertext/raw_rsa/ciphertext-data-large.ct new file mode 100644 index 0000000000000000000000000000000000000000..259d83ea5ae956148020b4f61061e0932dfc0d6e GIT binary patch literal 8931 zcmV<9A{^ZU1$Z7^6is}J`L|i_hTTxthx@jqK~FH>1eN=8g#YF14!H!E~>b!K{4Xkk!QH&t|WZcTMU zX>fO9Fj{7IYc)bkD_KrxI5}=vZA@-iF)?B?dT>NecRf7-0RRVQ_G1Zf78CWqASsHuf&#Cv~zrlE-)e zUfZV6-nAVObj4#1!JmAU+mqu@az9t$OXxnk5803-@QD< zz?bdfo}l+!fMRPxRAH+2<*^W{TSI)~=tnThz~HB}TH@hmu%=z=2xBQjEBWm^VGIm%OCpynJO`K%*6TnNLGuhUxAXZO)v^?#);rWP8<-Q;~otGXEn@W7o!-a+)Hbejn2 z4IY(e-)(n)b;eNUA||0dar4YS8+)vqyV+RxvWPo|6qI~APTmcGTbzCGExld-3#bGKhgAiI` znkxWo!_Cv&pknArq=FYHh_KSCH%&UOa6y1)hF0ssII09~KT_!sJ2+z1X{9=(p- zis}lXO$9%#-tScm5V{4nmrovqBG~Fwuu(M7xv0h-S^xk50RR9100000000000p^KM zW>9rd{&@wb@&)jk=ks=7er(-uc8;R-5T)@&kn7n*I6-H2Ig`-|J#=KE1%kDs&GIC? zvvF|LYq;N2wnnLkUvuXHFR)L&M!4%1pcVykxzn7L4zg_b9HJ4eAc2u4L7_T(QOpUl z{dmPC-w%L{9PFAB=s0Q;^qc_)!P}es$+ua3=2{VjYpJq86PyZtQ%M0QV3hQ{$Dw6T zhwZ!79|wc)y~ucD-#;eb%roe_+ETRH`~Y#rpU3~0h&i66FHA(`^9&*>y?c9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b{#ZCVpg2oFNhVP2U13?C%f#^k(O{e+=$6x)f;rs1JDV){iEa@WLe1#~ zTOJbj{cNa*Qg!#XOL@3K8$XD&uaAj>hI1vGx;_oe8)I7oO5HxFuUm^QLVoD2(&u3P z@xsU#qK~aCl=+b5?IgFGNf^R!>lQNjYmdT3SXyG-!Hwc4t9P zSypT{QZ+d-HF<1qcS&w-FVQ_G1Zf78CWqASs58naU+q=!I4UR#E z@T20HH+nZaMAp`4JhKekumPA%phX{?uTeZe$oqq!el!e^# zIH_IBCY9m@J7o*;2OC%`cAD(D?i00n;%&OUSBqG!`KXn@TfI7^2~yWX0a*62u{jVZav7z4X15V zhIrO{S!5RSER@7uBEMgC__rBIn8LF_)sGk|#~FYen}TFDaH);EvL@Ffi3tNfi=J?s z9|<(5w>~re7U07Ir*W6aiu(~#RbV1f@UTR_%BA~BD5tyPuY z2eYvgOxb&1oLbDeXvuODQnVuaa}rKesODduMtWdbl)hp%P=^`2C{O%sJkpjW_=_@oHiK>`0^*gtFIt|&j;{ITCYa2k}> z*<$OY3~uWJF#y5N|4Yk34eG>&1W+~RHWJDP;bPg83Z02S;I!(o!^u(-LK^&X(@=yK J#Rbn%t$1*ovReQE literal 0 HcmV?d00001 diff --git a/performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem b/performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem deleted file mode 100644 index 2d649570a..000000000 --- a/performance_tests/test/resources/keys/user_rsa_private_key_file_name.pem +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJJwIBAAKCAgEAwEkp2yRpTAgZa4MDNxq8eQ7rkaVw9QTdJr9NFAtjUpM/6UQA -RJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWyE2nm4MCHED62mEEbjbDwtLmiWK0g -iZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnfMpode5IQY3AZM3unIVFA043oD3ZP -RsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKhf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bQIeq+a1CldqHGQDf0rAcaIpEHMa -quIKMvbF0DFNUOrasOEdr3TU/CajrL1KXvso5KUVI7oqRXYSw/49fouBoWIeqdYO -CbKLAoIBAC9lzIgWMBuRIzO4mc5q5OYQrHygQJJtCobuK1WHsf+h3mH/KCvxwRvG -PSkXKAVBP6sufXRmRSoVqLO/olY2ExjFuVHdSJZLsSKZ/a8eBbituN9WcCN+YCF7 -u+65izM3j9K1y9CmV0igVQgV7VNhQ2OsEX/aHcWQPg1tHl94TxEe/MNX0sDKq9Ia -PfPYC8TT0s1qngq23TzF8ZwDxI4aSqC3uV8t80Yq0BhXYGAS7YsLnO22KGCVeF3A -gOOXpeJhIg7PkSRDY0Qn7XnVHO0UJyBmrHNatquiHX/L9vHtFSiNcT7NnII9G2bf -s9GP+78f865LEXBzWqJvA5Nad2/NLckCggEANWMjb5QcJqTSXn0f2UqJ7AicWoqQ -dMjpY79N+2iz2tlNFD9/BC/l6QGhM4YMVLNDwM2Aak37P8ZnQ9frEjMCEoD2bIlO -cWxVaXMP39rnLUPzg8D2TcjiQ2NBL4FDYXudZCUh4b1x70Gp2GiP7GxZwv2/SQhD -j7cc4oNwaE1hkiMhAYbPgWUU06JQwWPcD8UmKUgdp2ET+eUEwfV0GVtNOSfGoenf -ZqdaYcE8c3ft37JM5AsKo5h+G3qHOBRMEYHtQDybuvvFsg+hJ0BuxYt4mFubWZYL -V/tu4K1kmEZXgTvNZWSsZaIY2xBus2Ol2rKTahA0d9ffGeUhRj+UQrWpxg== ------END RSA PRIVATE KEY----- diff --git a/performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem b/performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem deleted file mode 100644 index 78cdbbfa6..000000000 --- a/performance_tests/test/resources/keys/user_rsa_public_key_file_name.pem +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwEkp2yRpTAgZa4MDNxq8 -eQ7rkaVw9QTdJr9NFAtjUpM/6UQARJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWy -E2nm4MCHED62mEEbjbDwtLmiWK0giZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnf -Mpode5IQY3AZM3unIVFA043oD3ZPRsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKh -f7ivmhVAKxwacXTb2yIynGljEgZZfkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruv -gaE6vArdndBQcUV/NAOBeDegsfAsic7OC9FD/3MFgLo2g72WYY3BuCNMDj8L3lWK -+vyC/S66cIvp1P2GzsccHSfcK0MC09ojnCbKF6D7tv5pIKhtvZRC7xcNv1ctS/fb -UbMy4tH+8iwvJlTRGZuuEYDwoBFowNS1oHxeO1PI1im93inAYt5GhkMuaZKLaY64 -xe51LJNcP1ovAhHaMG8UGfeCiNBRjGEP3pMG8sgLyw9k3gqMVzX4MUfPlXQh503k -3bVE/eymdsdZ1kAlMLR26IoQ6muAHtn0cy00RjRPy0hIQ2Z+ACog0ge91AyWgXjn -0WYI3AUOzVRZAoqS7ymf2zQfyb3WVYBMfyYT9IhUZlAWq8uzEkoFs47r0LKrv6DA -LX8MCeTVUP6ELg4Inaz8UDECAwEAAQ== ------END PUBLIC KEY----- diff --git a/tox.ini b/tox.ini index 0c0e493ca..8d4af1d2d 100644 --- a/tox.ini +++ b/tox.ini @@ -17,10 +17,10 @@ envlist = # The `mpl` prefix specifies a separate target, # i.e. `mpllocal` instead of `local`. # `mplXXX` contains tests using MPL components. - py{311,312}-mpl{local,examples,performance_tests}-mpl + py{311,312}-mpl{local,examples}-mpl nocmk, bandit, doc8, readme, docs, - {flake8,pylint}{,-tests,-examples,-performance_tests}, + {flake8,pylint}{,-tests,-examples}, isort-check, black-check, # prone to false positives vulture @@ -92,7 +92,6 @@ commands = examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples # MPL keyring examples require a special IAM role; run these separately under a separate set of permissions mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/ - performance_tests: {[testenv:base-command]commands} performance_tests/test/keyrings/ performance_tests/test/master_key_providers/ all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/ mplall: {[testenv:base-command]commands} test/ examples/test/ manual: {[testenv:base-command]commands} @@ -176,18 +175,6 @@ commands = --ignore D103,E203,W503 \ examples/test/ -[testenv:flake8-performance_tests] -basepython = {[testenv:flake8]basepython} -deps = {[testenv:flake8]deps} -commands = - flake8 performance_tests/src/ - flake8 \ - # Ingore D103 missing docstring errors in tests (test names should be self-documenting) - # E203 is not PEP8 compliant https://github.com/ambv/black#slices - # W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators - --ignore D103,E203,W503 \ - performance_tests/test/ - [testenv:pylint] basepython = python3 deps = @@ -208,13 +195,6 @@ commands = pylint --rcfile=examples/src/pylintrc examples/src/ pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/ -[testenv:pylint-performance_tests] -basepython = {[testenv:pylint]basepython} -deps = {[testenv:pylint]deps} -commands = - pylint --rcfile=performance_tests/pylintrc performance_tests/src/ - pylint --rcfile=performance_tests/pylintrc performance_tests/test/ - [testenv:pylint-tests] basepython = {[testenv:pylint]basepython} deps = {[testenv:pylint]deps} @@ -235,7 +215,6 @@ commands = doc/conf.py \ test/ \ examples/ \ - performance_tests/ \ {posargs} @@ -266,8 +245,6 @@ commands = isort -rc \ test \ # We do not include examples/test because of the need to modify sys.path for some imports examples/src/ \ - performance_tests/src/ \ - performance_tests/test/ \ doc \ setup.py \ {posargs} From 3799f18754c1fb88976ef8a8137ef9c396f40ba6 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 24 May 2024 16:21:39 -0700 Subject: [PATCH 10/33] adding pytest tests --- .../test/keyrings/test_aws_kms_keyring.py | 32 +++++++++++++++++++ .../test/keyrings/test_raw_aes_keyring.py | 26 +++++++++++++++ .../test/keyrings/test_raw_rsa_keyring.py | 26 +++++++++++++++ .../test_aws_kms_master_key_provider.py | 26 +++++++++++++++ .../test_raw_aes_master_key_provider.py | 26 +++++++++++++++ .../test_raw_rsa_master_key_provider.py | 26 +++++++++++++++ 6 files changed, 162 insertions(+) diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 2f8c7cddd..8c6a6dd96 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -5,6 +5,8 @@ import time import click +import click.testing +import pytest from tqdm import tqdm from aws_encryption_sdk_performance_tests.keyrings.aws_kms_keyring import ( @@ -164,5 +166,35 @@ def decrypt( decrypt_kms_keyring]) +@pytest.fixture +def runner(): + """Click runner""" + return click.testing.CliRunner() + + +def test_create(runner): + """Test the create_keyring function""" + result = runner.invoke(create_kms_keyring.commands['create'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_create_given_kms_client(runner): + """Test the create_keyring_given_kms_client function""" + result = runner.invoke(create_kms_keyring_given_kms_client.commands['create-given-kms-client'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_encrypt(runner): + """Test the encrypt_using_keyring function""" + result = runner.invoke(encrypt_kms_keyring.commands['encrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_decrypt(runner): + """Test the decrypt_using_keyring function""" + result = runner.invoke(decrypt_kms_keyring.commands['decrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + if __name__ == "__main__": kms_keyring_test() diff --git a/performance_tests/test/keyrings/test_raw_aes_keyring.py b/performance_tests/test/keyrings/test_raw_aes_keyring.py index cd593ed8e..bb45b6049 100644 --- a/performance_tests/test/keyrings/test_raw_aes_keyring.py +++ b/performance_tests/test/keyrings/test_raw_aes_keyring.py @@ -5,6 +5,8 @@ import time import click +import click.testing +import pytest from tqdm import tqdm from aws_encryption_sdk_performance_tests.keyrings.raw_aes_keyring import ( @@ -120,5 +122,29 @@ def decrypt( decrypt_raw_aes_keyring]) +@pytest.fixture +def runner(): + """Click runner""" + return click.testing.CliRunner() + + +def test_create(runner): + """Test the create_keyring function""" + result = runner.invoke(create_raw_aes_keyring.commands['create'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_encrypt(runner): + """Test the encrypt_using_keyring function""" + result = runner.invoke(encrypt_raw_aes_keyring.commands['encrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_decrypt(runner): + """Test the decrypt_using_keyring function""" + result = runner.invoke(decrypt_raw_aes_keyring.commands['decrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + if __name__ == "__main__": raw_aes_keyring_test() diff --git a/performance_tests/test/keyrings/test_raw_rsa_keyring.py b/performance_tests/test/keyrings/test_raw_rsa_keyring.py index ac690e760..d3a3d0f8f 100644 --- a/performance_tests/test/keyrings/test_raw_rsa_keyring.py +++ b/performance_tests/test/keyrings/test_raw_rsa_keyring.py @@ -5,6 +5,8 @@ import time import click +import click.testing +import pytest from tqdm import tqdm from aws_encryption_sdk_performance_tests.keyrings.raw_rsa_keyring import ( @@ -127,5 +129,29 @@ def decrypt( decrypt_raw_rsa_keyring]) +@pytest.fixture +def runner(): + """Click runner""" + return click.testing.CliRunner() + + +def test_create(runner): + """Test the create_keyring function""" + result = runner.invoke(create_raw_rsa_keyring.commands['create'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_encrypt(runner): + """Test the encrypt_using_keyring function""" + result = runner.invoke(encrypt_raw_rsa_keyring.commands['encrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_decrypt(runner): + """Test the decrypt_using_keyring function""" + result = runner.invoke(decrypt_raw_rsa_keyring.commands['decrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + if __name__ == "__main__": raw_rsa_keyring_test() diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py index ef1377d44..fc6486f24 100644 --- a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -5,6 +5,8 @@ import time import click +import click.testing +import pytest from tqdm import tqdm from aws_encryption_sdk_performance_tests.master_key_providers.aws_kms_master_key_provider import ( @@ -129,5 +131,29 @@ def decrypt( decrypt_kms_key_provider]) +@pytest.fixture +def runner(): + """Click runner""" + return click.testing.CliRunner() + + +def test_create(runner): + """Test the create_key_provider function""" + result = runner.invoke(create_kms_key_provider.commands['create'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_encrypt(runner): + """Test the encrypt_using_key_provider function""" + result = runner.invoke(encrypt_kms_key_provider.commands['encrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_decrypt(runner): + """Test the decrypt_using_key_provider function""" + result = runner.invoke(decrypt_kms_key_provider.commands['decrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + if __name__ == "__main__": kms_key_provider_test() diff --git a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py index 22f8787ef..fd5bba293 100644 --- a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py @@ -5,6 +5,8 @@ import time import click +import click.testing +import pytest from tqdm import tqdm from aws_encryption_sdk_performance_tests.master_key_providers.raw_aes_master_key_provider import ( @@ -120,5 +122,29 @@ def decrypt( decrypt_raw_aes_key_provider]) +@pytest.fixture +def runner(): + """Click runner""" + return click.testing.CliRunner() + + +def test_create(runner): + """Test the create_key_provider function""" + result = runner.invoke(create_raw_aes_key_provider.commands['create'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_encrypt(runner): + """Test the encrypt_using_key_provider function""" + result = runner.invoke(encrypt_raw_aes_key_provider.commands['encrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_decrypt(runner): + """Test the decrypt_using_key_provider function""" + result = runner.invoke(decrypt_raw_aes_key_provider.commands['decrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + if __name__ == "__main__": raw_aes_key_provider_test() diff --git a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py index 3b8e4c89b..4ac4ccf1f 100644 --- a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py @@ -5,6 +5,8 @@ import time import click +import click.testing +import pytest from tqdm import tqdm from aws_encryption_sdk_performance_tests.master_key_providers.raw_rsa_master_key_provider import ( @@ -120,5 +122,29 @@ def decrypt( decrypt_raw_rsa_key_provider]) +@pytest.fixture +def runner(): + """Click runner""" + return click.testing.CliRunner() + + +def test_create(runner): + """Test the create_key_provider function""" + result = runner.invoke(create_raw_rsa_key_provider.commands['create'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_encrypt(runner): + """Test the encrypt_using_key_provider function""" + result = runner.invoke(encrypt_raw_rsa_key_provider.commands['encrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + +def test_decrypt(runner): + """Test the decrypt_using_key_provider function""" + result = runner.invoke(decrypt_raw_rsa_key_provider.commands['decrypt'], ['--n_iters', 1]) + assert result.exit_code == 0 + + if __name__ == "__main__": raw_rsa_key_provider_test() From 51adb3328cb5e3e427fff6e98a619585818b5c2f Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 24 May 2024 17:10:53 -0700 Subject: [PATCH 11/33] updating tox file --- tox.ini | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 8d4af1d2d..85a1b4dd6 100644 --- a/tox.ini +++ b/tox.ini @@ -17,10 +17,10 @@ envlist = # The `mpl` prefix specifies a separate target, # i.e. `mpllocal` instead of `local`. # `mplXXX` contains tests using MPL components. - py{311,312}-mpl{local,examples}-mpl + py{311,312}-mpl{local,examples,performance_tests}-mpl nocmk, bandit, doc8, readme, docs, - {flake8,pylint}{,-tests,-examples}, + {flake8,pylint}{,-tests,-examples,-performance_tests}, isort-check, black-check, # prone to false positives vulture @@ -92,6 +92,7 @@ commands = examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples # MPL keyring examples require a special IAM role; run these separately under a separate set of permissions mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/ + performance_tests: {[testenv:base-command]commands} performance_tests/test/keyrings/ performance_tests/test/master_key_providers/ all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/ mplall: {[testenv:base-command]commands} test/ examples/test/ manual: {[testenv:base-command]commands} @@ -175,6 +176,18 @@ commands = --ignore D103,E203,W503 \ examples/test/ +[testenv:flake8-performance_tests] +basepython = {[testenv:flake8]basepython} +deps = {[testenv:flake8]deps} +commands = + flake8 performance_tests/src/ + flake8 \ + # Ingore D103 missing docstring errors in tests (test names should be self-documenting) + # E203 is not PEP8 compliant https://github.com/ambv/black#slices + # W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators + --ignore D103,E203,W503 \ + performance_tests/test/ + [testenv:pylint] basepython = python3 deps = @@ -195,6 +208,13 @@ commands = pylint --rcfile=examples/src/pylintrc examples/src/ pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/ +[testenv:pylint-performance_tests] +basepython = {[testenv:pylint]basepython} +deps = {[testenv:pylint]deps} +commands = + pylint --rcfile=performance_tests/pylintrc performance_tests/src/ + pylint --rcfile=performance_tests/pylintrc --disable R0801 performance_tests/test/ + [testenv:pylint-tests] basepython = {[testenv:pylint]basepython} deps = {[testenv:pylint]deps} @@ -215,6 +235,7 @@ commands = doc/conf.py \ test/ \ examples/ \ + performance_tests/ \ {posargs} @@ -245,6 +266,7 @@ commands = isort -rc \ test \ # We do not include examples/test because of the need to modify sys.path for some imports examples/src/ \ + performance_tests/ \ doc \ setup.py \ {posargs} @@ -319,6 +341,15 @@ commands = {[testenv:flake8-examples]commands} {[testenv:pylint-examples]commands} +[testenv:linters-performance-tests] +basepython = python3 +deps = + {[testenv:flake8-performance_tests]deps} + {[testenv:pylint-performance_tests]deps} +commands = + {[testenv:flake8-performance_tests]commands} + {[testenv:pylint-performance_tests]commands} + # Documentation [testenv:docs] basepython = python3 From 4b3b68a3d58dd73e53712f3e32c3a32e1999fc6c Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 24 May 2024 19:44:22 -0700 Subject: [PATCH 12/33] fix --- performance_tests/consolidate_results.py | 3 ++- tox.ini | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/performance_tests/consolidate_results.py b/performance_tests/consolidate_results.py index 3a246b3a3..fd2325b6a 100644 --- a/performance_tests/consolidate_results.py +++ b/performance_tests/consolidate_results.py @@ -2,8 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 """Script for consolidating results for execution times""" -import csv import argparse +import csv + import numpy as np diff --git a/tox.ini b/tox.ini index 85a1b4dd6..d949cb5af 100644 --- a/tox.ini +++ b/tox.ini @@ -17,10 +17,10 @@ envlist = # The `mpl` prefix specifies a separate target, # i.e. `mpllocal` instead of `local`. # `mplXXX` contains tests using MPL components. - py{311,312}-mpl{local,examples,performance_tests}-mpl + py{311,312}-mpl{local,examples,performancetests}-mpl nocmk, bandit, doc8, readme, docs, - {flake8,pylint}{,-tests,-examples,-performance_tests}, + {flake8,pylint}{,-tests,-examples,-performancetests}, isort-check, black-check, # prone to false positives vulture @@ -92,7 +92,7 @@ commands = examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples # MPL keyring examples require a special IAM role; run these separately under a separate set of permissions mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/ - performance_tests: {[testenv:base-command]commands} performance_tests/test/keyrings/ performance_tests/test/master_key_providers/ + performancetests: {[testenv:base-command]commands} performance_tests/test/keyrings/ performance_tests/test/master_key_providers/ all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/ mplall: {[testenv:base-command]commands} test/ examples/test/ manual: {[testenv:base-command]commands} @@ -176,7 +176,7 @@ commands = --ignore D103,E203,W503 \ examples/test/ -[testenv:flake8-performance_tests] +[testenv:flake8-performancetests] basepython = {[testenv:flake8]basepython} deps = {[testenv:flake8]deps} commands = @@ -208,7 +208,7 @@ commands = pylint --rcfile=examples/src/pylintrc examples/src/ pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/ -[testenv:pylint-performance_tests] +[testenv:pylint-performance-tests] basepython = {[testenv:pylint]basepython} deps = {[testenv:pylint]deps} commands = @@ -266,7 +266,6 @@ commands = isort -rc \ test \ # We do not include examples/test because of the need to modify sys.path for some imports examples/src/ \ - performance_tests/ \ doc \ setup.py \ {posargs} From ebd419a2c11e338bb57f5b93a6222087d44b8bd7 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 27 May 2024 19:40:16 -0700 Subject: [PATCH 13/33] fix tox --- tox.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index d949cb5af..e074d32a3 100644 --- a/tox.ini +++ b/tox.ini @@ -343,11 +343,11 @@ commands = [testenv:linters-performance-tests] basepython = python3 deps = - {[testenv:flake8-performance_tests]deps} - {[testenv:pylint-performance_tests]deps} + {[testenv:flake8-performancetests]deps} + {[testenv:pylint-performancetests]deps} commands = - {[testenv:flake8-performance_tests]commands} - {[testenv:pylint-performance_tests]commands} + {[testenv:flake8-performancetests]commands} + {[testenv:pylint-performancetests]commands} # Documentation [testenv:docs] From bcdc43a890cfa9d12eaa2970f2a65f556939ac51 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 27 May 2024 19:42:31 -0700 Subject: [PATCH 14/33] fix pylint tox --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e074d32a3..ca14c7ceb 100644 --- a/tox.ini +++ b/tox.ini @@ -208,7 +208,7 @@ commands = pylint --rcfile=examples/src/pylintrc examples/src/ pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/ -[testenv:pylint-performance-tests] +[testenv:pylint-performancetests] basepython = {[testenv:pylint]basepython} deps = {[testenv:pylint]deps} commands = From e27f1499fb5f805cc4783ed2d287c81287dee785 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Tue, 28 May 2024 07:30:39 -0700 Subject: [PATCH 15/33] add perf test to codebuild --- codebuild/py312/performance_tests_mpl.yml | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 codebuild/py312/performance_tests_mpl.yml diff --git a/codebuild/py312/performance_tests_mpl.yml b/codebuild/py312/performance_tests_mpl.yml new file mode 100644 index 000000000..3802df90c --- /dev/null +++ b/codebuild/py312/performance_tests_mpl.yml @@ -0,0 +1,37 @@ +# Runs the performance tests for the MPL in an environment with the MPL installed +version: 0.2 + +env: + variables: + # No TOXENV. This runs multiple environments. + REGION: "us-west-2" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: 3.12 + build: + commands: + - cd /root/.pyenv/plugins/python-build/../.. && git pull && cd - + - pyenv install --skip-existing 3.12.0 + - pyenv local 3.12.0 + - pip install --upgrade pip + - pip install setuptools + - pip install "tox < 4.0" + # Assume special role to access keystore + - TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-Py312ExamplesMpl") + - export TMP_ROLE + - export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId') + - export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey') + - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') + - aws sts get-caller-identity + # Run MPL-specific tests with special role + - tox -e py312-mplperformancetests-mpl From 979194bc31e64e8409aca1007cf6b8586b54310c Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Tue, 28 May 2024 08:04:17 -0700 Subject: [PATCH 16/33] added perf tests to buildspec.yml --- buildspec.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildspec.yml b/buildspec.yml index 873e5941e..4d8c020c8 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -250,6 +250,10 @@ batch: buildspec: codebuild/py312/integ_mpl.yml env: image: aws/codebuild/standard:7.0 + - identifier: py312_performance_tests_mpl + buildspec: codebuild/py312/performance_tests_mpl.yml + env: + image: aws/codebuild/standard:7.0 - identifier: py312_examples buildspec: codebuild/py312/examples.yml env: From 52992909e6b3ff388fea199a211fd3fc7c2cdcfe Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Tue, 28 May 2024 08:28:02 -0700 Subject: [PATCH 17/33] fix --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ca14c7ceb..4cd15b90b 100644 --- a/tox.ini +++ b/tox.ini @@ -92,7 +92,7 @@ commands = examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples # MPL keyring examples require a special IAM role; run these separately under a separate set of permissions mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/ - performancetests: {[testenv:base-command]commands} performance_tests/test/keyrings/ performance_tests/test/master_key_providers/ + performancetests: {[testenv:base-command]commands} performance_tests/test/ -m examples all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/ mplall: {[testenv:base-command]commands} test/ examples/test/ manual: {[testenv:base-command]commands} From a67e80d60f7a263a1ae3a919c00c1fcce97ceb53 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Tue, 28 May 2024 21:43:49 -0700 Subject: [PATCH 18/33] fix tests in ci tox --- codebuild/py311/performance_tests_mpl.yml | 38 ++++ codebuild/py312/performance_tests_mpl.yml | 3 +- performance_tests/{README.md => README.rst} | 0 performance_tests/tox.ini | 193 ++++++++++++++++++++ tox.ini | 36 +--- 5 files changed, 236 insertions(+), 34 deletions(-) create mode 100644 codebuild/py311/performance_tests_mpl.yml rename performance_tests/{README.md => README.rst} (100%) create mode 100644 performance_tests/tox.ini diff --git a/codebuild/py311/performance_tests_mpl.yml b/codebuild/py311/performance_tests_mpl.yml new file mode 100644 index 000000000..a814b6ccf --- /dev/null +++ b/codebuild/py311/performance_tests_mpl.yml @@ -0,0 +1,38 @@ +# Runs the performance tests for the MPL in an environment with the MPL installed +version: 0.2 + +env: + variables: + # No TOXENV. This runs multiple environments. + REGION: "us-west-2" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: 3.11 + build: + commands: + - cd /root/.pyenv/plugins/python-build/../.. && git pull && cd - + - pyenv install --skip-existing 3.11.0 + - pyenv local 3.11.0 + - pip install --upgrade pip + - pip install setuptools + - pip install "tox < 4.0" + # Assume special role to access keystore + - TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-Py312ExamplesMpl") + - export TMP_ROLE + - export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId') + - export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey') + - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') + - aws sts get-caller-identity + # Run MPL-specific tests with special role + - cd performance_tests/ + - tox diff --git a/codebuild/py312/performance_tests_mpl.yml b/codebuild/py312/performance_tests_mpl.yml index 3802df90c..f2f2e8aff 100644 --- a/codebuild/py312/performance_tests_mpl.yml +++ b/codebuild/py312/performance_tests_mpl.yml @@ -34,4 +34,5 @@ phases: - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') - aws sts get-caller-identity # Run MPL-specific tests with special role - - tox -e py312-mplperformancetests-mpl + - cd performance_tests/ + - tox diff --git a/performance_tests/README.md b/performance_tests/README.rst similarity index 100% rename from performance_tests/README.md rename to performance_tests/README.rst diff --git a/performance_tests/tox.ini b/performance_tests/tox.ini new file mode 100644 index 000000000..4474dc5ea --- /dev/null +++ b/performance_tests/tox.ini @@ -0,0 +1,193 @@ +[tox] +envlist = + # The performance tests only work for python 3.11 and 3.12 + py{311,312}-performance_tests-mpl + bandit, readme + # TODO: Activate doc8 after finalizing README.rst + ; bandit, doc8, readme + +# Additional test environments: +# +# linters :: Runs all linters over all source code. +# linters-tests :: Runs all linters over all tests. + +# Autoformatter helper environments: +# +# autoformat : Apply all autoformatters +# +# black-check : Check for "black" issues +# blacken : Fix all "black" issues +# +# isort-seed : Generate a known_third_party list for isort. +# NOTE: make the "known_third_party = " line in setup.cfg before running this +# NOTE: currently it incorrectly identifies this library too; make sure you remove it +# isort-check : Check for isort issues +# isort : Fix isort issues + +# Operational helper environments: +# +# build :: Builds source and wheel dist files. +# test-release :: Builds dist files and uploads to testpypi pypirc profile. +# release :: Builds dist files and uploads to pypi pypirc profile. + +[testenv:base-command] +commands = pytest test/ +deps = + click + + +[testenv] +passenv = + # Pass through AWS credentials + AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN \ + # AWS Role access in CodeBuild is via the contaner URI + AWS_CONTAINER_CREDENTIALS_RELATIVE_URI \ + # Pass through AWS profile name (useful for local testing) + AWS_PROFILE +sitepackages = False +deps = + -rrequirements.txt + # Install the MPL requirements if the `-mpl` suffix is present + mpl: -rrequirements_mpl.txt + .. +commands = + # awses_local: {[testenv:base-command]commands} + performance_tests: {[testenv:base-command]commands} + +# mypy +[testenv:mypy-coverage] +commands = + # Make mypy linecoverage report readable by coverage + python -c \ + "t = open('.coverage', 'w');\ + c = open('build/coverage.json').read();\ + t.write('!coverage.py: This is a private format, don\'t read it directly!\n');\ + t.write(c);\ + t.close()" + coverage report -m + +[testenv:mypy-common] +basepython = python3 +deps = + coverage + mypy>=0.600 + mypy_extensions + typing>=3.6.2 + +[testenv:mypy-py3] +basepython = {[testenv:mypy-common]basepython} +deps = {[testenv:mypy-common]deps} +commands = + python -m mypy \ + --linecoverage-report build \ + src/aws_encryption_sdk_performance_tests/ \ + {posargs} + {[testenv:mypy-coverage]commands} + +[testenv:blacken-src] +basepython = python3 +deps = -r../dev_requirements/linter-requirements.txt +commands = + black --line-length 120 \ + src/aws_encryption_sdk_performance_tests/ \ + setup.py \ + test/ \ + {posargs} + + +[testenv:blacken] +basepython = python3 +deps = + {[testenv:blacken-src]deps} +commands = + {[testenv:blacken-src]commands} + +[testenv:black-check] +basepython = python3 +deps = + {[testenv:blacken]deps} +commands = + {[testenv:blacken-src]commands} --diff + +[testenv:isort-seed] +basepython = python3 +deps = -r../dev_requirements/linter-requirements.txt +commands = seed-isort-config + +[testenv:isort] +basepython = python3 +deps = -r../dev_requirements/linter-requirements.txt +commands = isort -rc \ + src \ + test \ + setup.py \ + {posargs} + +[testenv:isort-check] +basepython = python3 +deps = {[testenv:isort]deps} +commands = {[testenv:isort]commands} -c + +[testenv:autoformat] +basepython = python3 +deps = + {[testenv:blacken]deps} + {[testenv:isort]deps} + .. +commands = + {[testenv:blacken]commands} + {[testenv:isort]commands} + +[testenv:doc8] +basepython = python3 +deps = -r../dev_requirements/linter-requirements.txt +commands = doc8 README.rst + +[testenv:bandit] +basepython = python3 +deps = -r../dev_requirements/linter-requirements.txt +commands = bandit -r src/aws_encryption_sdk_performance_tests/ + +[testenv:linters] +basepython = python3 +deps = + {[testenv:doc8]deps} + {[testenv:bandit]deps} +commands = + {[testenv:doc8]commands} + {[testenv:bandit]commands} + +# Release tooling +[testenv:park] +basepython = python3 +skip_install = true +deps = -r../dev_requirements/release-requirements.txt +commands = python setup.py park + +[testenv:build] +basepython = python3 +skip_install = true +deps = + -r../dev_requirements/release-requirements.txt +commands = + python setup.py sdist bdist_wheel + +[testenv:test-release] +basepython = python3 +skip_install = true +deps = + {[testenv:build]deps} + twine +commands = + {[testenv:build]commands} + twine upload --skip-existing --repository testpypi dist/* + +[testenv:release] +basepython = python3 +skip_install = true +deps = + {[testenv:build]deps} + twine +commands = + {[testenv:build]commands} + twine upload --skip-existing --repository pypi dist/* diff --git a/tox.ini b/tox.ini index 4cd15b90b..9152f51a6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = # <3.11: run all non-MPL tests - py{37,38,39,310}-{local,integ,accept,examples}, + py{38,39,310}-{local,integ,accept,examples}, # >=3.11: run all tests with MPL installed and without MPL installed # The `-mpl` suffix tells tox to install the MPL. # In the case where the suffix IS NOT appended, @@ -17,10 +17,10 @@ envlist = # The `mpl` prefix specifies a separate target, # i.e. `mpllocal` instead of `local`. # `mplXXX` contains tests using MPL components. - py{311,312}-mpl{local,examples,performancetests}-mpl + py{311,312}-mpl{local,examples}-mpl nocmk, bandit, doc8, readme, docs, - {flake8,pylint}{,-tests,-examples,-performancetests}, + {flake8,pylint}{,-tests,-examples}, isort-check, black-check, # prone to false positives vulture @@ -92,7 +92,6 @@ commands = examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples # MPL keyring examples require a special IAM role; run these separately under a separate set of permissions mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/ - performancetests: {[testenv:base-command]commands} performance_tests/test/ -m examples all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/ mplall: {[testenv:base-command]commands} test/ examples/test/ manual: {[testenv:base-command]commands} @@ -176,18 +175,6 @@ commands = --ignore D103,E203,W503 \ examples/test/ -[testenv:flake8-performancetests] -basepython = {[testenv:flake8]basepython} -deps = {[testenv:flake8]deps} -commands = - flake8 performance_tests/src/ - flake8 \ - # Ingore D103 missing docstring errors in tests (test names should be self-documenting) - # E203 is not PEP8 compliant https://github.com/ambv/black#slices - # W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators - --ignore D103,E203,W503 \ - performance_tests/test/ - [testenv:pylint] basepython = python3 deps = @@ -208,13 +195,6 @@ commands = pylint --rcfile=examples/src/pylintrc examples/src/ pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/ -[testenv:pylint-performancetests] -basepython = {[testenv:pylint]basepython} -deps = {[testenv:pylint]deps} -commands = - pylint --rcfile=performance_tests/pylintrc performance_tests/src/ - pylint --rcfile=performance_tests/pylintrc --disable R0801 performance_tests/test/ - [testenv:pylint-tests] basepython = {[testenv:pylint]basepython} deps = {[testenv:pylint]deps} @@ -235,7 +215,6 @@ commands = doc/conf.py \ test/ \ examples/ \ - performance_tests/ \ {posargs} @@ -340,15 +319,6 @@ commands = {[testenv:flake8-examples]commands} {[testenv:pylint-examples]commands} -[testenv:linters-performance-tests] -basepython = python3 -deps = - {[testenv:flake8-performancetests]deps} - {[testenv:pylint-performancetests]deps} -commands = - {[testenv:flake8-performancetests]commands} - {[testenv:pylint-performancetests]commands} - # Documentation [testenv:docs] basepython = python3 From 0aeafa91699c0d866e19f100f1f4f3734b9da547 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Tue, 28 May 2024 22:09:00 -0700 Subject: [PATCH 19/33] fix --- codebuild/py311/performance_tests_mpl.yml | 2 +- codebuild/py312/performance_tests_mpl.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codebuild/py311/performance_tests_mpl.yml b/codebuild/py311/performance_tests_mpl.yml index a814b6ccf..2debb1185 100644 --- a/codebuild/py311/performance_tests_mpl.yml +++ b/codebuild/py311/performance_tests_mpl.yml @@ -35,4 +35,4 @@ phases: - aws sts get-caller-identity # Run MPL-specific tests with special role - cd performance_tests/ - - tox + - tox -e py311-performance_tests-mpl diff --git a/codebuild/py312/performance_tests_mpl.yml b/codebuild/py312/performance_tests_mpl.yml index f2f2e8aff..97dbf359f 100644 --- a/codebuild/py312/performance_tests_mpl.yml +++ b/codebuild/py312/performance_tests_mpl.yml @@ -35,4 +35,4 @@ phases: - aws sts get-caller-identity # Run MPL-specific tests with special role - cd performance_tests/ - - tox + - tox -e py312-performance_tests-mpl From ade03c60a525338181eec24d7e6965c45c47531e Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 12:54:00 -0700 Subject: [PATCH 20/33] fix codebuild --- codebuild/py311/performance_tests_mpl.yml | 3 +-- codebuild/py312/performance_tests_mpl.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/codebuild/py311/performance_tests_mpl.yml b/codebuild/py311/performance_tests_mpl.yml index 2debb1185..db97bfee6 100644 --- a/codebuild/py311/performance_tests_mpl.yml +++ b/codebuild/py311/performance_tests_mpl.yml @@ -34,5 +34,4 @@ phases: - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') - aws sts get-caller-identity # Run MPL-specific tests with special role - - cd performance_tests/ - - tox -e py311-performance_tests-mpl + - cd performance_tests/ && tox -e py311-performance_tests-mpl diff --git a/codebuild/py312/performance_tests_mpl.yml b/codebuild/py312/performance_tests_mpl.yml index 97dbf359f..c9589ed23 100644 --- a/codebuild/py312/performance_tests_mpl.yml +++ b/codebuild/py312/performance_tests_mpl.yml @@ -34,5 +34,4 @@ phases: - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') - aws sts get-caller-identity # Run MPL-specific tests with special role - - cd performance_tests/ - - tox -e py312-performance_tests-mpl + - cd performance_tests/ && tox -e py312-performance_tests-mpl From 1d89d08ec4748d329035db3561bb761b12eb1440 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 12:58:08 -0700 Subject: [PATCH 21/33] tox remove 312 perf tests --- performance_tests/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/performance_tests/tox.ini b/performance_tests/tox.ini index 4474dc5ea..9444da868 100644 --- a/performance_tests/tox.ini +++ b/performance_tests/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = # The performance tests only work for python 3.11 and 3.12 - py{311,312}-performance_tests-mpl + py{311}-performance_tests-mpl bandit, readme # TODO: Activate doc8 after finalizing README.rst ; bandit, doc8, readme From 706f915774730cd98d31b5febbb9ea3e91b64220 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 13:40:20 -0700 Subject: [PATCH 22/33] debug --- buildspec.yml | 4 ++++ codebuild/py311/performance_tests_mpl.yml | 3 ++- codebuild/py312/performance_tests_mpl.yml | 3 ++- performance_tests/test/keyrings/test_aws_kms_keyring.py | 3 +++ performance_tests/tox.ini | 4 ++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 4d8c020c8..792579467 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -164,6 +164,10 @@ batch: buildspec: codebuild/py311/integ_mpl.yml env: image: aws/codebuild/standard:7.0 + - identifier: py311_performance_tests_mpl + buildspec: codebuild/py311/performance_tests_mpl.yml + env: + image: aws/codebuild/standard:7.0 - identifier: py311_examples buildspec: codebuild/py311/examples.yml env: diff --git a/codebuild/py311/performance_tests_mpl.yml b/codebuild/py311/performance_tests_mpl.yml index db97bfee6..2debb1185 100644 --- a/codebuild/py311/performance_tests_mpl.yml +++ b/codebuild/py311/performance_tests_mpl.yml @@ -34,4 +34,5 @@ phases: - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') - aws sts get-caller-identity # Run MPL-specific tests with special role - - cd performance_tests/ && tox -e py311-performance_tests-mpl + - cd performance_tests/ + - tox -e py311-performance_tests-mpl diff --git a/codebuild/py312/performance_tests_mpl.yml b/codebuild/py312/performance_tests_mpl.yml index c9589ed23..97dbf359f 100644 --- a/codebuild/py312/performance_tests_mpl.yml +++ b/codebuild/py312/performance_tests_mpl.yml @@ -34,4 +34,5 @@ phases: - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') - aws sts get-caller-identity # Run MPL-specific tests with special role - - cd performance_tests/ && tox -e py312-performance_tests-mpl + - cd performance_tests/ + - tox -e py312-performance_tests-mpl diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 8c6a6dd96..880c35156 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -47,6 +47,8 @@ def create( elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) + print('time_list', time_list) + print('output_file', output_file) PerfTestUtils.write_time_list_to_csv(time_list, output_file) @@ -175,6 +177,7 @@ def runner(): def test_create(runner): """Test the create_keyring function""" result = runner.invoke(create_kms_keyring.commands['create'], ['--n_iters', 1]) + print('time_list', result.output) assert result.exit_code == 0 diff --git a/performance_tests/tox.ini b/performance_tests/tox.ini index 9444da868..f53950c83 100644 --- a/performance_tests/tox.ini +++ b/performance_tests/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = # The performance tests only work for python 3.11 and 3.12 - py{311}-performance_tests-mpl + py{311,312}-performance_tests-mpl bandit, readme # TODO: Activate doc8 after finalizing README.rst ; bandit, doc8, readme @@ -31,7 +31,7 @@ envlist = # release :: Builds dist files and uploads to pypi pypirc profile. [testenv:base-command] -commands = pytest test/ +commands = pytest -s -v test/ deps = click From 9dbcb4d1429f7964364f57ae9330e93f922d5b8c Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 14:42:02 -0700 Subject: [PATCH 23/33] fix kms keyring test --- .../keyrings/hierarchy_keyring.py | 143 ++++++++++++++++++ .../utils/util.py | 2 +- .../test/keyrings/test_aws_kms_keyring.py | 18 +-- performance_tests/tox.ini | 2 +- 4 files changed, 153 insertions(+), 12 deletions(-) create mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py new file mode 100644 index 000000000..208820c92 --- /dev/null +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py @@ -0,0 +1,143 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Performance tests for the hierarchy keyring.""" + +import aws_encryption_sdk +import boto3 +from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders +from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig +from aws_cryptographic_materialproviders.mpl.models import CreateAwsKmsKeyringInput +from aws_cryptographic_materialproviders.mpl.references import IKeyring + +from aws_cryptographic_materialproviders.keystore import KeyStore +from aws_cryptographic_materialproviders.keystore.config import KeyStoreConfig +from aws_cryptographic_materialproviders.keystore.models import CreateKeyInput, KMSConfigurationKmsKeyArn +from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders +from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig +from aws_cryptographic_materialproviders.mpl.models import ( + CacheTypeDefault, + CreateAwsKmsHierarchicalKeyringInput, + DefaultCache, +) +from aws_cryptographic_materialproviders.mpl.references import IBranchKeyIdSupplier, IKeyring +from typing import Dict # noqa pylint: disable=wrong-import-order + +import aws_encryption_sdk +from aws_encryption_sdk import CommitmentPolicy +from aws_encryption_sdk.exceptions import AWSEncryptionSDKClientError + +from .branch_key_id_supplier_example import ExampleBranchKeyIdSupplier + + +def create_keyring( + key_store_table_name: str, + logical_key_store_name: str, + kms_key_id: str +): + """Demonstrate how to create a hierarchy keyring. + + Usage: create_keyring(key_store_table_name, logical_key_store_name, kms_key_id) + :param key_store_table_name: Name of the KeyStore DynamoDB table. + :type key_store_table_name: string + :param logical_key_store_name: Logical name of the KeyStore. + :type logical_key_store_name: string + :param kms_key_id: KMS Key identifier for the KMS key you want to use. + :type kms_key_id: string + + For more information on KMS Key identifiers, see + https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id + """ + # Create boto3 clients for DynamoDB and KMS. + ddb_client = boto3.client('dynamodb', region_name="us-west-2") + kms_client = boto3.client('kms', region_name="us-west-2") + + # Configure your KeyStore resource. + # This SHOULD be the same configuration that you used + # to initially create and populate your KeyStore. + keystore: KeyStore = KeyStore( + config=KeyStoreConfig( + ddb_client=ddb_client, + ddb_table_name=key_store_table_name, + logical_key_store_name=logical_key_store_name, + kms_client=kms_client, + kms_configuration=KMSConfigurationKmsKeyArn( + value=kms_key_id + ), + ) + ) + + # Call CreateKey to create two new active branch keys + branch_key_id_a: str = keystore.create_key(input=CreateKeyInput()).branch_key_identifier + branch_key_id_b: str = keystore.create_key(input=CreateKeyInput()).branch_key_identifier + + # Create a branch key supplier that maps the branch key id to a more readable format + branch_key_id_supplier: IBranchKeyIdSupplier = ExampleBranchKeyIdSupplier( + tenant_1_id=branch_key_id_a, + tenant_2_id=branch_key_id_b, + ) + + # Create the Hierarchical Keyring. + mat_prov: AwsCryptographicMaterialProviders = AwsCryptographicMaterialProviders( + config=MaterialProvidersConfig() + ) + + keyring_input: CreateAwsKmsHierarchicalKeyringInput = CreateAwsKmsHierarchicalKeyringInput( + key_store=keystore, + branch_key_id_supplier=branch_key_id_supplier, + ttl_seconds=600, + cache=CacheTypeDefault( + value=DefaultCache( + entry_capacity=100 + ) + ), + ) + + keyring: IKeyring = mat_prov.create_aws_kms_hierarchical_keyring( + input=keyring_input + ) + + return keyring + + +def encrypt_using_keyring( + plaintext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to encrypt plaintext data using an AWS KMS keyring. + + Usage: encrypt_using_keyring(plaintext_data, keyring) + :param plaintext_data: plaintext data you want to encrypt + :type: bytes + :param keyring: Keyring to use for encryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + ciphertext_data, _ = client.encrypt( + source=plaintext_data, + keyring=keyring + ) + + return ciphertext_data + + +def decrypt_using_keyring( + ciphertext_data: bytes, + keyring: IKeyring +): + """Demonstrate how to decrypt ciphertext data using an AWS KMS keyring. + + Usage: decrypt_using_keyring(ciphertext_data, keyring) + :param ciphertext_data: ciphertext data you want to decrypt + :type: bytes + :param keyring: Keyring to use for decryption. + :type keyring: IKeyring + """ + client = aws_encryption_sdk.EncryptionSDKClient() + + decrypted_plaintext_data, _ = client.decrypt( + source=ciphertext_data, + keyring=keyring + ) + + return decrypted_plaintext_data diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py index 9d640b687..2c14cf367 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py @@ -97,6 +97,6 @@ def get_rsa_key_from_file(filename): @staticmethod def write_time_list_to_csv(time_list, filename): """Writes the time list to a CSV file.""" - with open('results/' + filename + '.csv', 'w', encoding='utf-8') as myfile: + with open(filename + '.csv', 'w', encoding='utf-8') as myfile: for time in time_list: myfile.write(str(time) + '\n') diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 880c35156..1d5ebb30f 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -30,7 +30,7 @@ def create_kms_keyring(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='kms_keyring_create') + default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_create') def create( kms_key_id: str, n_iters: int, @@ -46,9 +46,6 @@ def create( # calculate elapsed time in milliseconds elapsed_time = (time.time() - curr_time) * 1000 time_list.append(elapsed_time) - - print('time_list', time_list) - print('output_file', output_file) PerfTestUtils.write_time_list_to_csv(time_list, output_file) @@ -63,7 +60,7 @@ def create_kms_keyring_given_kms_client(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='kms_keyring_create_given_kms_client') + default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_create_given_kms_client') def create_given_kms_client( kms_key_id: str, n_iters: int, @@ -91,14 +88,15 @@ def encrypt_kms_keyring(): @encrypt_kms_keyring.command() @click.option('--plaintext_data_filename', - default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='kms_keyring_encrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_encrypt') def encrypt( plaintext_data_filename: str, kms_key_id: str, @@ -130,14 +128,15 @@ def decrypt_kms_keyring(): @decrypt_kms_keyring.command() @click.option('--ciphertext_data_filename', - default='test/resources/ciphertext/kms/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/kms/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='kms_keyring_decrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_decrypt') def decrypt( ciphertext_data_filename: str, kms_key_id: str, @@ -177,7 +176,6 @@ def runner(): def test_create(runner): """Test the create_keyring function""" result = runner.invoke(create_kms_keyring.commands['create'], ['--n_iters', 1]) - print('time_list', result.output) assert result.exit_code == 0 diff --git a/performance_tests/tox.ini b/performance_tests/tox.ini index f53950c83..4474dc5ea 100644 --- a/performance_tests/tox.ini +++ b/performance_tests/tox.ini @@ -31,7 +31,7 @@ envlist = # release :: Builds dist files and uploads to pypi pypirc profile. [testenv:base-command] -commands = pytest -s -v test/ +commands = pytest test/ deps = click From fea2075a93ddec783869cb66d6678de3aba327b1 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 15:10:43 -0700 Subject: [PATCH 24/33] print --- performance_tests/test/keyrings/test_aws_kms_keyring.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 1d5ebb30f..27ab92514 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -104,6 +104,8 @@ def encrypt( output_file: str ): """Performance test for the encrypt_using_keyring function.""" + print('plaintext_data_filename', plaintext_data_filename) + print('output_file', output_file) plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) keyring = create_keyring(kms_key_id) @@ -188,6 +190,7 @@ def test_create_given_kms_client(runner): def test_encrypt(runner): """Test the encrypt_using_keyring function""" result = runner.invoke(encrypt_kms_keyring.commands['encrypt'], ['--n_iters', 1]) + print('result.output', result.output) assert result.exit_code == 0 From d2b739f977ea52b9af6148f5e6d56b506a48e8fd Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 15:12:26 -0700 Subject: [PATCH 25/33] print correct --- performance_tests/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/performance_tests/tox.ini b/performance_tests/tox.ini index 4474dc5ea..f53950c83 100644 --- a/performance_tests/tox.ini +++ b/performance_tests/tox.ini @@ -31,7 +31,7 @@ envlist = # release :: Builds dist files and uploads to pypi pypirc profile. [testenv:base-command] -commands = pytest test/ +commands = pytest -s -v test/ deps = click From bd5505cd9c7a320c5242dbafc0cf423cca4b6ea8 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 15:23:45 -0700 Subject: [PATCH 26/33] add results folder to github --- .gitignore | 2 ++ performance_tests/results/__init__.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 performance_tests/results/__init__.py diff --git a/.gitignore b/.gitignore index 3184add64..0b75f759e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ __pycache__ test_keyrings/ # Ignore results of performance test performance_tests/results/* +# To track the results folder, keep the __init__.py file +!performance_tests/results/__init__.py # Ignore the memory profile logs mprofile_* diff --git a/performance_tests/results/__init__.py b/performance_tests/results/__init__.py new file mode 100644 index 000000000..120179eda --- /dev/null +++ b/performance_tests/results/__init__.py @@ -0,0 +1,3 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Stub module indicator to make linter configuration simpler.""" From dc2daea75cc034b49606f4d3de05406e57c0716b Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 16:46:51 -0700 Subject: [PATCH 27/33] fix all except kms keyring / mkp tests --- .../test/keyrings/test_aws_kms_keyring.py | 3 --- .../test/keyrings/test_raw_aes_keyring.py | 12 +++++++----- .../test/keyrings/test_raw_rsa_keyring.py | 12 +++++++----- .../test_aws_kms_master_key_provider.py | 12 +++++++----- .../test_raw_aes_master_key_provider.py | 12 +++++++----- .../test_raw_rsa_master_key_provider.py | 12 +++++++----- performance_tests/tox.ini | 2 +- 7 files changed, 36 insertions(+), 29 deletions(-) diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 27ab92514..1d5ebb30f 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -104,8 +104,6 @@ def encrypt( output_file: str ): """Performance test for the encrypt_using_keyring function.""" - print('plaintext_data_filename', plaintext_data_filename) - print('output_file', output_file) plaintext_data = PerfTestUtils.read_file(plaintext_data_filename) keyring = create_keyring(kms_key_id) @@ -190,7 +188,6 @@ def test_create_given_kms_client(runner): def test_encrypt(runner): """Test the encrypt_using_keyring function""" result = runner.invoke(encrypt_kms_keyring.commands['encrypt'], ['--n_iters', 1]) - print('result.output', result.output) assert result.exit_code == 0 diff --git a/performance_tests/test/keyrings/test_raw_aes_keyring.py b/performance_tests/test/keyrings/test_raw_aes_keyring.py index bb45b6049..fe0b1c566 100644 --- a/performance_tests/test/keyrings/test_raw_aes_keyring.py +++ b/performance_tests/test/keyrings/test_raw_aes_keyring.py @@ -26,7 +26,7 @@ def create_raw_aes_keyring(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_aes_keyring_create') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_keyring_create') def create( n_iters: int, output_file: str @@ -52,12 +52,13 @@ def encrypt_raw_aes_keyring(): @encrypt_raw_aes_keyring.command() @click.option('--plaintext_data_filename', - default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_aes_keyring_encrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_keyring_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -88,12 +89,13 @@ def decrypt_raw_aes_keyring(): @decrypt_raw_aes_keyring.command() @click.option('--ciphertext_data_filename', - default='test/resources/ciphertext/raw_aes/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_aes/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_aes_keyring_decrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_keyring_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int, diff --git a/performance_tests/test/keyrings/test_raw_rsa_keyring.py b/performance_tests/test/keyrings/test_raw_rsa_keyring.py index d3a3d0f8f..3a124b4ff 100644 --- a/performance_tests/test/keyrings/test_raw_rsa_keyring.py +++ b/performance_tests/test/keyrings/test_raw_rsa_keyring.py @@ -26,7 +26,7 @@ def create_raw_rsa_keyring(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_rsa_keyring_create') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_keyring_create') def create( n_iters: int, output_file: str @@ -55,12 +55,13 @@ def encrypt_raw_rsa_keyring(): @encrypt_raw_rsa_keyring.command() @click.option('--plaintext_data_filename', - default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_rsa_keyring_encrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_keyring_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -93,12 +94,13 @@ def decrypt_raw_rsa_keyring(): @decrypt_raw_rsa_keyring.command() @click.option('--ciphertext_data_filename', - default='test/resources/ciphertext/raw_rsa/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_rsa/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_rsa_keyring_decrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_keyring_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int, diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py index fc6486f24..224dbbc68 100644 --- a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -28,7 +28,7 @@ def create_kms_key_provider(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='kms_key_provider_create') + default='/'.join(__file__.split("/")[:-3]) + '/results/kms_key_provider_create') def create( kms_key_id: str, n_iters: int, @@ -55,14 +55,15 @@ def encrypt_kms_key_provider(): @encrypt_kms_key_provider.command() @click.option('--plaintext_data_filename', - default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='kms_key_provider_encrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/kms_key_provider_encrypt') def encrypt( plaintext_data_filename: str, kms_key_id: str, @@ -94,14 +95,15 @@ def decrypt_kms_key_provider(): @decrypt_kms_key_provider.command() @click.option('--ciphertext_data_filename', - default='test/resources/ciphertext/kms/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/kms/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='kms_key_provider_decrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/kms_key_provider_decrypt') def decrypt( ciphertext_data_filename: str, kms_key_id: str, diff --git a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py index fd5bba293..95a3f5807 100644 --- a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py @@ -26,7 +26,7 @@ def create_raw_aes_key_provider(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_aes_key_provider_create') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_key_provider_create') def create( n_iters: int, output_file: str @@ -52,12 +52,13 @@ def encrypt_raw_aes_key_provider(): @encrypt_raw_aes_key_provider.command() @click.option('--plaintext_data_filename', - default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_aes_key_provider_encrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_key_provider_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -88,12 +89,13 @@ def decrypt_raw_aes_key_provider(): @decrypt_raw_aes_key_provider.command() @click.option('--ciphertext_data_filename', - default='test/resources/ciphertext/raw_aes/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_aes/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_aes_key_provider_decrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_key_provider_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int, diff --git a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py index 4ac4ccf1f..2196f0fd5 100644 --- a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py @@ -26,7 +26,7 @@ def create_raw_rsa_key_provider(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_rsa_key_provider_create') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_key_provider_create') def create( n_iters: int, output_file: str @@ -52,12 +52,13 @@ def encrypt_raw_rsa_key_provider(): @encrypt_raw_rsa_key_provider.command() @click.option('--plaintext_data_filename', - default='test/resources/plaintext/plaintext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', + default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', prompt='Filename containing plaintext data you want to encrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_rsa_key_provider_encrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_key_provider_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -88,12 +89,13 @@ def decrypt_raw_rsa_key_provider(): @decrypt_raw_rsa_key_provider.command() @click.option('--ciphertext_data_filename', - default='test/resources/ciphertext/raw_rsa/ciphertext-data-' + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', + default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_rsa/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', prompt='Filename containing ciphertext data you want to decrypt') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='raw_rsa_key_provider_decrypt') + default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_key_provider_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int, diff --git a/performance_tests/tox.ini b/performance_tests/tox.ini index f53950c83..4474dc5ea 100644 --- a/performance_tests/tox.ini +++ b/performance_tests/tox.ini @@ -31,7 +31,7 @@ envlist = # release :: Builds dist files and uploads to pypi pypirc profile. [testenv:base-command] -commands = pytest -s -v test/ +commands = pytest test/ deps = click From 457d20d5bdafa2a178956cb767259d98af3d20ff Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 29 May 2024 17:09:32 -0700 Subject: [PATCH 28/33] fix --- .../keyrings/hierarchy_keyring.py | 143 ------------------ 1 file changed, 143 deletions(-) delete mode 100644 performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py deleted file mode 100644 index 208820c92..000000000 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/hierarchy_keyring.py +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -"""Performance tests for the hierarchy keyring.""" - -import aws_encryption_sdk -import boto3 -from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders -from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig -from aws_cryptographic_materialproviders.mpl.models import CreateAwsKmsKeyringInput -from aws_cryptographic_materialproviders.mpl.references import IKeyring - -from aws_cryptographic_materialproviders.keystore import KeyStore -from aws_cryptographic_materialproviders.keystore.config import KeyStoreConfig -from aws_cryptographic_materialproviders.keystore.models import CreateKeyInput, KMSConfigurationKmsKeyArn -from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders -from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig -from aws_cryptographic_materialproviders.mpl.models import ( - CacheTypeDefault, - CreateAwsKmsHierarchicalKeyringInput, - DefaultCache, -) -from aws_cryptographic_materialproviders.mpl.references import IBranchKeyIdSupplier, IKeyring -from typing import Dict # noqa pylint: disable=wrong-import-order - -import aws_encryption_sdk -from aws_encryption_sdk import CommitmentPolicy -from aws_encryption_sdk.exceptions import AWSEncryptionSDKClientError - -from .branch_key_id_supplier_example import ExampleBranchKeyIdSupplier - - -def create_keyring( - key_store_table_name: str, - logical_key_store_name: str, - kms_key_id: str -): - """Demonstrate how to create a hierarchy keyring. - - Usage: create_keyring(key_store_table_name, logical_key_store_name, kms_key_id) - :param key_store_table_name: Name of the KeyStore DynamoDB table. - :type key_store_table_name: string - :param logical_key_store_name: Logical name of the KeyStore. - :type logical_key_store_name: string - :param kms_key_id: KMS Key identifier for the KMS key you want to use. - :type kms_key_id: string - - For more information on KMS Key identifiers, see - https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id - """ - # Create boto3 clients for DynamoDB and KMS. - ddb_client = boto3.client('dynamodb', region_name="us-west-2") - kms_client = boto3.client('kms', region_name="us-west-2") - - # Configure your KeyStore resource. - # This SHOULD be the same configuration that you used - # to initially create and populate your KeyStore. - keystore: KeyStore = KeyStore( - config=KeyStoreConfig( - ddb_client=ddb_client, - ddb_table_name=key_store_table_name, - logical_key_store_name=logical_key_store_name, - kms_client=kms_client, - kms_configuration=KMSConfigurationKmsKeyArn( - value=kms_key_id - ), - ) - ) - - # Call CreateKey to create two new active branch keys - branch_key_id_a: str = keystore.create_key(input=CreateKeyInput()).branch_key_identifier - branch_key_id_b: str = keystore.create_key(input=CreateKeyInput()).branch_key_identifier - - # Create a branch key supplier that maps the branch key id to a more readable format - branch_key_id_supplier: IBranchKeyIdSupplier = ExampleBranchKeyIdSupplier( - tenant_1_id=branch_key_id_a, - tenant_2_id=branch_key_id_b, - ) - - # Create the Hierarchical Keyring. - mat_prov: AwsCryptographicMaterialProviders = AwsCryptographicMaterialProviders( - config=MaterialProvidersConfig() - ) - - keyring_input: CreateAwsKmsHierarchicalKeyringInput = CreateAwsKmsHierarchicalKeyringInput( - key_store=keystore, - branch_key_id_supplier=branch_key_id_supplier, - ttl_seconds=600, - cache=CacheTypeDefault( - value=DefaultCache( - entry_capacity=100 - ) - ), - ) - - keyring: IKeyring = mat_prov.create_aws_kms_hierarchical_keyring( - input=keyring_input - ) - - return keyring - - -def encrypt_using_keyring( - plaintext_data: bytes, - keyring: IKeyring -): - """Demonstrate how to encrypt plaintext data using an AWS KMS keyring. - - Usage: encrypt_using_keyring(plaintext_data, keyring) - :param plaintext_data: plaintext data you want to encrypt - :type: bytes - :param keyring: Keyring to use for encryption. - :type keyring: IKeyring - """ - client = aws_encryption_sdk.EncryptionSDKClient() - - ciphertext_data, _ = client.encrypt( - source=plaintext_data, - keyring=keyring - ) - - return ciphertext_data - - -def decrypt_using_keyring( - ciphertext_data: bytes, - keyring: IKeyring -): - """Demonstrate how to decrypt ciphertext data using an AWS KMS keyring. - - Usage: decrypt_using_keyring(ciphertext_data, keyring) - :param ciphertext_data: ciphertext data you want to decrypt - :type: bytes - :param keyring: Keyring to use for decryption. - :type keyring: IKeyring - """ - client = aws_encryption_sdk.EncryptionSDKClient() - - decrypted_plaintext_data, _ = client.decrypt( - source=ciphertext_data, - keyring=keyring - ) - - return decrypted_plaintext_data From 8fba0ccd848a81df332f6af112e40a12c2800da6 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 3 Jun 2024 09:18:15 -0700 Subject: [PATCH 29/33] updated README; refactoring --- .gitignore | 6 +- performance_tests/README.rst | 273 ++++++++++++------ performance_tests/results/.gitkeep | 0 performance_tests/results/__init__.py | 3 - .../__init__.py | 2 +- .../keyrings/aws_kms_keyring.py | 10 +- .../utils/util.py | 15 +- performance_tests/tox.ini | 86 ++++-- 8 files changed, 263 insertions(+), 132 deletions(-) create mode 100644 performance_tests/results/.gitkeep delete mode 100644 performance_tests/results/__init__.py diff --git a/.gitignore b/.gitignore index 0b75f759e..2843404d0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,9 +34,9 @@ __pycache__ # Ignore key materials generated by examples or tests test_keyrings/ # Ignore results of performance test -performance_tests/results/* -# To track the results folder, keep the __init__.py file -!performance_tests/results/__init__.py +performance_tests/results/*.csv +performance_tests/results/*.pstats +performance_tests/results/*.png # Ignore the memory profile logs mprofile_* diff --git a/performance_tests/README.rst b/performance_tests/README.rst index aefb11e01..9cbc26189 100644 --- a/performance_tests/README.rst +++ b/performance_tests/README.rst @@ -1,12 +1,14 @@ -# aws-encryption-sdk performance tests +##################################### +aws-encryption-sdk performance tests +##################################### -## License +This module runs performance tests for the `AWS Encryption SDK Python`_. -This project is licensed under the Apache-2.0 License. +******** +Overview +******** -## Overview - -This library tests the following keyrings / master key-providers: +This module tests the following keyrings / master key-providers: 1. KMS Keyring / KMS Master Key Provider 2. Raw AES Keyring / AES Master Key Provider @@ -14,122 +16,217 @@ This library tests the following keyrings / master key-providers: 4. Hierarchy Keyring 5. Caching CMM -For each test on the above keyrings / master key-providers, this package measures the execution time and memory consumption. +For each test on the above keyrings / master key-providers, this package measures: + +1. Execution time +2. Total memory consumption + +For each keyring / master key-provider, the execution time and memory consumption +is measured for three operations: -For each keyring / master key-provider, the execution time and memory consumption time is measured for three operations: 1. Create keyring / master key-provider 2. Encrypt 3. Decrypt -The usage of the performance tests is demonstrated through an [AWS KMS Keyring](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html). However, the procedure is the same for any keyring / master key-provider, with slight change in the input arguments. +The usage of the performance tests is demonstrated through an `AWS KMS Keyring`_. +However, the procedure is the same for any keyring / master key-provider, with slight +changes in the input arguments. + +The results for the performance test will be available in the results folder in the +performance_tests directory. + +********************** +Required Prerequisites +********************** + +* Python 3.11+ +* aws-encryption-sdk + +***** +Usage +***** + +Execution Time +============== + +Create Keyring +-------------- +To run the performance test for execution time, please use the +following commands in the performance_tests directory. + +.. code:: + + usage: python test/keyrings/test_aws_kms_keyring.py create + + Create a keyring to use for encryption and decryption. + + optional arguments: + -h, --help show this help message and exit. + --kms_key_id KMS_KEY_ID The KMS key ID you want to use. + --n_iters N_ITERS Number of iterations you want to + run the test for. For instance, + if n_iters = 100, this performance + test script will run the create_keyring + method 100 times and report the + execution time of each of the calls. + --output_file OUTPUT_FILE The output file for execution times + for each function call, + default='kms_keyring_create' in the + results folder. + + +Consolidate Results +~~~~~~~~~~~~~~~~~~~ + +In order to find the minimum, maximum, average, 99th percentile and bottom +99th percentile trimmed average times from the n_iters runs, please use the +following script from the performance_tests directory: -The results for the performance test will be available in the results folder in the performance_tests directory. +.. code:: -## Usage: Execution Time + usage: python consolidate_results.py results/kms_keyring_create.csv -### Create Keyring -To run the performance test for execution time, please use the following commands in the performance_tests directory -``` -python test/keyrings/test_aws_kms_keyring.py create -``` -#### Optional Arguments -* kms_key_id: The KMS key ID you want to use -* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the create_keyring method 100 times and report the execution time of each of the calls. -* output_file: The output file for execution times for each function call, default='kms_keyring_create' in the results folder +Encrypt +------- -#### Consolidate Results +To run the performance test for execution time, please use the following +commands in the performance_tests directory: -In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: -``` -python consolidate_results.py results/kms_keyring_create.csv -``` +.. code:: -### Encrypt -To run the performance test for execution time, please use the following commands in the performance_tests directory -``` -python test/keyrings/test_aws_kms_keyring.py encrypt -``` + usage: python test/keyrings/test_aws_kms_keyring.py encrypt -Here, you will receive a prompt on the terminal to specify the plaintext file you want to encrypt. Some example plaintext data files are present in the 'test/resources' directory. + optional arguments: + -h, --help show this help message and exit. + --plaintext_data_filename PLAINTEXT_DATA_FILENAME Filename containing plaintext data + you want to encrypt. + default='test/resources/plaintext/plaintext-data-medium.dat'. + You can choose to use any other plaintext + file as well. Some example plaintext + data files are present in the + 'test/resources' directory. + --kms_key_id KMS_KEY_ID The KMS key ID you want to use. + --n_iters N_ITERS Number of iterations you want to + run the test for. For instance, + if n_iters = 100, this performance + test script will run the create_keyring + method 100 times and report the + execution time of each of the calls. + --output_file OUTPUT_FILE The output file for execution times + for each function call, + default='kms_keyring_create' in the + results folder. -Alternatively, if you want to provide the arguments as flags without using the interactive CLI, you can run the command in the following manner: +Consolidate Results +~~~~~~~~~~~~~~~~~~~ -``` -python test/keyrings/test_aws_kms_keyring.py encrypt --plaintext_data_filename test/resources/plaintext-data-medium.dat -``` +In order to find the minimum, maximum, average, 99th percentile and bottom +99th percentile trimmed average times from the n_iters runs, please use the +following script from the performance_tests directory: -You can choose to use any other plaintext file as well. +.. code:: -#### Arguments -* plaintext_data_filename: Filename containing plaintext data you want to encrypt + usage: python consolidate_results.py results/kms_keyring_encrypt.csv -#### Optional Arguments -* kms_key_id: The KMS key ID you want to use to encrypt the data -* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the encrypt method 100 times and report the execution time of each of the calls. -* output_file: The output file for execution times for each function call, default='kms_keyring_encrypt' -#### Consolidate Results +Decrypt +------- -In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: -``` -python consolidate_results.py results/kms_keyring_encrypt.csv -``` +To run the performance test for execution time, please use the +following commands in the performance_tests directory -### Decrypt -To run the performance test for execution time, please use the following commands in the performance_tests directory -``` -python test/keyrings/test_aws_kms_keyring.py decrypt -``` +.. code:: -Here, you will receive a prompt on the terminal to specify the ciphertext file you want to decrypt. Some example ciphertext data files are present in the 'test/resources' directory. + usage: python test/keyrings/test_aws_kms_keyring.py decrypt -Alternatively, if you want to provide the arguments as flags without using the interactive CLI, you can run the command in the following manner: + optional arguments: + -h, --help show this help message and exit. + --ciphertext_data_filename CIPHERTEXT_DATA_FILENAME Filename containing ciphertext data + you want to decrypt. + default='test/resources/ciphertext/kms/ciphertext-data-medium.ct'. + You can choose to use any other + ciphertext file as well. Some example + ciphertext data files are present in + the 'test/resources' directory. + --kms_key_id KMS_KEY_ID The KMS key ID you want to use. + --n_iters N_ITERS Number of iterations you want to + run the test for. For instance, + if n_iters = 100, this performance + test script will run the create_keyring + method 100 times and report the + execution time of each of the calls. + --output_file OUTPUT_FILE The output file for execution times + for each function call, + default='kms_keyring_create' in the + results folder. -``` -python test/keyrings/test_aws_kms_keyring.py decrypt --ciphertext_data_filename test/resources/ciphertext-data-medium.ct -``` +Consolidate Results +~~~~~~~~~~~~~~~~~~~ -You can choose to use any other ciphertext file as well. +In order to find the minimum, maximum, average, 99th percentile and bottom +99th percentile trimmed average times from the n_iters runs, please use the +following script from the performance_tests directory: -#### Arguments -* ciphertext_data_filename: Filename containing ciphertext data you want to decrypt +.. code:: -#### Optional Arguments -* kms_key_id: The KMS key ID you want to use to decrypt the data -* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the decrypt method 100 times and report the execution time of each of the calls. -* output_file: The output file for execution times for each function call, default='kms_keyring_decrypt' + usage: python consolidate_results.py results/kms_keyring_decrypt.csv -#### Consolidate Results +Memory Consumption +================== -In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: -``` -python consolidate_results.py results/kms_keyring_decrypt.csv -``` +To get the memory consumption, simply replace 'python' +with 'mprof run' in the previously mentioned commands. -## Usage: Memory Consumption -To get the memory consumption, simply use 'mprof run' instead of 'python' in the previously mentioned commands. +For example, if you want to calculate the memory consumption +of the encrypt function of a AWS KMS Keyring, simply write: -For example, if you want to calculate the memory consumption of the encrypt function of a AWS KMS Keyring, simply write: -``` -mprof run test/keyrings/test_aws_kms_keyring.py encrypt --plaintext_data_filename test/resources/plaintext-data-medium.dat -``` +.. code:: + + usage: mprof run test/keyrings/test_aws_kms_keyring.py encrypt + + +This should generate an mprofile log file in your current directory. +This mprofile log file contains the total memory consumed by the program +with respect to time elapsed. +To plot the memory consumption with respect to time, please use the following +command from the same directory + +.. code:: + + usage: mprof plot -This should generate an mprofile log file in your current directory. To plot the memory consumption with time, please use the following command from the same directory -``` -mprof plot -``` This 'mprof plot' command will plot the most recent mprofile log file. -## Usage: Performance Graph -To generate a performance graph, please use the following command to generate the pstats log file by specifying the output pstats file path. Here, 'results/kms_keyring_create.pstats' is set as the default output file. -``` -python -m cProfile -o results/kms_keyring_create.pstats test/keyrings/test_aws_kms_keyring.py create -``` +Performance Graph +================= + +To generate a performance graph, please use the following command +to generate the pstats log file by specifying the output pstats file +path. Here, 'results/kms_keyring_create.pstats' is set as the default +output file. + +.. code:: + + usage: python -m cProfile -o results/kms_keyring_create.pstats test/keyrings/test_aws_kms_keyring.py create + + +After generating the pstats file, please run the following command +to generate the performance graph. The output performance graph will +be a .png file that you specify. Here, 'results/kms_keyring_create.png' +is set as the default output file. + +.. code:: + + usage: gprof2dot -f pstats results/kms_keyring_create.pstats | dot -Tpng -o results/kms_keyring_create.png && eog results/kms_keyring_create.png + + +Note: This project does not adhere to semantic versioning; as such it +makes no guarantees that functionality will persist across major, +minor, or patch versions. +**DO NOT** take a standalone dependency on this library. -After generating the pstats file, please run the following command to generate the performance graph. The output performance graph will be a .png file that you specify. Here, 'results/kms_keyring_create.png' is set as the default output file. -``` -gprof2dot -f pstats results/kms_keyring_create.pstats | dot -Tpng -o results/kms_keyring_create.png && eog results/kms_keyring_create.png -``` +.. _AWS Encryption SDK Python: https://github.com/aws/aws-encryption-sdk-python/ +.. _AWS KMS Keyring: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html diff --git a/performance_tests/results/.gitkeep b/performance_tests/results/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/performance_tests/results/__init__.py b/performance_tests/results/__init__.py deleted file mode 100644 index 120179eda..000000000 --- a/performance_tests/results/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -"""Stub module indicator to make linter configuration simpler.""" diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py b/performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py index bbfe61296..cf1bf0fb4 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/__init__.py @@ -1,4 +1,4 @@ # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 """Stub module indicator to make linter configuration simpler.""" -__version__ = "0.0.0" +__version__ = "0.1.0" diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py index 184bdd436..e846ec695 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/keyrings/aws_kms_keyring.py @@ -23,7 +23,7 @@ def create_keyring( https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id """ # Create a boto3 client for KMS. - kms_client = boto3.client('kms', region_name="us-west-2") + kms_client = create_kms_client() # Create a KMS keyring mat_prov: AwsCryptographicMaterialProviders = AwsCryptographicMaterialProviders( @@ -42,13 +42,15 @@ def create_keyring( return keyring -def create_kms_client(): +def create_kms_client(aws_region="us-west-2"): """Create an AWS KMS client. - Usage: create_kms_client() + Usage: create_kms_client(aws_region) + :param aws_region: AWS region to use for KMS client. + :type aws_region: string """ # Create a boto3 client for KMS. - kms_client = boto3.client('kms', region_name="us-west-2") + kms_client = boto3.client('kms', region_name=aws_region) return kms_client diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py index 2c14cf367..85ed56e1a 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py @@ -6,7 +6,7 @@ class PerfTestUtils: """Utility functions for AWS Encryption SDK performance tests.""" DEFAULT_N_ITERS = 100 - DEFAULT_FILE_SIZE = 'small' + DEFAULT_FILE_SIZE = 'medium' DEFAULT_AES_256_STATIC_KEY = \ b'_\xcf"\x82\x03\x12\x9d\x00\x8a\xed\xaf\xe4\x80\x1d\x00t\xa6P\xac\xb6\xfe\xc5\xf6/{\xe7\xaaO\x01\x13W\x85' DEFAULT_RSA_PUBLIC_KEY = bytes("-----BEGIN PUBLIC KEY-----\n" @@ -77,6 +77,19 @@ class PerfTestUtils: + "A/DHJmMI5bKETJyj1GhBE9LqypAI1Bo=\n" + "-----END PRIVATE KEY-----\n", "utf-8") + DEFAULT_ENCRYPTION_CONTEXT = { + "tenant": "TenantA", + "encryption": "context", + "is not": "secret", + "but adds": "useful metadata", + "that can help you": "be confident that", + "the data you are handling": "is what you think it is", + } + + DEFAULT_BRANCH_KEY_ID_A = 'a52dfaad-7dbd-4430-a1fd-abaa5299da07' + + DEFAULT_BRANCH_KEY_ID_B = '8ba79cef-581c-4125-9292-b057a29d42d7' + @staticmethod def read_file(filename): """Returns the contents of the file.""" diff --git a/performance_tests/tox.ini b/performance_tests/tox.ini index 4474dc5ea..1b7d073aa 100644 --- a/performance_tests/tox.ini +++ b/performance_tests/tox.ini @@ -2,9 +2,11 @@ envlist = # The performance tests only work for python 3.11 and 3.12 py{311,312}-performance_tests-mpl - bandit, readme - # TODO: Activate doc8 after finalizing README.rst - ; bandit, doc8, readme + bandit, doc8 + ; {flake8, pylint}{,-tests}, + isort-check, black-check, + # prone to false positives + vulture # Additional test environments: # @@ -51,49 +53,58 @@ deps = mpl: -rrequirements_mpl.txt .. commands = - # awses_local: {[testenv:base-command]commands} performance_tests: {[testenv:base-command]commands} -# mypy -[testenv:mypy-coverage] -commands = - # Make mypy linecoverage report readable by coverage - python -c \ - "t = open('.coverage', 'w');\ - c = open('build/coverage.json').read();\ - t.write('!coverage.py: This is a private format, don\'t read it directly!\n');\ - t.write(c);\ - t.close()" - coverage report -m - -[testenv:mypy-common] +[testenv:blacken-src] basepython = python3 -deps = - coverage - mypy>=0.600 - mypy_extensions - typing>=3.6.2 - -[testenv:mypy-py3] -basepython = {[testenv:mypy-common]basepython} -deps = {[testenv:mypy-common]deps} +deps = -r../dev_requirements/linter-requirements.txt commands = - python -m mypy \ - --linecoverage-report build \ + black --line-length 120 \ src/aws_encryption_sdk_performance_tests/ \ + setup.py \ + test/ \ {posargs} - {[testenv:mypy-coverage]commands} -[testenv:blacken-src] +# Linters +[testenv:flake8] basepython = python3 deps = -r../dev_requirements/linter-requirements.txt commands = - black --line-length 120 \ + flake8 \ src/aws_encryption_sdk_performance_tests/ \ setup.py \ - test/ \ {posargs} +[testenv:flake8-tests] +basepython = {[testenv:flake8]basepython} +deps = -r../dev_requirements/linter-requirements.txt +commands = + flake8 \ + # Ignore F811 redefinition errors in tests (breaks with pytest-mock use) + # E203 is not PEP8 compliant https://github.com/ambv/black#slices + # W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators + --ignore F811,E203,W503,D \ + test/ + +[testenv:pylint] +basepython = python3 +deps = + -r../dev_requirements/linter-requirements.txt +commands = + pylint \ + --rcfile=pylintrc \ + src/aws_encryption_sdk_performance_tests/ \ + setup.py \ + {posargs} + +[testenv:pylint-tests] +basepython = {[testenv:pylint]basepython} +deps = {[testenv:pylint]deps} +commands = + pylint \ + --rcfile=pylintrc \ + test/ \ + {posargs} [testenv:blacken] basepython = python3 @@ -143,6 +154,11 @@ basepython = python3 deps = -r../dev_requirements/linter-requirements.txt commands = doc8 README.rst +[testenv:readme] +basepython = python3 +deps = -r../dev_requirements/linter-requirements.txt +commands = python setup.py check -r -s + [testenv:bandit] basepython = python3 deps = -r../dev_requirements/linter-requirements.txt @@ -151,10 +167,16 @@ commands = bandit -r src/aws_encryption_sdk_performance_tests/ [testenv:linters] basepython = python3 deps = + {[testenv:flake8]deps} + {[testenv:pylint]deps} {[testenv:doc8]deps} + {[testenv:readme]deps} {[testenv:bandit]deps} commands = + {[testenv:flake8]commands} + {[testenv:pylint]commands} {[testenv:doc8]commands} + {[testenv:readme]commands} {[testenv:bandit]commands} # Release tooling From 71f7c0a795bf32af3920dd35316abaeb97338204 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 3 Jun 2024 09:33:20 -0700 Subject: [PATCH 30/33] removed requirements_mpl.txt --- performance_tests/requirements_mpl.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 performance_tests/requirements_mpl.txt diff --git a/performance_tests/requirements_mpl.txt b/performance_tests/requirements_mpl.txt deleted file mode 100644 index 209e10f2c..000000000 --- a/performance_tests/requirements_mpl.txt +++ /dev/null @@ -1 +0,0 @@ -aws-cryptographic-material-providers @ git+https://github.com/aws/aws-cryptographic-material-providers-library.git@lucmcdon/python-mpl#subdirectory=AwsCryptographicMaterialProviders/runtimes/python \ No newline at end of file From 8f76e56f01848cb69e597418e5082bf06018239b Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 3 Jun 2024 11:46:38 -0700 Subject: [PATCH 31/33] add requirements_mpl.txt --- performance_tests/requirements_mpl.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 performance_tests/requirements_mpl.txt diff --git a/performance_tests/requirements_mpl.txt b/performance_tests/requirements_mpl.txt new file mode 100644 index 000000000..209e10f2c --- /dev/null +++ b/performance_tests/requirements_mpl.txt @@ -0,0 +1 @@ +aws-cryptographic-material-providers @ git+https://github.com/aws/aws-cryptographic-material-providers-library.git@lucmcdon/python-mpl#subdirectory=AwsCryptographicMaterialProviders/runtimes/python \ No newline at end of file From f325071877c7a940c1fbdb151e82501075c048d2 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 3 Jun 2024 14:47:07 -0700 Subject: [PATCH 32/33] add default testing n_iters for automated testing results --- .../utils/util.py | 1 + .../test/keyrings/test_aws_kms_keyring.py | 12 ++++++++---- .../test/keyrings/test_raw_aes_keyring.py | 9 ++++++--- .../test/keyrings/test_raw_rsa_keyring.py | 9 ++++++--- .../test_aws_kms_master_key_provider.py | 9 ++++++--- .../test_raw_aes_master_key_provider.py | 9 ++++++--- .../test_raw_rsa_master_key_provider.py | 9 ++++++--- 7 files changed, 39 insertions(+), 19 deletions(-) diff --git a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py index 85ed56e1a..52914b76a 100644 --- a/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py +++ b/performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py @@ -6,6 +6,7 @@ class PerfTestUtils: """Utility functions for AWS Encryption SDK performance tests.""" DEFAULT_N_ITERS = 100 + DEFAULT_TESTING_N_ITERS = 1 DEFAULT_FILE_SIZE = 'medium' DEFAULT_AES_256_STATIC_KEY = \ b'_\xcf"\x82\x03\x12\x9d\x00\x8a\xed\xaf\xe4\x80\x1d\x00t\xa6P\xac\xb6\xfe\xc5\xf6/{\xe7\xaaO\x01\x13W\x85' diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index 1d5ebb30f..d395ddd97 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -175,25 +175,29 @@ def runner(): def test_create(runner): """Test the create_keyring function""" - result = runner.invoke(create_kms_keyring.commands['create'], ['--n_iters', 1]) + result = runner.invoke(create_kms_keyring.commands['create'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_create_given_kms_client(runner): """Test the create_keyring_given_kms_client function""" - result = runner.invoke(create_kms_keyring_given_kms_client.commands['create-given-kms-client'], ['--n_iters', 1]) + result = runner.invoke(create_kms_keyring_given_kms_client.commands['create-given-kms-client'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_encrypt(runner): """Test the encrypt_using_keyring function""" - result = runner.invoke(encrypt_kms_keyring.commands['encrypt'], ['--n_iters', 1]) + result = runner.invoke(encrypt_kms_keyring.commands['encrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_decrypt(runner): """Test the decrypt_using_keyring function""" - result = runner.invoke(decrypt_kms_keyring.commands['decrypt'], ['--n_iters', 1]) + result = runner.invoke(decrypt_kms_keyring.commands['decrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 diff --git a/performance_tests/test/keyrings/test_raw_aes_keyring.py b/performance_tests/test/keyrings/test_raw_aes_keyring.py index fe0b1c566..f63d4d180 100644 --- a/performance_tests/test/keyrings/test_raw_aes_keyring.py +++ b/performance_tests/test/keyrings/test_raw_aes_keyring.py @@ -132,19 +132,22 @@ def runner(): def test_create(runner): """Test the create_keyring function""" - result = runner.invoke(create_raw_aes_keyring.commands['create'], ['--n_iters', 1]) + result = runner.invoke(create_raw_aes_keyring.commands['create'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_encrypt(runner): """Test the encrypt_using_keyring function""" - result = runner.invoke(encrypt_raw_aes_keyring.commands['encrypt'], ['--n_iters', 1]) + result = runner.invoke(encrypt_raw_aes_keyring.commands['encrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_decrypt(runner): """Test the decrypt_using_keyring function""" - result = runner.invoke(decrypt_raw_aes_keyring.commands['decrypt'], ['--n_iters', 1]) + result = runner.invoke(decrypt_raw_aes_keyring.commands['decrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 diff --git a/performance_tests/test/keyrings/test_raw_rsa_keyring.py b/performance_tests/test/keyrings/test_raw_rsa_keyring.py index 3a124b4ff..91cd6e69f 100644 --- a/performance_tests/test/keyrings/test_raw_rsa_keyring.py +++ b/performance_tests/test/keyrings/test_raw_rsa_keyring.py @@ -139,19 +139,22 @@ def runner(): def test_create(runner): """Test the create_keyring function""" - result = runner.invoke(create_raw_rsa_keyring.commands['create'], ['--n_iters', 1]) + result = runner.invoke(create_raw_rsa_keyring.commands['create'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_encrypt(runner): """Test the encrypt_using_keyring function""" - result = runner.invoke(encrypt_raw_rsa_keyring.commands['encrypt'], ['--n_iters', 1]) + result = runner.invoke(encrypt_raw_rsa_keyring.commands['encrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_decrypt(runner): """Test the decrypt_using_keyring function""" - result = runner.invoke(decrypt_raw_rsa_keyring.commands['decrypt'], ['--n_iters', 1]) + result = runner.invoke(decrypt_raw_rsa_keyring.commands['decrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py index 224dbbc68..901b18285 100644 --- a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -141,19 +141,22 @@ def runner(): def test_create(runner): """Test the create_key_provider function""" - result = runner.invoke(create_kms_key_provider.commands['create'], ['--n_iters', 1]) + result = runner.invoke(create_kms_key_provider.commands['create'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_encrypt(runner): """Test the encrypt_using_key_provider function""" - result = runner.invoke(encrypt_kms_key_provider.commands['encrypt'], ['--n_iters', 1]) + result = runner.invoke(encrypt_kms_key_provider.commands['encrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_decrypt(runner): """Test the decrypt_using_key_provider function""" - result = runner.invoke(decrypt_kms_key_provider.commands['decrypt'], ['--n_iters', 1]) + result = runner.invoke(decrypt_kms_key_provider.commands['decrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 diff --git a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py index 95a3f5807..ed01334e1 100644 --- a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py @@ -132,19 +132,22 @@ def runner(): def test_create(runner): """Test the create_key_provider function""" - result = runner.invoke(create_raw_aes_key_provider.commands['create'], ['--n_iters', 1]) + result = runner.invoke(create_raw_aes_key_provider.commands['create'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_encrypt(runner): """Test the encrypt_using_key_provider function""" - result = runner.invoke(encrypt_raw_aes_key_provider.commands['encrypt'], ['--n_iters', 1]) + result = runner.invoke(encrypt_raw_aes_key_provider.commands['encrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_decrypt(runner): """Test the decrypt_using_key_provider function""" - result = runner.invoke(decrypt_raw_aes_key_provider.commands['decrypt'], ['--n_iters', 1]) + result = runner.invoke(decrypt_raw_aes_key_provider.commands['decrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 diff --git a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py index 2196f0fd5..1a99a5acc 100644 --- a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py @@ -132,19 +132,22 @@ def runner(): def test_create(runner): """Test the create_key_provider function""" - result = runner.invoke(create_raw_rsa_key_provider.commands['create'], ['--n_iters', 1]) + result = runner.invoke(create_raw_rsa_key_provider.commands['create'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_encrypt(runner): """Test the encrypt_using_key_provider function""" - result = runner.invoke(encrypt_raw_rsa_key_provider.commands['encrypt'], ['--n_iters', 1]) + result = runner.invoke(encrypt_raw_rsa_key_provider.commands['encrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 def test_decrypt(runner): """Test the decrypt_using_key_provider function""" - result = runner.invoke(decrypt_raw_rsa_key_provider.commands['decrypt'], ['--n_iters', 1]) + result = runner.invoke(decrypt_raw_rsa_key_provider.commands['decrypt'], + ['--n_iters', PerfTestUtils.DEFAULT_TESTING_N_ITERS]) assert result.exit_code == 0 From 4660344f6e4c41e75eb129afb2ac238f4384b896 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Wed, 5 Jun 2024 07:42:44 -0700 Subject: [PATCH 33/33] refactoring and fixes --- performance_tests/README.rst | 55 +++++++------------ performance_tests/consolidate_results.py | 29 +++++----- .../test/keyrings/test_aws_kms_keyring.py | 21 +++---- .../test/keyrings/test_raw_aes_keyring.py | 19 ++++--- .../test/keyrings/test_raw_rsa_keyring.py | 19 ++++--- .../test_aws_kms_master_key_provider.py | 19 ++++--- .../test_raw_aes_master_key_provider.py | 19 ++++--- .../test_raw_rsa_master_key_provider.py | 19 ++++--- 8 files changed, 97 insertions(+), 103 deletions(-) diff --git a/performance_tests/README.rst b/performance_tests/README.rst index 9cbc26189..ba9b89f15 100644 --- a/performance_tests/README.rst +++ b/performance_tests/README.rst @@ -8,7 +8,7 @@ This module runs performance tests for the `AWS Encryption SDK Python`_. Overview ******** -This module tests the following keyrings / master key-providers: +This module tests the following keyrings / master key providers: 1. KMS Keyring / KMS Master Key Provider 2. Raw AES Keyring / AES Master Key Provider @@ -16,20 +16,20 @@ This module tests the following keyrings / master key-providers: 4. Hierarchy Keyring 5. Caching CMM -For each test on the above keyrings / master key-providers, this package measures: +For each test on the above keyrings / master key providers, this package measures: 1. Execution time 2. Total memory consumption -For each keyring / master key-provider, the execution time and memory consumption +For each keyring / master key provider, the execution time and memory consumption is measured for three operations: -1. Create keyring / master key-provider +1. Create keyring / master key provider 2. Encrypt 3. Decrypt The usage of the performance tests is demonstrated through an `AWS KMS Keyring`_. -However, the procedure is the same for any keyring / master key-provider, with slight +However, the procedure is the same for any keyring / master key provider, with slight changes in the input arguments. The results for the performance test will be available in the results folder in the @@ -39,8 +39,18 @@ performance_tests directory. Required Prerequisites ********************** -* Python 3.11+ +* Python 3.8+ * aws-encryption-sdk +* boto3 >= 1.10.0 +* click +* tqdm +* pytest + +Recommended Prerequisites +========================= + +* aws-cryptographic-material-providers: >= 1.0.0 + * Requires Python 3.11+. ***** Usage @@ -74,19 +84,6 @@ following commands in the performance_tests directory. default='kms_keyring_create' in the results folder. - -Consolidate Results -~~~~~~~~~~~~~~~~~~~ - -In order to find the minimum, maximum, average, 99th percentile and bottom -99th percentile trimmed average times from the n_iters runs, please use the -following script from the performance_tests directory: - -.. code:: - - usage: python consolidate_results.py results/kms_keyring_create.csv - - Encrypt ------- @@ -118,18 +115,6 @@ commands in the performance_tests directory: default='kms_keyring_create' in the results folder. -Consolidate Results -~~~~~~~~~~~~~~~~~~~ - -In order to find the minimum, maximum, average, 99th percentile and bottom -99th percentile trimmed average times from the n_iters runs, please use the -following script from the performance_tests directory: - -.. code:: - - usage: python consolidate_results.py results/kms_keyring_encrypt.csv - - Decrypt ------- @@ -161,12 +146,14 @@ following commands in the performance_tests directory default='kms_keyring_create' in the results folder. -Consolidate Results -~~~~~~~~~~~~~~~~~~~ +Consolidate Time Results +======================== In order to find the minimum, maximum, average, 99th percentile and bottom 99th percentile trimmed average times from the n_iters runs, please use the -following script from the performance_tests directory: +following script from the performance_tests directory with the csv file +containing times for each of the n_iters runs generated in the previous +"Execution Time" section: .. code:: diff --git a/performance_tests/consolidate_results.py b/performance_tests/consolidate_results.py index fd2325b6a..2601417cc 100644 --- a/performance_tests/consolidate_results.py +++ b/performance_tests/consolidate_results.py @@ -14,16 +14,18 @@ def calculate_statistics(_csv_file): reader = csv.reader(file) data = [float(row[0]) for row in reader] + output_stats = {} + # Calculate statistics if data: data = np.sort(data) - _total_entries = len(data) - _average = np.mean(data) - _trimmed_average_99_bottom = np.mean(data[0:int(0.99 * len(data))]) - _minimum = min(data) - _maximum = max(data) - _perc_99 = np.percentile(data, 99) - return _total_entries, _average, _trimmed_average_99_bottom, _minimum, _maximum, _perc_99 + output_stats['total_entries'] = len(data) + output_stats['average'] = np.mean(data) + output_stats['trimmed_average_99_bottom'] = np.mean(data[0:int(0.99 * len(data))]) + output_stats['minimum'] = min(data) + output_stats['maximum'] = max(data) + output_stats['perc_99'] = np.percentile(data, 99) + return output_stats return None @@ -36,13 +38,12 @@ def calculate_statistics(_csv_file): statistics = calculate_statistics(args.csv_file) if statistics: - total_entries, average, trimmend_average_99_bottom, minimum, maximum, perc_99 = statistics print("CSV File:", args.csv_file) - print("Total Entries:", total_entries) - print("Average:", average) - print("Bottom 99th percentile trimmed average:", trimmend_average_99_bottom) - print("Minimum:", minimum) - print("Maximum:", maximum) - print("99th percentile:", perc_99) + print("Total Entries:", statistics['total_entries']) + print("Average:", statistics['average']) + print("Bottom 99th percentile trimmed average:", statistics['trimmed_average_99_bottom']) + print("Minimum:", statistics['minimum']) + print("Maximum:", statistics['maximum']) + print("99th percentile:", statistics['perc_99']) else: print("No data found in the CSV file.") diff --git a/performance_tests/test/keyrings/test_aws_kms_keyring.py b/performance_tests/test/keyrings/test_aws_kms_keyring.py index d395ddd97..950a2a82e 100644 --- a/performance_tests/test/keyrings/test_aws_kms_keyring.py +++ b/performance_tests/test/keyrings/test_aws_kms_keyring.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """This is a performance test for creating the AWS KMS keyring.""" +import os import time import click @@ -18,6 +19,8 @@ ) from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils +MODULE_ABS_PATH = os.path.abspath(__file__) + @click.group() def create_kms_keyring(): @@ -30,7 +33,7 @@ def create_kms_keyring(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_create') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/kms_keyring_create') def create( kms_key_id: str, n_iters: int, @@ -60,7 +63,7 @@ def create_kms_keyring_given_kms_client(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_create_given_kms_client') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/kms_keyring_create_given_kms_client') def create_given_kms_client( kms_key_id: str, n_iters: int, @@ -88,15 +91,14 @@ def encrypt_kms_keyring(): @encrypt_kms_keyring.command() @click.option('--plaintext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', - prompt='Filename containing plaintext data you want to encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/kms_keyring_encrypt') def encrypt( plaintext_data_filename: str, kms_key_id: str, @@ -128,15 +130,14 @@ def decrypt_kms_keyring(): @decrypt_kms_keyring.command() @click.option('--ciphertext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/kms/ciphertext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', - prompt='Filename containing ciphertext data you want to decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/ciphertext/kms/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/kms_keyring_decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/kms_keyring_decrypt') def decrypt( ciphertext_data_filename: str, kms_key_id: str, diff --git a/performance_tests/test/keyrings/test_raw_aes_keyring.py b/performance_tests/test/keyrings/test_raw_aes_keyring.py index f63d4d180..1e1da428a 100644 --- a/performance_tests/test/keyrings/test_raw_aes_keyring.py +++ b/performance_tests/test/keyrings/test_raw_aes_keyring.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """This is a performance test for creating the Raw AES keyring.""" +import os import time import click @@ -16,6 +17,8 @@ ) from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils +MODULE_ABS_PATH = os.path.abspath(__file__) + @click.group() def create_raw_aes_keyring(): @@ -26,7 +29,7 @@ def create_raw_aes_keyring(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_keyring_create') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_aes_keyring_create') def create( n_iters: int, output_file: str @@ -52,13 +55,12 @@ def encrypt_raw_aes_keyring(): @encrypt_raw_aes_keyring.command() @click.option('--plaintext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', - prompt='Filename containing plaintext data you want to encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_keyring_encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_aes_keyring_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -89,13 +91,12 @@ def decrypt_raw_aes_keyring(): @decrypt_raw_aes_keyring.command() @click.option('--ciphertext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_aes/ciphertext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', - prompt='Filename containing ciphertext data you want to decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/ciphertext/raw_aes/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_keyring_decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_aes_keyring_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int, diff --git a/performance_tests/test/keyrings/test_raw_rsa_keyring.py b/performance_tests/test/keyrings/test_raw_rsa_keyring.py index 91cd6e69f..476701ac0 100644 --- a/performance_tests/test/keyrings/test_raw_rsa_keyring.py +++ b/performance_tests/test/keyrings/test_raw_rsa_keyring.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """This is a performance test for creating the Raw RSA keyring.""" +import os import time import click @@ -16,6 +17,8 @@ ) from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils +MODULE_ABS_PATH = os.path.abspath(__file__) + @click.group() def create_raw_rsa_keyring(): @@ -26,7 +29,7 @@ def create_raw_rsa_keyring(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_keyring_create') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_rsa_keyring_create') def create( n_iters: int, output_file: str @@ -55,13 +58,12 @@ def encrypt_raw_rsa_keyring(): @encrypt_raw_rsa_keyring.command() @click.option('--plaintext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', - prompt='Filename containing plaintext data you want to encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_keyring_encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_rsa_keyring_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -94,13 +96,12 @@ def decrypt_raw_rsa_keyring(): @decrypt_raw_rsa_keyring.command() @click.option('--ciphertext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_rsa/ciphertext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', - prompt='Filename containing ciphertext data you want to decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/ciphertext/raw_rsa/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_keyring_decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_rsa_keyring_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int, diff --git a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py index 901b18285..b869245b5 100644 --- a/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """This is a performance test for creating the AWS KMS Master key-provider.""" +import os import time import click @@ -16,6 +17,8 @@ ) from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils +MODULE_ABS_PATH = os.path.abspath(__file__) + @click.group() def create_kms_key_provider(): @@ -28,7 +31,7 @@ def create_kms_key_provider(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/kms_key_provider_create') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/kms_key_provider_create') def create( kms_key_id: str, n_iters: int, @@ -55,15 +58,14 @@ def encrypt_kms_key_provider(): @encrypt_kms_key_provider.command() @click.option('--plaintext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', - prompt='Filename containing plaintext data you want to encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/kms_key_provider_encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/kms_key_provider_encrypt') def encrypt( plaintext_data_filename: str, kms_key_id: str, @@ -95,15 +97,14 @@ def decrypt_kms_key_provider(): @decrypt_kms_key_provider.command() @click.option('--ciphertext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/kms/ciphertext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', - prompt='Filename containing ciphertext data you want to decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/ciphertext/kms/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct') @click.option('--kms_key_id', default='arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/kms_key_provider_decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/kms_key_provider_decrypt') def decrypt( ciphertext_data_filename: str, kms_key_id: str, diff --git a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py index ed01334e1..375eca2ef 100644 --- a/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_aes_master_key_provider.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """This is a performance test for creating the Raw AES Master key-provider.""" +import os import time import click @@ -16,6 +17,8 @@ ) from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils +MODULE_ABS_PATH = os.path.abspath(__file__) + @click.group() def create_raw_aes_key_provider(): @@ -26,7 +29,7 @@ def create_raw_aes_key_provider(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_key_provider_create') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_aes_key_provider_create') def create( n_iters: int, output_file: str @@ -52,13 +55,12 @@ def encrypt_raw_aes_key_provider(): @encrypt_raw_aes_key_provider.command() @click.option('--plaintext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', - prompt='Filename containing plaintext data you want to encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_key_provider_encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_aes_key_provider_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -89,13 +91,12 @@ def decrypt_raw_aes_key_provider(): @decrypt_raw_aes_key_provider.command() @click.option('--ciphertext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_aes/ciphertext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', - prompt='Filename containing ciphertext data you want to decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/ciphertext/raw_aes/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_aes_key_provider_decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_aes_key_provider_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int, diff --git a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py index 1a99a5acc..5d6db861a 100644 --- a/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py +++ b/performance_tests/test/master_key_providers/test_raw_rsa_master_key_provider.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """This is a performance test for creating the Raw RSA Master key-provider.""" +import os import time import click @@ -16,6 +17,8 @@ ) from aws_encryption_sdk_performance_tests.utils.util import PerfTestUtils +MODULE_ABS_PATH = os.path.abspath(__file__) + @click.group() def create_raw_rsa_key_provider(): @@ -26,7 +29,7 @@ def create_raw_rsa_key_provider(): @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_key_provider_create') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_rsa_key_provider_create') def create( n_iters: int, output_file: str @@ -52,13 +55,12 @@ def encrypt_raw_rsa_key_provider(): @encrypt_raw_rsa_key_provider.command() @click.option('--plaintext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat', - prompt='Filename containing plaintext data you want to encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/plaintext/plaintext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.dat') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_key_provider_encrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_rsa_key_provider_encrypt') def encrypt( plaintext_data_filename: str, n_iters: int, @@ -89,13 +91,12 @@ def decrypt_raw_rsa_key_provider(): @decrypt_raw_rsa_key_provider.command() @click.option('--ciphertext_data_filename', - default='/'.join(__file__.split("/")[:-2]) + '/resources/ciphertext/raw_rsa/ciphertext-data-' - + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct', - prompt='Filename containing ciphertext data you want to decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-2]) + '/resources/ciphertext/raw_rsa/ciphertext-data-' + + PerfTestUtils.DEFAULT_FILE_SIZE + '.ct') @click.option('--n_iters', default=PerfTestUtils.DEFAULT_N_ITERS) @click.option('--output_file', - default='/'.join(__file__.split("/")[:-3]) + '/results/raw_rsa_key_provider_decrypt') + default='/'.join(MODULE_ABS_PATH.split("/")[:-3]) + '/results/raw_rsa_key_provider_decrypt') def decrypt( ciphertext_data_filename: str, n_iters: int,