Metadata-Version: 2.4
Name: cryptography-suite-gcp-kms
Version: 4.0.0b2
Summary: Google Cloud KMS key provider, including ML-KEM and X-Wing keys, for cryptography-suite v4 envelope encryption (pre-release; not independently audited).
Author: Mojtaba Zaferanloo
License-Expression: MIT
Project-URL: Homepage, https://github.com/Psychevus/cryptography-suite
Project-URL: Documentation, https://psychevus.github.io/cryptography-suite
Project-URL: Source, https://github.com/Psychevus/cryptography-suite/tree/main/packages/cryptography-suite-gcp-kms
Project-URL: Changelog, https://github.com/Psychevus/cryptography-suite/blob/main/CHANGELOG.md
Project-URL: Tracker, https://github.com/Psychevus/cryptography-suite/issues
Keywords: google-cloud,kms,ml-kem,post-quantum,envelope-encryption,cryptography
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Security :: Cryptography
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: cryptography-suite==4.0.0b2
Provides-Extra: google
Requires-Dist: google-cloud-kms>=3.0; extra == "google"

# cryptography-suite-gcp-kms

Google Cloud KMS provider for
[cryptography-suite](https://github.com/Psychevus/cryptography-suite), the
policy-driven envelope encryption SDK, including post-quantum ML-KEM and
X-Wing keys. Pre-release; not independently audited.

## Install

```console
python -m pip install "cryptography-suite-gcp-kms[google]"
```

## Use

```python
from google.cloud import kms

from cryptography_suite import EncryptionContext, KeyRef, Policy, Protector
from cryptography_suite_gcp_kms import PROVIDER_ID, GcpKmsProvider

key = "projects/acme/locations/europe-west4/keyRings/data/cryptoKeys/payments"
protector = Protector(
    provider=GcpKmsProvider(kms.KeyManagementServiceClient(), health_key=key),
    policy=Policy.enterprise(approved_providers=[PROVIDER_ID]),
    primary_key=KeyRef(PROVIDER_ID, key),
    audit_sink=audit_sink,
)
context = EncryptionContext({"tenant": "acme"}, purpose="payments")
envelope = protector.seal(b"...", context=context)
plaintext = protector.open(envelope, context=context)
```

You build the client: project, credentials, and transport are yours. The
provider never reads credentials or the environment and does not import the
Google libraries itself.

## Keys and permissions

| Item | Value |
| --- | --- |
| Keys | `ENCRYPT_DECRYPT` CryptoKeys (`GOOGLE_SYMMETRIC_ENCRYPTION`), named by CryptoKey resource name. Post-quantum: `KEY_ENCAPSULATION` CryptoKeys with `ML_KEM_768`, `ML_KEM_1024`, or `KEM_XWING`, named with an explicit CryptoKeyVersion. |
| Recorded version | The CryptoKeyVersion resource name. After rotating, `Protector.rewrap` moves envelopes to the new primary version without touching their records. |
| To seal | `roles/cloudkms.cryptoKeyEncrypter` and `roles/cloudkms.viewer`; for KEM keys, `roles/cloudkms.publicKeyViewer` and `roles/cloudkms.viewer` |
| To open | `roles/cloudkms.cryptoKeyDecrypter`; for KEM keys, `roles/cloudkms.decapsulator` |
| Health check | `cloudkms.cryptoKeys.get` on `health_key` |

## Behaviour

- **Binding.** Symmetric wraps call `Encrypt` on the exact version with the
  additional authenticated data `"cryptography-suite/v4 binding" || 0x00 ||
  SHA-256(protected header)`. Every request and response is checked end to
  end with CRC32C.
- **Post-quantum keys.** KEM wraps are standard RFC 9180 HPKE ciphertexts.
  Encapsulation runs locally on the version's public key (fetched once,
  checked, and cached) and needs ML-KEM in pyca/cryptography; unwrapping
  calls `Decapsulate`, so the private key never leaves Cloud KMS and the
  reader needs no ML-KEM support.
- **Timeouts.** Every call passes `retry=None` and a timeout of the time left
  before the operation's deadline, so the library's own retries (up to 60
  seconds per call by default, and none at all for `Decapsulate`) never
  apply and `provider_timeout_ms` holds.
- **Errors.** Cloud KMS errors map to stable error codes; quota and transient
  service errors are retryable within the policy's budget.

## Documentation

- [Key services guide](https://github.com/Psychevus/cryptography-suite/blob/main/docs/guide/key-services.md)
- [Post-quantum protection](https://github.com/Psychevus/cryptography-suite/blob/main/docs/guide/post-quantum.md)
- [Security policy](https://github.com/Psychevus/cryptography-suite/blob/main/SECURITY.md)

`cryptography_suite.providers.conformance.verify_provider` checks the
provider against a test key in your project.
