Metadata-Version: 2.4
Name: cryptography-suite-hashicorp-vault
Version: 4.0.0b2
Summary: HashiCorp Vault Transit key provider 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-hashicorp-vault
Project-URL: Changelog, https://github.com/Psychevus/cryptography-suite/blob/main/CHANGELOG.md
Project-URL: Tracker, https://github.com/Psychevus/cryptography-suite/issues
Keywords: hashicorp,vault,transit,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: hvac
Requires-Dist: hvac>=2.1; extra == "hvac"

# cryptography-suite-hashicorp-vault

HashiCorp Vault Transit provider for
[cryptography-suite](https://github.com/Psychevus/cryptography-suite), the
policy-driven envelope encryption SDK.
Pre-release; not independently audited.

## Install

```console
python -m pip install "cryptography-suite-hashicorp-vault[hvac]"
```

## Use

```python
import hvac

from cryptography_suite import EncryptionContext, KeyRef, Policy, Protector
from cryptography_suite_hashicorp_vault import PROVIDER_ID, VaultTransitProvider

client = hvac.Client(url="https://vault.internal:8200", token=vault_token, timeout=5)
protector = Protector(
    provider=VaultTransitProvider(client, mount_point="transit", health_key="payments"),
    policy=Policy.enterprise(approved_providers=[PROVIDER_ID]),
    primary_key=KeyRef(PROVIDER_ID, "payments"),
    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 `hvac.Client`: address, authentication method, TLS, and
namespace are yours. The provider never reads tokens or the environment and
does not import hvac itself.

## Keys and permissions

| Item | Value |
| --- | --- |
| Keys | Transit keys of type `aes256-gcm96`, `aes128-gcm96`, or `chacha20-poly1305`, not derived and not convergent, named by key name. |
| Recorded version | The key version. After `vault write -f transit/keys/<name>/rotate`, `Protector.rewrap` moves envelopes to the new latest version. |
| To seal | `read` on `transit/keys/<name>`, `update` on `transit/encrypt/<name>` |
| To open | `update` on `transit/decrypt/<name>` |
| Health check | `read` on `transit/keys/<health_key>` |

```text
path "transit/keys/payments"    { capabilities = ["read"] }
path "transit/encrypt/payments" { capabilities = ["update"] }
path "transit/decrypt/payments" { capabilities = ["update"] }
```

## Behaviour

- **Binding.** Each wrap sends a digest of the envelope header as Transit
  `associated_data`, so Vault itself authenticates the binding. This needs a
  Vault release whose Transit API accepts `associated_data`.
- **Key states.** Versions below the key's `min_decryption_version` are
  reported as disabled, so opening falls back to another recipient, such as
  an escrow key.
- **Key names.** Names must follow Vault's own grammar for Transit keys.
  hvac does not escape `/` or `..` in request paths, so any other name is
  refused before a request is built.
- **Timeouts.** hvac sets its timeout per client (30 seconds by default), not
  per call, so the policy's `provider_timeout_ms` is checked between attempts
  but cannot cut a call short. Keep the client's `timeout` within it.
- **Errors.** Vault errors map to stable error codes; rate limits, sealed or
  standby nodes, and transport failures are retryable within the policy's
  budget.

## Documentation

- [Key services guide](https://github.com/Psychevus/cryptography-suite/blob/main/docs/guide/key-services.md)
- [Rotation and recovery](https://github.com/Psychevus/cryptography-suite/blob/main/docs/guide/rotation-and-recovery.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 on your Vault.
