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

Unnecessary cryptographic derived types obsoletions #52303

Merged
31 commits merged into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3d01d78
Merge pull request #1 from dotnet/main
annchous May 4, 2021
ae7b109
add new obsoletion ID
annchous May 5, 2021
232775b
nowarn for new obsoletion
annchous May 5, 2021
f7005f8
add obsoletions to csproj
annchous May 5, 2021
bc94bc7
AesCryptoServiceProvider obsoletion
annchous May 5, 2021
adddf44
DESCryptoServiceProvider obsoletion
annchous May 5, 2021
56775ea
MD5CryptoServiceProvider obsoletion
annchous May 5, 2021
4fdff53
RC2CryptoServiceProvider obsoletion
annchous May 5, 2021
89ecc58
SHA1CryptoServiceProvider obsoletion
annchous May 5, 2021
76ce957
SHA256CryptoServiceProvider obsoletion
annchous May 5, 2021
acf6002
SHA384CryptoServiceProvider obsoletion
annchous May 5, 2021
7724dc9
SHA512CryptoServiceProvider obsoletion
annchous May 5, 2021
1294d03
TripleDESCryptoServiceProvider obsoletion
annchous May 5, 2021
eef5db8
add obsoletions to csproj
annchous May 5, 2021
4fea03a
*Managed obsoletions
annchous May 5, 2021
875a7ce
add pragma suppress for types usages
annchous May 5, 2021
9bbaddd
add nowarn in tests csproj
annchous May 5, 2021
f160484
add documentation
annchous May 5, 2021
ef88b0c
add nowarn to new identified tests csproj
annchous May 5, 2021
06f3e78
add pragma suppress for types usages #2
annchous May 5, 2021
7afc9d5
update documentation
annchous May 6, 2021
665f37d
fix md5 usage
annchous May 6, 2021
b364451
Merge branch 'main' into 46934-cryptographic-obsoletions
jeffhandley May 6, 2021
403413a
Fix indentation
jeffhandley May 6, 2021
4e5bef6
fix obsoletions inclusion in csproj
annchous May 6, 2021
f8067e9
remove extra obsoletions inclusion in csproj
annchous May 6, 2021
4b0f491
De-dupe project items that were in both the browser and non-browser c…
jeffhandley May 6, 2021
5a97ee0
Remove duplicate RandomNumberGeneratorImplementation.cs reference
jeffhandley May 6, 2021
f13b2b7
Update documentation
annchous May 6, 2021
87225b9
Merge branch 'main' into 46934-cryptographic-obsoletions
jeffhandley May 10, 2021
0d5a153
Remove duplicate Obsoletions.cs from project file (introduced in merge)
jeffhandley May 11, 2021
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
1 change: 1 addition & 0 deletions docs/project/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
| __`SYSLIB0018`__ | ReflectionOnly loading is not supported and throws PlatformNotSupportedException. |
| __`SYSLIB0019`__ | RuntimeEnvironment members SystemConfigurationFile, GetRuntimeInterfaceAsIntPtr, and GetRuntimeInterfaceAsObject are no longer supported and throw PlatformNotSupportedException. |
| __`SYSLIB0020`__ | JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull. |
| __`SYSLIB0021`__ | Derived cryptographic types are obsolete. Use the Create method on the underlying type instead. |
| __`SYSLIB0022`__ | The Rijndael and RijndaelManaged types are obsolete. Use Aes instead. |

## Analyzer Warnings
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/Common/src/System/Obsoletions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ internal static class Obsoletions
internal const string JsonSerializerOptionsIgnoreNullValuesMessage = "JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.";
internal const string JsonSerializerOptionsIgnoreNullValuesDiagId = "SYSLIB0020";

internal const string DerivedCryptographicTypesMessage = "Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.";
internal const string DerivedCryptographicTypesDiagId = "SYSLIB0021";

