Skip to content

Conversation

bartonjs
Copy link
Member

This updates TripleDES/3DES and RC2 to match the changes done for DES in #8227, namely:

  • Removes the samples from the Create(string) overload
    • The method is being marked as Obsolete in .NET 7
    • It had a different sample than Create() for C#, but reused the Create() sample in VB and C++/CLI
  • Fixes the bug in the sample that assumed CryptoStream.Read aggressively fills the destination.
  • Adds using statements (or the language-specific equivalent) for all IDisposable values.
  • Uses names for parameters and locals that are consistent with .NET guidelines and best practices.
  • Changes C++/CLI to use function prototypes so the functions are presented in the same order across all three languages.
  • Changes the method declarations in VB to a more canonical style.

The samples were all copied from their DES versions, but with the following transformations:

3DES:

  • s/des/tripleDes/g
  • s/DES/TripleDES/g

RC2:

  • s/des/rc2/g
  • s/a DES/an RC2/g
  • s/DES/RC2/g

Fixes #8140.

@bartonjs bartonjs requested a review from a team as a code owner September 13, 2022 21:25
@ghost ghost assigned bartonjs Sep 13, 2022
@ghost ghost added the area-System.Security Issues related to security practices for .NET developers. label Sep 13, 2022
@ghost
Copy link

ghost commented Sep 13, 2022

Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

This updates TripleDES/3DES and RC2 to match the changes done for DES in #8227, namely:

  • Removes the samples from the Create(string) overload
    • The method is being marked as Obsolete in .NET 7
    • It had a different sample than Create() for C#, but reused the Create() sample in VB and C++/CLI
  • Fixes the bug in the sample that assumed CryptoStream.Read aggressively fills the destination.
  • Adds using statements (or the language-specific equivalent) for all IDisposable values.
  • Uses names for parameters and locals that are consistent with .NET guidelines and best practices.
  • Changes C++/CLI to use function prototypes so the functions are presented in the same order across all three languages.
  • Changes the method declarations in VB to a more canonical style.

The samples were all copied from their DES versions, but with the following transformations:

3DES:

  • s/des/tripleDes/g
  • s/DES/TripleDES/g

RC2:

  • s/des/rc2/g
  • s/a DES/an RC2/g
  • s/DES/RC2/g

Fixes #8140.

Author: bartonjs
Assignees: bartonjs
Labels:

area-System.Security

Milestone: -

@opbld30
Copy link

opbld30 commented Sep 13, 2022

Docs Build status updates of commit c10a30a:

✅ Validation status: passed

File Status Preview URL Details
snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/CPP/memoryexample.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp ✅Succeeded View
snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RC2/Create/fileexample.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RC2/Create/fileexample1.cs ✅Succeeded n/a (file deleted)
snippets/csharp/System.Security.Cryptography/RC2/Create/memoryexample.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/RC2/Create/memoryexample1.cs ✅Succeeded n/a (file deleted)
snippets/csharp/System.Security.Cryptography/RC2/Create/project.csproj ✅Succeeded
snippets/csharp/System.Security.Cryptography/TripleDES/Create/fileexample.cs ✅Succeeded View
snippets/csharp/System.Security.Cryptography/TripleDES/Create/fileexample1.cs ✅Succeeded n/a (file deleted)
snippets/csharp/System.Security.Cryptography/TripleDES/Create/memoryexample.cs ✅Succeeded
snippets/csharp/System.Security.Cryptography/TripleDES/Create/project.csproj ✅Succeeded
snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb ✅Succeeded View
snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/project.csproj ✅Succeeded
snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/project.csproj ✅Succeeded
snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb ✅Succeeded View
snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.File/VB/fileexample.vb ✅Succeeded View
snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.File/VB/project.csproj ✅Succeeded
snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/project.csproj ✅Succeeded
snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/VB/memoryexample.vb ✅Succeeded View
xml/System.Security.Cryptography/RC2.xml ✅Succeeded View
xml/System.Security.Cryptography/TripleDES.xml ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@bartonjs bartonjs merged commit 42d86dc into dotnet:main Sep 15, 2022
@bartonjs bartonjs deleted the alg_create_samples branch September 15, 2022 20:23
@bartonjs bartonjs mentioned this pull request Jan 4, 2023
@bartonjs
Copy link
Member Author

bartonjs commented Jan 4, 2023

@gewarren https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.tripledescryptoserviceprovider?view=net-7.0 is still showing examples from before this change. Would you happen to know why? 😄

@gewarren
Copy link
Contributor

gewarren commented Jan 4, 2023

@gewarren https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.tripledescryptoserviceprovider?view=net-7.0 is still showing examples from before this change. Would you happen to know why? 😄

@bartonjs It doesn't look like you updated those examples:

snippets/cpp/VS_Snippets_CLR/Cryptography.3DESCSP.CreateEncryptor.File/CPP/fileexample.cpp
snippets/csharp/System.Security.Cryptography/TripleDESCryptoServiceProvider/Overview/fileexample.cs
snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DESCSP.CreateEncryptor.File/VB/fileexample.vb

snippets/cpp/VS_Snippets_CLR/Cryptography.3DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp
snippets/csharp/System.Security.Cryptography/TripleDESCryptoServiceProvider/Overview/memoryexample.cs
snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DESCSP.CreateEncryptor.Memory/VB/memoryexample.vb

@bartonjs
Copy link
Member Author

bartonjs commented Jan 4, 2023

Ah. That would, of course, do it.

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.

Improve or remove code examples for TripleDES, DES, and RC2.

3 participants