Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Cyphera Keychain — Python

CI Security License Key provider abstraction for the Cyphera Python SDK.

Installation

pip install cyphera-keychain

Usage

Memory provider (testing / development)

from cyphera_keychain import MemoryProvider, KeyRecord, Status

provider = MemoryProvider(
    KeyRecord(
        ref="customer-primary",
        version=1,
        status=Status.ACTIVE,
        material=bytes.fromhex("0123456789abcdef0123456789abcdef"),
        tweak=b"customer-ssn",
    )
)

record = provider.resolve("customer-primary")

Environment variable provider

from cyphera_keychain import EnvProvider

# Reads CYPHERA_CUSTOMER_PRIMARY_KEY (hex or base64)
provider = EnvProvider(prefix="CYPHERA")
record = provider.resolve("customer-primary")

File provider

from cyphera_keychain import FileProvider

provider = FileProvider("/etc/cyphera/keys.json")
record = provider.resolve("customer-primary")

Key file format:

{
  "keys": [
    {
      "ref": "customer-primary",
      "version": 1,
      "status": "active",
      "algorithm": "adf1",
      "material": "<hex or base64>",
      "tweak": "<hex or base64>"
    }
  ]
}

Providers

Provider Description Use case
MemoryProvider In-memory key store Testing, development
EnvProvider Keys from environment variables 12-factor / container deployments
FileProvider Keys from a local JSON file Secrets manager file injection
AwsKmsProvider AWS KMS data-key generation AWS workloads
GcpKmsProvider GCP Cloud KMS envelope encryption GCP workloads
AzureKvProvider Azure Key Vault RSA key-wrapping Azure workloads
VaultProvider HashiCorp Vault KV v2 secrets Multi-cloud / on-prem

Cloud KMS Providers

Cyphera ships four cloud-native providers for production deployments. Each generates or retrieves a 256-bit AES data key via the respective KMS service and caches the plaintext for the lifetime of the provider object.

AWS KMS

pip install "cyphera-keychain[aws]"
from cyphera_keychain import AwsKmsProvider

provider = AwsKmsProvider(
    "arn:aws:kms:us-east-1:123456789012:key/my-key-id",
    region="us-east-1",
)

record = provider.resolve("customer-primary")
# record.material  ->  32-byte AES-256 data key

The provider calls GenerateDataKey with KeySpec=AES_256 and sets EncryptionContext={"cyphera:ref": ref} for auditability. Results are cached per ref so subsequent calls within the same process do not incur additional KMS API calls.

GCP Cloud KMS

pip install "cyphera-keychain[gcp]"
from cyphera_keychain import GcpKmsProvider

KEY_NAME = (
    "projects/my-project/locations/global"
    "/keyRings/my-ring/cryptoKeys/my-key"
)

provider = GcpKmsProvider(KEY_NAME)
record = provider.resolve("customer-primary")

A random 32-byte plaintext key is generated locally with os.urandom(32) and wrapped via Encrypt (with the ref as additional authenticated data). The plaintext is cached in memory; the ciphertext is discarded after wrapping.

Azure Key Vault

pip install "cyphera-keychain[azure]"
from cyphera_keychain import AzureKvProvider

provider = AzureKvProvider(
    vault_url="https://my-vault.vault.azure.net",
    key_name="my-rsa-key",
)

record = provider.resolve("customer-primary")

A random 32-byte key is wrapped with the named RSA key using RSA-OAEP via the Azure Key Vault CryptographyClient. Authentication defaults to DefaultAzureCredential; pass a custom credential to override.

HashiCorp Vault (KV v2)

pip install "cyphera-keychain[vault]"
from cyphera_keychain import VaultProvider

provider = VaultProvider(
    url="https://vault.internal.example.com",
    token="s.mytoken",
    mount="secret",
)

record = provider.resolve("customer-primary")

Key records are read from Vault KV v2 at path {mount}/{ref}. The secret data must contain version, status, algorithm, and material fields (hex or base64). Multi-version keys can be stored as a versions JSON array for rotation support.

License

Apache 2.0

Metadata

Release files for cyphera-keychain 0.0.1a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cyphera-keychain 0.0.1a1
File Size Uploaded
cyphera_keychain-0.0.1a1.tar.gz 18.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cyphera-keychain 0.0.1a1
File Interpreter ABI Platform
cyphera_keychain-0.0.1a1-py3-none-any.whl Python 3 none any Details

Total release size: 35.6 kB

Release files / cyphera_keychain-0.0.1a1.tar.gz

Download URL cyphera_keychain-0.0.1a1.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bac85db2bda155302fa5cac23efddd36338495529f1531181a7ade684f489ac6
BLAKE2b-256 checksum
How to use checksums
5a111b54574bad5a15a89661c9033fe4511bc0d62eee407a455d2cdd29ef6fc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Release files / cyphera_keychain-0.0.1a1-py3-none-any.whl

Download URL cyphera_keychain-0.0.1a1-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2747ec4c5e5f8dad6710153a66075094a39fdf0e154266ef7463aa5c706d3679
BLAKE2b-256 checksum
How to use checksums
bfba4158362ce53a408f10f36972ce047909ef2ba5b0fc5d69886e570113418a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.1a1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page