AWS Cryptography Internal Standard Library

1.11.2 · active · verified Thu Apr 16

The `aws-cryptography-internal-standard-library` is an internal Python library, a foundational component primarily utilized by the AWS Cryptographic Material Providers Library (MPL) and subsequently by the AWS Encryption SDK. It provides cryptographic primitives and standard library interfaces for other AWS cryptography projects. Users are strongly advised against taking a standalone dependency on this library, as its internal nature means there are no guarantees about API stability or functionality between minor versions. The current version is 1.11.2, and its release cadence aligns with its dependent AWS cryptography libraries.

Common errors

Warnings

Install

Imports

Quickstart

This library is designed for internal use by other AWS cryptography projects, not for direct public consumption. Attempting to use it directly may lead to unpredictable behavior and breaking changes. The recommended way to leverage AWS cryptographic best practices is through higher-level libraries such as the AWS Encryption SDK, which internally manages and utilizes this standard library. The commented-out example demonstrates how you would typically encrypt and decrypt data using the AWS Encryption SDK, which is the intended interface for end-users.

print('The aws-cryptography-internal-standard-library is an internal dependency.')
print('Direct interaction is not recommended as its API is unstable and not for public use.')
print('Instead, use public-facing libraries like the AWS Encryption SDK (aws-encryption-sdk).')

# Example of how you would typically interact with encryption functionality
# through the AWS Encryption SDK, which internally uses libraries like this one.
# This code snippet is for illustration and requires additional setup (AWS credentials, KMS key).

# import aws_encryption_sdk
# from aws_encryption_sdk.keyrings.aws_kms import AwsKmsKeyring

# key_arn = os.environ.get('KMS_KEY_ARN', 'arn:aws:kms:us-west-2:111122223333:key/example-key-id')
# plaintext = b'my secret data'

# try:
#     # Instantiate the AWS Encryption SDK client
#     client = aws_encryption_sdk.EncryptionSDKClient()

#     # Create a KMS Keyring (this uses the AWS Cryptographic Material Providers Library internally)
#     keyring = AwsKmsKeyring(key_ids=[key_arn])

#     # Encrypt the data
#     ciphertext, header = client.encrypt(source=plaintext, keyring=keyring)
#     print(f'Ciphertext: {ciphertext.hex()}')

#     # Decrypt the data
#     decrypted_plaintext, _ = client.decrypt(source=ciphertext, keyring=keyring)
#     print(f'Decrypted plaintext: {decrypted_plaintext.decode()}')

# except Exception as e:
#     print(f'Error demonstrating AWS Encryption SDK: {e}')
#     print('Please ensure AWS credentials and a valid KMS_KEY_ARN are configured.')

view raw JSON →