Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CryptoConfigForwarder et al. #112306

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,9 @@
<Compile Include="System\Security\Cryptography\CngUIProtectionLevels.cs" />
<Compile Include="System\Security\Cryptography\ConcurrencyBlock.cs" />
<Compile Include="System\Security\Cryptography\ConcurrentSafeKmac.cs" />
<Compile Include="System\Security\Cryptography\CryptoConfigForwarder.cs" />
<Compile Include="System\Security\Cryptography\CryptoConfig.cs" />
<Compile Include="System\Security\Cryptography\CryptographicOperations.cs" />
<Compile Include="System\Security\Cryptography\CryptographicUnexpectedOperationException.cs" />
<Compile Include="System\Security\Cryptography\CryptoConfig.cs" />
<Compile Include="System\Security\Cryptography\CryptoConfig.Common.cs" />
<Compile Include="System\Security\Cryptography\CryptoStream.cs" />
<Compile Include="System\Security\Cryptography\CryptoStreamMode.cs" />
<Compile Include="System\Security\Cryptography\CspParameters.cs" />
Expand Down Expand Up @@ -1865,7 +1863,7 @@
<Reference Include="System.Threading.Thread" />
</ItemGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows' and '$(TargetPlatformIdentifier' != 'browser'">
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows' and '$(TargetPlatformIdentifier)' != 'browser'">
<Reference Include="System.Console" Condition="'$(Configuration)' == 'Debug'" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static AsymmetricAlgorithm Create() =>
throw new PlatformNotSupportedException(SR.Cryptography_DefaultAlgorithm_NotSupported);

[Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresUnreferencedCode(CryptoConfigForwarder.CreateFromNameUnreferencedCodeMessage)]
[RequiresUnreferencedCode(CryptoConfig.CreateFromNameUnreferencedCodeMessage)]
public static AsymmetricAlgorithm? Create(string algName) =>
CryptoConfigForwarder.CreateFromName<AsymmetricAlgorithm>(algName);
CryptoConfig.CreateFromName<AsymmetricAlgorithm>(algName);

public virtual int KeySize
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

namespace System.Security.Cryptography
{
public partial class CryptoConfig
public class CryptoConfig
{
internal const string CreateFromNameUnreferencedCodeMessage = "The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.";

// .NET does not support AllowOnlyFipsAlgorithms
public static bool AllowOnlyFipsAlgorithms => false;

#if !BROWSER
private const string AssemblyName_Pkcs = "System.Security.Cryptography.Pkcs";

Expand Down Expand Up @@ -493,6 +498,21 @@ public static void AddAlgorithm(Type algorithm, params string[] names)
return CreateFromName(name, null);
}

[RequiresUnreferencedCode(CreateFromNameUnreferencedCodeMessage)]
internal static T? CreateFromName<T>(string name) where T : class
{
object? o = CreateFromName(name);
try
{
return (T?)o;
}
catch
{
(o as IDisposable)?.Dispose();
throw;
}
}

[UnsupportedOSPlatform("browser")]
public static void AddOID(string oid, params string[] names)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ protected HMAC() { }
throw new PlatformNotSupportedException(SR.Cryptography_DefaultAlgorithm_NotSupported);

[Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresUnreferencedCode(CryptoConfigForwarder.CreateFromNameUnreferencedCodeMessage)]
[RequiresUnreferencedCode(CryptoConfig.CreateFromNameUnreferencedCodeMessage)]
public static new HMAC? Create(string algorithmName) =>
CryptoConfigForwarder.CreateFromName<HMAC>(algorithmName);
CryptoConfig.CreateFromName<HMAC>(algorithmName);

public string HashName
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ protected HashAlgorithm() { }

[Obsolete(Obsoletions.DefaultCryptoAlgorithmsMessage, DiagnosticId = Obsoletions.DefaultCryptoAlgorithmsDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static HashAlgorithm Create() =>
CryptoConfigForwarder.CreateDefaultHashAlgorithm();
throw new PlatformNotSupportedException(SR.Cryptography_DefaultAlgorithm_NotSupported);

[Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresUnreferencedCode(CryptoConfigForwarder.CreateFromNameUnreferencedCodeMessage)]
[RequiresUnreferencedCode(CryptoConfig.CreateFromNameUnreferencedCodeMessage)]
public static HashAlgorithm? Create(string hashName) =>
CryptoConfigForwarder.CreateFromName<HashAlgorithm>(hashName);
CryptoConfig.CreateFromName<HashAlgorithm>(hashName);

public virtual int HashSize => HashSizeValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ protected KeyedHashAlgorithm() { }
throw new PlatformNotSupportedException(SR.Cryptography_DefaultAlgorithm_NotSupported);

[Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresUnreferencedCode(CryptoConfigForwarder.CreateFromNameUnreferencedCodeMessage)]
[RequiresUnreferencedCode(CryptoConfig.CreateFromNameUnreferencedCodeMessage)]
public static new KeyedHashAlgorithm? Create(string algName) =>
CryptoConfigForwarder.CreateFromName<KeyedHashAlgorithm>(algName);
CryptoConfig.CreateFromName<KeyedHashAlgorithm>(algName);

public virtual byte[] Key
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public static SymmetricAlgorithm Create() =>
throw new PlatformNotSupportedException(SR.Cryptography_DefaultAlgorithm_NotSupported);

[Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresUnreferencedCode(CryptoConfigForwarder.CreateFromNameUnreferencedCodeMessage)]
[RequiresUnreferencedCode(CryptoConfig.CreateFromNameUnreferencedCodeMessage)]
public static SymmetricAlgorithm? Create(string algName) =>
CryptoConfigForwarder.CreateFromName<SymmetricAlgorithm>(algName);
CryptoConfig.CreateFromName<SymmetricAlgorithm>(algName);

public virtual int FeedbackSize
{
Expand Down
Loading