Stop using linknames in the Windows ecdsa backend#2371
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the Windows ECDSA backend’s dependency on //go:linkname for ASN.1 signature encoding/decoding by extending the ECDSA backend API to support (a) native ASN.1 signatures where available and (b) raw (r, s) signature components where needed, so crypto/ecdsa can perform encoding/decoding itself.
Changes:
- Updated
crypto/ecdsa’sGenerateKey,SignASN1, andVerifyASN1systemcrypto fast paths to use the newcryptobackend/ecdsaAPIs and to gate onSupportsCurve. - Extended the ECDSA backend surface to include
Sign/Verify(raw components) alongsideSignASN1/VerifyASN1(DER), allowing Windows to avoid linknames. - Updated the vendored backend implementation in the vendor patch to match the new API shape.
Show a summary per file
| File | Description |
|---|---|
| patches/0002-Add-crypto-backends.patch | Switch crypto/ecdsa to prefer backend ASN.1 signing/verification and fall back to raw (r,s) when ASN.1 isn’t supported (removes need for linknames). |
| patches/0001-Vendor-external-dependencies.patch | Updates vendored cryptobackend/ecdsa implementations to the new API (adds raw/component + ASN.1 entrypoints). |
| cryptobackend/ecdsa/ecdsa_windows.go | Removes linkname-based ASN.1 dependency by implementing raw Sign/Verify and returning ErrUnsupported for ASN.1 operations. |
| cryptobackend/ecdsa/ecdsa_linux.go | Adds raw/component entrypoints as unsupported (since Linux backend uses ASN.1 natively) and exposes ASN.1 operations. |
| cryptobackend/ecdsa/ecdsa_darwin.go | Adds raw/component entrypoints as unsupported (since Darwin backend uses ASN.1 natively) and exposes ASN.1 operations. |
| cryptobackend/ecdsa/nobackend.go | Adds stubbed (panic) definitions for the expanded ECDSA backend API. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 2
gdams
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CNG backend had to use linknames to encode/decode the ASN.1 DER ECDSA signature using the logic from
crypto/ecdsa. Other backends don't have this problem because they support ASN.1 signatures natively.This PR decouples the Windows backend from the
crypto/ecdsaencoding implementation by removing the linknamed functions and adding a new backend API that returns the raw ECDSA signature components so thatcrypto/ecdsacan encode them appropriately, as it already does for the native FIPS 140 module.Note that we could make the OpenSSL/Darwin backend to operate on raw signatures too, but that would make the backend implementation a bit more complex and less performance, given that those are their native signature representations.