2 Commits
Author SHA1 Message Date
Radek d121b0f0f6 Add test suite and switch API to lifespan handler
test_entropy.py covers the HMAC-DRBG (determinism, reseed, length,
reseed limit), health checks (random passes, frozen/all-ones/short/
long-run rejected), a bit-balance smoke test on DRBG output, and the
API endpoints including auth gating. All 16 tests pass without a
camera (producer is stubbed).

Switch api.py from the deprecated @app.on_event('startup') to the
lifespan async context manager. Add pytest to requirements.txt.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-09-02 11:51:55 +01:00
Radek 1b99573b65 Add FastAPI entropy service with simple API-key auth and Dockerfile
api.py runs the camera producer in a background thread and serves the
latest entropy blob over HTTP. Endpoints: GET / (info), GET /healthz
(liveness, unauthenticated), GET /entropy (returns {hex, bits, ts}).
Auth is a single shared secret via X-API-Key header, controlled by the
ENTROPY_API_KEY env var; empty means no auth, so it is easy to start
open and lock down later. All config is via env vars for containers.

Dockerfile uses python:3.12-slim, installs OpenCV runtime libs, pins
deps from requirements.txt, exposes 8000, and has a healthcheck against
/healthz. Run with: docker build -t entropy-rng . && docker run -p 8000:8000 \
-e ENTROPY_CAMERA_URL=http://192.168.0.200/mjpg/video.mjpg entropy-rng

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-09-02 11:51:19 +01:00