Skip to content

[crypto] ec/ecdsa suites stale (unexecutable) and P-256 public API header contradicts private visibility #1055

Closed

Description

@eas4ai

Summary

Two verified-but-unfiled items from the lib/std/crypto/ec.w audit (P-256 math itself verifies exactly against openssl/python oracles — these are API/coverage gaps, not math defects).

  1. tests/test_ec.w / tests/test_ecdsa.w do not execute (same drift class as [tests] crypto suites (bigint/rsa/crypto) not executable: stale unsafe:/-> void syntax #1053, which covered bigint/rsa/crypto suites): unsafe: single-line prefix rejected (test_ec.w:39, test_ecdsa.w:56, ...), &mut, -> void. Reproduced with with-stage1 check this session. The RFC 6979 vectors they assert were confirmed correct against openssl — only the harness is broken.
  2. (Low/design) p256_compute_public / p256_ecdh sit under a ── Public API ── header but are module-private (external probe denied with symbol ... is private), so external users have no reachable P-256 API while tls.w/ecdsa.w call intra-package. Either the header or the visibility is wrong.

Explicitly NOT filed: p256_ecdh peer-key validation (no prefix/on-curve/infinity checks) — held without an independent oracle defining degenerate output; asserting one would enshrine behavior. Left as an owner decision. Variable-time point_mul noted as info only.

Activity

  1. ehartford commented on Sep 16, 2026

    @ehartford
    Contributor

    Review: reproduced

    Verdict. Both items established. (1) tests/test_ec.w and tests/test_ecdsa.w do not compile (stale unsafe: prefix, &mut, -> void), the same drift class as #1053, and like those files they live in tests/ which no test target scans, so P-256/ECDSA have no executable coverage. (2) p256_compute_public and p256_ecdh sit under a ── Public API ── header but are declared non-pub, so an external caller is denied — the header and the visibility contradict each other. As the report says, the P-256 math itself is not in question here; these are API/coverage gaps.

    Tested.

    Source main @ 5809ac1 (2026-09-14); ec.w and the two test files 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 errors
    Platform macOS Darwin 25.6.0 arm64

    Claim 1 (with check, both compilers):

    error: unsafe: requires a newline and indented block; use unsafe { ... } or unsafe *ptr
     --> tests/test_ec.w:39:13
    39 |     unsafe: p256_compute_public(&priv_key[0] as *const u8, &mut pub_key[0] as *mut u8)
    

    test_ecdsa.w:56 fails identically. Both files also carry &mut/-> void drift. And no .Test target globs tests/ (they all scan test/), so even a compiling file would not run — confirmed by grep of build.w.

    Claim 2 (external use std.crypto.ec calling the "public" entry):

    error: symbol 'p256_compute_public' is private to module '<embedded-std>/std/crypto/ec.w'
     --> ec.w:5:14
    

    Source facts (5809ac1).

    Root cause. Test rot plus a header/visibility mismatch, both dating to the crypto port. No compiler defect. Direct check + source evidence.

    Related. #1053 (bigint/rsa/crypto test drift, tests/ not wired in), #1054 (AEAD non-pub + poly1305), #1018 (std.time non-pub surface). No open PR.

    Recommendation — champion, small.

    Acceptance criteria: with build :test runs an ec/ecdsa suite that asserts the RFC 6979 vectors; a pub P-256 API is reachable from an external program (or the header is corrected to reflect intentional privacy).

    Explicitly not assessed (per the report). p256_ecdh peer-key validation (no on-curve/infinity checks) — left as an owner decision without an oracle for degenerate output; and the variable-time point_mul, informational only. 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 for the stale suites.

    $ with check tests/test_ec.w
    error: unsafe: requires a newline and indented block; use unsafe { ... } or unsafe *ptr
     --> tests/test_ec.w:39:13
    $ with check tests/test_ecdsa.w
    error: unsafe: requires a newline and indented block; use unsafe { ... } or unsafe *ptr
     --> tests/test_ecdsa.w:56:22
    

    lib/std/crypto/ec.w has no pub fn (0 of its functions); its header no longer advertises a public API.

    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): P-256 (the public key of 1 is G) and ECDSA (RFC 6979 A.2.5 verifies; refused over a digest with one bit flipped) have known answers that run, in test/behavior/behav_crypto_kats_hmac_bigint_prf.w; the dead tests/test_ec.w and test_ecdsa.w are deleted. Item 2: ec.w's header now says the P-256 functions are the package's own (std.tls and std.crypto.ecdsa call them); a program reaches P-256 through std.tls.

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