Skip to main content

A Tigrbl key management service for Swarmauri.

Project description

Tigrbl Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - tigrbl_kms


Tigrbl KMS

Tigrbl KMS provides a lightweight key management service built on FastAPI.

Deploy

Run the service with the provided CLI:

uv run --package tigrbl_kms --directory pkgs/standards/tigrbl_kms tigrbl-kms --host 127.0.0.1 --port 8000 --no-reload

Verify

Once the service starts, you can verify it is running:

curl http://127.0.0.1:8000/system/healthz

The endpoint returns {"ok": true} when deployment succeeds.

Create a key and encrypt data

Initialize the SQLite database:

uv run --package tigrbl_kms --directory pkgs/standards/tigrbl_kms -- python - <<'PY'
from tigrbl_kms.app import engine
from tigrbl.orm.tables import Base
import asyncio

async def init():
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)

asyncio.run(init())
PY

Start a demo server that injects a simple crypto provider:

uv run --package tigrbl_kms --directory pkgs/standards/tigrbl_kms -- python - <<'PY'
import uvicorn
from tigrbl_kms.app import app
from types import SimpleNamespace

class DummyCrypto:
    async def encrypt(self, *, kid, plaintext, alg, aad=None, nonce=None):
        return SimpleNamespace(nonce=b'n', ct=plaintext[::-1], tag=b't', version=1, alg=alg)

    async def decrypt(self, *, kid, ciphertext, nonce, tag=None, aad=None, alg=None):
        return ciphertext[::-1]

@app.middleware("http")
async def add_crypto(request, call_next):
    request.state.crypto = DummyCrypto()
    return await call_next(request)

uvicorn.run(app, host="127.0.0.1", port=8000, reload=False)
PY

In another terminal, create a key:

curl -s -X POST http://127.0.0.1:8000/kms/Key \
  -H "Content-Type: application/json" \
  -d '{"name":"demo","algorithm":"AES256_GCM"}'

Example response:

{"id":"5e454eb6-7739-453b-9aee-21d60032a773","name":"demo","algorithm":"AES256_GCM","status":"enabled","primary_version":1}

Encrypt some data with the key (the plaintext must be base64-encoded):

PLAINTEXT=$(echo -n 'hello world' | base64)
curl -s -X POST http://127.0.0.1:8000/kms/Key/5e454eb6-7739-453b-9aee-21d60032a773/encrypt \
  -H "Content-Type: application/json" \
  -d "{\"plaintext_b64\":\"$PLAINTEXT\"}"

Sample output:

{"kid":"5e454eb6-7739-453b-9aee-21d60032a773","version":1,"alg":"AES256_GCM","nonce_b64":"bg==","ciphertext_b64":"ZGxyb3cgb2xsZWg=","tag_b64":"dA=="}

The ciphertext is base64 encoded and can be decrypted with the corresponding decrypt endpoint.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tigrbl_kms-0.3.0.dev4.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tigrbl_kms-0.3.0.dev4-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file tigrbl_kms-0.3.0.dev4.tar.gz.

File metadata

  • Download URL: tigrbl_kms-0.3.0.dev4.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for tigrbl_kms-0.3.0.dev4.tar.gz
Algorithm Hash digest
SHA256 8157ee08ab436df42a96d713d32094a31b66ccd76c65954bc3a48ae4ae71e9df
MD5 07161cb2c2a26d6e829513b4f86fd8aa
BLAKE2b-256 063c6da1588d424924e6ec2e99f4aa045b6ad31c24ff1d79752b338b2ed9f882

See more details on using hashes here.

File details

Details for the file tigrbl_kms-0.3.0.dev4-py3-none-any.whl.

File metadata

File hashes

Hashes for tigrbl_kms-0.3.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 f300638af4c9c7bb42b2183e90cad86bf6279512dbd10b4d54fb9bf216aef3c2
MD5 e943c5b53b9d12f0cf13ee743c979f0f
BLAKE2b-256 aaede5c92e2b93c71016c1b5ac080281940d34dbddda45493c60aec604ce90fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page