Consolidate RSA tests into S.S.C.#129924
Draft
PranavSenthilnathan wants to merge 1 commit into
Draft
Conversation
Contributor
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates RSA-related tests from the CNG/CSP/OpenSSL test projects into System.Security.Cryptography.Tests, aligning RSA with the prior DSA/EC consolidation approach by introducing provider/factory abstractions and per-provider test registrations.
Changes:
- Refactors shared RSA test implementations under
src/libraries/Common/tests/.../RSA/from static to abstract instance-based tests with a provider (RSAProvider) accessor. - Moves provider-specific RSA tests/providers into
src/libraries/System.Security.Cryptography/tests/, adds per-provider “registration” leaf classes, and updates project files to compile them under the right platform conditions. - Replaces some xUnit static-conditional attributes with
SkipTestException-based skipping where provider capabilities differ.
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Security.Cryptography/tests/System.Security.Cryptography.Tests.csproj | Adds/remaps RSA-related sources into the consolidated crypto test project and removes older RSAFactory-linked sources. |
| src/libraries/System.Security.Cryptography/tests/RSATestRegistration.OpenSsl.cs | Adds OpenSSL leaf registration classes for the instance-based RSA test bases. |
| src/libraries/System.Security.Cryptography/tests/RSATestRegistration.Default.cs | Adds default-provider leaf registration classes for the instance-based RSA test bases. |
| src/libraries/System.Security.Cryptography/tests/RSATestRegistration.Csp.cs | Adds CSP leaf registration classes for the instance-based RSA test bases. |
| src/libraries/System.Security.Cryptography/tests/RSATestRegistration.Cng.cs | Adds CNG leaf registration classes for the instance-based RSA test bases. |
| src/libraries/System.Security.Cryptography/tests/RSASignatureFormatterTests.NoKey.cs | Splits “no key” RSA signature formatter coverage into a standalone static test class. |
| src/libraries/System.Security.Cryptography/tests/RsaOpenSslTests.cs | Moves RSAOpenSsl behavioral tests into the consolidated test project (Unix/OpenSSL-conditioned). |
| src/libraries/System.Security.Cryptography/tests/RSAOpenSslProvider.cs | Introduces an OpenSSL-backed RSAProvider implementation for RSA test instantiation. |
| src/libraries/System.Security.Cryptography/tests/RSAKeyExchangeFormatterTests.Default.cs | Moves RSAKeyExchange formatter argument tests into a default-only static test class. |
| src/libraries/System.Security.Cryptography/tests/RSAImportExportCspBlobTests.cs | Moves/imports CSP blob import/export tests into the consolidated test project. |
| src/libraries/System.Security.Cryptography/tests/RSACryptoServiceProviderTests.cs | Updates CSP RSA tests to use SkipTestException capability checks instead of static conditional-member gating. |
| src/libraries/System.Security.Cryptography/tests/RSACryptoServiceProviderProvider.cs | Introduces an RSAProvider implementation for RSACryptoServiceProvider-backed runs. |
| src/libraries/System.Security.Cryptography/tests/RSACryptoServiceProviderBackCompat.cs | Updates back-compat tests to use the new provider capability properties. |
| src/libraries/System.Security.Cryptography/tests/RsaCngTests.cs | Moves CNG RSA tests into the consolidated test project and updates provider checks. |
| src/libraries/System.Security.Cryptography/tests/RSACngProvider.cs | Introduces a CNG-backed RSAProvider implementation. |
| src/libraries/System.Security.Cryptography/tests/DefaultRSATests.cs | Renames/moves default RSA base-virtual behavior tests into a DefaultRSATests static class. |
| src/libraries/System.Security.Cryptography/tests/DefaultRSAProvider.cs | Replaces the prior IRSAProvider/RSAFactory pattern with a concrete RSAProvider singleton. |
| src/libraries/System.Security.Cryptography/tests/AsymmetricSignatureFormatterTests.cs | Broadens helper accessibility to enable reuse from non-derived static test types. |
| src/libraries/System.Security.Cryptography.OpenSsl/tests/System.Security.Cryptography.OpenSsl.Tests.csproj | Removes RSA sources now hosted by the consolidated crypto tests. |
| src/libraries/System.Security.Cryptography.OpenSsl/tests/RSAOpenSslProvider.cs | Removes the old OpenSSL RSA provider/factory wiring. |
| src/libraries/System.Security.Cryptography.Csp/tests/System.Security.Cryptography.Csp.Tests.csproj | Removes RSA sources now hosted by the consolidated crypto tests. |
| src/libraries/System.Security.Cryptography.Csp/tests/RSACryptoServiceProviderProvider.cs | Removes the old CSP RSA provider/factory wiring. |
| src/libraries/System.Security.Cryptography.Cng/tests/System.Security.Cryptography.Cng.Tests.csproj | Removes RSA sources now hosted by the consolidated crypto tests. |
| src/libraries/System.Security.Cryptography.Cng/tests/RSACngProvider.cs | Removes the old CNG RSA provider/factory wiring. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/SignVerify.netcoreapp.cs | Converts netcoreapp-specific Sign/Verify test variants to abstract bases for provider-driven execution. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/SignVerify.cs | Refactors core Sign/Verify tests to instance-based execution with provider capability checks. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAXml.cs | Converts RSA XML tests to instance-based execution with provider capability checks. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSASignatureFormatterTests.cs | Converts signature formatter tests to instance-based execution with provider capability checks. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAProvider.cs | Adds the new provider abstraction used by instance-based RSA test suites. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAKeyPemTests.cs | Converts PEM tests to instance-based execution with a provider accessor. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAKeyFileTests.cs | Converts key file tests to instance-based execution with provider capability checks. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAKeyExchangeFormatterTests.cs | Converts key exchange formatter tests to instance-based execution with a provider accessor. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAFactoryTests.cs | Converts factory tests to instance-based execution with a provider accessor. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/RSAFactory.cs | Removes the old IRSAProvider + static RSAFactory indirection. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/KeyGeneration.cs | Converts key generation tests to instance-based execution with a provider accessor. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/ImportExport.cs | Converts import/export tests to instance-based execution with provider capability checks. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/EncryptDecrypt.netcoreapp.cs | Converts netcoreapp-specific Encrypt/Decrypt test variants to abstract bases. |
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/RSA/EncryptDecrypt.cs | Refactors core Encrypt/Decrypt tests to instance-based execution with provider capability checks. |
Comment on lines
+30
to
+34
|
|
||
| public sealed class EncryptDecrypt_Array_OpenSsl : EncryptDecrypt_Array | ||
| { | ||
| protected override RSAProvider RSAFactory => RSAOpenSslProvider.Instance; | ||
| } |
Comment on lines
+614
to
+618
| if ((requiresSha1Signature && !RSAFactory.SupportsSha1Signatures) || | ||
| (requiresMd5Signature && !RSAFactory.SupportsMd5Signatures)) | ||
| { | ||
| return; | ||
| } |
Comment on lines
989
to
+996
| [Theory] | ||
| [MemberData(nameof(HashAlgorithmNames))] | ||
| public void PssRoundtrip(string hashAlgorithmName) | ||
| public void PssRoundtrip(string hashAlgorithmName, Func<RSAProvider, bool> isSupported) | ||
| { | ||
| if (!isSupported(RSAFactory)) | ||
| { | ||
| return; | ||
| } |
Comment on lines
699
to
+710
| [Theory] | ||
| [MemberData(nameof(OaepPaddingModes))] | ||
| public void NonPowerOfTwoKeySizeOaepRoundtrip(RSAEncryptionPadding oaepPaddingMode) | ||
| public void NonPowerOfTwoKeySizeOaepRoundtrip( | ||
| RSAEncryptionPadding oaepPaddingMode, | ||
| bool requiresSha2Oaep, | ||
| bool requiresSha3) | ||
| { | ||
| if ((requiresSha2Oaep && !RSAFactory.SupportsSha2Oaep) || | ||
| (requiresSha3 && !RSAFactory.SupportsSha3)) | ||
| { | ||
| return; | ||
| } |
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.
Moves RSA tests from CNG, CSP and OpenSSL test projects into the S.S.C. test project. This uses the same approach as DSA (#129320) and ECDSA (#129552):
Contributes to #66338