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.dev5.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.dev5-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tigrbl_kms-0.3.0.dev5.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.dev5.tar.gz
Algorithm Hash digest
SHA256 1f8b0b7e6676a43a827665ae141a9e4e6843b956fad52cdad5fbec1fdb349389
MD5 7d150f7fff182d6fd2d03c9b872202be
BLAKE2b-256 68fa9441a50c9a2438401f9cd14d3c2fdacb6bad635e2bc1dc57af37f2ca78dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tigrbl_kms-0.3.0.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 b925deeb4da990c902dc0e3ae4e69cabb289adb259e7de6824d2b3faf639a771
MD5 0678fc7ee03b05f0a83d895f1986b014
BLAKE2b-256 a16d947110d03de2a6d9b19c676183e23b1e2588e0d9f2d63cd72624b397606f

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