internal const string RijndaelMessage = "The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.";
internal const string RijndaelDiagId = "SYSLIB0022";
}
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
SYSLIB0003: Code Access Security (CAS).
SYSLIB0004: Constrained Execution Region (CER).
SYSLIB0017: Strong name signing.
SYSLIB0021: Derived cryptographic types.
SYSLIB0022: Rijndael types.
-->
<NoWarn Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017;SYSLIB0022</NoWarn>
<NoWarn Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017;SYSLIB0021;SYSLIB0022</NoWarn>
<!-- Reset these properties back to blank, since they are defaulted by Microsoft.NET.Sdk -->
<WarningsAsErrors Condition="'$(WarningsAsErrors)' == 'NU1605'" />
<!-- Set the documentation output file globally. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public int GetHashCode(RuntimeTypeHandle obj)
public class DataContract
{
static Dictionary<RuntimeTypeHandle, DataContract> cache = new Dictionary<RuntimeTypeHandle, DataContract>(RuntimeTypeHandleEqualityComparer.Comparer);
static MD5CryptoServiceProvider md5 = null;
static MD5 md5 = null;

Type underlyingType;
bool isValueType;
Expand Down Expand Up @@ -267,7 +267,7 @@ internal static string ExpandGenericParameters(string format, IGenericNameProvid
private static string GetNamespacesDigest(string namespaces)
{
if (md5 == null)
md5 = new MD5CryptoServiceProvider();
md5 = MD5.Create();
byte[] namespaceBytes = Encoding.UTF8.GetBytes(namespaces);
byte[] digestBytes = md5.ComputeHash(namespaceBytes);
char[] digestChars = new char[24];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void Dispose() { }
public void Encrypt(byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[]? associatedData = null) { }
public void Encrypt(System.ReadOnlySpan<byte> nonce, System.ReadOnlySpan<byte> plaintext, System.Span<byte> ciphertext, System.Span<byte> tag, System.ReadOnlySpan<byte> associatedData = default(System.ReadOnlySpan<byte>)) { }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public sealed partial class AesManaged : System.Security.Cryptography.Aes
Expand Down Expand Up @@ -824,6 +825,7 @@ protected SHA1() { }
public static int HashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination) { throw null; }
public static bool TryHashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA1Managed : System.Security.Cryptography.SHA1
{
Expand All @@ -846,6 +848,7 @@ protected SHA256() { }
public static int HashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination) { throw null; }
public static bool TryHashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA256Managed : System.Security.Cryptography.SHA256
{
Expand All @@ -868,6 +871,7 @@ protected SHA384() { }
public static int HashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination) { throw null; }
public static bool TryHashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA384Managed : System.Security.Cryptography.SHA384
{
Expand All @@ -890,6 +894,7 @@ protected SHA512() { }
public static int HashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination) { throw null; }
public static bool TryHashData(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA512Managed : System.Security.Cryptography.SHA512
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[UnsupportedOSPlatform("browser")]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class AesManaged : Aes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public partial class CryptoConfig

switch (name)
{
#pragma warning disable SYSLIB0021 // Obsolete: derived cryptographic types
// hardcode mapping for SHA* algorithm names from https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.cryptoconfig?view=net-5.0#remarks
case "SHA":
case "SHA1":
Expand All @@ -50,6 +51,7 @@ public partial class CryptoConfig
case "SHA-512":
case "System.Security.Cryptography.SHA512":
return new SHA512Managed();
#pragma warning restore SYSLIB0021
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ private static Dictionary<string, object> DefaultNameHT
#pragma warning disable SYSLIB0022 // Rijndael types are obsolete
Type RijndaelManagedType = typeof(System.Security.Cryptography.RijndaelManaged);
#pragma warning restore SYSLIB0022
#pragma warning disable SYSLIB0021 // Obsolete: derived cryptographic types
Type AesManagedType = typeof(System.Security.Cryptography.AesManaged);
Type SHA256DefaultType = typeof(System.Security.Cryptography.SHA256Managed);
Type SHA384DefaultType = typeof(System.Security.Cryptography.SHA384Managed);
Type SHA512DefaultType = typeof(System.Security.Cryptography.SHA512Managed);
#pragma warning restore SYSLIB0021

string SHA1CryptoServiceProviderType = "System.Security.Cryptography.SHA1CryptoServiceProvider, " + AssemblyName_Csp;
string MD5CryptoServiceProviderType = "System.Security.Cryptography.MD5CryptoServiceProvider," + AssemblyName_Csp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
// SHA1Managed has a copy of the same implementation as SHA1
public sealed class SHA1Managed : SHA1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
// SHA256Managed has a copy of the same implementation as SHA256
public sealed class SHA256Managed : SHA256
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
// SHA384Managed has a copy of the same implementation as SHA384
public sealed class SHA384Managed : SHA384
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
// SHA512Managed has a copy of the same implementation as SHA512
public sealed class SHA512Managed : SHA512
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<UseAndroidCrypto Condition="'$(TargetsAndroid)' == 'true'">true</UseAndroidCrypto>
<UseAppleCrypto Condition="'$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">true</UseAppleCrypto>
<!-- SYSLIB0021: Derived cryptographic types are obsolete -->
<NoWarn>$(NoWarn);SYSLIB0021</NoWarn>
jeffhandley marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)System\IO\PositionValueStream.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Security.Cryptography
{
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class AesCryptoServiceProvider : System.Security.Cryptography.Aes
{
Expand Down Expand Up @@ -73,6 +74,7 @@ public enum CspProviderFlags
NoPrompt = 64,
CreateEphemeralKey = 128,
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class DESCryptoServiceProvider : System.Security.Cryptography.DES
{
Expand Down Expand Up @@ -128,6 +130,7 @@ public enum KeyNumber
Exchange = 1,
Signature = 2,
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class MD5CryptoServiceProvider : System.Security.Cryptography.MD5
{
Expand Down Expand Up @@ -164,6 +167,7 @@ protected override void Dispose(bool disposing) { }
public override byte[] GetBytes(int cb) { throw null; }
public override void Reset() { }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class RC2CryptoServiceProvider : System.Security.Cryptography.RC2
{
Expand Down Expand Up @@ -228,6 +232,7 @@ public override void ImportParameters(System.Security.Cryptography.RSAParameters
public override bool VerifyHash(byte[] hash, byte[] signature, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.Security.Cryptography.RSASignaturePadding padding) { throw null; }
public bool VerifyHash(byte[] rgbHash, string str, byte[] rgbSignature) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA1CryptoServiceProvider : System.Security.Cryptography.SHA1
{
Expand All @@ -239,6 +244,7 @@ protected override void HashCore(System.ReadOnlySpan<byte> source) { }
public override void Initialize() { }
protected override bool TryHashFinal(System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA256CryptoServiceProvider : System.Security.Cryptography.SHA256
{
Expand All @@ -250,6 +256,7 @@ protected override void HashCore(System.ReadOnlySpan<byte> source) { }
public override void Initialize() { }
protected override bool TryHashFinal(System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA384CryptoServiceProvider : System.Security.Cryptography.SHA384
{
Expand All @@ -261,6 +268,7 @@ protected override void HashCore(System.ReadOnlySpan<byte> source) { }
public override void Initialize() { }
protected override bool TryHashFinal(System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class SHA512CryptoServiceProvider : System.Security.Cryptography.SHA512
{
Expand All @@ -272,6 +280,7 @@ protected override void HashCore(System.ReadOnlySpan<byte> source) { }
public override void Initialize() { }
protected override bool TryHashFinal(System.Span<byte> destination, out int bytesWritten) { throw null; }
}
[System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class TripleDESCryptoServiceProvider : System.Security.Cryptography.TripleDES
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
Link="Common\System\Security\Cryptography\KeySizeHelpers.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\CryptoPool.cs"
Link="Common\System\Security\Cryptography\CryptoPool.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="System\Security\Cryptography\CapiHelper.Unix.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class AesCryptoServiceProvider : Aes
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class DESCryptoServiceProvider : DES
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class DESCryptoServiceProvider : DES
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class MD5CryptoServiceProvider : MD5
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public PasswordDeriveBytes(byte[] password, byte[]? salt, string hashName, int i
this(password, salt, hashName, iterations, new CspParameters()) { }
#pragma warning restore CA1416

#pragma warning disable SYSLIB0021 // Obsolete: derived cryptographic types
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The correct hash algorithm is being preserved by the DynamicDependency.")]
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(SHA1CryptoServiceProvider))]
public PasswordDeriveBytes(string strPassword, byte[]? rgbSalt, CspParameters? cspParams) :
Expand All @@ -50,6 +51,7 @@ public PasswordDeriveBytes(string strPassword, byte[]? rgbSalt, CspParameters? c
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(SHA1CryptoServiceProvider))]
public PasswordDeriveBytes(byte[] password, byte[]? salt, CspParameters? cspParams) :
this(password, salt, "SHA1", 100, cspParams) { }
#pragma warning restore SYSLIB0021

[RequiresUnreferencedCode(HashAlgorithmUnreferencedCodeMessage)]
public PasswordDeriveBytes(string strPassword, byte[]? rgbSalt, string strHashName, int iterations, CspParameters? cspParams) :
Expand Down
Loading