Skip to content

Commit 357ffd5

Browse files
committed
feedback
1 parent 9e3d100 commit 357ffd5

File tree

5 files changed

+16
-28
lines changed

5 files changed

+16
-28
lines changed

Examples/runtimes/python/DynamoDBEncryption/src/keyring/hierarchical_keyring_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
"""
4-
Example demonstrates DynamoDb Encryption using a Hierarchical Keyring.
4+
Example demonstrating DynamoDb Encryption using a Hierarchical Keyring.
55
66
This example sets up DynamoDb Encryption for the AWS SDK client
77
using the Hierarchical Keyring, which establishes a key hierarchy

Examples/runtimes/python/DynamoDBEncryption/src/keyring/kms_ecdh_keyring_example.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
KmsPublicKeyDiscoveryInput,
3131
)
3232
from aws_cryptographic_material_providers.mpl.references import IKeyring
33+
from aws_cryptography_primitives.smithygenerated.aws_cryptography_primitives.models import ECDHCurveSpec
3334
from aws_dbesdk_dynamodb.encrypted.client import EncryptedClient
3435
from aws_dbesdk_dynamodb.structures.dynamodb import (
3536
DynamoDbTableEncryptionConfig,
@@ -125,12 +126,7 @@ def kms_ecdh_keyring_get_item_put_item(
125126

126127
keyring_input = CreateAwsKmsEcdhKeyringInput(
127128
kms_client=boto3.client("kms"),
128-
# Supported curve specifications:
129-
# - ECC_NIST_P256
130-
# - ECC_NIST_P384
131-
# - ECC_NIST_P521
132-
# - SM2
133-
curve_spec="ECC_NIST_P256",
129+
curve_spec=ECDHCurveSpec.ECC_NIST_P256,
134130
key_agreement_scheme=KmsEcdhStaticConfigurationsKmsPrivateKeyToStaticPublicKey(
135131
KmsPrivateKeyToStaticPublicKeyInput(
136132
sender_kms_identifier=ecc_key_arn,
@@ -190,7 +186,7 @@ def kms_ecdh_discovery_get_item(ddb_table_name: str, ecc_recipient_key_arn: str)
190186

191187
keyring_input = CreateAwsKmsEcdhKeyringInput(
192188
kms_client=boto3.client("kms"),
193-
curve_spec="ECC_NIST_P256",
189+
curve_spec=ECDHCurveSpec.ECC_NIST_P256,
194190
key_agreement_scheme=KmsEcdhStaticConfigurationsKmsPublicKeyDiscovery(
195191
KmsPublicKeyDiscoveryInput(recipient_kms_identifier=ecc_recipient_key_arn)
196192
),

Examples/runtimes/python/DynamoDBEncryption/src/keyring/raw_ecdh_keyring_example.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ def raw_ecdh_keyring_get_item_put_item(ddb_table_name: str, curve_spec: str):
106106
mat_prov = AwsCryptographicMaterialProviders(config=MaterialProvidersConfig())
107107

108108
keyring_input = CreateRawEcdhKeyringInput(
109-
# Supported curve specifications:
110-
# - ECC_NIST_P256
111-
# - ECC_NIST_P384
112-
# - ECC_NIST_P521
113-
# - SM2
114109
curve_spec=curve_spec,
115110
key_agreement_scheme=RawEcdhStaticConfigurationsRawPrivateKeyToStaticPublicKey(
116111
RawPrivateKeyToStaticPublicKeyInput(
@@ -166,11 +161,6 @@ def ephemeral_raw_ecdh_keyring_put_item(ddb_table_name: str, curve_spec: str):
166161
mat_prov = AwsCryptographicMaterialProviders(config=MaterialProvidersConfig())
167162

168163
keyring_input = CreateRawEcdhKeyringInput(
169-
# Supported curve specifications:
170-
# - ECC_NIST_P256
171-
# - ECC_NIST_P384
172-
# - ECC_NIST_P521
173-
# - SM2
174164
curve_spec=curve_spec,
175165
key_agreement_scheme=RawEcdhStaticConfigurationsEphemeralPrivateKeyToStaticPublicKey(
176166
EphemeralPrivateKeyToStaticPublicKeyInput(recipient_public_key=public_key_bytes)
@@ -220,11 +210,6 @@ def discovery_raw_ecdh_keyring_get_item(ddb_table_name: str, curve_spec: str):
220210
mat_prov = AwsCryptographicMaterialProviders(config=MaterialProvidersConfig())
221211

222212
keyring_input = CreateRawEcdhKeyringInput(
223-
# Supported curve specifications:
224-
# - ECC_NIST_P256
225-
# - ECC_NIST_P384
226-
# - ECC_NIST_P521
227-
# - SM2
228213
curve_spec=curve_spec,
229214
key_agreement_scheme=RawEcdhStaticConfigurationsPublicKeyDiscovery(
230215
PublicKeyDiscoveryInput(recipient_static_private_key=private_key_utf8_encoded)

Examples/runtimes/python/DynamoDBEncryption/test/cleanup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
Test cleanup utilities for DynamoDB Encryption SDK.
55
66
This module provides utilities for cleaning up resources after running tests.
7-
NOTE: This is only a test utility and should not be used in production code.
7+
8+
WARNING: Please be careful. This is only a test utility and should NOT be used in production code.
89
It is specifically designed for cleaning up test resources after test execution.
10+
- Running this code on production resources or any data you want to keep could result
11+
in cryptographic shredding (permanent loss of access to encrypted data).
12+
- Only use this on test resources that you are willing to permanently delete.
13+
- Never run this against any production DynamoDB tables. Ensure you have backups
14+
of any important data before running cleanup operations.
915
"""
1016
import boto3
1117

