AWS KMS protection¶
Optional dependency and release status
This API is included in the 0.2.0 release. From the reviewed source
checkout, install its locked dependencies with
uv sync --extra aws-kms --locked. Use the exact-version command in the
installation guide
only after the signed release workflow completes.
aws_kms ¶
AWS KMS envelope protection without an AWS SDK dependency in the runtime.
SafeReference
module-attribute
¶
SafeReference = Annotated[str, StringConstraints(min_length=1, max_length=255), AfterValidator(_validate_safe_reference)]
KmsKeyIdentifier
module-attribute
¶
KmsKeyIdentifier = Annotated[str, StringConstraints(min_length=1, max_length=2048), AfterValidator(_validate_kms_key_id)]
__all__
module-attribute
¶
__all__ = ['AwsKmsEnvelopeProtection', 'GeneratedDataKey', 'KmsDataKeyClient', 'KmsKeyIdentifier', 'WrappedDataKey', 'WrappedDataKeyDeleteOutcome', 'WrappedDataKeyPersistenceOutcomeUnknownError', 'WrappedDataKeyStore']
KeyedCommitment ¶
ProposalBoundCommitmentProvider ¶
Bases: Protocol
Commitment provider bound to a complete tenant-scoped proposal identity.
create_for
async
¶
create_for(*, proposal_identity: ProposalIdentity, canonical_payload: bytes) -> KeyedCommitment
verify_for
async
¶
verify_for(*, proposal_identity: ProposalIdentity, canonical_payload: bytes, commitment: KeyedCommitment) -> bool
destroy_commitment_for
async
¶
destroy_commitment_for(*, proposal_identity: ProposalIdentity, commitment: KeyedCommitment) -> None
ProposalBoundProtectionCodec ¶
Bases: Protocol
Protection codec bound to a complete tenant-scoped proposal identity.
protect_for
async
¶
protect_for(*, proposal_identity: ProposalIdentity, canonical_payload: bytes) -> ProtectedPayload
unprotect_for
async
¶
unprotect_for(*, proposal_identity: ProposalIdentity, payload: ProtectedPayload) -> bytes
destroy_payload_for
async
¶
destroy_payload_for(*, proposal_identity: ProposalIdentity, payload: ProtectedPayload) -> None
ProtectedPayload ¶
ExperimentalModel ¶
ProposalIdentity ¶
GeneratedDataKey
dataclass
¶
WrappedDataKey ¶
Bases: ExperimentalModel
Durable proposal binding for one KMS-wrapped data key.
model_config
class-attribute
instance-attribute
¶
model_config = ConfigDict(hide_input_in_errors=True, ser_json_bytes='base64', val_json_bytes='base64')
WrappedDataKeyDeleteOutcome ¶
Bases: StrEnum
Authoritative result of atomic proposal-bound wrapped-key deletion.
KmsDataKeyClient ¶
Bases: Protocol
Minimal async port a host adapts to its AWS KMS client.
Generate adapters must copy AWS's plaintext response into a bytearray
and discard the SDK response before returning. The protection adapter
overwrites that buffer after use.
generate_data_key
async
¶
generate_data_key(*, key_id: str, encryption_context: Mapping[str, str], number_of_bytes: int) -> GeneratedDataKey
decrypt_data_key
async
¶
decrypt_data_key(*, key_id: str, ciphertext: bytes, encryption_context: Mapping[str, str]) -> bytes | bytearray
WrappedDataKeyStore ¶
Bases: Protocol
Durable, authoritative storage for proposal-scoped wrapped keys.
A completed write, including one whose acknowledgement is lost, must be
visible to a subsequent get through the same adapter.
delete_if_matches
async
¶
delete_if_matches(*, key_handle: str, proposal_identity: ProposalIdentity, purpose: EnvelopePurpose, key_version: str) -> WrappedDataKeyDeleteOutcome
WrappedDataKeyPersistenceOutcomeUnknownError ¶
WrappedDataKeyPersistenceOutcomeUnknownError(*, proposal_identity: ProposalIdentity, key_handle: str, purpose: EnvelopePurpose)
AwsKmsEnvelopeProtection ¶
AwsKmsEnvelopeProtection(*, key_id: str, kms: KmsDataKeyClient, envelopes: WrappedDataKeyStore)
Bases: ProposalBoundCommitmentProvider, ProposalBoundProtectionCodec
KMS-wrapped HMAC commitments and AES-256-GCM private snapshots.
The host supplies AWS SDK calls through KmsDataKeyClient and stores
wrapped keys separately through WrappedDataKeyStore. Deleting a wrapped
proposal key is the idempotent erasure boundary; the shared KMS key remains.
create_for
async
¶
create_for(*, proposal_identity: ProposalIdentity, canonical_payload: bytes) -> KeyedCommitment
verify_for
async
¶
verify_for(*, proposal_identity: ProposalIdentity, canonical_payload: bytes, commitment: KeyedCommitment) -> bool
destroy_commitment_for
async
¶
destroy_commitment_for(*, proposal_identity: ProposalIdentity, commitment: KeyedCommitment) -> None
protect_for
async
¶
protect_for(*, proposal_identity: ProposalIdentity, canonical_payload: bytes) -> ProtectedPayload
unprotect_for
async
¶
unprotect_for(*, proposal_identity: ProposalIdentity, payload: ProtectedPayload) -> bytes
destroy_payload_for
async
¶
destroy_payload_for(*, proposal_identity: ProposalIdentity, payload: ProtectedPayload) -> None
_encryption_context ¶
_encryption_context(*, key_handle: str, proposal_identity: ProposalIdentity, purpose: EnvelopePurpose) -> dict[str, str]
_authenticated_metadata ¶
_authenticated_metadata(*, key_handle: str, proposal_identity: ProposalIdentity, purpose: EnvelopePurpose, key_id: str, key_version: str) -> bytes