Use CryptoKit for recovering public key from private EC keys on macOS - #134868
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b3784a91-b7e4-4d75-8e18-4146850fd5bd
Contributor
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified that would block approval.
Review effort: Lite
Findings: None
What changed in this PR
This PR centralizes Apple EC public-key derivation from private scalar-only parameters using CryptoKit, enabling the faster path on macOS as well as mobile Apple platforms.
Changes:
- Moves the CryptoKit-based derivation helper to shared Apple code.
- Removes the macOS PKCS#8 round-trip implementation.
- Removes obsolete platform-specific usings and duplicate code.
Validation: No build or tests were run in this review.
| File | Description |
|---|---|
| src/libraries/Common/src/System/Security/Cryptography/EccAppleCrypto.macOS.cs | Updated as part of this pull request. |
| src/libraries/Common/src/System/Security/Cryptography/EccAppleCrypto.iOS.cs | Updated as part of this pull request. |
| src/libraries/Common/src/System/Security/Cryptography/EccAppleCrypto.cs | Updated as part of this pull request. |
bartonjs
approved these changes
Sep 29, 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.
In #134682 we added support for iOS and tvOS to import private-key only values (
ECParametersthat contain onlyD).This worked on macOS previously by round-tripping through PKCS#8. This is significantly more expensive, both in CPU and memory. Let's use the CryptoKit approach so that we have a single implementation and use the better one on macOS.
This is around a 100x improvement in time.
Benchmark code: