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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tigrbl_kms-0.3.0.dev3.tar.gz
Algorithm Hash digest
SHA256 70eec34e7beecbb0cf4d874154c89b751eca735e23c60fe6a458b2093979a3b1
MD5 8a8307a403c757afb6e2aaabeffc1b3d
BLAKE2b-256 edd942327e7d43d777b08f30a4ca9551aeff85c069518d07ab7bfd021420d8a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tigrbl_kms-0.3.0.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 ee5589cf73fdf2dd8024cb0386dd4289553ad078ed442e0ddb7e0aa9f8a287f6
MD5 5974b592136bc0502551303ba00bdf5a
BLAKE2b-256 27f861a289869d5fc18c2baf675ecb29878ebce344dbe2a4de4a876316a2a790

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