S27: HPKE-Base content wrap + public-key directory; reject xor on send
Routing/error fields stay clear. Content is X25519-HKDF-SHA256-ChaCha20.
This commit is contained in:
parent
9cdc64b185
commit
94919185a9
8 changed files with 364 additions and 13 deletions
|
|
@ -13,7 +13,8 @@ from typing import Any, Dict, List, Optional # types
|
|||
from .error_bundle import NetworkErrorBundle, build_bundle, log_summary # failure path
|
||||
|
||||
|
||||
ALLOWED_ALG = {"npe", "lab-xor", "plain-lab"} # signed-config crypto.mode set
|
||||
ALLOWED_ALG = {"npe"} # production E2E; lab-xor/plain-lab rejected for content
|
||||
LAB_ALG = {"lab-xor", "plain-lab"} # only if SM_ALLOW_LAB=1
|
||||
|
||||
|
||||
class RouteResult:
|
||||
|
|
@ -65,7 +66,13 @@ def handle_send(
|
|||
return _fail("SM-PLAINTEXT-BODY", "mailbox", lid, sender_pub, system_pub, "body field forbidden")
|
||||
if not to: # catalog reject: missing to
|
||||
return _fail("SM-MISSING-TO", "mailbox", lid, sender_pub, system_pub, "missing to")
|
||||
if alg and alg not in ALLOWED_ALG: # alg not in signed config
|
||||
import os # SM_ALLOW_LAB
|
||||
|
||||
allow_lab = os.environ.get("SM_ALLOW_LAB") == "1"
|
||||
allowed = set(ALLOWED_ALG)
|
||||
if allow_lab:
|
||||
allowed |= LAB_ALG
|
||||
if alg and alg not in allowed: # xor/plain are not production content
|
||||
return _fail("SM-BAD-ALG", "mailbox", lid, sender_pub, system_pub, "alg not allowed")
|
||||
if alg != "plain-lab" and not ct: # empty ciphertext when not plain-lab
|
||||
return _fail("SM-EMPTY-CT", "mailbox", lid, sender_pub, system_pub, "empty ciphertext")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue