Files
schattenpost/web/_interop_rawrgb.py
Claude Code 7569cd3fab SPS3: Poly1305-Einmal-MAC + Public-Ready README/LICENSE
Authentifizierung für CLI und Web:
- Poly1305 (RFC 8439) pur in Python (bigint) und JS (BigInt), keine neue Dependency
- MAC-Schluessel pro Nachricht frisch aus dem Pad (len+32), encrypt-then-MAC
  ueber Header + Ciphertext; reveal lehnt manipulierte/desynchrone Bilder hart ab
- Stego-Format SPS2 -> SPS3 (16-B-Tag im Header); alte SPS2-Bilder werden noch
  gelesen, aber als unauthentifiziert markiert
- Service-Worker-Cache auf v3 gebumpt
- Interop-Runner (web/_interop_run.sh): RFC-Vektor cross-impl, beide Richtungen,
  Tamper-Erkennung

README fuer Public ueberarbeitet (ehrliches Bedrohungsmodell, Voraussetzungen,
Projektstruktur, Tests) + MIT-LICENSE.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-15 10:46:04 +00:00

25 lines
979 B
Python

#!/usr/bin/env python3
"""Test-Helfer: PNG <-> rohes RGB-Byte-Array (nur für den Interop-Test)."""
import os
import sys
from PIL import Image
if sys.argv[1] == "mkcarrier": # mkcarrier <out.png> <W> <H> -> Rausch-Trägerbild
w, h = int(sys.argv[3]), int(sys.argv[4])
img = Image.frombytes("RGB", (w, h), os.urandom(w * h * 3))
img.save(sys.argv[2], "PNG")
print("ok")
elif sys.argv[1] == "png2rgb": # png2rgb <in.png> <out.bin> -> stdout: "W H"
img = Image.open(sys.argv[2]).convert("RGB")
w, h = img.size
with open(sys.argv[3], "wb") as fh:
fh.write(bytes([v for px in img.getdata() for v in px]))
print(w, h)
elif sys.argv[1] == "rgb2png": # rgb2png <in.bin> <W> <H> <out.png>
w, h = int(sys.argv[3]), int(sys.argv[4])
data = open(sys.argv[2], "rb").read()
img = Image.new("RGB", (w, h))
img.putdata([tuple(data[i:i + 3]) for i in range(0, len(data), 3)])
img.save(sys.argv[5], "PNG")
print("ok")