Skip to content

Commit de63002

Browse files
authored
Merge pull request #127 from shinji-san/release-v0.10.1
Release v0.10.1 Fixed - Fixed BigIntCalculator's Equals method to avoid timing attacks. The slow equal implementation is used now. Resolves: No entry
2 parents 2916c6f + 9cbbd2a commit de63002

12 files changed

+141
-136
lines changed

.github/workflows/dotnetfx.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/checkout@v3
2020

2121
- name: Setup Nuget.exe
22-
uses: nuget/setup-nuget@v1.1.1
22+
uses: nuget/setup-nuget@v1.2.0
2323
with:
2424
nuget-version: latest
2525

@@ -33,5 +33,5 @@ jobs:
3333
3434
- name: Test with xUnit.net console runner
3535
run: |
36-
cd "$Env:GITHUB_WORKSPACE\packages\xunit.runner.console.2.4.1\tools\net462"
37-
.\xunit.console $Env:GITHUB_WORKSPACE\tests\bin\Release\SecretSharingDotNetTest.dll
36+
cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\"
37+
.\MSBuild.exe /p:Configuration=Release $Env:GITHUB_WORKSPACE\tests\SecretSharingDotNetFx4.6.2Test.csproj /t:Test

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.10.1] - 2023-05-08
8+
### Fixed
9+
- Fixed BigIntCalculator's Equals method to avoid timing attacks. The slow equal implementation is used now.
10+
711
## [0.10.0] - 2022-12-24
812
### Added
913
- Added .NET 7 support
@@ -178,7 +182,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
178182
- Added `LICENSE.md`
179183
- Added `README.md`
180184

181-
[0.10.0]: https://github.com/shinji-san/SecretSharingDotNet/compare/v0.9.0...0.10.0
185+
[0.10.1]: https://github.com/shinji-san/SecretSharingDotNet/compare/v0.10.0...v0.10.1
186+
[0.10.0]: https://github.com/shinji-san/SecretSharingDotNet/compare/v0.9.0...v0.10.0
182187
[0.9.0]: https://github.com/shinji-san/SecretSharingDotNet/compare/v0.8.0...v0.9.0
183188
[0.8.0]: https://github.com/shinji-san/SecretSharingDotNet/compare/v0.7.0...v0.8.0
184189
[0.7.0]: https://github.com/shinji-san/SecretSharingDotNet/compare/v0.6.0...v0.7.0

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ An C# implementation of Shamir's Secret Sharing.
7474
</thead>
7575
<tbody>
7676
<tr>
77-
<td rowspan=9><a href="https://github.com/shinji-san/SecretSharingDotNet/actions?query=workflow%3A%22SecretSharingDotNet+NuGet%22" target="_blank"><img src="https://github.com/shinji-san/SecretSharingDotNet/workflows/SecretSharingDotNet%20NuGet/badge.svg?branch=v0.10.0" alt="SecretSharingDotNet NuGet"/></a></td>
78-
<td rowspan=9><a href="https://badge.fury.io/nu/SecretSharingDotNet" target="_blank"><img src="https://badge.fury.io/nu/SecretSharingDotNet.svg" alt="NuGet Version 0.10.0"/></a></td>
79-
<td rowspan=9><a href="https://github.com/shinji-san/SecretSharingDotNet/tree/v0.10.0" target="_blank"><img src="https://img.shields.io/badge/SecretSharingDotNet-0.10.0-green.svg?logo=github&logoColor=959da5&color=2ebb4e&labelColor=2b3137" alt="Tag"/></a></td>
77+
<td rowspan=9><a href="https://github.com/shinji-san/SecretSharingDotNet/actions?query=workflow%3A%22SecretSharingDotNet+NuGet%22" target="_blank"><img src="https://github.com/shinji-san/SecretSharingDotNet/workflows/SecretSharingDotNet%20NuGet/badge.svg?branch=v0.10.1" alt="SecretSharingDotNet NuGet"/></a></td>
78+
<td rowspan=9><a href="https://badge.fury.io/nu/SecretSharingDotNet" target="_blank"><img src="https://badge.fury.io/nu/SecretSharingDotNet.svg" alt="NuGet Version 0.10.1"/></a></td>
79+
<td rowspan=9><a href="https://github.com/shinji-san/SecretSharingDotNet/tree/v0.10.1" target="_blank"><img src="https://img.shields.io/badge/SecretSharingDotNet-0.10.1-green.svg?logo=github&logoColor=959da5&color=2ebb4e&labelColor=2b3137" alt="Tag"/></a></td>
8080
<td>Standard 2.0</td>
8181
</tr>
8282
<tr>
@@ -110,10 +110,10 @@ An C# implementation of Shamir's Secret Sharing.
110110

111111
1. Open a console and switch to the directory, containing your project file.
112112

113-
2. Use the following command to install version 0.10.0 of the SecretSharingDotNet package:
113+
2. Use the following command to install version 0.10.1 of the SecretSharingDotNet package:
114114

115115
```dotnetcli
116-
dotnet add package SecretSharingDotNet -v 0.10.0 -f <FRAMEWORK>
116+
dotnet add package SecretSharingDotNet -v 0.10.1 -f <FRAMEWORK>
117117
```
118118
119119
3. After the completition of the command, look at the project file to make sure that the package is successfuly installed.
@@ -122,7 +122,7 @@ An C# implementation of Shamir's Secret Sharing.
122122
123123
```xml
124124
<ItemGroup>
125-
<PackageReference Include="SecretSharingDotNet" Version="0.10.0" />
125+
<PackageReference Include="SecretSharingDotNet" Version="0.10.1" />
126126
</ItemGroup>
127127
```
128128
## Remove SecretSharingDotNet package

