Skip to content

Commit 95bc7de

Browse files
author
Ivan Tikhonov
committed
IT.Hashing.Gost 2.0
1 parent faed209 commit 95bc7de

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

IT.Hashing.Gost/GOST3411_2012Digest.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public virtual int DoFinal(byte[] output, int outOff)
5656
return 64;
5757
}
5858

59-
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
6059
public virtual int DoFinal(Span<byte> output)
6160
{
6261
int lenM = 64 - bOff;
@@ -87,7 +86,6 @@ public virtual int DoFinal(Span<byte> output)
8786
Reset();
8887
return 64;
8988
}
90-
#endif
9189

9290
public int GetByteLength()
9391
{
@@ -96,7 +94,6 @@ public int GetByteLength()
9694

9795
public abstract int GetDigestSize();
9896

99-
10097
public void Reset()
10198
{
10299
bOff = 64;
@@ -143,32 +140,29 @@ public void BlockUpdate(byte[] input, int inOff, int len)
143140
}
144141
}
145142

146-
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
147143
public void BlockUpdate(ReadOnlySpan<byte> input)
148144
{
149145
while (bOff != 64 && input.Length > 0)
150146
{
151147
Update(input[0]);
152-
input = input[1..];
148+
input = input.Slice(1);
153149
}
154150
while (input.Length >= 64)
155151
{
156-
input[..64].CopyTo(tmp.AsSpan());
152+
input.Slice(0, 64).CopyTo(tmp.AsSpan());
157153
reverse(tmp, block);
158154
g_N(h, N, block);
159155
addMod512(N, 512);
160156
addMod512(Sigma, block);
161157

162-
input = input[64..];
158+
input = input.Slice(64);
163159
}
164160
while (input.Length > 0)
165161
{
166162
Update(input[0]);
167-
input = input[1..];
163+
input = input.Slice(1);
168164
}
169165
}
170-
#endif
171-
172166
private static void Fill(
173167
byte[] buf,
174168
byte b)

IT.Hashing.Gost/GOST3411_2012_256Digest.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ public override int DoFinal(byte[] output, int outOff)
4040
return 32;
4141
}
4242

43-
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
4443
public override int DoFinal(Span<byte> output)
4544
{
4645
Span<byte> result = stackalloc byte[64];
4746
base.DoFinal(result);
4847

49-
result[32..].CopyTo(output);
48+
result.Slice(32).CopyTo(output);
5049

5150
return 32;
5251
}
53-
#endif
5452
}

IT.Hashing.Gost/IT.Hashing.Gost.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
77
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
@@ -13,7 +13,7 @@
1313
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1414
<Authors>Ivan Tikhonov</Authors>
1515
<Copyright>Ivan Tikhonov © 2023</Copyright>
16-
<Version>2.0.0-pre1</Version>
16+
<Version>2.0.0</Version>
1717
<PackageTags>Gost Hashing Managed</PackageTags>
1818
<PackageReadmeFile>Readme.md</PackageReadmeFile>
1919
<PackageIcon>Icon.png</PackageIcon>
@@ -32,8 +32,12 @@
3232
<None Include="..\Icon.png" Pack="true" PackagePath="\" />
3333
</ItemGroup>
3434

35+
<ItemGroup Condition="$(TargetFramework) == 'netstandard2.0'">
36+
<PackageReference Include="System.Memory" Version="4.6.3" />
37+
</ItemGroup>
38+
3539
<ItemGroup>
36-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
40+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.102" PrivateAssets="All" />
3741
</ItemGroup>
3842

3943
</Project>

0 commit comments

Comments
 (0)