aws-cryptographic-materials-providers-library-python
These are the docs for the AWS Cryptographic Materials Providers Library for Python.
The latest full documentation can be found at Read the Docs.
Find us on GitHub.
Security
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our vulnerability reporting page. Please do not create a public GitHub issue.
Getting Started
Required Prerequisites
Python 3.11+
cryptography >= 43.0.1
boto3 >= 1.35.42
Installation
Note
If you have not already installed cryptography, you might need to install additional prerequisites as detailed in the cryptography installation guide for your operating system.
$ pip install aws-cryptographic-material-providers
Concepts
The AWS Cryptographic Materials Providers Library (MPL) is available in multiple languages. The concepts in the Python implementation of the MPL are the same as in other languages. For more information on concepts in the MPL, see the README for all languages.
Thread safety
The MaterialProviders client and all provided CryptoMaterialsManagers (CMMs) are thread safe.
But keyrings that call AWS Key Management Service (KMS) and CMMs that use keyrings that call KMS MUST not be shared between threads, for reasons outlined in the boto3 docs.
(Keyrings that call KMS are identified by the string Kms in their name. ex. AwsKmsKeyring, AwsKmsMrkDiscoveryMultiKeyring, etc.)
Finally, while the provided implementations of ICryptographicMaterialsCache are thread-safe,
there is currently no thread-safe keyring implementation that supports using a cache.
AWS Cryptographic Material Providers Library
📣 Note: This repository contains the source code and related files for all language implementations of the AWS Cryptographic Material Providers Library. See our supported languages section for more information.
The AWS Cryptographic Material Providers Library abstracts lower level cryptographic materials management of encryption and decryption materials. It uses cryptographic best practices to protect the data keys that protect your data. The data key is protected with a key encryption key called a wrapping key. The encryption method returns the data key and one or more encrypted data keys. Supported libraries use this information to perform envelope encryption. The data key is used to protect your data, and the encrypted data keys are stored alongside your data so you don’t need to keep track of the data keys separately. You can use AWS KMS keys in AWS Key Management Service(AWS KMS) as wrapping keys. The AWS Cryptographic Material Providers Library also provides APIs to define and use wrapping keys from other key providers.
The AWS Cryptographic Material Providers Library provides methods for encrypting and decrypting cryptographic materials used in higher level client side encryption libraries.
Security
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our vulnerability reporting page. Please do not create a public GitHub issue.
Getting Started
Repository structure
This repository is a top level repository which houses all source code in order to compile this library into different runtimes.
This library is written in Dafny, a formally verifiable programming language that can be compiled into different runtimes. This library is currently ONLY supported in Java, .NET, Python, Rust and Go.
Optional Prerequisites
AWS Integration
You don’t need an Amazon Web Services (AWS) account to use the AWS Cryptographic Material Providers Library, but some APIs require an AWS account, an AWS KMS key, or an Amazon DynamoDB Table. If you are using the AWS Cryptographic Material Providers Library for Java you will need the AWS SDK for Java V2. If you are using the AWS Cryptographic Material Providers Library for .NET you will need the AWS SDK for .NET V3. If you are using the AWS Cryptographic Material Providers Library for Python you will need boto3. If you are using the AWS Cryptographic Material Providers Library for Rust you will need the AWS SDK for Rust V1. If you are using the AWS Cryptographic Material Providers Library for Go you will need the AWS SDK for Go V2.
NOTE: The KmsAsyncClient and DynamoDBAsyncClient are not supported, only the synchronous clients.
To create an AWS account, go to Sign In or Create an AWS Account and then choose I am a new user. Follow the instructions to create an AWS account.
To create a symmetric encryption KMS key in AWS KMS, see Creating Keys.
To download and install the AWS SDK for Java 2.x, see Installing the AWS SDK for Java 2.x.
To download and install the AWS SDK for .Net 3.x see Installing the AWS SDK for .Net v3
To download and install boto3 see Installing boto3
To download and install the AWS SDK for Rust 1.x see Installing the AWS SDK for Rust v1
To download and install the AWS SDK for Go 2.x see Installing the AWS SDK for Go v2
Supported Languages
Java
.NET
Python
Rust
Go
Dafny
FAQ
See the Frequently Asked Questions page in the official documentation.
Modules
Changelog
Note: Starting April 20, 2026, all runtime-specific changes are tracked in separate changelogs:
Java: CHANGELOG-java.md
.NET: CHANGELOG-dotnet.md
Python: CHANGELOG-python.md
Go: CHANGELOG.md (Go has always maintained its changelog in a separate directory)
If a runtime-specific changelog is not present, there has been no new release for that runtime after April 20, 2026.
Each changelog entry below applies to all runtimes unless specified by a language suffix.
2.0.0-net (2026-03-11)
This release is available only in the following languages:
DotNet (as v2.0.0)
⚠ BREAKING CHANGES
.net: Add support for AWS SDK V4 and remove support for AWS SDK V3.
feat
1.11.2 (2026-02-02)
This release is available in the following languages:
DotNet
Python
NOTE
This library is NOT impacted by CVE-2026-26007. This library does not use SECT curves.
Fixes – DotNet
Maintenance – All Languages
Maintenance – Python
Maintenance – Go
Maintenance – Rust
Miscellaneous
1.11.1 (2025-07-29)
This release is available in the following languages:
Python
Maintenance – All Languages
Maintenance – Python
Maintenance – Go
Maintenance – Rust
Miscellaneous
cfn: add trusted policy for optools mpl-python roles (#1602) (436d939)
CI: fix daily CI and add slack notification to it (#1647) (c546646)
CI: Test Rust on Dafny prerelease in nightly build (#1623) (92070bc)
CI: update to not trigger workflow on PR comments (#1640) (c62e8cf)
deps: bump slackapi/slack-github-action from 2.1.0 to 2.1.1 in /.github/workflows (#1638) (40b643f)
Go: Add Go release script and workflow to run it (#1562) (1c563bd)
1.11.0 (2025-06-17)
This release is available in the following languages:
Java
Python
Fixes – All Languages
Maintenance – All Languages
dafny: BK fix to extract encryption context for branch key materials (#1523) (95856ac)
dafny: don’t recalculate RSA key on every decrypt (#1448) (f318912)
dafny: store privateKey in RawRSAKeyring because some Java code needs it (#1450) (1c29322)
dafny: support for memory size constraints (#1481) (8d2c2b5)
dafny: update UInt and MemoryMath as needed for DB-ESDK (#1488) (49e596b)
Maintenance – Java
Maintenance – Go
Maintenance – Rust
Miscellaneous
add MPL CI to principal of KmsKeyForRobbieOnly (#1528) (527f69d)
CFN for two new roles to prove prefixing/defixing behavior (#1538) (e810e7d)
Create Static Key Store table for storing static branch keys (#1456) (96b8058)
dafny: add tests for multiple utf8 ec entries (#1424) (131ae58)
install polymorph dependencies in github workflows (#1514) (eb68525)
1.10.1 (2025-03-27)
This release is available in the following languages:
Java
Maintenance – All Languages
Maintenance – Java
Miscellaneous
1.10.0 (2025-03-24)
This release is available in the following languages:
Python
Miscellaneous – Python
Miscellaneous
1.9.0 (2025-02-03)
This release is available in the following languages:
Java
Bug Fixes
CI (d9e2a1e)
DafnyLibraries.FileIO extern (b150c48)
ECDH ValidatePublicKey err msg (34a48fc)
GHW: check-files apply to PR, not to diff b/w HEAD and branch (#1075) (1f53a92)
line breaks (21536c7)
PR comments (798214b)
PR comments (a21c0b3)
PR comments (7dd95bc)
PR comments (eed0d87)
PR comments (435515e)
region (5930ae4)
region (e3454b5)
remove @sensitive from smithy models (#1123) (c939f3a)
revert pyproject.toml drop (b5dbb5c)
rust code used for testing must be allowed dead code (#1148) (5997919)
SetToSequence should be a method, not a function (#1035) (1169bc8)
Features
1.8.0 (2024-11-19)
This release is available in the following languages:
Java
Bug Fixes
Drop SelectOpt from MutableMap (bdb6509)
Externs (0bc1f96)
formatting (b608ab8)
Python-Release: Run validate tests from release commit (41c0c94)
Python: CMCs release lock for unhandled runtime exceptions (#979) (1510b77)
remove input and output traits on DynamoDB operations (#1012) (8377acf)
rust CI (42e39cc)
Features
1.7.4 (2024-11-06)
This release is available in the following languages:
Python
Bug Fixes
1.7.3 (2024-10-31)
This release is available in the following languages:
Python
Bug Fixes
1.7.2 (2024-10-22)
This release is available in the following languages:
Python
Bug Fixes
1.7.1 (2024-10-11)
This release is available in the following languages:
Python
This is the first release for the Python implementation of the AWS Cryptographic Material Providers Library. (#805) (cfb2f7e)
Bug Fixes
1.7.0 (2024-09-23)
Features
1.6.0 (2024-09-10)
Bug Fixes
Features
1.5.1 (2024-07-08)
Fixes
1.5.0 (2024-06-17)
Features
1.4.0 (2024-05-20)
Features
The Hierarchical Keyring’s Keystore now supports four (4) KMSConfigurations:
kmsKeyArn
kmsMRKeyArn
discovery
mrDiscovery
See our JavaDocs for details on how these options effect the relationship between a Keystore and KMS.
Maintenance
.NET : Bump dependency BouncyCastle.Cryptography from 2.2.1 to 2.3.1. (#329)
.NET : Bump dependency AWSSDK.Core from 3.7.300.2 to 3.7.304.2. (#329)
Java : Move InternalResult into StandardLibrary(Internal) (#325)
1.3.0 (2024-04-24)
Bug Fixes
Features
1.2.0 (2024-01-08)
Features
* add command line parser (#131)
Bug Fixes
* resolve awssdk:core dependency in TestVectors build.gradle.kts (#177)
* add more tests to ComputeSetToOrderedSequence (#111)
* Empty string defers to SDK default region (#127)
* update mpl .csproj to use project references (#134)
* newest polymorph for newest shims. Catch all exceptions. DDB only (#135)
* update README for repo rename update (#147)
* rerun latest polymorph. (#128)
* typo lead to two verification, no format (#130)
* Improve compatibility with Dafny 4.4 (#129)
Maintenance
* A variety of fixes to the libraries CI and testing
1.0.2 (2023-10-18)
Bug Fixes
* CmpError must return custom error message (#118) (86abacc)
* Deafult entryPruningTailSize (#93) (0344e9f)
* Fix brittle concurrent test (#105) (#60) (c043162)
* fix typo in encryption materials validation (cd6b0aa), closes #84
* fix typo in encryption materials validation (89a234c)
* Forward the underlying error (#90) (bc21551)
1.0.1 2023-07-26
Fix
Fixes a runtime check in
VersionKeyKey Store API that no longer checks for the CipherText length on the output of a KMS ReEncrypt API call.
1.0.0 2023-07-21
Features
Introduces Thread Safe Cryptographic Materials Caches (CMCs):
Storm Tracking Cache Safe for use in a multi threaded environment, tries to prevent redundant or overly parallel backend calls. See Spec changes for details.
Multi Threaded Cache Safe for use in a multi threaded environment, but no extra functionality
BREAKING CHANGES
CMCs:
Original Cryptographic Materials Cache has been renamed to Single Threaded Cache
CreateCryptographicMaterialsCacheInputnow ONLY acceptsCacheType, which determines which, if any, of the three implemented CMCs will be returned.The
DefaultCacheisStormTrackingCache
CreateAwsKmsHierarchicalKeyringInput:no longer has a
maxCacheSizefieldnow has an optional
cachefield for aCacheType
Hierarchical Keyring’s Key Store:
The Hierarchical Keyring’s Key Store’s Data Structure has changed. As such, entries persisted in the Key Store with prior versions of this library are NOT compatibale. Instead, we recommend Creating a new DynamoDB Table for this version of the Key Store.
The Key Store’s
CreateKeyInputnow takes:An Optional
String branchKeyIdentifierAn Optional
EncryptionContext encryptionContextThis
encryptionContextwill be added to the Encryption Context sent to KMS prefixed withaws-crypto-ec:
Creating a Key now also calls KMS:ReEncrypt
CreateKeyStoreno longer creates a GSIThe Encryption Context used with KMS’
GenerateDataKeyWithoutPlaintextno longer include’s the discarded GSI’sstatus.More details about the Key Store’s changes are avaible in our Specification:
Maintenance
A variety of fixes to the libraries CI and testing
Fix
Fixes Required Encryption Context CMM and UpdateUsageMetadata names in smithy model
1.0.0-preview-3 2023-06-22
Fix
Fixes PutCacheEntry
PutCacheEntry will now update an entry. This simplifies using the cache in concurrent situations. Rather than having the caller implement some retry logic the cache will now update the entry.
Fixes pom.xml to include runtime version of BouncyCastle and removes bundling of BC in the jar.
1.0.0-preview-2 2023-06-19
Fix
Fixes build file to correctly generate pom file with correct dependencies during release.
1.0.0-preview-1 2023-06-07
Features
Initial release of the AWS Cryptographic Material Providers Library. This release is considered a developer preview and is not intended for production use cases.