diff options
author | Kevin Jones <kevin@vcsjones.com> | 2021-08-12 06:35:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 06:35:05 +0300 |
commit | c5faf00fd5df6ffb619aa8d2592618fc982f36ff (patch) | |
tree | 57731211f7561bad73211386efafe539483854b3 | |
parent | 0e88ddca25a069b86b49fcc40537c79506d51e5c (diff) |
Obsolete Rfc2898DeriveBytes.CryptDeriveKey (#57002)
* Obsolete Rfc2898DeriveBytes.CryptDeriveKey
* Apply suggestions from code review
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
5 files changed, 8 insertions, 0 deletions
diff --git a/docs/project/list-of-diagnostics.md b/docs/project/list-of-diagnostics.md index 9cfc6276277..e4f82872eeb 100644 --- a/docs/project/list-of-diagnostics.md +++ b/docs/project/list-of-diagnostics.md @@ -87,6 +87,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute | __`SYSLIB0030`__ | HMACSHA1 always uses the algorithm implementation provided by the platform. Use a constructor without the useManagedSha1 parameter. | | __`SYSLIB0031`__ | EncodeOID is obsolete. Use the ASN.1 functionality provided in System.Formats.Asn1. | | __`SYSLIB0032`__ | Recovery from corrupted process state exceptions is not supported; HandleProcessCorruptedStateExceptionsAttribute is ignored. | +| __`SYSLIB0033`__ | Rfc2898DeriveBytes.CryptDeriveKey is obsolete and is not supported. Use PasswordDeriveBytes.CryptDeriveKey instead. | ## Analyzer Warnings diff --git a/src/libraries/Common/src/System/Obsoletions.cs b/src/libraries/Common/src/System/Obsoletions.cs index 5838c7dd79f..d4ace3a02ce 100644 --- a/src/libraries/Common/src/System/Obsoletions.cs +++ b/src/libraries/Common/src/System/Obsoletions.cs @@ -107,5 +107,8 @@ namespace System internal const string CorruptedStateRecoveryMessage = "Recovery from corrupted process state exceptions is not supported; HandleProcessCorruptedStateExceptionsAttribute is ignored."; internal const string CorruptedStateRecoveryDiagId = "SYSLIB0032"; + + internal const string Rfc2898CryptDeriveKeyMessage = "Rfc2898DeriveBytes.CryptDeriveKey is obsolete and is not supported. Use PasswordDeriveBytes.CryptDeriveKey instead."; + internal const string Rfc2898CryptDeriveKeyDiagId = "SYSLIB0033"; } } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs b/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs index f6ec2c3a42d..662b0dea37a 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs @@ -639,6 +639,7 @@ namespace System.Security.Cryptography public System.Security.Cryptography.HashAlgorithmName HashAlgorithm { get { throw null; } } public int IterationCount { get { throw null; } set { } } public byte[] Salt { get { throw null; } set { } } + [System.ObsoleteAttribute("Rfc2898DeriveBytes.CryptDeriveKey is obsolete and is not supported. Use PasswordDeriveBytes.CryptDeriveKey instead.", DiagnosticId = "SYSLIB0033", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public byte[] CryptDeriveKey(string algname, string alghashname, int keySize, byte[] rgbIV) { throw null; } protected override void Dispose(bool disposing) { } public override byte[] GetBytes(int cb) { throw null; } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.cs index d7a81686cda..9c0909109c5 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.cs @@ -210,6 +210,7 @@ namespace System.Security.Cryptography return password; } + [Obsolete(Obsoletions.Rfc2898CryptDeriveKeyMessage, DiagnosticId = Obsoletions.Rfc2898CryptDeriveKeyDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public byte[] CryptDeriveKey(string algname, string alghashname, int keySize, byte[] rgbIV) { // If this were to be implemented here, CAPI would need to be used (not CNG) because of diff --git a/src/libraries/System.Security.Cryptography.Algorithms/tests/Rfc2898Tests.cs b/src/libraries/System.Security.Cryptography.Algorithms/tests/Rfc2898Tests.cs index 5e064943723..85b273ba28e 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/tests/Rfc2898Tests.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/tests/Rfc2898Tests.cs @@ -369,7 +369,9 @@ namespace System.Security.Cryptography.DeriveBytesTests { using (var deriveBytes = new Rfc2898DeriveBytes(TestPassword, s_testSalt)) { +#pragma warning disable SYSLIB0033 // Rfc2898DeriveBytes.CryptDeriveKey is obsolete Assert.Throws<PlatformNotSupportedException>(() => deriveBytes.CryptDeriveKey("RC2", "SHA1", 128, new byte[8])); +#pragma warning restore SYSLIB0033 } } |