Examples/runtimes/python/DynamoDBEncryption/test/keyring/test_raw_ecdh_keyring_example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""Test raw ECDH keyring examples."""
44
import pytest
5+
from aws_cryptography_primitives.smithygenerated.aws_cryptography_primitives.models import ECDHCurveSpec
56

67
from ...src.keyring.raw_ecdh_keyring_example import (
78
discovery_raw_ecdh_keyring_get_item,
@@ -28,7 +29,7 @@ def test_static_raw_ecdh_keyring_example():
2829

2930
# Part of using these keyrings is knowing which curve the keys used in the key agreement
3031
# lie on. The keyring will fail if the keys do not lie on the configured curve.
31-
raw_ecdh_keyring_get_item_put_item(TEST_DDB_TABLE_NAME, "ECC_NIST_P256")
32+
raw_ecdh_keyring_get_item_put_item(TEST_DDB_TABLE_NAME, ECDHCurveSpec.ECC_NIST_P256)
3233

3334

3435
def test_ephemeral_raw_ecdh_keyring_example():
@@ -43,7 +44,7 @@ def test_ephemeral_raw_ecdh_keyring_example():
4344

4445
# Part of using these keyrings is knowing which curve the keys used in the key agreement
4546
# lie on. The keyring will fail if the keys do not lie on the configured curve.
46-
ephemeral_raw_ecdh_keyring_put_item(TEST_DDB_TABLE_NAME, "ECC_NIST_P256")
47+
ephemeral_raw_ecdh_keyring_put_item(TEST_DDB_TABLE_NAME, ECDHCurveSpec.ECC_NIST_P256)
4748

4849

4950
def test_discovery_raw_ecdh_keyring_example():
@@ -65,9 +66,9 @@ def test_discovery_raw_ecdh_keyring_example():
6566

6667
# In this call we are writing a record that is written with an ephemeral sender key pair.
6768
# The recipient will be able to decrypt the message
68-
ephemeral_raw_ecdh_keyring_put_item(TEST_DDB_TABLE_NAME, "ECC_NIST_P256")
69+
ephemeral_raw_ecdh_keyring_put_item(TEST_DDB_TABLE_NAME, ECDHCurveSpec.ECC_NIST_P256)
6970

7071
# In this call we are reading a record that was written with the recipient's public key.
7172
# It will use the recipient's private key and the sender's public key stored in the message to
7273
# calculate the appropriate shared secret to successfully decrypt the message.
73-
discovery_raw_ecdh_keyring_get_item(TEST_DDB_TABLE_NAME, "ECC_NIST_P256")
74+
discovery_raw_ecdh_keyring_get_item(TEST_DDB_TABLE_NAME, ECDHCurveSpec.ECC_NIST_P256)

0 commit comments

Comments
 (0)