Skip to content

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Oct 1, 2024

Summary

The RNGCryptoServiceProvider class is obsolete in .NET. Instead of using this class directly, using RandomNumberGenerator.Create to get the appropriate implementation, which works for all .NETs (including .NET Framework).

The only remaining use of RNGCryptoServiceProvider in examples is documentation for RNGCryptoServiceProvider itself.

Fixes #10329
Fixes #10011
Fixes #10018

@vcsjones vcsjones requested a review from bartonjs October 1, 2024 15:01
@vcsjones vcsjones requested a review from a team as a code owner October 1, 2024 15:01
@ghost ghost added the area-System.Security Issues related to security practices for .NET developers. label Oct 1, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones

This comment was marked as outdated.

Copy link

Learn Build status updates of commit ba66130:

✅ Validation status: passed

File Status Preview URL Details
snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACRIPEMD160/CPP/hmacripemd160.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACRIPEMD160/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACRIPEMD160/Overview/hmacripemd160.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACSHA256/Overview/hmacsha256.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACSHA384/Overview/hmacsha384.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACSHA512/Overview/hmacsha512.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/MACTripleDES/Overview/program.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RandomNumberGenerator/GetBytes/source.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RandomNumberGenerator/GetNonZeroBytes/source.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs ✅Succeeded View
snippets/csharp/VS_Snippets_CFX/samlattribute/cs/source.cs ✅Succeeded View
snippets/visualbasic/VS_Snippets_CFX/samlattribute/vb/source.vb ✅Succeeded View

This comment lists only the first 25 files in the pull request.
For more details, please refer to the build report.

For any questions, please:

Copy link
Contributor

Choose a reason for hiding this comment

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

@adegeo Why does Snippets 5000 care about this file given that it's configured to ignore .cpp files? See

ExtensionsCodeTriggers: .cs;.vb;.fs;.xaml;.razor;.cshtml;.vbhtml;.sln;.csproj;.fsproj;.vbproj;.proj
.

Copy link

Learn Build status updates of commit ebc217a:

✅ Validation status: passed

File Status Preview URL Details
snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACRIPEMD160/CPP/hmacripemd160.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACRIPEMD160/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/makefile ✅Succeeded
snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACRIPEMD160/Overview/hmacripemd160.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACSHA256/Overview/hmacsha256.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACSHA384/Overview/hmacsha384.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/HMACSHA512/Overview/hmacsha512.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/MACTripleDES/Overview/program.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RandomNumberGenerator/GetBytes/source.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RandomNumberGenerator/GetNonZeroBytes/source.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs ✅Succeeded View
snippets/csharp/VS_Snippets_CFX/samlattribute/cs/makefile ✅Succeeded n/a (file deleted or renamed)
snippets/csharp/VS_Snippets_CFX/samlattribute/cs/Project.csproj ✅Succeeded

This comment lists only the first 25 files in the pull request.
For more details, please refer to the build report.

For any questions, please:

@gewarren gewarren merged commit 1e1ae05 into dotnet:main Oct 1, 2024
3 of 4 checks passed
@vcsjones vcsjones deleted the purge-rngcsp branch October 1, 2024 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Security Issues related to security practices for .NET developers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RNGCryptoServiceProvider() is obsolete Obsolete RNGCryptoServiceProvider Update Rfc2898DeriveBytes Example Code
3 participants