Skip to content

Commit eb57c12

Browse files
authored
Replace CngCommon hash with OneShotHashHelpers.
1 parent 94480f1 commit eb57c12

File tree

5 files changed

+9
-74
lines changed

5 files changed

+9
-74
lines changed

src/libraries/Common/src/System/Security/Cryptography/DSACng.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public override KeySizes[] LegalKeySizes
4747

4848
// Need to override since base methods throw a "override me" exception: makes SignData/VerifyData function.
4949
protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm) =>
50-
CngCommon.HashData(data, offset, count, hashAlgorithm);
50+
HashOneShotHelpers.HashData(hashAlgorithm, new ReadOnlySpan<byte>(data, offset, count));
5151

5252
protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm) =>
53-
CngCommon.HashData(data, hashAlgorithm);
53+
HashOneShotHelpers.HashData(hashAlgorithm, data);
5454

5555
protected override bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) =>
56-
CngCommon.TryHashData(source, destination, hashAlgorithm, out bytesWritten);
56+
HashOneShotHelpers.TryHashData(hashAlgorithm, source, destination, out bytesWritten);
5757

5858
private void ForceSetKeySize(int newKeySize)
5959
{

src/libraries/Common/src/System/Security/Cryptography/ECDsaCng.HashData.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ namespace System.Security.Cryptography
1010
public sealed partial class ECDsaCng : ECDsa
1111
{
1212
protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm) =>
13-
CngCommon.HashData(data, offset, count, hashAlgorithm);
13+
HashOneShotHelpers.HashData(hashAlgorithm, new ReadOnlySpan<byte>(data, offset, count));
1414

1515
protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm) =>
16-
CngCommon.HashData(data, hashAlgorithm);
16+
HashOneShotHelpers.HashData(hashAlgorithm, data);
1717

1818
protected override bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) =>
19-
CngCommon.TryHashData(source, destination, hashAlgorithm, out bytesWritten);
19+
HashOneShotHelpers.TryHashData(hashAlgorithm, source, destination, out bytesWritten);
2020
}
2121
}

src/libraries/Common/src/System/Security/Cryptography/RSACng.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public override KeySizes[] LegalKeySizes
4646
}
4747

4848
protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm) =>
49-
CngCommon.HashData(data, offset, count, hashAlgorithm);
49+
HashOneShotHelpers.HashData(hashAlgorithm, new ReadOnlySpan<byte>(data, offset, count));
5050

5151
protected override bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) =>
52-
CngCommon.TryHashData(data, destination, hashAlgorithm, out bytesWritten);
52+
HashOneShotHelpers.TryHashData(hashAlgorithm, data, destination, out bytesWritten);
5353

5454
protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm) =>
55-
CngCommon.HashData(data, hashAlgorithm);
55+
HashOneShotHelpers.HashData(hashAlgorithm, data);
5656

5757
private void ForceSetKeySize(int newKeySize)
5858
{

src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,6 @@
17051705
<Compile Include="System\Security\Cryptography\ChaCha20Poly1305.Windows.cs" />
17061706
<Compile Include="System\Security\Cryptography\CngAlgorithmCore.cs" />
17071707
<Compile Include="System\Security\Cryptography\CngAsnFormatter.cs" />
1708-
<Compile Include="System\Security\Cryptography\CngCommon.Hash.cs" />
17091708
<Compile Include="System\Security\Cryptography\CngCommon.SignVerify.cs" />
17101709
<Compile Include="System\Security\Cryptography\CngHelpers.cs" />
17111710
<Compile Include="System\Security\Cryptography\CngKey.cs" />

src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CngCommon.Hash.cs

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)