From befaf8e8a89af110af87207e2fb10d3599967bbc Mon Sep 17 00:00:00 2001 From: Alex J Lennon Date: Thu, 3 Dec 2026 15:14:46 +0000 Subject: [PATCH 1/3] Make PQC server reports readable and coloured Assisted-by: Briar --- docs/server-tests.md | 28 ++++++- server_test.py | 157 ++++++++++++++++++++++++++++++++++---- tests/test_server_test.py | 94 ++++++++++++++++++++++- 3 files changed, 261 insertions(+), 18 deletions(-) diff --git a/docs/server-tests.md b/docs/server-tests.md index 2dee00b..fcf4b57 100644 --- a/docs/server-tests.md +++ b/docs/server-tests.md @@ -1,7 +1,11 @@ # Test a running strict-PQC lab `server_test.py` prints a table of 16 tests, their observations and what each -result means. Only run it against a lab you are authorised to test. It publishes +result means. HTTPS and MQTTS/MQTT have separate sections, with a colour-coded +summary at the top. Each test has a result/name/timing row, followed by wrapped +`Observed` and `Means` lines. Expected rejections are explicitly labelled. +Output fits the terminal width (40–120 columns). Only run it against a lab you +are authorised to test. It publishes a small message on a unique `lab/pqc-check/…` topic and attempts a forbidden publish. Do not point it at a production broker. @@ -35,10 +39,30 @@ mechanism; do not put its value in shell command history. A command-line read/write access to `lab/#`, but no access to `forbidden/#`. Use `--openssl /path/to/openssl` for a specific executable. Add `--json` for -structured results and environment versions, without credentials. +structured results, environment versions and verified endpoint/certificate +details, without credentials. Existing `environment` and `tests` fields are +retained; `endpoints` is an additional field. Exit codes: **0** all pass; **1** a behaviour failed; **2** setup, transport or client errors (including runs which also have failures). +## Colours, protocols and certificates + +Interactive terminals use green **PASS**, red **FAIL**, amber **ERROR** and cyan +section headings. Status words remain visible without colour. Redirection, +`NO_COLOR` and `TERM=dumb` disable automatic colour. Override with +`--color always` or `--color never`; `--json` never contains colour escapes. + +Each endpoint shows the observed application protocol (HTTP version/status or +MQTT5/QoS1), TLS version, cipher, hybrid key exchange and TLS handshake signature. +Certificate information comes from the actual CA/name-verified Python TLS peer: +subject, issuer, DNS SANs, public-key algorithm, certificate-signature algorithm, +validity dates, full days remaining and full leaf SHA256 fingerprint. The TLS +handshake signature and X.509 certificate signature are labelled separately. +If both endpoints present the same leaf, its details are shown once and the +other endpoint references it. Missing verified information is not filled in +from an expected/configured profile. This is leaf inspection, not a complete +certificate-chain or revocation audit. + ## Reading the results | Test | Expected observation | What it establishes | diff --git a/server_test.py b/server_test.py index 2e4712f..2da64ba 100644 --- a/server_test.py +++ b/server_test.py @@ -14,8 +14,11 @@ from pathlib import Path import re import secrets +import shutil import ssl import subprocess +import sys +import textwrap import time from transport_test import TLS, group_check, mqtt_connect, packet, send, string @@ -71,6 +74,7 @@ class Suite: def __init__(self, options, password): self.options, self.password = options, password self.rows = [] + self.endpoints = {} def check(self, name, meaning, action): started = time.monotonic() @@ -85,8 +89,46 @@ def check(self, name, meaning, action): "meaning": meaning, "milliseconds": round((time.monotonic()-started)*1000)}) def connect(self, port, **kwargs): - return TLS(port, str(self.options.cafile), hostname=kwargs.pop("hostname", self.options.host), - address=self.options.host, **kwargs) + negative = bool(kwargs) + client = TLS(port, str(self.options.cafile), hostname=kwargs.pop("hostname", self.options.host), + address=self.options.host, **kwargs) + try: + if not negative: + self.remember_certificate(port, client) + return client + except BaseException: + client.close() + raise + + def remember_certificate(self, port, client): + """Record public details only after Python verifies the TLS peer.""" + endpoint = self.endpoints.setdefault(str(port), {}) + der = client.tls.getpeercert(binary_form=True) + fingerprint = hashlib.sha256(der).hexdigest() + if endpoint.get("certificate", {}).get("sha256") == fingerprint: + return + cert = client.tls.getpeercert() + parsed = subprocess.run([self.options.openssl, "x509", "-inform", "DER", "-noout", "-text"], + input=der, capture_output=True, check=True, timeout=5).stdout.decode() + def field(label): + match = re.search(r"^\s*" + re.escape(label) + r":\s*(.+)$", parsed, re.M) + require(match is not None, "Missing certificate " + label) + return match[1].strip() + def distinguished_name(parts): + return ", ".join(f"{key}={value}" for part in parts for key, value in part) + expires = ssl.cert_time_to_seconds(cert["notAfter"]) + endpoint.update(tls_version=client.tls.version(), cipher=client.tls.cipher()[0], + key_exchange=GROUP if client.groups == [0x11ec] else str(client.groups), + certificate={ + "subject": distinguished_name(cert.get("subject", ())), + "issuer": distinguished_name(cert.get("issuer", ())), + "san": [kind + ":" + value for kind, value in cert.get("subjectAltName", ())], + "public_key_algorithm": field("Public Key Algorithm"), + "signature_algorithm": field("Signature Algorithm"), + "valid_from": cert["notBefore"], "valid_until": cert["notAfter"], + "days_remaining": int((expires-time.time())//86400), + "sha256": fingerprint, "ca_and_hostname_verified": True, + }) def openssl(self, port, mode): base = [self.options.openssl, "s_client", "-connect", f"{self.options.host}:{port}", @@ -99,7 +141,13 @@ def openssl(self, port, mode): "TLS1.2": ["-tls1_2"], } result = subprocess.run(base + profiles[mode], input="", text=True, capture_output=True, timeout=10) - return handshake_result(result, positive=mode == "pqc") + detail = handshake_result(result, positive=mode == "pqc") + if mode == "pqc": + text = result.stdout + result.stderr + cipher = next((x.split(": ", 1)[1] for x in text.splitlines() if x.startswith("Ciphersuite: ")), "unknown") + self.endpoints.setdefault(str(port), {}).update( + tls_version="TLSv1.3", key_exchange=GROUP, handshake_signature=SIGNATURE, cipher=cipher) + return detail def certificate_rejection(self, port, hostname=True): options = {"hostname": "wrong-hostname.invalid"} if hostname else {"trust": False} @@ -131,6 +179,7 @@ def https(self): headers, separator, body = bytes(response).partition(b"\r\n\r\n") require(separator and re.match(rb"HTTP/1\.[01] 200(?: |\r|$)", headers), "HTTPS did not return HTTP 200") require(b"PQC lab: TLS 1.3" in body, "Missing expected PQC lab test page") + self.endpoints[str(self.options.https_port)]["application"] = headers.split(b" ", 1)[0].decode() + " / HTTP 200" return (f"HTTP 200; page matched; group 0x11ec; leaf SHA256 {fingerprint[:16]}…; " f"expires {cert.get('notAfter', 'unknown')}") @@ -160,6 +209,7 @@ def mqtt_exchange(self): send(subscriber, 0x40, body[2+size:4+size]) send(publisher, 0xe0, b"") send(subscriber, 0xe0, b"") + self.endpoints[str(self.options.mqtt_port)]["application"] = "MQTT 5 / QoS 1 / exact payload delivered" return f"MQTT5; QoS1; {len(message)} bytes delivered exactly; group 0x11ec" def mqtt_bad_password(self): @@ -197,15 +247,92 @@ def run(self): return self.rows -def report(rows): - print("\nTEST | RESULT | OBSERVED | WHAT IT MEANS") - print("-" * 100) - for row in rows: - print(f"{row['test']} | {row['status']} | {row['observed']} ({row['milliseconds']} ms) | {row['meaning']}") +def use_color(mode): + return mode == "always" or (mode == "auto" and sys.stdout.isatty() + and "NO_COLOR" not in os.environ and os.environ.get("TERM") != "dumb") + + +def report(rows, width=None, color="auto", endpoints=None, environment=None): + """Grouped, coloured terminal report; never truncate test evidence.""" + width = max(40, min(width or shutil.get_terminal_size((100, 24)).columns, 120)) + name_width = width - 19 + colors = {"PASS": "32", "FAIL": "31", "ERROR": "33", "heading": "1;36", "muted": "90"} + enabled = use_color(color) + def clean(value): + return re.sub(r"[\x00-\x1f\x7f-\x9f]", "?", str(value)) + def paint(value, kind): + return f"\033[{colors[kind]}m{value}\033[0m" if enabled else value + def heading(value): + print("\n" + paint(clean(value), "heading")) + print(paint("─" * width, "muted")) + + def explain(label, value): + print(textwrap.fill(clean(value), width=width, initial_indent=" " + label + ": ", + subsequent_indent=" ")) + counts = {status: sum(x["status"] == status for x in rows) for status in ("PASS", "FAIL", "ERROR")} - print("\n" + "; ".join(f"{v} {k}" for k, v in counts.items())) - print("PASS on a rejection test means the unwanted connection was refused for the expected reason.") - print("ERROR means no security conclusion: fix client setup/network and rerun. This is not a compliance certificate.") + heading("PQC SERVER CHECK") + print(" | ".join(paint(f"{v} {k}", k) for k, v in counts.items())) + if environment: + explain("Server", environment["host"]) + explain("Client CLI", environment["openssl_cli"]) + explain("Python TLS", environment["python_tls"]) + groups = (("HTTPS", [x for x in rows if x["test"].startswith("HTTPS")]), + ("MQTTS / MQTT", [x for x in rows if x["test"].startswith(("MQTT ", "MQTTS "))]), + ("Other checks", [x for x in rows if not x["test"].startswith(("HTTPS", "MQTT ", "MQTTS "))])) + seen_certificates = {} + for label, checks in groups: + if not checks: + continue + port = environment.get("https_port" if label == "HTTPS" else "mqtt_port") if environment else None + title = f"{label} :{port}" if port is not None else label + heading(title) + info = (endpoints or {}).get(str(port), {}) + if info: + explain("Protocol", info.get("application", "Application not verified")) + explain("Transport", info.get("tls_version", "not observed")) + explain("Key exchange", info.get("key_exchange", "not observed")) + explain("TLS authentication", info.get("handshake_signature", "not observed")) + explain("Cipher", info.get("cipher", "not observed")) + cert = info.get("certificate") + if cert: + if cert["sha256"] in seen_certificates: + explain("Certificate", "Same verified leaf as " + seen_certificates[cert["sha256"]]) + else: + seen_certificates[cert["sha256"]] = title + explain("Certificate subject", cert["subject"]) + explain("Issued by", cert["issuer"]) + explain("DNS / SAN", ", ".join(cert["san"])) + explain("Certificate algorithms", f"key {cert['public_key_algorithm']}; signature {cert['signature_algorithm']}") + explain("Valid from", cert["valid_from"]) + explain("Expires", f"{cert['valid_until']} ({cert['days_remaining']} full days remaining)") + explain("Leaf SHA256", cert["sha256"]) + explain("Trust", "CA chain and hostname verified against supplied lab CA") + else: + explain("Certificate", "Not observed on a verified Python application connection") + print() + print(f"{'RESULT':<6} {'TEST':<{name_width}} {'TIME':>9}") + for row in checks: + names = textwrap.wrap(clean(row["test"]), width=name_width) or [""] + for index, name in enumerate(names): + status = paint(f"{row['status']:<6}", row["status"]) if index == 0 else " " * 6 + elapsed = str(row["milliseconds"]) + " ms" if index == len(names)-1 else "" + print(f"{status} {name:<{name_width}} {elapsed:>9}") + observed = row["observed"] + if row["status"] == "PASS" and "reject" in row["test"]: + observed = "Expected rejection — " + observed + explain("Observed", observed) + explain("Means", row["meaning"]) + print() + heading("HOW TO READ THIS") + print() + for note in ( + "PASS on a rejection test means the unwanted connection was refused for the expected reason.", + "FAIL means the expected behaviour was not observed.", + "ERROR means no security conclusion: fix client setup/network and rerun.", + "These tests are not a compliance certificate.", + ): + print(textwrap.fill(note, width=width)) def main(argv=None): @@ -218,6 +345,8 @@ def main(argv=None): parser.add_argument("--password-file", type=Path, help="Password file; otherwise read PQC_MQTT_PASSWORD") parser.add_argument("--openssl", default="openssl", help="OpenSSL 3.5+ CLI") parser.add_argument("--json", action="store_true", help="Print structured results instead of the table") + parser.add_argument("--color", choices=("auto", "always", "never"), default="auto", + help="Terminal colours (auto respects NO_COLOR and redirected output)") options = parser.parse_args(argv) try: password = options.password_file.read_text().rstrip("\r\n") if options.password_file else os.environ.get("PQC_MQTT_PASSWORD", "") @@ -237,11 +366,9 @@ def main(argv=None): "openssl_cli": version, "python_tls": ssl.OPENSSL_VERSION, "utc": datetime.now(timezone.utc).isoformat()} if options.json: - print(json.dumps({"environment": metadata, "tests": rows}, indent=2)) + print(json.dumps({"environment": metadata, "endpoints": suite.endpoints, "tests": rows}, indent=2)) else: - print(f"Strict-PQC lab: {options.host}; HTTPS {options.https_port}; MQTTS {options.mqtt_port}") - print(f"CLI: {version}\nPython TLS: {ssl.OPENSSL_VERSION}") - report(rows) + report(rows, color=options.color, endpoints=suite.endpoints, environment=metadata) return 2 if any(row["status"] == "ERROR" for row in rows) else int(any(row["status"] == "FAIL" for row in rows)) diff --git a/tests/test_server_test.py b/tests/test_server_test.py index ee82dbe..05bbaf9 100644 --- a/tests/test_server_test.py +++ b/tests/test_server_test.py @@ -1,6 +1,7 @@ """Offline tests of the live-runner verdicts; no network or credentials.""" import argparse import io +import os import subprocess import unittest from contextlib import redirect_stdout @@ -59,6 +60,80 @@ def test_openssl_timeout_is_error_not_pass(self): class RunnerTests(unittest.TestCase): + def test_certificate_details_are_observed_and_cached(self): + client = unittest.mock.Mock() + client.groups = [0x11ec] + cert = {"subject": ((("commonName", "mqtt.example.test"),),), + "issuer": ((("commonName", "Test CA"),),), + "subjectAltName": (("DNS", "mqtt.example.test"),), + "notBefore": "Dec 3 14:39:22 2026 GMT", "notAfter": "Jan 2 14:39:22 2027 GMT"} + client.tls.getpeercert.side_effect = lambda binary_form=False: b"test-public-der" if binary_form else cert + client.tls.version.return_value = "TLSv1.3" + client.tls.cipher.return_value = ("TLS_AES_256_GCM_SHA384", "TLSv1.3", 256) + parsed = subprocess.CompletedProcess(["openssl"], 0, stdout=b"Public Key Algorithm: ML-DSA-65\nSignature Algorithm: ML-DSA-65\n") + suite = server_test.Suite(argparse.Namespace(openssl="openssl"), "not-a-real-password") + with patch("server_test.subprocess.run", return_value=parsed) as command: + suite.remember_certificate(8090, client) + suite.remember_certificate(8090, client) + command.assert_called_once() + observed = suite.endpoints["8090"]["certificate"] + self.assertEqual(observed["issuer"], "commonName=Test CA") + self.assertEqual(observed["public_key_algorithm"], "ML-DSA-65") + self.assertEqual(observed["signature_algorithm"], "ML-DSA-65") + self.assertEqual(len(observed["sha256"]), 64) + self.assertNotIn("not-a-real-password", str(suite.endpoints)) + + def test_certificate_inspection_failure_closes_verified_connection(self): + client = unittest.mock.Mock() + suite = server_test.Suite(argparse.Namespace(host="mqtt.example.test", cafile="ca.pem"), "unused") + with patch("server_test.TLS", return_value=client), patch.object(suite, "remember_certificate", side_effect=ValueError("bad metadata")): + with self.assertRaises(ValueError): + suite.connect(8090) + client.close.assert_called_once() + + def test_colour_modes_and_no_colour_environment(self): + with patch("server_test.sys.stdout.isatty", return_value=True), patch.dict(os.environ, {"TERM": "xterm"}, clear=True): + self.assertTrue(server_test.use_color("auto")) + self.assertFalse(server_test.use_color("never")) + with patch.dict(os.environ, {"NO_COLOR": "1"}): + self.assertFalse(server_test.use_color("auto")) + self.assertTrue(server_test.use_color("always")) + with patch("server_test.sys.stdout.isatty", return_value=False): + self.assertFalse(server_test.use_color("auto")) + + def test_coloured_report_keeps_explicit_status_words(self): + out = io.StringIO() + rows = [{"test": "HTTPS reject classical group", "status": status, + "observed": "server alert", "meaning": "Classical-only client must fail", "milliseconds": 1} + for status in ("PASS", "FAIL", "ERROR")] + with redirect_stdout(out): + server_test.report(rows, color="always") + for code, status in ((32, "PASS"), (31, "FAIL"), (33, "ERROR")): + self.assertIn(f"\033[{code}m", out.getvalue()) + self.assertIn(status, out.getvalue()) + self.assertIn("Expected rejection", out.getvalue()) + + def test_certificate_summary_distinguishes_tls_and_certificate_signatures(self): + info = {"tls_version": "TLSv1.3", "key_exchange": server_test.GROUP, + "handshake_signature": "mldsa65", "cipher": "TLS_AES_256_GCM_SHA384", + "application": "HTTP/1.1 / HTTP 200", "certificate": { + "subject": "commonName=mqtt.example.test", "issuer": "commonName=Test CA", + "san": ["DNS:mqtt.example.test"], "public_key_algorithm": "ML-DSA-65", + "signature_algorithm": "ML-DSA-65", "valid_from": "Dec 3 2026 GMT", + "valid_until": "Jan 2 2027 GMT", "days_remaining": 29, "sha256": "a"*64, + "ca_and_hostname_verified": True}} + row = {"test": "HTTPS PQC TLS", "status": "PASS", "observed": "verified", + "meaning": "Authentication works", "milliseconds": 1} + out = io.StringIO() + with redirect_stdout(out): + server_test.report([row], color="never", endpoints={"8090": info}, + environment={"host": "mqtt.example.test", "https_port": 8090, + "mqtt_port": 8890, "openssl_cli": "OpenSSL3.5", "python_tls": "OpenSSL3.5"}) + text = out.getvalue() + for field in ("Protocol", "TLS authentication", "Certificate algorithms", "Test CA", "DNS / SAN", "Expires", "Leaf SHA256", "Trust"): + self.assertIn(field, text) + self.assertNotIn("\033[", text) + def test_distinct_failure_and_operational_error(self): suite = server_test.Suite(None, "not-a-real-password") def fail(): @@ -95,10 +170,27 @@ def test_table_explains_negative_pass_and_errors(self): with redirect_stdout(out): server_test.report([{"test": "TLS", "status": "PASS", "observed": "verified", "meaning": "Authentication works", "milliseconds": 1}]) - self.assertIn("WHAT IT MEANS", out.getvalue()) + self.assertIn("Observed: verified", out.getvalue()) + self.assertIn("Means: Authentication works", out.getvalue()) self.assertIn("ERROR means no security conclusion", out.getvalue()) self.assertIn("unwanted connection was refused", out.getvalue()) + def test_table_wraps_without_losing_details(self): + observation = "TLS1.3 X25519MLKEM768 mldsa65 verified certificate and exact application delivery" + row = {"test": "MQTTS reject classical signature", "status": "PASS", + "observed": observation, "meaning": "Classical-only authentication must fail.", + "milliseconds": 123} + for width in (40, 60, 80, 120): + out = io.StringIO() + with self.subTest(width=width), redirect_stdout(out): + server_test.report([row], width=width) + lines = out.getvalue().splitlines() + self.assertTrue(all(len(line) <= width for line in lines)) + flattened = " ".join(out.getvalue().split()) + self.assertIn(observation, flattened) + self.assertIn(row["test"], flattened) + self.assertIn("123 ms", flattened) + if __name__ == "__main__": unittest.main() From 9df7ab3cd8404b34f809d85ff3d0a8393231a717 Mon Sep 17 00:00:00 2001 From: Alex J Lennon Date: Thu, 3 Dec 2026 15:17:42 +0000 Subject: [PATCH 2/3] Include the live coloured-report example in README Assisted-by: Briar --- README.md | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/README.md b/README.md index 1cf7b2c..7884ac0 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,130 @@ rejection, trust/name validation and MQTT authentication/ACLs. Network/setup errors never count as successful rejection. See [server-test instructions and result meanings](docs/server-tests.md), including prerequisites and exit codes. +## Example live test output + +Captured on **3 December 2026** against the Dynamic Devices lab: **16 passed, +0 failed, 0 errors**. Timings and certificate lifetime below are a snapshot, +not current monitoring. Interactive terminals colour PASS green, FAIL red and +ERROR amber; this Markdown example is plain text. Use `--color always` to +force terminal colour or `--color never` to disable it. + +
+Show the full report, including protocols and verified certificate details + +```text +PQC SERVER CHECK +──────────────────────────────────────────────────────────────────────────────────────────────────── +16 PASS | 0 FAIL | 0 ERROR + Server: mqtt.dynamicdevices.co.uk + Client CLI: OpenSSL 3.5.5 27 Jan 2026 (Library: OpenSSL 3.5.5 27 Jan 2026) + Python TLS: OpenSSL 3.5.5 27 Jan 2026 + +HTTPS :8090 +──────────────────────────────────────────────────────────────────────────────────────────────────── + Protocol: HTTP/1.1 / HTTP 200 + Transport: TLSv1.3 + Key exchange: X25519MLKEM768 + TLS authentication: mldsa65 + Cipher: TLS_AES_256_GCM_SHA384 + Certificate subject: commonName=mqtt.dynamicdevices.co.uk + Issued by: commonName=Dynamic Devices PQC Test CA + DNS / SAN: DNS:mqtt.dynamicdevices.co.uk + Certificate algorithms: key ML-DSA-65; signature ML-DSA-65 + Valid from: Dec 3 14:39:22 2026 GMT + Expires: Jan 2 14:39:22 2027 GMT (29 full days remaining) + Leaf SHA256: 91e46ac6a90bd5886b529a1ccd58fe189861673e554b6dae5f50b5210129afc7 + Trust: CA chain and hostname verified against supplied lab CA + +RESULT TEST TIME +PASS HTTPS PQC TLS 223 ms + Observed: TLS1.3; X25519MLKEM768; mldsa65; TLS_AES_256_GCM_SHA384 + Means: Verified hybrid key exchange AND ML-DSA-65 server authentication. + +PASS HTTPS reject classical group 102 ms + Observed: Expected rejection — Server sent fatal TLS rejection alert + Means: X25519-only key exchange must fail: no classical-only fallback. + +PASS HTTPS reject classical signature 103 ms + Observed: Expected rejection — Server sent fatal TLS rejection alert + Means: RSA-only authentication must fail: ML-DSA-65 capability is required. + +PASS HTTPS reject TLS1.2 111 ms + Observed: Expected rejection — Server sent fatal TLS rejection alert + Means: Older TLS protocol must fail: this listener requires TLS1.3. + +PASS HTTPS reject wrong name 101 ms + Observed: Expected rejection — Certificate verification rejected (code 62) + Means: Client must reject a certificate for another DNS name. + +PASS HTTPS reject untrusted CA 106 ms + Observed: Expected rejection — Certificate verification rejected (code 19) + Means: Client with an empty trust store must reject the lab chain. + +PASS HTTPS page 255 ms + Observed: HTTP 200; page matched; group 0x11ec; leaf SHA256 91e46ac6a90bd588…; expires Jan 2 + 14:39:22 2027 GMT + Means: A verified Python TLS connection transfers the expected lab page. + + +MQTTS / MQTT :8890 +──────────────────────────────────────────────────────────────────────────────────────────────────── + Protocol: MQTT 5 / QoS 1 / exact payload delivered + Transport: TLSv1.3 + Key exchange: X25519MLKEM768 + TLS authentication: mldsa65 + Cipher: TLS_AES_256_GCM_SHA384 + Certificate: Same verified leaf as HTTPS :8090 + +RESULT TEST TIME +PASS MQTTS PQC TLS 202 ms + Observed: TLS1.3; X25519MLKEM768; mldsa65; TLS_AES_256_GCM_SHA384 + Means: Verified hybrid key exchange AND ML-DSA-65 server authentication. + +PASS MQTTS reject classical group 101 ms + Observed: Expected rejection — Server sent fatal TLS rejection alert + Means: X25519-only key exchange must fail: no classical-only fallback. + +PASS MQTTS reject classical signature 91 ms + Observed: Expected rejection — Server sent fatal TLS rejection alert + Means: RSA-only authentication must fail: ML-DSA-65 capability is required. + +PASS MQTTS reject TLS1.2 108 ms + Observed: Expected rejection — Server sent fatal TLS rejection alert + Means: Older TLS protocol must fail: this listener requires TLS1.3. + +PASS MQTTS reject wrong name 116 ms + Observed: Expected rejection — Certificate verification rejected (code 62) + Means: Client must reject a certificate for another DNS name. + +PASS MQTTS reject untrusted CA 106 ms + Observed: Expected rejection — Certificate verification rejected (code 19) + Means: Client with an empty trust store must reject the lab chain. + +PASS MQTT publish/subscribe 604 ms + Observed: MQTT5; QoS1; 58 bytes delivered exactly; group 0x11ec + Means: Real authenticated delivery, not merely a successful TLS handshake. + +PASS MQTT reject bad password 227 ms + Observed: Expected rejection — CONNACK 0x87: bad credentials/not authorised + Means: TLS encryption does not replace MQTT authentication. + +PASS MQTT reject forbidden topic 357 ms + Observed: Expected rejection — PUBACK 0x87: Not authorised + Means: Test user may publish to lab/#, not arbitrary broker topics. + + +HOW TO READ THIS +──────────────────────────────────────────────────────────────────────────────────────────────────── + +PASS on a rejection test means the unwanted connection was refused for the expected reason. +FAIL means the expected behaviour was not observed. +ERROR means no security conclusion: fix client setup/network and rerun. +These tests are not a compliance certificate. +``` + +
+ ## What has been tested The following results come from the original local experiments. Ported-source From cb723abef0b96f2c603caa06d2b5a03324499e79 Mon Sep 17 00:00:00 2001 From: Alex J Lennon Date: Thu, 3 Dec 2026 15:18:37 +0000 Subject: [PATCH 3/3] Label the negotiated TLS group precisely Assisted-by: Briar --- README.md | 4 ++-- server_test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7884ac0..2194e84 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ HTTPS :8090 ──────────────────────────────────────────────────────────────────────────────────────────────────── Protocol: HTTP/1.1 / HTTP 200 Transport: TLSv1.3 - Key exchange: X25519MLKEM768 + Hybrid group: X25519MLKEM768 TLS authentication: mldsa65 Cipher: TLS_AES_256_GCM_SHA384 Certificate subject: commonName=mqtt.dynamicdevices.co.uk @@ -100,7 +100,7 @@ MQTTS / MQTT :8890 ──────────────────────────────────────────────────────────────────────────────────────────────────── Protocol: MQTT 5 / QoS 1 / exact payload delivered Transport: TLSv1.3 - Key exchange: X25519MLKEM768 + Hybrid group: X25519MLKEM768 TLS authentication: mldsa65 Cipher: TLS_AES_256_GCM_SHA384 Certificate: Same verified leaf as HTTPS :8090 diff --git a/server_test.py b/server_test.py index 2da64ba..cae1865 100644 --- a/server_test.py +++ b/server_test.py @@ -291,7 +291,7 @@ def explain(label, value): if info: explain("Protocol", info.get("application", "Application not verified")) explain("Transport", info.get("tls_version", "not observed")) - explain("Key exchange", info.get("key_exchange", "not observed")) + explain("Hybrid group", info.get("key_exchange", "not observed")) explain("TLS authentication", info.get("handshake_signature", "not observed")) explain("Cipher", info.get("cipher", "not observed")) cert = info.get("certificate")