Skip to content

Consolidate EC tests into S.S.C.#129552

Open
PranavSenthilnathan wants to merge 2 commits into
dotnet:mainfrom
PranavSenthilnathan:consolidate-ec-tests
Open

Consolidate EC tests into S.S.C.#129552
PranavSenthilnathan wants to merge 2 commits into
dotnet:mainfrom
PranavSenthilnathan:consolidate-ec-tests

Conversation

@PranavSenthilnathan

Copy link
Copy Markdown
Member

Moves EC tests from System.Security.Cryptography.OpenSsl.Tests and System.Security.Cryptography.Cng.Tests to System.Security.Cryptography.Tests. Similar to #129320, the high-level strategy is:

  • Create concrete ECDSA/ECDH factories (CNG, OpenSsl and default/ECDsa/ECDiffieHellman).
  • Change static EC test classes to instance EC test class with virtualized ECDSA/ECDH factory accessors.
  • Add a test registration class for each provider as a leaf of the instance-ified classes.
  • XUnit conditional attributes can only reference static members, so instead move to throwing SkipTestException where needed.
  • XUnit member data attributes can only reference static members, so, in the few places we need to, loop inside the test.

Contributes to #66338

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

Pull request overview

This PR restructures elliptic-curve (ECDsa/ECDH) test coverage so provider-specific tests (CNG / OpenSSL / default) run under System.Security.Cryptography.Tests, using provider abstractions and “test registration” leaf classes to avoid per-assembly duplication and to work around xUnit’s static-only constraints.

Changes:

  • Introduces provider abstractions (ECDsaProvider, ECDiffieHellmanProvider) plus concrete singleton providers for Default/Cng/OpenSsl, and refactors common EC tests to be instance-based with provider overrides.
  • Adds per-provider “test registration” leaf classes in System.Security.Cryptography.Tests and removes EC test wiring from the OpenSsl/Cng test projects.
  • Replaces xUnit conditional/static-member patterns with ConditionalFact/ConditionalTheory + SkipTestException runtime skipping (with new helpers).

Reviewed changes

