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 20 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 @@ -70,6 +70,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. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When possible, the message should also indicate what should be done to resolve the warning. Is the following accurate, @bartonjs?

Suggested change
| __`SYSLIB0021`__ | Derived cryptographic types are obsolete. |
| __`SYSLIB0021`__ | Derived cryptographic types are obsolete. Use the Create method on the underlying type instead. |

When this is changed, it will need to be updated in Obsoletions.cs and the ref sources too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's technically correct. I don't know if "underlying type" is the best wording, but I can't come up with an obviously better one.

  • "algorithm's abstract class"
  • "abstract class representing the algorithm"
  • "base type"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gewarren do you have a suggestion for a message better than this?

Derived cryptographic types are obsolete. Use the Create method on the underlying type instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest "...Use the Create method on the base type instead."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest "...Use the Create method on the base type instead."

@jeffhandley apply this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. Thanks!

Side note -- I'm sorry about the trouble with the project file; I hope you didn't mind that I pushed commits to fix it. Since that was an existing issue unrelated to your changes, I didn't want to burden you with fixing that up. I'm glad this PR uncovered it though!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note -- I'm sorry about the trouble with the project file; I hope you didn't mind that I pushed commits to fix it. Since that was an existing issue unrelated to your changes, I didn't want to burden you with fixing that up. I'm glad this PR uncovered it though!

It's okay, of course I was not against helping with the resolution of problems in the project file! Finished with the documentation :)


## 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 @@ -71,5 +71,8 @@ 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.";
internal const string DerivedCryptographicTypesDiagId = "SYSLIB0021";
}
}
2 changes: 1 addition & 1 deletion src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<NoWarn Condition="'$(GeneratePlatformNotSupportedAssembly)' == 'true' or '$(GeneratePlatformNotSupportedAssemblyMessage)' != ''">$(NoWarn);nullable;CA1052</NoWarn>
<!-- Ignore Obsolete errors within the generated shims that type-forward types.
SYSLIB0003: Code Access Security (CAS). SYSLIB0004: Constrained Execution Region (CER). SYSLIB0017: Strong name signing. -->
jeffhandley marked this conversation as resolved.
Show resolved Hide resolved
<NoWarn Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017</NoWarn>
<NoWarn Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017;SYSLIB0021</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
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<NoWarn>$(NoWarn);SYSLIB0021</NoWarn>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a reason why System.Runtime.Serialization.Xml.Tests would need the NoWarn.

If it's explicitly testing serialization for one of the obsoleted types, a pragma around that/those test(s) is more appropriate. Otherwise, it would probably be a place that's doing the old/wrong pattern that should be updated to better code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was here.
According to the errors the problematic lines are

static MD5CryptoServiceProvider md5 = null; // <--- line 211

and

if (md5 == null)
  md5 = new MD5CryptoServiceProvider(); // <--- line 270

The method using this type:

private static string GetNamespacesDigest(string namespaces)

What then needs to be done?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this code is just an example of the bad pattern. So we should fix it 😄

  • Change the field type from MD5CryptoServiceProvider to MD5
  • Change the ctor call to MD5.Create()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for the instructions 🙂 Just fixed!

</PropertyGroup>
<ItemGroup>
<Compile Include="$(TestSourceFolder)DataContractSerializerStressTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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.", 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 @@ -808,6 +809,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.", 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 @@ -830,6 +832,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.", 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 @@ -852,6 +855,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.", 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 @@ -874,6 +878,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.", 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
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);INTERNAL_ASYMMETRIC_IMPLEMENTATIONS</DefineConstants>
Expand All @@ -16,6 +16,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Security\Cryptography\CryptoConfig.Common.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs" Link="Common\System\Obsoletions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsBrowser)' != 'true'">
<Compile Include="Internal\Cryptography\AesImplementation.cs" />
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 @@ -120,10 +120,12 @@ private static Dictionary<string, object> DefaultNameHT
Type HMACSHA384Type = typeof(System.Security.Cryptography.HMACSHA384);
Type HMACSHA512Type = typeof(System.Security.Cryptography.HMACSHA512);
Type RijndaelManagedType = typeof(System.Security.Cryptography.RijndaelManaged);
#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,7 @@
<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>
<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.", 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.", 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.", 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.", 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.", 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.", 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.", 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.", 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.", 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 @@ -131,4 +131,7 @@
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Thread" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonPath)System\Obsoletions.cs" Link="Common\System\Obsoletions.cs" />
</ItemGroup>
jeffhandley marked this conversation as resolved.
Show resolved Hide resolved
</Project>
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace System.Security.Cryptography
{
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class RC2CryptoServiceProvider : RC2
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace System.Security.Cryptography
//
// If you change this file, make the corresponding changes to all of the SHA*CryptoServiceProvider.cs files.
//
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class SHA1CryptoServiceProvider : SHA1
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace System.Security.Cryptography
//
// If you change this file, make the corresponding changes to all of the SHA*CryptoServiceProvider.cs files.
//
[Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class SHA256CryptoServiceProvider : SHA256
{
Expand Down
Loading