src/Math/BigIntCalculator.cs

+24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace SecretSharingDotNet.Math
3535
using System.Collections.Generic;
3636
using System.Collections.ObjectModel;
3737
using System.Numerics;
38+
using System.Runtime.CompilerServices;
3839

3940
/// <summary>
4041
/// <see cref="Calculator"/> implementation of <see cref="System.Numerics.BigInteger"/>
@@ -53,6 +54,29 @@ public BigIntCalculator(BigInteger val) : base(val) { }
5354
/// <param name="data">byte stream representation of numeric value</param>
5455
public BigIntCalculator(byte[] data) : base(new BigInteger(data)) { }
5556

57+
/// <summary>
58+
/// Determines whether this instance and an <paramref name="other"/> specified <see cref="Calculator{BigInteger}"/> instance are equal.
59+
/// </summary>
60+
/// <param name="other">The <see cref="Calculator{BigInteger}"/> instance to compare</param>
61+
/// <returns><see langword="true"/> if the value of the <paramref name="other"/> parameter is the same as the value of this instance; otherwise <see langword="false"/>.
62+
/// If <paramref name="other"/> is <see langword="null"/>, the method returns <see langword="false"/>.</returns>
63+
/// <remarks>This is a Slow Equal Implementation to avoid a timing attack. See the reference for more details:
64+
/// https://bryanavery.co.uk/cryptography-net-avoiding-timing-attack/</remarks>
65+
[MethodImpl(MethodImplOptions.NoOptimization)]
66+
public override bool Equals(Calculator<BigInteger> other)
67+
{
68+
var valueLeft = this.Value.ToByteArray();
69+
var valueRight = other?.Value.ToByteArray() ?? Array.Empty<byte>();
70+
71+
var diff = (uint)valueLeft.Length ^ (uint)valueRight.Length;
72+
for (var i = 0; i < valueLeft.Length && i < valueRight.Length; i++)
73+
{
74+
diff |= (uint)(valueLeft[i] ^ valueRight[i]);
75+
}
76+
77+
return diff == 0;
78+
}
79+
5680
/// <summary>
5781
/// This method represents the Greater Than operator.
5882
/// </summary>

src/Math/Calculator`1.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public static implicit operator Calculator<TNumber>(TNumber number)
299299
/// <param name="other">The <see cref="Calculator{TNumber}"/> instance to compare</param>
300300
/// <returns><see langword="true"/> if the value of the <paramref name="other"/> parameter is the same as the value of this instance; otherwise <see langword="false"/>.
301301
/// If <paramref name="other"/> is <see langword="null"/>, the method returns <see langword="false"/>.</returns>
302-
public bool Equals(Calculator<TNumber> other)
302+
public virtual bool Equals(Calculator<TNumber> other)
303303
{
304304
return other != null && this.Value.Equals(other.Value);
305305
}

src/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
[assembly: Guid("1c21b99c-2de4-4ca5-b4ce-bc95cf89369e")]
1717

18-
[assembly: AssemblyVersion("0.10.0")]
19-
[assembly: AssemblyFileVersion("0.10.0")]
18+
[assembly: AssemblyVersion("0.10.1")]
19+
[assembly: AssemblyFileVersion("0.10.1")]
2020
[assembly: NeutralResourcesLanguage("en")]
2121

2222
[assembly: System.CLSCompliant(true)]

src/SecretSharingDotNet.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1111
<PackageId>SecretSharingDotNet</PackageId>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
13-
<PackageReleaseNotes>Changelog: https://github.com/shinji-san/SecretSharingDotNet/blob/0.10.0/CHANGELOG.md</PackageReleaseNotes>
13+
<PackageReleaseNotes>Changelog: https://github.com/shinji-san/SecretSharingDotNet/blob/v0.10.1/CHANGELOG.md</PackageReleaseNotes>
1414
<PackageDescription>An C# implementation of Shamir's Secret Sharing</PackageDescription>
1515
<PackageReadmeFile>README.md</PackageReadmeFile>
1616
<PackageTags>secret sharing;shamir secret sharing;cryptography</PackageTags>
1717
<PackageProjectUrl>https://github.com/shinji-san/SecretSharingDotNet</PackageProjectUrl>
1818
<RepositoryUrl>https://github.com/shinji-san/SecretSharingDotNet</RepositoryUrl>
1919
<RepositoryType>git</RepositoryType>
20-
<Version>0.10.0</Version>
20+
<Version>0.10.1</Version>
2121
<Authors>Sebastian Walther</Authors>
2222
<Company>Private Person</Company>
2323
<GenerateDocumentationFile>true</GenerateDocumentationFile>

tests/SecretSharingDotNet6Test.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
1414
<PackageReference Include="xunit" Version="2.4.2" />
1515
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1616
<PrivateAssets>all</PrivateAssets>

tests/SecretSharingDotNet7Test.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
14-
<PackageReference Include="xunit" Version="2.4.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
14+
<PackageReference Include="xunit" Version="2.4.2" />
1515
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)