Skip to content

[release/11.0-rc2] Managed HPKE - #134443

Merged
artl93 merged 1 commit into
dotnet:release/11.0-rc2from
bartonjs:port_hpke_rc2
Sep 23, 2026
Merged

artl93 merged 1 commit into
dotnet:release/11.0-rc2from
bartonjs:port_hpke_rc2

Conversation

@bartonjs

Copy link
Copy Markdown
Member

cherry-pick of 2023ab7 (#133804)

Customer Impact

  • Customer reported
  • Found internally

New API for .NET 11 to support using HPKE as part of the PQC transition effort.

Regression

  • Yes
  • No

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.

@azure-pipelines

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

@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.

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

🔵 Needs a closer look

Unresolved nonce-secret cleanup and API-approval concerns, with validation not run, require human review.

Review effort: Lite
Findings: 1 High severity · 2 Low severity

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.");

@artl93 artl93 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.

M2 (non-tactics) approved.

@bartonjs

Copy link
Copy Markdown
Member Author

/ba-g #134367

@bartonjs bartonjs added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 22, 2026
@bartonjs

Copy link
Copy Markdown
Member Author

Approved via email

@artl93
artl93 merged commit 474ed96 into dotnet:release/11.0-rc2 Sep 23, 2026
102 of 106 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc2 milestone Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Security Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants