Skip to content

[release-branch.go1.26] Honor the testing random reader in ML-KEM - #2656

Merged
George Adams (gdams) merged 1 commit into
microsoft/release-branch.go1.26from
dev/gdams/mlkem-random-go1.26
Oct 28, 2026
Merged

George Adams (gdams) merged 1 commit into
microsoft/release-branch.go1.26from
dev/gdams/mlkem-random-go1.26

Conversation

@gdams

@gdams George Adams (gdams) commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Fresh replacement for closed, unmerged #2502, restoring its ML-KEM randomness fix against the current Go 1.26 release patch stack. The equivalent Go 1.27 fix was merged in #2501.

  • Check the public crypto/rand.Reader before routing ML-KEM-768/1024 constructors to a native backend. testing/cryptotest.SetGlobalRandom replaces that reader, but the internal reader remains the default.
  • Dispatch methods according to the implementation stored in each key, so Go fallback keys remain usable after the RNG override is reset and native keys remain usable during an override.
  • Update the crypto dependency rule for the new public RNG import.
  • Regenerate the existing crypto integration patch and its index; no module/vendor or Go submodule pointer changes, no test skips, and no new permanent tests.

Why

Both the Windows Server 2025 tests in #2649 and Intel macOS 26 tests in #2650 fail testing/cryptotest/TestSetGlobalRandom/mlkem.GenerateKey768: native ML-KEM generation bypasses the seeded Go RNG. This PR contains only the ML-KEM fix and generated patch metadata. It is the bottom layer of native stack #2659: #2656 → #2658 (Windows Server 2025) → #2657 (Intel macOS 26), landing on microsoft/release-branch.go1.26. Use GitHub’s native stack merge flow; GitHub updates remaining PR bases as lower layers land. No manual retargeting is needed, and auto-merge is disabled.

Validation

  • Built the patched Go 1.26.10 toolchain on macOS/arm64.
  • Reproduced the exact failing deterministic ML-KEM test locally with the old generation dispatch, then confirmed it passes with the fix restored.
  • Passed existing TestSetGlobalRandom, ML-KEM roundtrip/bad-length/accumulated/size tests, and go/build.TestDependencies.
  • Temporary 768/1024 probes passed for seeded-key repeatability, native keys under an RNG override, and fallback/private/imported-public keys after RNG reset; probes were removed.
  • Go-only (GOEXPERIMENT=nosystemcrypto) controls passed.
  • Cross-compiled Windows/amd64 ML-KEM and cryptotest test binaries; Windows runtime validation remains with CI.
  • Squashed source changes into the existing integration commit and regenerated via git go-patch extract; patch extraction succeeds and actual source whitespace checks pass.

Restore the unmerged backport from #2502 (e027b6b), refreshed against the current release patch stack. Gate ML-KEM constructors on the public random reader, keep methods dispatching through each key's stored implementation, and update the dependency rule for crypto/rand. Regenerate the integration patch and index with git-go-patch.

Co-authored-by: qmuntal <quimmuntal@gmail.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 12:01
@gdams
George Adams (gdams) requested a review from a team as a code owner October 28, 2026 12:01
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@gdams

Copy link
Copy Markdown
Member Author

Stack is now wired:

Both platform branches have been rebased onto this fix, and pipeline-generation tests pass on each. Merge this prerequisite first, then retarget the two platform PRs to the release branch. Both original CI failures were the same ML-KEM deterministic-randomness assertion.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The PR description still treats the included Intel Darwin macOS 26 migration as a separate stacked change, leaving its scope and validation summary inaccurate.

No open issues 🎉

What changed in this PR

Restores the Go 1.26 ML-KEM randomness fix so seeded testing readers are honored and keys remain usable across reader changes. The diff also includes the Intel macOS hosted-agent migration from #2650.

Changes:

  • Gate native ML-KEM constructors on the public random reader and dispatch key methods by their stored implementation.
  • Update crypto dependency rules and regenerate the integration patch metadata.
  • Switch Intel Darwin agents to macOS 26 and update the hosted-image documentation link, leaving ARM64 unchanged.
File Description
patches/​index.json Refreshes the integration patch checksum and index entries.
patches/​0004-Use-crypto-backends.patch Updates ML-KEM dispatch and crypto dependency rules.
eng/​pipeline/​stages/​pool-2.yml Moves Intel Darwin agents to macOS 26 and updates the documentation link.

Review effort: Balanced

@gdams

Copy link
Copy Markdown
Member Author

Correction: I caused #2649 and #2650 to auto-merge by changing their base while their existing auto-merge settings were enabled. That was my mistake, not a manual merge by the user.

Restored this branch to the original tested ML-KEM-only commit 77ebb40944 using an explicit force-with-lease. The platform changes are no longer in this PR.

Replacement stacked PRs, all with auto-merge disabled:

Merge this fix into the release branch first, then retarget the two children to the release branch and merge them separately. Do not merge the children into this branch.

@gdams
George Adams (gdams) enabled stacked auto-merge October 28, 2026 13:19
@gdams
George Adams (gdams) merged commit 75e2e5f into microsoft/release-branch.go1.26 Oct 28, 2026
47 of 48 checks passed
@gdams
George Adams (gdams) deleted the dev/gdams/mlkem-random-go1.26 branch October 28, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants