Skip to content

Support private scalar-only imports on iOS - #134682

Merged
vcsjones merged 3 commits into
dotnet:mainfrom
vcsjones:apple-d-dh
Sep 26, 2026
Merged

vcsjones merged 3 commits into
dotnet:mainfrom
vcsjones:apple-d-dh

Conversation

@vcsjones

Copy link
Copy Markdown
Member

On iOS / tvOS / MacCatalyst, importing an EC key with only d would fail because it was not implemented. Previously it was not implemented because CryptoKit was not available to the platform. But now it is, so lets implement it.

This matters for HPKE - right now most integration tests for HPKE are failing because HPKE depends on being able to import only the private scalar. This fixes all HPKE tests on mobile Apple platforms.

@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security
See info in area-owners.md if you want to be subscribed.

@vcsjones
vcsjones requested a balanced review from Copilot September 25, 2026 21:49
@vcsjones

Copy link
Copy Markdown
Member Author

/azp help

@azure-pipelines

This comment was marked as resolved.

@vcsjones

Copy link
Copy Markdown
Member Author

/azp list

@azure-pipelines

This comment was marked as outdated.

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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.

Copilot review overview

🟢 Approval recommended

The implementation follows existing Swift interop patterns and enables comprehensive existing ECDH, ECDSA, and HPKE coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Adds EC public-key derivation from a private scalar on Apple mobile platforms, enabling private-only ECDH/ECDSA and HPKE key imports.

Changes:

  • Implements NIST P-256/P-384/P-521 derivation through CryptoKit.
  • Adds managed Swift interop and native entry-point registration.
  • Enables existing private-only key import tests on Apple mobile platforms.
File Description
pal_swiftbindings.swift Derives public keys using CryptoKit.
pal_swiftbindings.h Declares the Swift export.
entrypoints.c Registers the native entry point.
DefaultECDiffieHellmanProvider.Unix.cs Enables existing derivation tests.
EccAppleCrypto.iOS.cs Integrates derivation into Apple-mobile key import.
Interop.Ecc.cs Adds managed-to-Swift interop and error handling.

@vcsjones
vcsjones requested a review from bartonjs September 25, 2026 21:56
Comment thread src/libraries/Common/src/System/Security/Cryptography/EccAppleCrypto.iOS.cs Outdated

@bartonjs bartonjs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The stackalloc size isn't a blocker, so signing off with the feedback. If we want to trim it, I'll sign off on that, too.

Comment thread src/libraries/Common/src/System/Security/Cryptography/EccAppleCrypto.iOS.cs Outdated
@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

/ba-g iOS failures are unrelated

@vcsjones
vcsjones merged commit c29faec into dotnet:main Sep 26, 2026
100 of 104 checks passed
@vcsjones

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@vcsjones
vcsjones deleted the apple-d-dh branch September 26, 2026 12:23
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 27, 2026
@vcsjones vcsjones added the cryptographic-docs-impact Issues impacting cryptographic docs. Cleared and reused after documentation is updated each release. label Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Security cryptographic-docs-impact Issues impacting cryptographic docs. Cleared and reused after documentation is updated each release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants