15 Commits
Author SHA1 Message Date
Radek e07030d81e Rewrite README with change log and full requirements
Replace README.md with a single comprehensive doc. Add a "What Changed"
section mapping each improvement to its commit (DRBG fix, health checks,
cleanup, HTTP service, auth, tests, docs). Expand Requirements into
software, system libraries, hardware, kernel-RNG, and container
subsections. Keep the existing usage, HTTP service, container, remote
consumption, and tests sections.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-09-02 13:10:38 +01:00
Radek de17686a9b Update README and notes for DRBG, health checks, and HTTP service
Rewrite README to reflect the actual pipeline (frame -> health check
-> SHA-256 -> HMAC-DRBG -> emit), document all entropy.py flags, the
HTTP service endpoints and env vars, container build/run, Kubernetes
notes, and the remote-consumption rngd flow. Fix the notes.md typos
and align its commands with the new --out flag.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-09-02 11:52:24 +01:00
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
Radek ab70195a07 Consolidate scripts, add requirements.txt, remove dead files
Remove entropy-rng-cam.py and entropy-rng-opencv.py, which were
superseded by entropy.py (args, loop mode, DRBG) and carried the same
unused-entropy bug. Remove the empty 0-byte `file`. Add requirements.txt
with pinned opencv and the FastAPI stack for the upcoming API stage.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-09-02 11:25:20 +01:00
Radek 8ac9ab92eb Add FIPS 140-2 health checks on raw frames
Add health.py with monobit, runs, and long-run tests (FIPS 140-2 Annex C
thresholds for a 20000-bit sample). Wire into entropy.py so raw JPEG
bytes are tested before hashing; a frozen or degraded camera frame is
rejected and not used to seed the DRBG. Runs thresholds are doubled
because we count 0-runs and 1-runs together. Add --no-health to disable.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-08-31 09:42:12 +01:00
Radek 239672ca63 Fix core RNG: seed HMAC-DRBG from camera frame hash
The previous version computed a SHA-256 of the frame into a variable
named `entropy` and then discarded it, drawing instead from the OS
CSPRNG via secrets.randbits(). The camera contributed nothing.

Replace with a NIST SP 800-90A HMAC-DRBG seeded from the frame hash so
the camera genuinely contributes entropy. Add --interval for loop
rate control, --out for writing raw bytes to a FIFO, mutual exclusion
of --loop/--single, and bit-multiple validation.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-08-31 09:41:12 +01:00
Radek a2dedb502e notes 2026-04-20 09:08:16 +01:00
Radek 9703eb7b9a bufer fix 2026-03-12 13:07:41 +00:00
Radek 853dceda87 random loop n flags 2026-03-12 10:25:06 +00:00
Radek ce4c9d9cbc random loop n flags 2026-03-12 10:18:21 +00:00
Radek ab36b50a30 random loop 2026-03-12 10:17:18 +00:00
Radek 139f74c530 more entropy 2026-03-12 09:42:53 +00:00
Radek 3f035dea5a more entropy 2026-03-12 09:39:24 +00:00
Radek dda1ecf619 initial scripts 2026-03-11 15:45:22 +00:00