Skip to content

Commit 8c27d1c

Browse files
Copilotkrwq
andauthored
Replace SHA-256-specific recommendations in 12 snippet files with NIST-approved language
Agent-Logs-Url: https://github.com/dotnet/dotnet-api-docs/sessions/6dd58f84-d55d-4ebe-96bd-c0632ea15c42 Co-authored-by: krwq <660048+krwq@users.noreply.github.com>
1 parent b0d07c7 commit 8c27d1c

12 files changed

Lines changed: 22 additions & 22 deletions

File tree

snippets/csharp/System.CodeDom/CodeChecksumPragma/Overview/codedirective.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static void DemonstrateCodeDirectives(string providerName, string sourceFileName
8585
}
8686

8787
// This example uses the SHA1 and MD5 algorithms.
88-
// Due to collision problems with SHA1 and MD5, Microsoft recommends SHA256 or better.
88+
// Due to collision problems with SHA1 and MD5, Microsoft recommends using a NIST-approved hash function.
8989
private static Guid HashMD5 = new Guid(0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99);
9090
private static Guid HashSHA1 = new Guid(0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60);
9191

snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public override string KeyExchangeAlgorithm
203203
// Retrieves the name of the signature alogrithm.
204204
//<Snippet7>
205205
// This example uses the SHA1 algorithm.
206-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
206+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
207207
public override string SignatureAlgorithm
208208
{
209209
get {return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";}

snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static void Main(string[] args)
2020
// Create a new SHA1 provider.
2121
//<Snippet4>
2222
// This example uses the SHA1 algorithm.
23-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
23+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
2424
SHA1CryptoServiceProvider SHA1alg =
2525
(SHA1CryptoServiceProvider)CryptoConfig.CreateFromName("SHA1");
2626
//</Snippet4>
@@ -41,14 +41,14 @@ static void Main(string[] args)
4141
// (OID) from the string name of the SHA1 algorithm.
4242
//<Snippet3>
4343
// This example uses the SHA1 algorithm.
44-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
44+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
4545
string sha1Oid = CryptoConfig.MapNameToOID("SHA1");
4646
//</Snippet3>
4747

4848
// Encode the specified object identifier.
4949
//<Snippet6>
5050
// This example uses the SHA1 algorithm.
51-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
51+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
5252
byte[] encodedMessage = CryptoConfig.EncodeOID(sha1Oid);
5353
//</Snippet6>
5454

snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void Main(String[] args)
3232
// Create the key and set it to the Key property
3333
// of the TripleDESCryptoServiceProvider object.
3434
// This example uses the SHA1 algorithm.
35-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
35+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
3636
tdes.Key = pdb.CryptDeriveKey("TripleDES", "SHA1", 192, tdes.IV);
3737

3838
//</Snippet2>

snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignHash/class1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//<Snippet1>
22
// This example uses the SHA1 algorithm.
3-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
3+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
44
using System;
55
using System.Text;
66
using System.Security.Cryptography;

snippets/csharp/VS_Snippets_CFX/samlattribute/cs/source.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ public class Elements
922922
public class ComputedKeyAlgorithms
923923
{
924924
// This example uses the SHA1 algorithm.
925-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
925+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
926926
public const string PSHA1 = "http://schemas.xmlsoap.org/ws/2005/02/trust/CK/PSHA1";
927927
}
928928
}
@@ -1067,7 +1067,7 @@ public bool ComputeKey
10671067
public static byte[] ComputeCombinedKey(byte[] requestorEntropy, byte[] issuerEntropy, int keySize)
10681068
{
10691069
// This example uses the SHA1 algorithm.
1070-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
1070+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
10711071
KeyedHashAlgorithm kha = new HMACSHA1(requestorEntropy, true);
10721072

10731073
byte[] key = new byte[keySize / 8]; // Final key
@@ -1179,7 +1179,7 @@ protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
11791179
// Write the wst:ComputeKey start tag.
11801180
writer.WriteStartElement(Constants.Trust.Elements.ComputedKey, Constants.Trust.NamespaceUri);
11811181
// This example uses the SHA1 algorithm.
1182-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
1182+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
11831183
writer.WriteValue(Constants.Trust.ComputedKeyAlgorithms.PSHA1);
11841184
writer.WriteEndElement(); // wst:ComputedKey
11851185
writer.WriteEndElement(); // wst:RequestedSecurityToken
@@ -1311,7 +1311,7 @@ public static SamlSecurityToken CreateSamlToken(string stsName,
13111311

13121312
// Create a SigningCredentials instance from the key associated with the issuerToken.
13131313
// This example uses the SHA1 algorithm.
1314-
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
1314+
// Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
13151315
SigningCredentials signingCredentials = new SigningCredentials(issuerToken.SecurityKeys[0],
13161316
SecurityAlgorithms.RsaSha1Signature,
13171317
SecurityAlgorithms.Sha1Digest,

snippets/visualbasic/System.CodeDom/CodeChecksumPragma/Overview/codedirective.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Class CodeDirectiveDemo
7272
End Sub
7373

7474
' This example uses the SHA1 and MD5 algorithms.
75-
' Due to collision problems with SHA1 and MD5, Microsoft recommends SHA256 or better.
75+
' Due to collision problems with SHA1 and MD5, Microsoft recommends using a NIST-approved hash function.
7676
Private Shared HashMD5 As New Guid(&H406EA660, &H64CF, &H4C82, &HB6, &HF0, &H42, &HD4, &H81, &H72, &HA7, &H99)
7777
Private Shared HashSHA1 As New Guid(&HFF1816EC, &H65FF, &H4D10, &H87, &HF7, &H6F, &H49, &H63, &H83, &H34, &H60)
7878

snippets/visualbasic/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Namespace Contoso
182182
' Retrieves the name of the signature alogrithm.
183183
'<Snippet7>
184184
' This example uses the SHA1 algorithm.
185-
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
185+
' Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
186186
Public Overrides ReadOnly Property SignatureAlgorithm() As String
187187
Get
188188
Return "http://www.w3.org/2000/09/xmldsig#rsa-sha1"

snippets/visualbasic/System.Security.Cryptography/CryptoConfig/Overview/members.vb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Public Class Form1
2626
' Create a new SHA1 provider.
2727
'<Snippet4>
2828
' This example uses the SHA1 algorithm.
29-
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
29+
' Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
3030
Dim SHA1alg As SHA1CryptoServiceProvider
3131
SHA1alg = CType( _
3232
cryptoConfig.CreateFromName("SHA1"), SHA1CryptoServiceProvider)
@@ -50,14 +50,14 @@ Public Class Form1
5050
'<Snippet3>
5151
' (OID) from the string name of the SHA1 algorithm.
5252
' This example uses the SHA1 algorithm.
53-
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
53+
' Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
5454
Dim sha1Oid As String = cryptoConfig.MapNameToOID("SHA1")
5555
'</Snippet3>
5656

5757
' Encode the specified object identifier.
5858
'<Snippet6>
5959
' This example uses the SHA1 algorithm.
60-
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
60+
' Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
6161
Dim encodedMessage() As Byte = cryptoConfig.EncodeOID(sha1Oid)
6262
'</Snippet6>
6363

snippets/visualbasic/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Module PasswordDerivedBytesExample
3131
' Create the key and set it to the Key property
3232
' of the TripleDESCryptoServiceProvider object.
3333
' This example uses the SHA1 algorithm.
34-
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
34+
' Due to collision problems with SHA1, Microsoft recommends using a NIST-approved hash function.
3535
tdes.Key = pdb.CryptDeriveKey("TripleDES", "SHA1", 192, tdes.IV)
3636
' </Snippet2>
3737

0 commit comments

Comments
 (0)