Registry / aws / aws-cryptographic-material-providers

aws-cryptographic-material-providers

JSON →
library1.11.2pypypiunverified

The AWS Cryptographic Material Providers Library for Python offers advanced key management functionalities, primarily focusing on KMS keyrings, for use with the AWS Encryption SDK. It simplifies the process of obtaining and managing cryptographic materials from sources like AWS KMS. The current version is 1.11.2, and it receives updates typically several times a year, often in conjunction with the AWS Encryption SDK or for KMS feature enhancements.

pip install aws-cryptographic-material-providers
INSTALL
IMPORT
SIG · AWS-CRYPTOGRAPHIC-
A
aws-cryptographic-material-providers
awspythonv1.11.2
Install
5.3s avg
Import
Disk
82MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.11.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✓ —
✓ 5.95s
py 3.12
✓ —
✓ 5.33s
py 3.13
✓ —
✓ 4.73s
py 3.9
✕ build_error
✕ build_error
82MB installed
● package 82MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KmsKeyring
from aws_cryptographic_material_providers.mpl import KmsKeyring
from aws_cryptographic_material_providers.mpl import KmsKeyring

This quickstart demonstrates how to initialize `KmsKeyring` and use it with the `EncryptionSDKClient` from the `aws-encryption-sdk` to encrypt and decrypt data. A valid AWS KMS Key ARN and appropriate AWS credentials are required for successful execution. If `KMS_KEY_ARN` is not set, it will only demonstrate the keyring instantiation.

import os from aws_encryption_sdk import EncryptionSDKClient from aws_encryption_sdk.keyrings.kms import KmsKeyring import boto3 # Replace with your KMS Key ARN (e.g., arn:aws:kms:REGION:ACCOUNT:key/KEY_ID) KMS_KEY_ARN = os.environ.get("KMS_KEY_ARN", "arn:aws:kms:us-east-1:123456789012:key/EXAMPLE-KEY-ID") if "EXAMPLE-KEY-ID" in KMS_KEY_ARN: print("WARNING: Please set the KMS_KEY_ARN environment variable to a valid KMS key.") print("Example: export KMS_KEY_ARN=arn:aws:kms:us-east-1:123456789012:key/your-key-id") # Initialize the AWS Encryption SDK client client = EncryptionSDKClient() # Initialize the KMS Keyring # For production, consider passing an explicit boto3 KMS client for better control: # kms_client = boto3.client("kms", region_name=os.environ.get("AWS_REGION", "us-east-1")) # keyring = KmsKeyring(generator_key_id=KMS_KEY_ARN, client=kms_client) keyring = KmsKeyring(generator_key_id=KMS_KEY_ARN) # Example data to encrypt plain_text = b"my secret data" if "EXAMPLE-KEY-ID" not in KMS_KEY_ARN: # Encrypt the data ciphertext, header = client.encrypt(source=plain_text, keyring=keyring) print(f"Encrypted data (first 50 bytes): {ciphertext[:50]}...") # Decrypt the data decrypted_text, _ = client.decrypt(source=ciphertext, keyring=keyring) print(f"Decrypted data: {decrypted_text}") assert decrypted_text == plain_text print("Encryption and decryption successful!") else: print("\nKMS Keyring initialized. To perform actual encryption/decryption, set KMS_KEY_ARN and ensure AWS credentials are configured.") print("This quickstart demonstrates the instantiation and use of KmsKeyring within the AWS Encryption SDK context.")
Debug
Known issues
breakingThe library now requires Python 3.11 or newer. Older Python versions (e.g., 3.8, 3.9, 3.10) are no longer supported, leading to installation or runtime errors.
fix
Upgrade your Python environment to 3.11 or later. Check the `requires_python` field in PyPI for the latest requirements.
affects: <1.11.0
gotchaStrict dependency on specific `boto3` and `cryptography` versions. Installing incompatible versions of these libraries can lead to runtime errors or unexpected behavior due to API changes or missing features.
fix
Always install `aws-cryptographic-material-providers` in a clean virtual environment or ensure `pip install -U aws-cryptographic-material-providers` to let pip resolve compatible dependencies. Avoid manually pinning `boto3` or `cryptography` to versions outside the library's specified ranges (`~=1.34.0` for boto3, `~=42.0.5` for cryptography in 1.11.2).
affects: All versions
gotchaRelying on implicit `boto3` client creation for `KmsKeyring` can lead to issues in complex environments or when using specific region/config overrides. It's best practice to explicitly pass a configured `boto3` KMS client.
fix
When initializing `KmsKeyring`, provide an explicit `boto3.client('kms', region_name='...')` instance. For example: `kms_client = boto3.client('kms'); keyring = KmsKeyring(generator_key_id=KMS_KEY_ARN, client=kms_client)`.
affects: All versions
Upgrade
Version history
1.11.2latest on PyPI · released Feb 23, 2026
Audit
Dependencies
boto3requiredRequired for interacting with AWS KMS and other AWS services.
cryptographyrequiredProvides underlying cryptographic primitives and operations.
aws-encryption-sdkoptionalWhile this library provides material providers, its primary utility is realized when integrated with the AWS Encryption SDK for actual encryption/decryption operations. It's often installed as a dependency of the SDK.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources