Skip to content

[tests] test_tls.w stale (unsafe: syntax), PRF/conn checks never run #1063

Closed

Description

@eas4ai

Summary

tests/test_tls.w does not execute at 450733e (same drift class
as #1053/#1055, which named other suites): unsafe: single-line
prefix rejected at :36 and throughout, so the PRF determinism
probe and conn-init checks never run in CI.

Evidence

with-stage1 check tests/test_tls.w fails at :36
(unsafe: tls_prf_sha256(). The PRF logic itself is correct —
verified independently this session (100-byte output byte-exact
vs a python P_SHA256 oracle, .audit/probes/tls/prf.w) — only
the harness is stale.

Notes

Mechanical migration to current unsafe { } syntax. The suite's
PRF assertions are weak (non-zero + deterministic, no expected
bytes); promote the oracle-computed vector when migrating.

Activity

  1. ehartford commented on Sep 16, 2026

    @ehartford
    Contributor

    Review: reproduced

    Verdict. Established: tests/test_tls.w does not compile — the stale unsafe: statement prefix is rejected, so the PRF and conn-init checks never run. Same test-rot class as #1053 (bigint/rsa/crypto) and #1055 (ec/ecdsa). As with those, fixing the syntax alone is not enough: tls_prf_sha256 is module-private and the file is in tests/, which no test target scans.

    Tested.

    Source main @ 5809ac1 (2026-09-14); tests/test_tls.w unchanged since the reported revision 450733e
    Compilers with v0.15.2.1 built from 5809ac1 (staging worktree); a compiler built from 450733e with the nightly-20260903 seed. Same error
    Platform macOS Darwin 25.6.0 arm64

    with check tests/test_tls.w, both compilers:

    error: unsafe: requires a newline and indented block; use unsafe { ... } or unsafe *ptr
     --> tests/test_tls.w:36:13
    36 |     unsafe: tls_prf_sha256(
    

    Two unsafe: sites in the file; the first blocks compilation.

    Further blockers (same as #1053/#1055). tls_prf_sha256 is declared unsafe fn (not pub) at lib/std/tls.w:114, and the test does use std.tls, so after the syntax fix it would fail with a privacy error (§18.3). And no .Test target in build.w globs tests/ (they scan test/), so the file never runs in with build :test. So "mechanical migration" understates it: the test also needs a pub/same-module home and suite wiring.

    Root cause. Test rot since the TLS port; no compiler defect. Direct check + source evidence.

    Severity. Low as a test-hygiene item, but it is why the far more serious TLS defects have no backstop: #1061 (no authentication), #1062 (unclamped handshake lengths). This suite is also where the PRF vector (which I confirmed correct elsewhere) should be pinned.

    Related. #1053, #1055, #1054 (same drift/privacy/wiring pattern across crypto suites). No open PR.

    Recommendation — champion (bundle with #1053/#1055). Migrate unsafe: to unsafe { }, give tls_prf_sha256 (and any other exercised entry points) a test-visible surface or co-locate the test in the module, move the file under test/, and replace the weak "non-zero + deterministic" PRF assertion with the oracle-computed vector. Acceptance criteria: with build :test runs a TLS suite that asserts the PRF against a known vector and covers conn init; a red result appears if the PRF regresses.

    Not tested. I did not run the repaired suite (it needs the privacy change to compile). Linux/Windows not exercised.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    Contributor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced.

    $ with check tests/test_tls.w
    error: unsafe: requires a newline and indented block; use unsafe { ... } or unsafe *ptr
     --> tests/test_tls.w:36:13
    

    post-release: test coverage, the same class as #1053.

  3. added this to the post-v0.16.0 milestone on Oct 28, 2026
  4. ehartford commented on Nov 11, 2026

    @ehartford
    Contributor

    Merged to main ae20d89 (#3251): std.tls's P_SHA256 PRF has a known answer that runs (the TLS working group's vector), tls_prf_sha256_kat, checked by test/behavior/behav_crypto_kats_hmac_bigint_prf.w; the dead tests/test_tls.w is deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions