[release/11.0-rc2] Managed HPKE - #134443
Merged
Merged
Conversation
cherry-pick of 2023ab7
bartonjs
requested review from
artl93 and
vcsjones
and
a lite review from Copilot
September 22, 2026 18:28
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 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
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Unresolved nonce-secret cleanup and API-approval concerns, with validation not run, require human review.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
This pull request adds experimental managed HPKE support for .NET 11, including KEM, KDF, AEAD, public APIs, compatibility forwarding, and tests.
Changes:
- Implements managed DHKEM, HKDF/SHAKE, AES-GCM, and ChaCha20-Poly1305.
- Adds HPKE APIs, diagnostics, metadata, resources, and type forwards.
- Adds contract, interoperability, key, platform, and vector tests.
- Follow-up remains for nonce cleanup, API approval, vector provenance, ordering, resources, and formatting.
- Build and tests were not run.
| File | Summary |
|---|---|
src/libraries/System.Security.Cryptography/tests/System.Security.Cryptography.Tests.csproj |
Includes HPKE implementation tests. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeX25519DiffieHellmanKemAdapter.cs |
Implements X25519 DHKEM. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeManagedKemAdapter.cs |
Provides managed KEM derivation logic. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeManagedKdfAdapter.cs |
Implements managed HKDF and SHAKE handling. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeManagedChaCha20Poly1305AeadAdapter.cs |
Adds ChaCha20-Poly1305 support. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeManagedAesAeadAdapter.cs |
Adds AES-GCM support. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeManagedAeadAdapter.cs |
Selects managed AEAD adapters. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeKemMetadata.Managed.cs |
Provides managed KEM metadata. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeKdfMetadata.Managed.cs |
Provides managed KDF metadata. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeImplementation.NotSupported.cs |
Provides unsupported-platform behavior. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeImplementation.Managed.cs |
Implements managed HPKE contexts and operations; nonce cleanup remains. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeECDiffieHellmanKemAdapter.cs |
Implements NIST-curve DHKEM. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HpkeAeadMetadata.Managed.cs |
Detects managed AEAD support. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/FixedMemoryKeyBox.cs |
Adds protected key-memory access support. |
src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj |
Includes HPKE implementation sources. |
src/libraries/System.Security.Cryptography/src/Resources/Strings.resx |
Adds HPKE resources; ordering and unused-string cleanup remain. |
src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs |
Defines the public HPKE reference surface; API approval follow-up remains. |
src/libraries/Microsoft.Bcl.Cryptography/tests/Microsoft.Bcl.Cryptography.Tests.csproj |
Includes shared HPKE tests. |
src/libraries/Microsoft.Bcl.Cryptography/src/Resources/Strings.resx |
Adds compatibility-target resources. |
src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.Forwards.cs |
Forwards HPKE types; ordering cleanup remains. |
src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.csproj |
Adds compatibility build support. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeTests.cs |
Tests public HPKE API behavior. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeTestDataTests.cs |
Validates test-vector coverage. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeTestData.cs |
Defines shared test-vector models. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeSuiteTests.cs |
Tests suite metadata and equality. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeSenderContractTests.cs |
Tests sender contracts. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeRecipientContractTests.cs |
Tests recipient contracts. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeNotSupportedTests.cs |
Tests unsupported-platform behavior. |
src/libraries/Common/tests/System/Security/Cryptography/HpkeKeyTests.cs |
Tests key generation, import, and export. |
src/libraries/Common/src/System/Security/Cryptography/HpkeSuite.cs |
Defines HPKE suites. |
src/libraries/Common/src/System/Security/Cryptography/HpkeSender.cs |
Defines sender context APIs. |
src/libraries/Common/src/System/Security/Cryptography/HpkeRecipient.cs |
Defines recipient context APIs. |
src/libraries/Common/src/System/Security/Cryptography/HpkeKemMetadata.cs |
Defines KEM metadata and sizes. |
src/libraries/Common/src/System/Security/Cryptography/HpkeKem.cs |
Defines KEM algorithms. |
src/libraries/Common/src/System/Security/Cryptography/HpkeKdfMetadata.cs |
Defines KDF metadata and limits. |
src/libraries/Common/src/System/Security/Cryptography/HpkeKdf.cs |
Defines KDF algorithms. |
src/libraries/Common/src/System/Security/Cryptography/HpkeAeadMetadata.cs |
Defines AEAD metadata. |
src/libraries/Common/src/System/Security/Cryptography/HpkeAead.cs |
Defines AEAD algorithms. |
src/libraries/Common/src/System/Experimentals.cs |
Registers the HPKE experimental diagnostic. |
docs/project/list-of-diagnostics.md |
Documents the HPKE diagnostic. |
Comment on lines
+410
to
+411
| _aeadAdapter.Dispose(); | ||
| _exporterSecret.Dispose(); |
Comment on lines
+150
to
+179
| <data name="Argument_HpkeCiphertextTooShort" xml:space="preserve"> | ||
| <value>The ciphertext must be at least {0} bytes long to contain the authentication tag.</value> | ||
| </data> | ||
| <data name="Argument_HpkeEncapsulatedSecretLength" xml:space="preserve"> | ||
| <value>The encapsulated secret must be exactly {0} bytes long.</value> | ||
| </data> | ||
| <data name="Argument_HpkeExportLengthTooLarge" xml:space="preserve"> | ||
| <value>The exported secret length can be at most {0} bytes.</value> | ||
| </data> | ||
| <data name="Argument_HpkeExporterContextTooLong" xml:space="preserve"> | ||
| <value>The exporter context exceeds the maximum length of {0} bytes.</value> | ||
| </data> | ||
| <data name="Argument_HpkeIkmTooLong" xml:space="preserve"> | ||
| <value>The input keying material exceeds the maximum length of {0} bytes.</value> | ||
| </data> | ||
| <data name="Argument_HpkeKdfInfoLength" xml:space="preserve"> | ||
| <value>The specified info exceeds the maximum length of {0} bytes.</value> | ||
| </data> | ||
| <data name="Argument_HpkePskIdEmpty" xml:space="preserve"> | ||
| <value>The pre-shared key identifier must not be empty.</value> | ||
| </data> | ||
| <data name="Argument_HpkePskIdTooLong" xml:space="preserve"> | ||
| <value>The pre-shared key identifier exceeds the maximum length of {0} bytes.</value> | ||
| </data> | ||
| <data name="Argument_HpkePskTooLong" xml:space="preserve"> | ||
| <value>The pre-shared key exceeds the maximum length of {0} bytes.</value> | ||
| </data> | ||
| <data name="Argument_HpkePskTooShort" xml:space="preserve"> | ||
| <value>The pre-shared key must be at least {0} bytes long.</value> | ||
| </data> |
| case HpkeKem.MLKEM1024_P384: | ||
| return false; | ||
| default: | ||
| Debug.Fail($"Kem ${Kem}'s support is unknown."); |
This was referenced Sep 22, 2026
Member
Author
|
/ba-g #134367 |
Member
Author
|
Approved via email |
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.


cherry-pick of 2023ab7 (#133804)
Customer Impact
New API for .NET 11 to support using HPKE as part of the PQC transition effort.
Regression
Testing
This standalone feature is extensively tested in this PR.
Risk
Low. The feature is entirely isolated, only consumers of these new
[Experimental]types are affected.This change contains the full API set for the feature, but does not represent full functionality (e.g. Win32 interop instead of the managed implementation on Windows), which can be added in servicing.