Skip to content

Commit 7f95db8

Browse files
committed
added README; minor fix
1 parent f1fca97 commit 7f95db8

4 files changed

+21
-18
lines changed

examples/src/migration/README.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
##################
2+
Migration Examples
3+
##################
4+
5+
The native Python ESDK now uses the `AWS Cryptographic Material Providers Library`_,
6+
which introduces keyrings in place of the Master Key Provider. The MPL abstracts lower
7+
level cryptographic materials management of encryption and decryption materials.
8+
9+
This directory contains some examples to migrate from the legacy Master Key Providers
10+
to keyrings. Here is the list of examples:
11+
1. Migration to AWS KMS Keyring from AWS KMS Master Key Provider
12+
2. Migration to Raw AES Keyring from Raw AES Master Key Provider
13+
3. Migration to Raw RSA Keyring from Raw RSA Master Key Provider
14+
4. Setting a 'CommitmentPolicy' during migration
15+
16+
.. _AWS Cryptographic Material Providers Library: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html

examples/src/migration/migration_to_aws_kms_keyring_from_aws_kms_master_key_provider_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
For more information on how to use KMS keyrings, see
2121
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html
2222
"""
23-
2423
import boto3
2524
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
2625
from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig

examples/src/migration/migration_to_raw_aes_keyring_from_raw_aes_master_key_provider_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
For more information on how to use Raw AES keyrings, see
2525
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-raw-aes-keyring.html
2626
"""
27+
import secrets
2728

2829
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
2930
from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig
@@ -46,8 +47,7 @@
4647
"the data you are handling": "is what you think it is",
4748
}
4849

49-
DEFAULT_AES_256_STATIC_KEY = \
50-
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'
50+
DEFAULT_AES_256_STATIC_KEY = secrets.token_bytes(32)
5151

5252
DEFAULT_KEY_NAME_SPACE = "Some managed raw keys"
5353

examples/src/migration/migration_to_raw_rsa_keyring_from_raw_rsa_master_key_provider_example.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@
2828
For more information on how to use Raw RSA keyrings, see
2929
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-raw-rsa-keyring.html
3030
"""
31-
32-
33-
import aws_encryption_sdk
34-
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
35-
from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig
36-
from aws_cryptographic_materialproviders.mpl.models import CreateRawRsaKeyringInput, PaddingScheme
37-
from aws_cryptographic_materialproviders.mpl.references import IKeyring
38-
import aws_encryption_sdk
39-
from aws_encryption_sdk.identifiers import EncryptionKeyType, WrappingAlgorithm
40-
from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey
41-
from aws_encryption_sdk.key_providers.raw import RawMasterKeyProvider
42-
from typing import Dict # noqa pylint: disable=wrong-import-order
43-
import sys
44-
4531
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
4632
from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig
4733
from aws_cryptographic_materialproviders.mpl.models import CreateRawRsaKeyringInput, PaddingScheme
@@ -54,7 +40,9 @@
5440
import aws_encryption_sdk
5541
from aws_encryption_sdk import CommitmentPolicy
5642
from aws_encryption_sdk.exceptions import AWSEncryptionSDKClientError
57-
43+
from aws_encryption_sdk.identifiers import EncryptionKeyType, WrappingAlgorithm
44+
from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey
45+
from aws_encryption_sdk.key_providers.raw import RawMasterKeyProvider
5846

5947
EXAMPLE_DATA: bytes = b"Hello World"
6048

0 commit comments

Comments
 (0)