Copilot reviewed 63 out of 64 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Security.Cryptography/tests/X509Certificates/ExportTests.cs Updates EC export tests to use new provider capability checks (one ECDH gating issue found).
src/libraries/System.Security.Cryptography/tests/TestData.Cng.cs Adds CNG-specific key blobs and helpers into consolidated test project (Windows-only).
src/libraries/System.Security.Cryptography/tests/System.Security.Cryptography.Tests.csproj Wires in new providers/registrations and links shared helpers for consolidated EC tests.
src/libraries/System.Security.Cryptography/tests/ECDsaTestRegistration.OpenSsl.cs Adds OpenSSL ECDsa test leaf classes selecting the OpenSSL provider.
src/libraries/System.Security.Cryptography/tests/ECDsaTestRegistration.Default.cs Adds default ECDsa test leaf classes selecting the default provider.
src/libraries/System.Security.Cryptography/tests/ECDsaTestRegistration.Cng.cs Adds CNG ECDsa test leaf classes selecting the CNG provider.
src/libraries/System.Security.Cryptography/tests/EcDsaOpenSslTests.cs Refactors OpenSSL-specific ECDsa tests to runtime skip checks + provider override.
src/libraries/System.Security.Cryptography/tests/EcDsaOpenSslProvider.cs Renames/reshapes OpenSSL ECDsa provider implementation to derive from ECDsaProvider.
src/libraries/System.Security.Cryptography/tests/ECDsaCngTests.cs Refactors CNG-specific ECDsa tests to use provider abstraction and runtime skip checks.
src/libraries/System.Security.Cryptography/tests/ECDsaCngProvider.cs Renames/reshapes CNG ECDsa provider implementation to derive from ECDsaProvider.
src/libraries/System.Security.Cryptography/tests/ECDsaCngImportExportTests.cs Refactors CNG-only import/export tests to use provider abstraction + runtime skip checks.
src/libraries/System.Security.Cryptography/tests/ECDiffieHellmanTestRegistration.OpenSsl.cs Adds OpenSSL ECDH test leaf classes selecting the OpenSSL provider.
src/libraries/System.Security.Cryptography/tests/ECDiffieHellmanTestRegistration.Default.cs Adds default ECDH test leaf classes selecting the default provider.
src/libraries/System.Security.Cryptography/tests/ECDiffieHellmanTestRegistration.Cng.cs Adds CNG ECDH test leaf classes selecting the CNG provider.
src/libraries/System.Security.Cryptography/tests/EcDiffieHellmanOpenSslTests.cs Refactors OpenSSL-specific ECDH tests to runtime skip checks and static execution.
src/libraries/System.Security.Cryptography/tests/EcDiffieHellmanOpenSslProvider.cs Adds OpenSSL ECDH provider implementation for consolidated tests.
src/libraries/System.Security.Cryptography/tests/ECDiffieHellmanCngTests.cs Extracts/renames CNG-specific ECDH test class away from shared partial base.
src/libraries/System.Security.Cryptography/tests/ECDiffieHellmanCngProvider.cs Renames/reshapes CNG ECDH provider implementation to derive from ECDiffieHellmanProvider.
src/libraries/System.Security.Cryptography/tests/DefaultECDsaTests.cs Renames/updates default ECDsa tests to use ECDsa.Create() directly.
src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Windows.cs Refactors default ECDsa provider for Windows to derive from ECDsaProvider.
src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Unix.cs Refactors default ECDsa provider for Unix to derive from ECDsaProvider.
src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.cs Refactors default ECDsa provider core implementation as a singleton ECDsaProvider.
src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Browser.cs Refactors browser default ECDsa provider shim to match new abstraction.
src/libraries/System.Security.Cryptography/tests/DefaultECDsaProvider.Android.cs Refactors Android default ECDsa provider shim to match new abstraction.
src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanTests.cs Renames/updates default ECDH tests to use ECDiffieHellman.Create() directly.
src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Windows.cs Refactors default ECDH provider for Windows to derive from ECDiffieHellmanProvider.
src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Unix.cs Refactors default ECDH provider for Unix to derive from ECDiffieHellmanProvider.
src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.cs Refactors default ECDH provider core implementation as a singleton ECDiffieHellmanProvider.
src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Browser.cs Refactors browser default ECDH provider shim to match new abstraction.
src/libraries/System.Security.Cryptography/tests/DefaultECDiffieHellmanProvider.Android.cs Refactors Android default ECDH provider shim to match new abstraction.
src/libraries/System.Security.Cryptography.OpenSsl/tests/System.Security.Cryptography.OpenSsl.Tests.csproj Removes EC test wiring now covered by consolidated test project.
src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDiffieHellmanOpenSslProvider.cs Deletes OpenSSL EC provider previously living in OpenSsl test project.
src/libraries/System.Security.Cryptography.Cng/tests/System.Security.Cryptography.Cng.Tests.csproj Removes EC test wiring; links shared TestData.Cng.cs instead.
src/libraries/System.Security.Cryptography.Cng/tests/PropertyTests.cs Removes now-unneeded EC test namespace usage due to consolidation.
src/libraries/System.Security.Cryptography.Cng/tests/OpenTests.cs Removes now-unneeded EC test namespace usage due to consolidation.
src/libraries/Common/tests/System/Security/Cryptography/ExceptionHelpers.cs Adds SkipTestException.ThrowUnless/ThrowWhen helpers to support runtime skipping.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaXml.cs Makes shared ECDsa XML tests abstract/instance-based under new provider model.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTestsBase.cs Adds abstract provider accessor; converts capability probes to instance members.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.NistValidation.cs Converts helper methods to instance context for provider-based execution.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.netcoreapp.cs Switches some MemberData patterns to inline loops + runtime skipping.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaTests.cs Makes shared ECDsa tests abstract and provider-driven; adjusts data generation patterns.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaStub.cs Deletes obsolete stub type now that tests instantiate via provider.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaSignatureFormatTests.cs Caches generated keys per provider instance; converts to provider-driven generation.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaProvider.cs Adds new provider abstraction for ECDsa.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaKeyFileTests.cs Makes key-file tests abstract and provider-capability-driven.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaImportExport.cs Refactors import/export tests to runtime skip checks + provider execution.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaFactoryTests.cs Converts factory tests to abstract/provider-driven instance tests.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDsa/ECDsaFactory.cs Deletes old static factory indirection replaced by provider abstraction.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.Xml.cs Converts XML tests to instance-based execution under provider model.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.Tls.cs Replaces MemberData usage with per-keysize loops; keeps behavior via helpers.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.Raw.cs Converts raw-derivation tests to runtime skip checks + loop helpers.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.NistValidation.cs Converts NIST validation helpers to instance context for provider-based execution.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.ImportExport.cs Refactors import/export tests to runtime skip checks + provider execution.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.Hmac.cs Converts HMAC derivation tests to loop-based execution + runtime skip checks.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.Hash.cs Converts hash derivation tests to loop-based execution + runtime skip checks.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanTests.cs Makes shared ECDH tests abstract/provider-driven; adds per-provider keysize caches + loop helpers.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanProvider.cs Adds new provider abstraction for ECDiffieHellman.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanKeyPemTests.cs Fixes namespace/abstraction and routes key creation through provider.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanFactoryTests.cs Converts factory tests to abstract/provider-driven instance tests.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDiffieHellmanFactory.cs Deletes old static factory indirection replaced by provider abstraction.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/ECDiffieHellman/ECDhKeyFileTests.cs Makes key-file tests abstract and provider-capability-driven.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/EC/ECKeyFileTests.cs Virtualizes per-algorithm capabilities (explicit curves / public-key derivation / curve support).
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/EC/EccTestBase.cs Reworks curve data sets for runtime validation rather than static filtering.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/EC/CurveDef.cs Moves curve validity checks to provider-specific methods.

Comment thread src/libraries/System.Security.Cryptography/tests/X509Certificates/ExportTests.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants